Bible Network Crypto DeFi Onchain RWA AI Agent Stablecoin Chain SAFU CryptoTax DeFAI AGI Claude Me Claude Skill Claude Design Claude Cowork
Independent Media
Not affiliated with any project
Exploring the Frontier of AI Intelligence
claude-me.com
LATEST
Claude Haiku 5.5 Launches at $0.10 per Million Input Tokens, but Price Jumps 5x Past 100K: Do the Math Before You Migrate  ·  Claude Code Hooks Add onFailure: "block": A Mistyped Script Path No Longer Lets Your Policy Gate Silently Pass Everything  ·  Claude Code's Agent Tool Gets an effort Parameter: One Subagent Type, No More Separate Copies for Every Thinking Depth  ·  Claude Code Adds --max-findings: Stop Code Review From Dumping a Hundred Suggestions on You at Once  ·  Claude Code Adds Mods: Plugins Can Now Change Deeper Behavior, But Even Anthropic Hasn't Said How to Judge the Quality  ·  Barclays Scales Up Claude: Targeting 50% Developer Adoption of Claude Code by Year End, Sorting 120,000 Emails a Day
practice

Claude Code Hooks Add onFailure: "block": A Mistyped Script Path No Longer Lets Your Policy Gate Silently Pass Everything

30-Second Version · For the impatient
When a policy hook breaks, the default is to let everything through, so your gate may have been dead all along until someone mistyped a single path.

Full Explanation +
01 · Why did this happen?

How is onFailure: "Block" different from exiting with code 2 inside the script?

Exit 2 is the script declaring, after running normally, that the action is not allowed, and it assumes the script actually started and reached that line. onFailure: "block" covers the case where the script never ran, timed out or exited unexpectedly, meaning the checker itself failed.

They complement each other: exit 2 expresses the verdict, and onFailure makes sure that when the checker falls over, the default is not to let the action through.

02 · What is the mechanism?

Should every hook get onFailure: "Block"?

No. For helper hooks such as notifications, logging and formatting, carrying on when they break is usually better than stalling everything, and fail-closed turns those small problems into work stoppages.

Turn it on only for gates where a missed block costs more than a false block, such as the few guarding production, payment commands and customer data.

03 · How does it affect me?

How do I confirm my gate hook really blocks?

The most direct way is a deliberately broken test: point the script path at something that does not exist, or make it sleep past its timeout, then trigger the action it guards and see whether the action is actually blocked.

You can also use claude Plugin validate for hook error-handling advice, but a real test is the only way to prove the gate holds when it fails.

04 · What should I do?

Can I find this option in the official docs, and should I use it now?

When I checked, the readable part of the official hooks page did not yet list it, and the semantics come only from a one-line changelog entry. That means the exact field location and applicable events are yours to verify.

Test it first in a scratch project with a hook that fails on purpose, and roll it into shared team settings once the documentation catches up.

Full Content +

Claude Code v2.1.295 (October 8, 2026) adds onFailure: "Block" for command and HTTP hooks. The changelog describes it as blocking the action when a hook cannot start, times out or exits unexpectedly. To see what it fixes, start with the old default behavior.

The Old Default Was Fail-Open

The official hooks documentation is explicit: for most events, when a script path does not exist or is not executable, the shell exits with a code such as 127, Claude Code shows a non-blocking notice, and the action proceeds. The docs even warn that when you set up a policy hook, a mistyped path in settings.json leaves the gate silently disabled. Timeouts work the same way: a timed-out command, http or mcp_tool hook on PreToolUse does not block the tool call, and the docs say not to count on a stalled hook as a gate. Non-2xx HTTP responses and connection failures are also non-blocking errors. Even exit code 1, the conventional Unix failure code, is non-blocking without valid JSON; only exit 2 blocks.

onFailure: "block" Flips It to Fail-Closed

In other words, policy hooks used to be fail-open: if the checker itself broke, there was effectively no check. onFailure: "block" lets you choose fail-closed per hook: if it cannot start, times out or exits unexpectedly, the action is blocked instead of continuing through the normal permission flow. That matters most for gates where a false block is acceptable and a missed block is not, such as hooks that guard certain directories, deployment commands, or call an external compliance API for approval. One caveat: the part of the official hooks page I could read does not yet list this option, so the semantics above come from the one-line changelog entry. Which settings field it goes in, which events it applies to and how it interacts with timeout should be confirmed against updated official docs, and you should verify it yourself with a deliberately mistyped hook before relying on it.

Using It Without Locking Yourself Out

The cost of fail-closed is availability: if the compliance service behind an HTTP hook goes down, every action it guards is blocked. Turn it on only for genuinely high-risk gates, handle predictable errors inside the hook script, and keep an explicit escape hatch such as a managed-settings switch that can disable the hook quickly. Also, v2.1.295 adds advice from claude Plugin validate on hooks, and v2.1.290 already lists whether each gating hook has a .catch; together they help you find gates with no error handling before launch.

What This Means for Your Money

If your team uses hooks to guard things that must not be touched, such as production credentials, payment-related commands or customer data directories, audit them today: which hooks would turn into silent pass-throughs if they broke? List them, add onFailure: "block" to the highest-risk few, and write a test that fails on purpose. Discovering two months later that a gate had been dead all along costs far more than ten minutes of checking.

Sources: Claude Code changelog (v2.1.295, v2.1.290), Claude Code hooks reference
Diagram
Hook Failure: Fail-Open vs Fail-Closedhook 無法正常執行時,預設放行與 onFailure block 兩條路徑的對比Hook Failure: Fail-Open vs Fail-ClosedGate hook cannot run properlymissing path / timeout / unexpected exitDefault (fail-open)Non-blocking notice shownAction proceedsGate silently disabledonFailure: block (fail-closed)Action is blockedFailure becomes visibleCost: availability riskUse fail-closed only where a missed block costs more than a false blockClaude Me · claude-me.com
Feel free to share. Please credit the source.
Ask a Question
Please enter at least 10 characters
Related Articles
Claude Code's Agent Tool Gets an effort Parameter: One Subagent Type, No More Separate Copies for Every Thinking Depth
practice · Oct 10
Claude Code Adds --max-findings: Stop Code Review From Dumping a Hundred Suggestions on You at Once
practice · Oct 06
Claude Agent SDK Adds verbatim_prompts: Turning Off Automatic @path Expansion and Slash-Command Dispatch to Stop Untrusted Text From Executing as Commands
practice · Oct 06
Claude Agent SDK Fixes a Background-Subagent Bug: stdin Closing Too Early Right When a Subagent Finishes Breaks the Next Turn
practice · Oct 06
More Related Topics