Pair the Error With the Last Thing You Changed
What it is
Why it works
Most bugs you hit are regressions: something worked, you changed something, now it fails. The stack trace tells you where it breaks; the recent diff tells you what is new. Their intersection is a tiny search space. Giving Claude both lets it reason about cause and effect instead of reading the whole file looking for anything suspicious.
When to use it
A failure that appeared after a recent edit, deploy, or dependency bump — especially when the trace points into code you didn't touch but the trigger was something you did.
When not to use it
Longstanding bugs with no recent change to anchor to, or heisenbugs where the trigger is timing or environment rather than a diff. There, reproduction beats regression-hunting.
Prompt
Here is the full error and stack trace:
<paste — do not truncate>
Here is the change I made just before it started failing:
<paste diff or description>
Explain the specific mechanism by which this change could produce this trace. If the change looks unrelated, say so and name what else could cause this exact error. Then propose the smallest fix.Example
A Cannot read properties of undefined trace points into a rendering helper you never edited. You paste it alongside the diff where you made an API field optional. Claude connects them: the field is now sometimes absent, the helper assumed it, and it hands you a one-line guard at the real call site rather than in the helper.
Advanced version
When the change is large, ask Claude to bisect it: which single hunk of the diff, removed on its own, would most likely make the error disappear? This turns a big diff into a ranked list of suspects you can test one at a time.
Common mistakes
- Truncating the stack trace to the top line — the frame that matters is often three or four down.
- Describing the change vaguely ("I refactored the API") instead of pasting the actual diff, so Claude can't see what really moved.
- Assuming the trace's top frame is the cause; it's usually just where the symptom surfaced.