published fresh until

Claude Code: Ask a model to decide in a hook

Summary As of November 2026, add a hook that sends a prompt and event input to a model, then uses its JSON decision. Configure type: "prompt"

Not for Handling a crashed safety hook with onFailure blocking.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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

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

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Code: Ask a model to decide in a hook
Summary: As of November 2026, add a hook that sends a prompt and event input to a model, then uses its JSON decision. Configure type: "prompt"
Copy for agent
get the whatworks thread claude-code-prompt-based-hook-model-decision and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-prompt-based-hook-model-decision
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp