ClaudeDebuggingLevel 2: Context

How Do You Find What Change Broke Your Code?

Give Claude the full error and the last known good point together, and ask how the change caused the error. In Claude Code, Claude can read the diff itself. In the Claude app, you have to paste it, because the GitHub integration doesn't include commit history.

Prompt to copy
This started failing after a recent change.

Failing command: [command]
Full error:
[paste the whole trace]
Last known good: [commit, tag or date of the last working deploy]

Run the command to confirm it fails. Read what changed with `git log --stat [good]..HEAD` and `git diff [good]..HEAD`.

Explain the exact mechanism by which a specific change causes this error, naming the changed lines and the frame in the trace. If nothing in the diff explains it, say so and list what else changed, such as dependencies, config or environment. Don't fix anything until I've read your explanation.
  1. 1Full error and trace
  2. 2Diff since last good
  3. 3Named mechanism
  4. 4Smallest fix
A rule of thumb for regressions, not an Anthropic chart: the trace says where it fails, and the diff says what's new.
  • Exit 0good commit
  • Exit 1 to 127bad commit, except 125
  • Exit 125skip this commit
  • Any other codeaborts the bisect
How git bisect run reads your script's exit code, per the git-bisect docs. A build that can't compile must exit 125, or it gets blamed.

Try it now

  1. 1Start Claude Code at the repo root and send the prompt. For a saved log, Anthropic's docs show cat error.log | claude -p "what's going on here".
  2. 2If the error is only on screen, paste a screenshot with Ctrl+V, or Alt+V on Windows and WSL.
  3. 3Check the answer. It should name a changed line and a frame in the trace. It worked if undoing that one change makes the error go away.

Use it when

A failure that appeared after an edit, a deploy or a dependency bump, especially when the trace points into code you didn't touch.

Skip it when

An old bug with no recent change to anchor to, or a failure caused by timing or environment. Asking how a diff caused it pushes Claude to blame the diff. Use the reproduce or two-hypotheses approach instead.

Why it works

A regression gives you two clues. The stack trace says where it fails, and the diff says what's new. Asking Claude to connect them means looking at far less code than asking it to read a whole file for anything suspicious. That reasoning is a rule of thumb, not a vendor claim. Claude Code runs shell commands, so it can run your failing command and git diff itself, and Anthropic's bug-fixing tips say to give it the command that reproduces the issue and gets a stack trace. In the app, Anthropic's help page says the GitHub integration reads files only, with no commit history or pull requests, so Claude can't see what changed unless you show it.

Example

Cannot read properties of undefined (reading 'name') points into renderInvoice.ts, which you never edited. Your last commit made customer optional in the API type. A good answer connects the two: customer can now be missing, and renderInvoice assumes it isn't. Then the real choice is whether to guard at the call site or keep the field required, and that's yours to make.

Going further

For a long gap, have Claude run git bisect. Git's docs define the contract: git bisect run <cmd> tests each commit and treats exit 0 as good, 1 to 127 except 125 as bad, and 125 as skip, while other codes abort. So a build that can't compile must exit 125, or it gets blamed. Bisect checks out commits in your working tree, so run it in a separate checkout started with claude --worktree bisect. Watch two traps there: a worktree branches from your default branch unless worktree.baseRef is "head", and it's a fresh checkout without your dependencies or .env.

Common mistakes

  • Cutting the trace to its top line. The frame that matters is often further down, and the top is usually only where the symptom surfaced.
  • Saying "I refactored the API" in the Claude app without pasting git diff. Claude can't see what moved.
  • Using /rewind to test whether Claude's own edit caused it, then trusting the result. Restore code only reverts what checkpoints tracked, and a file only a Bash command changed stays as it is.
  • Bisecting with a flaky test. Each wrong answer sends the search down the wrong half of your history.

Sources

Checked 6 November 2026. Products change often, so confirm details with the vendor.

Related

Beyond the course