Why doesn't my Claude Code hook block anything?
A Claude Code PreToolUse hook blocks a tool call only when it exits with code 2. Exit 1 is a non-blocking error, so the tool still runs. Timeouts and a mistyped script path also fail open. For hard rules, put deny entries in .claude/settings.json: deny is checked first and an allow cannot override it.
The breakdown
Exit 2 blocks. Exit 1 does not.
Anthropic's Claude Code hooks docs say a PreToolUse hook stops the tool when it exits with code 2. Exit code 1 is treated as a non-blocking error: the hook can log, but the tool call continues. One digit is the whole difference between a security gate and a log line.
Timeouts and bad paths fail open
If the hook times out, or the script path in your config is wrong, Claude Code does not treat that as a block. The tool still runs. A hook you think is protecting the repo may never have run.
Use permission rules for hard denies
For rules that must always hold, use permission rules in .claude/settings.json. Anthropic's permissions docs say deny is evaluated first, and an allow cannot override a deny. That is the place for "never run this tool" policy.
CLAUDE.md is guidance, not enforcement
Project instructions such as CLAUDE.md shape what the model tries to do. They do not change what Claude Code allows at the tool layer. Treat them as advice. Put real blocks in hooks (exit 2) or in permission deny rules.
Network still belongs outside
Hooks and permission files control tools inside Claude Code. Outbound network policy still belongs at a gateway or proxy the agent cannot rewrite.
The question at the end of the video: Have you checked what your hooks exit with?
Sources
FAQ
What exit code blocks a Claude Code PreToolUse hook?
Exit code 2. Per Anthropic's hooks docs, that is the code that prevents the tool from running. Exit code 1 does not block.
Does exit code 1 stop the tool in Claude Code?
No. Exit 1 is a non-blocking error. The hook can report a problem, but Claude Code still runs the tool. Use exit 2 when the call must be denied.
Where should hard allow and deny rules live?
In .claude/settings.json permission rules. Deny is checked first, and an allow cannot override a deny. That is stronger than relying on CLAUDE.md text alone.
Are CLAUDE.md rules a security control?
No. They guide the model. They do not change Claude Code's allow and deny machinery. Pair them with hooks that exit 2 and with explicit deny rules for anything that must never run.
































