<< Home | Prompting craft
Claude executes failing tests and provides output receipts before coding
| Area | Prompting craft |
| AI used | Claude |
| Source | Reddit thread |
| Posted | 2026-06-15 |
The move
Require Claude to define a falsifiable check and run a failing test before writing any code changes.| When this works | When it doesn't |
|---|---|
| Claude gets stuck in loops implementing code changes that fail to produce the desired outcome without testing them. It works when editing system instructions or CLAUDE.md for automated coding tasks. | The task cannot be verified via automated commands or lacks a test execution environment. |
Key details
- If it cannot specify a falsifiable check, then it isn't prepared to code.
- provide a command followed by the output, rather than simply stating 'I tested it'
- failing test first methodology
Prompt for your AI
Add the following rule to your CLAUDE.md or system prompt:
Rule: If you cannot specify a falsifiable check, then you are not prepared to code. Avoid letting "test it" become an ambiguous directive.
Follow the failing test first methodology before writing any code changes:
1. Specify a clear, falsifiable check for the task before editing any project files.
2. Create a test that is guaranteed to fail on the existing code base.
3. Execute the test command. Provide the receipt by showing the exact terminal command followed by its raw execution output proving the failure.
4. Only after confirming the test failure receipt, implement the minimum necessary code modifications.
5. Re-run the test command and display the new receipt showing the test passing.
Guardrails:
- Never simply state "I tested it" or summarize results in prose.
- Always output the raw execution receipt (command and output).
- If a test cannot be executed automatically, stop and notify the user before modifying code.
Before you give me the final result, check with me:
- A failing test was written and executed before any implementation code was modified.
- The test output receipt shows the exact command line and raw failure output.
- The test check is falsifiable and specific rather than an ambiguous statement.
What happened
A user was stuck in a loop where Claude made code edits that failed to fix issues, requiring constant manual prompts to test. By adding a rule to CLAUDE.md requiring a falsifiable check and execution output receipts before coding, Claude was forced to write and verify failing tests first.Who confirmed it
The failing test first methodology proves to be far more effective than testing afterward.Give it to your agent
Read https://howtheyuse.ai/p/claude-performs-mandatory-failing-tests-before-coding.md and help me do this.