Skip to content

Claude Code hooks can block instead of failing open

Claude Code 2.1.295 adds an onFailure: "block" setting for command and HTTP hooks, so a hook that crashes, times out or exits oddly stops the action instead of letting it through.

Source: Anthropic

Anthropic shipped Claude Code 2.1.295 on 8 October, adding an onFailure: "block" setting for command and HTTP hooks. Until now, if a hook could not start, timed out, or exited with an unexpected code, the action it was meant to gate proceeded anyway. A typo in a hook script, not just a deliberate exit, could let a blocked command through.

Setting onFailure: "block" on a hook flips that default from fail-open to fail-closed, and it’s scoped to command and HTTP hooks specifically:

{
  "type": "command",
  "command": "./check-policy.sh",
  "onFailure": "block"
}

The same release adds Program Status Protocol (OSC 7501) support, so terminals that implement it can show whether Claude Code is working, waiting on you, or done, plus an optional models list on Claude apps gateway upstreams to restrict which models a given upstream serves.

Why it matters: anyone using hooks to enforce a policy, say blocking rm -rf or gating a risky tool call, has been trusting that the enforcement script itself never breaks. Fail-open is a reasonable default for a hook that just adds context, but it’s the wrong one for a hook whose entire job is to say no. This setting makes that a choice instead of an accident.

Share

More from The Wire

All briefs