Block Stop until tests pass with a hook
A Stop hook can refuse to end the turn if tests fail, looping the model back until the work is actually green.
- Type: Prompt
- Tags: Coding Agent Hacks, Intermediate, Claude Code
- Updated: 2026-10-01
Prompt
A Stop hook can refuse to end the turn if tests fail, looping the model back until the work is actually green. Stop hooks run when the agent thinks it's done. Exit code 2 + a stderr message tells the model 'no, keep going.' Pair with a fast test runner so the loop is tight. The model literally cannot ship broken code. Implementation example: // .claude/settings.json { "hooks": { "Stop": [{ "matcher": "", "hooks": [{ "type": "command", "command": "pnpm test --run || echo 'tests failing — fix before stopping' >&2 && exit 2" }] }] } }
More prompts
- Expense Report Automation System — Save More Time
- Meeting Scheduling Link Standardization — Save More Time
- Invoice Generation and Delivery Automation — Save More Time
- Document Template Automation Library — Save More Time
- Calendar Management Automation Rules — Save More Time
- File Organization and Naming System — Save More Time
- Recurring Payment Automation Setup — Save More Time
- Data Entry Elimination Framework — Save More Time