Make Claude Reproduce the Bug Before It Fixes It
What it is
Why it works
The default failure mode of AI debugging is a plausible fix for the wrong cause. Requiring a reproduction makes Claude commit to a specific theory of the bug, which you can sanity-check before code changes. It converts 'here's a guess' into 'here's the mechanism'.
When to use it
Any non-obvious bug: intermittent failures, wrong output with no error, state that only breaks in combination. Especially valuable when you can't easily run the code yourself yet.
When not to use it
Trivial, obvious errors (a typo, a missing import) where reproduction is slower than the fix. Don't add ceremony to a one-character change.
Prompt
Here is the bug: <symptom>.
Here is the relevant code: <paste>.
Before proposing any fix:
1. Explain the exact sequence of events that produces this bug.
2. Write a minimal failing test or input that reproduces it.
3. State your confidence and what would disprove your theory.
Only after that, propose the smallest fix and explain why it addresses the root cause, not the symptom.Example
For an off-by-one that only appears on the last page of pagination, Claude first writes a test with total = pageSize * 2 that fails, names the boundary condition, then changes a single < to <= — and you trust it because the test now passes for the right reason.
Advanced version
Ask Claude to list two competing hypotheses and the observation that would distinguish them. This catches cases where the first plausible cause is not the real one, and turns debugging into a short experiment rather than a patch.
Common mistakes
- Accepting the first fix without the reproduction step — you patch a symptom and the bug returns in a new shape.
- Pasting the whole repo instead of the relevant slice, burying the signal in noise.
- Not stating the expected vs actual behaviour, so Claude optimises for the wrong target.