# Test-First Bug Fixing Approach

| Field | Value |
| --- | --- |
| Content type | [Writing](https://dopamine-prompt.com/en/type/writing) |
| Models | [GPT](https://dopamine-prompt.com/en/model/gpt) |
| License | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) |
| Source | Submitted by [una\_w](https://dopamine-prompt.com/en/u/16733233-0301-4b40-ab2e-02f1a2b20a33) |
| Last updated | 2026-11-26 |

## Prompt

```
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.
```

## Words you can change

The words in brackets in the prompt can be replaced with your own.

- `{bug}`: Type your own.

Web page: <https://dopamine-prompt.com/en/prompts/test-first-bug-fixing-approach>
