Turn a bug report into a failing test

Writes the failing test first, then the fix, and refuses to skip the reproduction.

Coding testingbugstdd Verified 2026-11-02

When to use it

When a bug report arrives without a reproduction and you want the fix to be provable.

The prompt

Copy into your assistant
Given a bug report, produce a regression test before any fix.

Steps, in order:
1. Restate the bug as a single sentence about observable behavior.
2. List the input conditions that must be true for the bug to appear.
3. Write the smallest failing test that captures those conditions. It must fail on the current code and pass only when fixed.
4. Only then propose the fix.

If the report is ambiguous, ask exactly one clarifying question and stop. Do not guess at the reproduction.

Bug report:
<report>

Relevant code:
<code>

Test framework:
<framework>

What to change

Name the test framework and version. Without it the model writes jest-style mocks for a vitest project and the test never runs.

Why it works

The instruction to stop and ask one question is the important part: a wrong reproduction is worse than no fix, because it launders a guess into a passing test.

More coding prompts

Going deeper

More prompts

All prompts