The most common failure of a coding agent is not a wrong answer. It is stopping: writing a summary, asking “shall I continue?”, or announcing that all tests pass when they do not. Whiplash Driven Development answers with a push. A Stop hook automates the push inside the tool.
What a Stop hook is
Claude Code lets you run commands at fixed points of its work, configured in .claude/settings.json. A Stop hook runs when Claude is about to end its turn. The hook can allow that, or block it and hand Claude a reason to continue. In Claude Code, a hook that exits with code 2 blocks the action and its error output is fed back to Claude.
That is exactly the WDD loop: when the agent wants to stop, check the work; if it is not done, send it back with the evidence.
The hook
.claude/settings.json:
{
"hooks": {
"Stop": [
{ "hooks": [{ "type": "command", "command": "bash .claude/hooks/tempo-gate.sh", "timeout": 600 }] }
]
}
}
.claude/hooks/tempo-gate.sh (shortened; the kit builder writes the full one with your verifier and budget):
#!/usr/bin/env bash
VERIFY='npm test'
MAX=20
count=$(cat .wdd/stop-count 2>/dev/null || echo 0)
if bash -c "$VERIFY" > .wdd/verify.log 2>&1; then echo 0 > .wdd/stop-count; exit 0; fi
if [ "$count" -ge "$MAX" ]; then echo 0 > .wdd/stop-count; exit 0; fi
echo $((count + 1)) > .wdd/stop-count
{ echo "Not quite my tempo. $VERIFY still fails:"; tail -n 40 .wdd/verify.log; } >&2
exit 2
The three parts that matter
- The verifier decides. The hook does not ask the agent whether it is finished. It runs the check.
- The evidence goes back. The last lines of the failing output are the reason. The agent gets the facts, not just a refusal.
- There is a budget. After a set number of blocked stops, the hook lets go. A gate with no limit can trap an agent that is truly stuck, spending money on rounds that will never converge. When the budget runs out, a person decides what to change.
Things to watch
- Slow checks make slow stops. The hook runs every time the agent tries to finish. If the verifier takes ten minutes, so does every attempted stop; run a fast subset in the hook and the full suite at the end.
- Do not let the agent edit the hook. Say so in the standing orders, and keep
.claude/out of the files it is meant to change. - Sandbox it. An agent that cannot stop will keep running commands. Run it somewhere that cannot hurt.
- Versions change. Hook settings and behaviour depend on the Claude Code version; check its documentation.
Hooks or a loop script?
A Stop hook keeps one long session going; a loop script starts a fresh headless session each round, with state carried in files and git. Fresh sessions avoid context rot on very long runs; a hook is simpler and keeps the agent’s working memory. Many people use both: a hook inside each session, and a loop around sessions.