Stackmark › Prompts

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

Privacy · Terms · llms.txt