Building a SaaS tool or MCP server? Get listed or sponsor AgentStackList →
Claude Coding By Sarah Mitchell

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

  1. Run claude --version and check the hooks section of Anthropic's Claude Code docs for the failure setting.
  2. Add the block-on-failure option to hooks that enforce policy (secret scans, test gates).
  3. Leave formatting and logging hooks failing open.
  4. 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

All Claude tricks →