title: "Bug Fix Prompt Template" tested_with: claude-code: "1.0.x" codex-cli: "0.2.x" last_updated: 2026-03-21 status: proven difficulty: beginner prerequisites: []
Bug Fix Prompt Template
When to Use This Prompt
When you've identified a bug and want the agent to investigate and fix it.
The Prompt
There's a bug where [describe the symptom — what happens vs. what should happen].
The relevant code is likely in [file or directory]. [Optional: describe any reproduction steps.]
Please:
1. Read the relevant code and identify the root cause
2. Fix the bug
3. Add a test that would have caught this bug
# Adapt this by:
# - Replace [symptom] with what you actually observe
# - Replace [file or directory] with where you think the issue is (or omit if unsure)
# - Add reproduction steps if you have them
# - Remove the test step if tests aren't set up yet
Why It Works
- Symptom-first: Tells the agent what's wrong without prescribing the fix
- Scoped: Points to the likely location, reducing search time
- Three-step structure: Read → Fix → Test prevents the agent from jumping to conclusions
- Test requirement: Ensures the fix is verified and prevents regression
Variations
When you don't know where the bug is:
Users report that [symptom]. I don't know where the relevant code is.
Search the codebase for code related to [feature area] and identify the root cause.
When you know the exact cause:
In [file:line], [describe the incorrect behavior]. This should instead [describe correct behavior].
Fix it and update any tests affected by the change.
Example Output
The agent should: read the file(s), explain what it found, show the fix, and write a test. If it jumps straight to editing without reading first, that's a sign to use the explore-before-change pattern.