Tutorial · Intermediate

Turn your most frequent app error into a tested fix you can review

Your app keeps hitting the same errors, and copying stack traces from Sentry into a chat is slow. Connect Sentry to Claude Code for one project: ask "what are my top errors this week?" and you get a ranked list with files and lines; ask it to fix one and you get a branch with a test and the fix, ready for you to review.
[ The result ]

Whenever you ask, Claude Code lists the top unresolved Sentry issues for one project and prepares a tested fix on a separate branch. It can't see your other projects or change issues in Sentry.

[ How it's wired ]
  1. Install Claude Code and sign in

    We use Claude Code here, not a chat window, because the fix needs to run your tests and make a branch in the code on your machine. Open a terminal and run the install command below (macOS, Linux or WSL). On Homebrew you can run 'brew install --cask claude-code' instead. Open a new terminal window and run 'claude --version'. If it prints a version number, the install worked. Go to the folder of the app that sends errors to Sentry and run 'claude'. Follow the browser prompts to log in, then type /exit to close the session for now.

    curl -fsSL https://claude.ai/install.sh | bash
    claude --version
    cd ~/path/to/your-app
    claude
  2. Find your Sentry organization and project slugs

    Sign in at sentry.io and open the project you want the agent to see. Write down two short lowercase names. The organization slug is the part before .sentry.io in your Sentry address. The project slug can differ from the name you see in your Projects list, so copy it from the project's URL or from Project Settings → General. Pick a single project. You'll put both names in the server address so the agent sees only this project.

  3. Add the Sentry MCP server, scoped to one project

    Run the command below in your app's folder. Replace your-org and your-project with your slugs. When the address names a project, Sentry's server uses that org and project by default and hides the tools for browsing other projects. The command prints an 'Added ...' line. Without a --scope flag, the server is saved in local scope: only for this project and only for you, never committed to git.

    claude mcp add --transport http sentry https://mcp.sentry.dev/mcp/your-org/your-project
  4. Sign in to Sentry with OAuth

    Start 'claude' in the same folder and type /mcp. Select 'sentry' and finish the login in your browser with your Sentry account. On Sentry's consent screen, look at the list of permission groups before you approve. Sentry's server groups its tools into skills such as Inspect Issues & Events, Seer, Triage Issues and Manage Projects & Teams, and the consent screen may show all of them ticked on first sign-in. For this guide, keep Inspect Issues & Events and untick Triage Issues and Manage Projects & Teams (and Seer, if you don't plan to use it). Then Sentry itself won't give this session the tools that change issues or projects. If your screen looks different, approve and rely on the deny rules in the next step. Back in the terminal, run 'claude mcp list' in a second window. The sentry line should say ✔ Connected. '! Needs authentication' means the login didn't finish, so open /mcp and try again. In /mcp you can also open the server and see its tool list.

    /mcp
    claude mcp list
  5. Block the agent from changing Sentry issues

    We want the agent to read errors, not resolve, comment on, link, assign or archive them, and not change your project settings either. Sentry's server has tools that change things, such as add_issue_note (adds a comment), add_team_to_project, create_project, create_team, create_dsn, create_alert_rule, create_monitor, create_metric_monitor, create_uptime_monitor and several delete tools. The exact list can change, so we block them by prefix: deny rules accept a wildcard in the tool name, and one rule like mcp__sentry__update_* covers every tool whose name starts with update_. Create the file .claude/settings.local.json in your app's folder (or add to it if it exists) with the deny rules below. The last rule blocks analyze_issue_with_seer, which can start Seer, Sentry's AI debugger. Seer may be billed separately, so check the current Seer pricing on sentry.io/pricing before you allow it. Then open /mcp, select 'sentry' and look through its tool list. If you see any other tool that changes something and isn't covered by a prefix below, add it to the list in the same form, mcp__sentry__ plus the tool name. A rule for a tool your list doesn't show does no harm. A tool denied by name or by a wildcard is removed from Claude's context entirely, and deny rules are checked before ask and allow rules, so Claude can't call these tools even if you approve something broader later. Also keep Claude Code in the default Manual permission mode. It then asks before it runs shell commands or edits files, so you see every step.

    {
      "permissions": {
        "deny": [
          "mcp__sentry__update_*",
          "mcp__sentry__create_*",
          "mcp__sentry__delete_*",
          "mcp__sentry__add_*",
          "mcp__sentry__remove_*",
          "mcp__sentry__link_*",
          "mcp__sentry__unlink_*",
          "mcp__sentry__analyze_issue_with_seer"
        ]
      }
    }
  6. Ask for your top unresolved errors

    Restart 'claude' so the new rule loads, then paste the prompt below. Claude calls the Sentry tools (approve each call when it asks) and returns a short ranked list with issue IDs, counts and the files involved. Nothing in your code or in Sentry changes at this step.

    Using the Sentry tools, list the 5 most frequent unresolved issues in this project from the last 7 days. For each one show: issue ID, title, event count, users affected, and the top in-app stack frame (file and line in this repo). Don't change anything in Sentry or in the code yet.
  7. Reproduce one error and propose a fix on a branch

    Pick one issue from the list, ideally one whose stack trace points at your own code, and paste the prompt below with its ID. Claude reads the events, writes a test that fails the same way, makes the smallest fix, and runs the tests. Approve the git, file and test commands as it asks. When it's done, review the change with 'git diff main' on the new branch (or master, or whatever your default branch is). You merge it yourself, or throw the branch away.

    Take Sentry issue <ISSUE-ID>. 1) Read its latest events and stack trace. 2) Create a branch named fix/sentry-<ISSUE-ID>. 3) Write a test that reproduces the error and show me it fails. 4) Make the smallest safe fix, with no unrelated refactors. 5) Run the test and the existing tests, lint and typecheck. 6) Commit on the branch and summarise the root cause and the diff. Stop and tell me if you can't reproduce it. Don't touch auth, billing, migrations or infrastructure code. Don't resolve, comment on or assign the issue in Sentry, and don't push or merge.
DoneStuck on a step? Reply to any Daily AI Brief email and ask.
[ One tutorial a week ]

Get the next automation before it's posted.

One short email with the AI stories that matter. What happened in AI, why it matters, one tool worth trying. Free. Unsubscribe anytime.

More tutorials

All tutorials
01Find out what you missed in a long lecture with a free quiz and flashcards20 min · Beginner · 7 steps02Make Claude Code follow your project's rules in every session15 min · Beginner · 7 steps03Read all your newsletters in one email every Friday30 min · Intermediate · 8 steps
[ Daily AI Brief ]

The AI news that matters, in your inbox.

One short email with the AI stories that matter. What happened in AI, why it matters, one tool worth trying. Free. Unsubscribe anytime.