Claude Code Code Mode lets a script's tool call through when a PreToolUse hook errors
In Claude Code 2.1.329, a PreToolUse hook that errors no longer refuses a Code Mode script's tool call, matching behaviour outside Code Mode. Hooks that must refuse need "onFailure": "block".
What does this mean for me?
Action needed
Engineering leadership
Cost, risk, timeline, team impact Action neededIf your organization uses PreToolUse hooks as security or policy guards in Claude Code, a failing hook no longer blocks Code Mode scripts from 2.1.329. Have the owners of those hooks make them fail-closed now.
Engineer
What to change, what breaks, what to test Action neededAdd "onFailure": "block" to every PreToolUse command, HTTP or MCP tool hook that must refuse a call when it errors. Without it, a crashing or timing-out hook lets a Code Mode script's tool call run.
General consumer
Using the Claude apps, not the API No impactNothing to do — this affects Claude Code hook configuration, not the Claude apps.
Claude Code 2.1.329 changes what happens in Code Mode when a PreToolUse hook fails. Until now, a hook that errored refused the tool call a Code Mode script made. From 2.1.329 the call goes ahead, which is how a failing hook already behaved outside Code Mode.
This matters for anyone using a PreToolUse hook as a guard — a policy check, a secret scanner, a command filter. If that hook crashes, times out or otherwise errors, a script’s tool call now runs instead of being blocked.
To keep a hook fail-closed, set "onFailure": "block" on it. The changelog names command, HTTP and MCP tool hooks as the kinds that take this setting.
Topics: Coding tools