Fix a Failing Test Without Cheating

Point an AI agent at a red test and keep it honest: find the real cause, fix the code, and never edit the assertion just to make it pass.

The prompt

The test below is failing. Find the root cause before changing anything, and explain it. Fix the code under test, not the test, unless you can show the test itself is wrong; if so, explain why before editing it. Don't skip, delete or loosen assertions. Run the test suite afterward and report the result.

Test:
{{test}}

Failure output:
{{output}}

Works in ChatGPT, Claude, Gemini and other assistants. Replace the highlighted placeholders with your own content.

How to use it

Paste the failing test at {{test}} and the full failure output at {{output}}. The prompt asks for the root cause first and rules out weakening the test, which is where AI fixes most often go wrong.

Tips for better results

  • Include the whole output, not just the last line; the cause is often earlier.
  • If the agent says the test is wrong, check its reasoning before accepting the edit.
  • Run the full suite afterward, not only the one test.

Save this prompt in Promta

Keep it in your library and paste it from the menu bar, a hotkey or your iPhone keyboard, without leaving the app you're in.

Download Free on App Store

Free to start · iPhone & Mac

Related prompts

Browse all 80 prompts