Find Why a Test Fails
A failing test can mean the code is wrong or the test is wrong. This prompt makes the model decide which one first, so it doesn't 'fix' the test just to make it pass.
Works with Claude, ChatGPT and Gemini4 fields
This Python + pytest test fails:
```
def test_slugify_accents():
assert slugify('Café Déjà') == 'cafe-deja'
```
Output:
```
AssertionError: assert 'caf-d-j' == 'cafe-deja'
```
Code under test:
```
def slugify(s):
return re.sub(r'[^a-z0-9]+', '-', s.lower()).strip('-')
```
First decide: is the code wrong, or is the test's expectation wrong? Explain why in two sentences.
Then give the smallest change that fixes the right side, and one extra test case that would have caught this earlier.
Do not weaken or delete the test to make it pass.
Everything you type stays in your browser. Remove passwords, keys and personal data before pasting anything into an AI tool.
Why this prompt is written this way
- Which side is wrong. Forcing a decision stops the common shortcut of editing the assertion.
- No weakening. An explicit rule against deleting or loosening the test protects what the test is for.
- One more test. Asking for an extra case turns one bug fix into better coverage.
Example answer
Illustrative and shortened, to show the shape of a good answer. Real answers vary by model.
The code is wrong: the regex drops accented letters instead of converting them.
Fix: normalize with unicodedata.normalize('NFKD', s) and drop combining marks before the regex.
Extra test: slugify('Ünïcode Ünits') == 'unicode-units'.
Tips
- Paste the exact output, including the diff the test runner prints.
- Run the test again after the fix and paste the result if it still fails.
How to use it
- Replace the example values with your own. The prompt on the right updates as you type.
- Press Copy prompt and paste it into any AI chat, or open it straight in Claude or ChatGPT.
- Save it as prompt.md if you want to reuse it.