
- Updated
Let an AI agent fix failing tests properly
This prompt tells Claude Code or Cursor to run your tests and fix the failures the right way. It must explain each failure first and must never delete, skip or weaken a test just to make it pass.
Run [TEST COMMAND, e.g. npm test] and fix the failing tests. Rules: - Find out why each test fails before changing anything. - If the code is wrong, fix the code. If the test is outdated, explain why before changing it. - Never delete a test, skip it, or loosen an assertion just to make it pass. - Keep changes small and run the tests again after each fix. When everything passes, give me a short list of each failure, its cause and the fix, and point out anything that looks like a real bug in the product.
The "never delete or skip a test" line matters. Without it, agents sometimes make tests pass the easy way.
Get a better result
A working session in which the agent runs your tests, finds the cause of each failure, fixes the code or explains why a test is out of date, re-runs after each change and ends with a short list of failures, causes and fixes.
Snapshot tests are updated blindly so that they pass.
Fix: Add “never update a snapshot without first showing me the diff and explaining why the new output is correct”.
- It runs only the failing test, then a fix breaks another one. Add “at the end run the full suite and paste its summary line”. A green single test proves little.
- A flaky or environment-related test is “fixed” by changing real code. Say “if a test passes on a re-run with no change, report it as flaky and do not change the product code”.
Use “do not edit any file. For each failing test, give the cause, the file and line, and the change you would make”. You review the plan first, then let the agent apply it.
Stop and show me the diff for any snapshot or test you changed, explain why the new output is right, then run the whole suite and paste the summary line.
Guides that use this prompt
More chat & writing prompts
See all 465 →More like this
- Plan an A/B test properlyChatGPT · Gemini · Claude
- Write Cursor project rules for your codebaseClaude Code · Cursor
- Write a CLAUDE.md file for your projectClaude Code · Cursor
- Real estate agent introductionVeo · Kling
- Turn a fixed bug into a regression testClaude · ChatGPT · Claude Code



