The prompt
Score 10 of 10, Excellent
Use it when You are handing a bug to Claude Code, Codex or another coding agent and want a root-cause fix with proof, not a guess.
- {{symptom}}
- {{expected_behavior}}
- {{location}}
- {{repro_steps}}
- {{error_output}}
- {{ruled_out}}
- {{off_limits}}
- {{test_command}}
Full prompt and why it works
Prompt
Goal: Fix this bug: {{symptom}}. Fixed means: {{expected_behavior}}. Context: - Where it happens: {{location}} - Steps to reproduce: {{repro_steps}} - Exact error or log output: """ {{error_output}} """ - Already ruled out: {{ruled_out}} Constraints: - Find the root cause before changing code. Read the code path end to end and explain the cause in 2 to 3 sentences before you edit. - Make the smallest change that fixes the cause, so that the diff is easy to review. Do not refactor, rename or reformat unrelated code, and do not change public interfaces or the database schema. - Do not modify or delete existing tests to make them pass. Do not touch {{off_limits}}. - Follow the patterns already used in the surrounding code, such as how this module handles and logs errors. Done when: - A new regression test reproduces the bug: it fails before your fix and passes after it. Put it with the existing tests for this code, following the project's naming (for example parser.test.ts next to parser.ts, or tests/test_parser.py). - The full test suite passes: {{test_command}} Verify: run the test command, read the output, and iterate until it passes. Then report in this format: Root cause (2 to 3 sentences), Files changed, Test command and the last 20 lines of its output. If the cause is still unclear after investigating, or the fix needs a change to something off limits, stop and ask before editing. If you are not sure that the behavior I described as fixed is right, say so.
Variables
- {{symptom}}
- What goes wrong, in one sentence.
- {{expected_behavior}}
- What correct behavior looks like, as specifically as you can.
- {{location}}
- The files, functions or endpoints involved, as far as you know.
- {{repro_steps}}
- The steps or the request that triggers the bug.
- {{error_output}}
- The exact error, stack trace or log lines, pasted rather than described.
- {{ruled_out}}
- What you already checked, so the agent does not repeat it. "Nothing yet" is fine.
- {{off_limits}}
- Files, folders or systems that must not change, for example migrations or generated code.
- {{test_command}}
- The command that runs the tests, for example npm test or pytest.
Why it works
- What good looks like. A Done when section with a failing-then-passing regression test gives the agent a check it can run, instead of its own opinion that the bug is fixed.
- What to avoid. It rules out the usual shortcuts: editing tests until they pass, refactoring on the side, touching code that is off limits.
- If unsure. An unclear cause or an off-limits fix means stop and ask, which prevents a confident wrong patch.