Test-First Bug Fixing Approach Prompt
A ready-to-paste prompt for test-first bug fixing approach. It opens with: "Take a test-first approach: 1) Read the relevant source files and existing tests." It's for developers. Use it when you want a back-and-forth session rather than a single answer.
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.
Source: awesome-chatgpt-prompts (CC0).
How to use this prompt
- 1
Copy the prompt
Use the copy button, or type its Retext trigger in any app to paste it.
- 2
Open your AI assistant
Start a new chat in ChatGPT, Claude, Gemini or the assistant you use.
- 3
Fill in the details
Replace any [bracketed] parts with your own details.
- 4
Check and refine
Read the answer, then reply with one change at a time.
Tips for better results
- •Fill in [bug] before you send it. The rest of the prompt depends on those details.
- •Keep the whole session in one chat. A new chat forgets the role, so you would need to paste the prompt again.
- •Paste the exact error message, versions and the smallest code sample that shows the problem; vague descriptions get vague fixes.
Get the free prompt pack
Our best coding prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.
Variations
Context first
Add this line at the end: Before you start, ask me up to three questions about my test-first bug fixing approach task and wait for my answers.
Session recap
Add this line: When I type "recap", summarize what we have covered so far in five bullet points, then carry on.
Save it as a Retext snippet
Retext is a free text expander for Mac. Save this prompt once, then type ;test-first in any app (ChatGPT, Claude, your editor, a browser tab) and the full prompt is pasted in.
- Click Add to Retext. The prompt installs as a snippet with the trigger ;test-first.
- Change the trigger in Retext if you prefer a different one.
- Type the trigger wherever you want the prompt, then fill in the brackets.
Frequently asked questions
What does the Test-First Bug Fixing Approach prompt do?
A ready-to-paste prompt for test-first bug fixing approach. It opens with: "Take a test-first approach: 1) Read the relevant source files and existing tests." It's written for developers.
Which AI tools does it work with?
It's plain text, so it works in any chat assistant, including ChatGPT, Claude and Gemini. Paste it as the first message of a new chat.
What do I need to fill in?
Replace [bug] with your own details. Leave the rest as it is unless you want to change how the AI answers.
Can I save this prompt as a snippet?
Yes. Click Add to Retext and it installs as a snippet with the trigger ;test-first. Type that in any Mac app to paste the full prompt.
Related Templates
Get the free prompt pack
Our best coding prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.