Make Claude Code hooks block when they break
A developer pointed out that Claude Code hooks fail open by default: if a hook script crashes, times out or has a typo in its path, you get an error notice and the command runs anyway. According to the post, version 2.1.295 added an onFailure: "block" setting so a broken hook stops the tool call instead. The suggested split: safety checks like lint gates, secret scans and tests should fail closed; convenience hooks like formatting and logging can fail open.
Why it matters
A guardrail that silently switches off when it breaks is worse than no guardrail, because you think you are protected.
Who it's for
Teams that rely on Claude Code hooks for secret scanning, tests or other checks.
How to try it
- Run claude --version and check the hooks section of Anthropic's Claude Code docs for the failure setting.
- Add the block-on-failure option to hooks that enforce policy (secret scans, test gates).
- Leave formatting and logging hooks failing open.
- Test it by temporarily breaking a hook's path and checking that the tool call is stopped.
Plan & availability: Claude Code CLI; the post says the setting arrived in v2.1.295.
Note: reported by users on X; we haven't independently confirmed it works in the current version.
Source: @yoshibuild on X
Written by Sarah Mitchell from the original post. Checked Oct 17, 2026. Features, plans and availability can change, so confirm on the source before you rely on it.
claude-codehookssecurity
More Claude tricks
- One URL and one key for all your MCP servers: ngrok's MCP Gateway is live · Dec 2
- OpenCode 2.4.2 cuts about 700 tokens per request and tunes GPT-6.2 · Nov 26
- OpenCode 2.4 gives your coding agent a browser, automations, and video generation · Nov 24
- Claude Code 2.1.330 draws your charts with easel and lets scheduled tasks run 30 days · Nov 21