# Automate weekly performance triage with Claude Code

> Set up a Claude Code scheduled task that uses the Sentry MCP server to find your slowest endpoints each week, run Seer analysis, and open GitHub PRs with fixes.

**URL:** https://sentry.io/cookbook/performance-bot-sentry-claude/

---

Set up a recurring Claude Code task that queries Sentry for your slowest endpoints every Monday, analyzes the root cause, and opens a GitHub PR with the fix. No custom bot infrastructure required.

**Time:** 15-20 minutes | **Difficulty:** Beginner

## What You'll Learn

- Configured the Sentry MCP server in Claude Code

- Enabled Seer and connected your GitHub repos for accurate root cause analysis

- Created a scheduled task that runs weekly performance triage automatically

- Used `search_issues`, `get_issue_details`, and `analyze_issue_with_seer` to query and analyze performance data

- Had GitHub PRs with performance fixes opened for you automatically

**Topics:** Sentry MCP, Performance, Tracing, Seer, Issues

## Steps

### 1. Connect the Sentry MCP server to Claude Code

The Sentry MCP server gives Claude Code access to your issues, traces, spans, and Seer analysis through natural language. This recipe only reads and analyzes data with it; fixes go out as GitHub PRs via the `gh` CLI. The fastest way to add it is with the Claude Code CLI. Run the command below, then type `/mcp` inside Claude Code to authenticate with your Sentry organization via OAuth. Once authenticated, Claude Code can query your Sentry data in any session, including scheduled tasks.

### 2. Enable Seer and connect your GitHub repos

Seer is Sentry's AI debugging agent that uses Sentry data to create root cause analysis for issues, as well as fixes. You can query Sentry data using the MCP, but Seer is what guides you to what really caused the issue and how to fix it. [Enable Seer](https://sentry.io/orgredirect/organizations/:orgslug/settings/seer/) in your org settings, then connect your [GitHub repositories](https://sentry.io/orgredirect/organizations/:orgslug/settings/integrations/github/) so Seer can examine your actual source code alongside trace data.

### 3. Verify the connection with a test query

Before setting up automation, test everything interactively. Open Claude Code and paste the prompt below. It tests the full chain: querying issues, pulling trace details, and running Seer analysis. Seer can take a few minutes to produce a root cause analysis, so give it time. If you see results returned, the connection is working end-to-end. If you get an authentication error, type `/mcp` to re-authenticate.

### 4. Create a weekly performance triage task

Claude Code scheduled tasks run a prompt on a cron schedule. Create a task that fires every Monday at 9 AM, queries Sentry for your worst performance issues, and opens GitHub PRs with fixes. Seer works best on error-type issues. For performance issues like N+1 queries and slow DB calls, Seer may or may not produce a fix, so the task prompt also has Claude Code analyze the code directly using the trace context. Between Seer and Claude Code's own analysis, most issues get actionable suggestions. The task runs in a fresh Claude Code session with full access to your MCP servers and shell.

### 5. Verify the first scheduled run

Don't wait until Monday. Trigger the task manually for the first run. In Claude Code, open the scheduled tasks list and run your task on demand, or paste the task prompt into an interactive session to watch it execute step by step. Then check three things to confirm it worked:

### 6. Tune thresholds and extend

Once the first run looks good, tune the task to match your team's signal-to-noise tolerance. Start with a high threshold (3000ms P95) and lower it as you build confidence in the PR quality. You can update the scheduled task prompt at any time without recreating it. Filter by specific Sentry projects or environments, increase the PR cap as reviewers build trust in the output, or create separate tasks for different services with different thresholds. GitHub already notifies your team when PRs are opened, so you get visibility without extra tooling.

### 7. Review and merge performance PRs

Each PR the task opens includes the Sentry trace link, Seer's root cause analysis, and a description of what changed and why. Review these the same way you would review any PR. Check the diff against the trace to verify the root cause makes sense, and run your test suite before merging. Over time, you'll develop a feel for which fixes are merge-ready and which need manual adjustment. If your team prefers to triage in Linear or another tool instead of PRs, modify the task prompt to create tickets there with the same trace links and analysis.

## FAQ

**Does Claude Code modify anything in Sentry?**

It can, but not in this specific recipe. The Sentry MCP server supports write operations, like updating an issue's status or assignment, but the task prompt here only calls read tools (`search_issues`, `get_issue_details`, `analyze_issue_with_seer`). Fixes are shipped as GitHub PRs via the `gh` CLI, not written back to your Sentry account.

**How much does this cost to run weekly?**

Claude Code scheduled tasks use your existing Claude plan credits. A typical run analyzing 3-5 slow endpoints costs a few cents in token usage. There is no separate infrastructure cost: no CI minutes, no cloud functions, no servers to maintain.

**What happens if my machine is off when the task is scheduled?**

The task won't fire while the machine is off. Claude Code uses a local scheduler, so the machine needs to be running for cron tasks to execute. If you need guaranteed uptime, consider running Claude Code on an always-on machine or cloud VM.

**Can I use this with a self-hosted Sentry instance?**

The Sentry MCP server at mcp.sentry.dev works with Sentry's cloud service (sentry.io). For self-hosted Sentry, you would need to use direct API calls via curl in the task prompt instead of the MCP tools.

**Do I need to install any SDKs or packages?**

No. This recipe uses Claude Code (which you already have), the Sentry MCP server (a remote URL, nothing to install), and the gh CLI (pre-installed on most developer machines). There is no package.json, no dependencies, and no build step.

---

*Source: [sentry.io/cookbook/performance-bot-sentry-claude/](https://sentry.io/cookbook/performance-bot-sentry-claude/)*
