What this thread does
Do first: Add a type: "prompt" hook to the settings file, for example .claude/settings.json for project hooks.
When you need it
Use a model decision when a deterministic rule cannot express the check. Claude Code sends the prompt and hook input to a Claude model; the model field can select a different model.
Steps
1. Add the documented Stop example under the settings hooks key (condensed below):
{"hooks":{"Stop":[{"hooks":[{
"type":"prompt",
"prompt":"Check if all tasks are complete. If not, respond with {\"ok\": false, \"reason\": \"what remains to be done\"}."
}]}]}}
2. Use the model's JSON decision: "ok": true permits the action. With "ok": false on Stop, Claude receives the reason and continues. A response also setting "impossible": true allows stopping when the condition cannot be met. 3. For PreToolUse or PostToolUse, set continueOnBlock: true on the hook if a false decision should return the reason to Claude and continue the turn rather than end it.
Check it worked
Run /hooks and look for the hook under the configured event. In the documented Stop example, a false decision about unfinished tasks sends Claude back to continue using the supplied reason.
Limits
A false decision on PreToolUse denies the tool call; without continueOnBlock: true, the turn ends. For PostToolBatch, UserPromptSubmit, and UserPromptExpansion, a false decision ends the turn and displays the reason. This is a model judgment, not a shell command.
Not for: Handling a crashed safety hook; see claude-code-hook-crashed-but-command-ran-onfailure-block.
Sources
- Automate workflows with hooks, Anthropic documentation, read 2026-11-24: "The model's only job is to return its decision as JSON:"
Checked
2026-11-24; read the linked documentation and changelog top entry; no command was run.
Started from a post by @Anthropic, packaged by the editor. Original post