Test-First Bug Fixing Approach
Guide to fixing bugs using a test-first approach, ensuring code reliability through systematic testing and implementation.
Prompt template
- Format
- Text Parameterized
- Outputs
- result (text)
I have a bug: ${bug}. Take a test-first approach: 1) Read the relevant source files and existing tests. 2) Write a failing test that reproduces the exact bug. 3) Run the test suite to confirm it fails. 4) Implement the minimal fix. 5) Re-run the full test suite. 6) If any test fails, analyze the failure, adjust the code, and re-run—repeat until ALL tests pass. 7) Then grep the codebase for related code paths that might have the same issue and add tests for those too. 8) Summarize every change made and why. Do not ask me questions—make reasonable assumptions and document them.
Replace the ${…} placeholders with your values
before using this prompt. See parameters
and defaults below
Parameters
Replace each placeholder with your own value, or use its default when one is provided
${bug}
bug
Required
What you'll create
The workflow verifies failure before implementation and repeats only when tests expose issues. A closing explanation records changes and assumptions.
Frequently asked questions
Does the process start by patching code without a test?
No. A failing test for the exact bug comes first.
Comments
Tried this prompt? Share what you made, compare results, or ask a question