Prove It Bug Fix
When given a bug or error report, reproduce it with a failing test before attempting a fix.
When to use
- •User reports a bug, error, or unexpected behavior
- •Stack trace or error message is provided
- •Something "doesn't work" or "broke"
Test Level Hierarchy
Reproduce at the lowest level that can capture the bug:
- •Unit test - Pure logic bugs, isolated functions (lives next to the code)
- •Integration test - Component interactions, API boundaries (lives next to the code)
- •E2E/UX spec test - Full user flows, browser-dependent behavior (follow project conventions)
Steps
- •
Reproduce with subagent
- •Spawn a subagent (Task tool) to write a test that demonstrates the bug
- •The test MUST fail before any fix is attempted
- •If the test passes, the bug isn't properly reproduced—refine the test
- •
Fix
- •Only after reproduction is confirmed, implement the fix
- •Keep the fix minimal and focused
- •
Confirm
- •Run the test again—it must now pass
- •This proves the fix works
Subagent Prompt Template
code
Write a test that reproduces this bug:
{bug_description}
Requirements:
- Choose the appropriate test level (unit/integration/e2e)
- The test MUST fail currently to prove the bug exists
- Name the test descriptively (e.g., `test_cart_total_excludes_deleted_items`)
- Place the test following project conventions
Run the test and confirm it fails before reporting back.
If Reproduction Isn't Feasible
Some bugs are environment-specific or transient. If a test truly can't capture the bug:
- •Document why (e.g., "Race condition only occurs under load")
- •Add logging or assertions that would catch it if it recurs
- •Note this in the commit message
Never skip reproduction silently.