
What happened
Running Claude Code 2.1.331 with a hook that blocks rm -rf, exit 1 let the build folder be deleted in all 3 runs, while exit 2 kept it in all 3; adding "onFailure": "block" stopped even a mistyped hook path.
Why it matters
A broken or mistyped hook fails silently in unattended runs — no hook mention appeared in Claude's final report — so anyone relying on PreToolUse hooks as a safety net may be unprotected without knowing it.
Summaries like this, every morning.
The test set out to answer a question many teams skip: does the hook actually stop anything? Kosuke ran Claude Code 2.1.331 with claude -p in a fresh folder containing build/a.txt, using only that folder's .claude/settings.json and .claude/hooks/, and judged each run by whether the build folder survived — not by what Claude said.
The failure modes turned out to be independent of each other. A hook that exits 1 is treated by Claude Code as a non-blocking error, per Anthropic's own reference, even though 1 is the usual Unix failure code; the same applies to a mistyped script path or a Python KeyError, which left no trace in the stream-json log that exit 1 and the exception cases produced. String matching added a separate weakness: the rm -rf hook passed 17 of 22 delete commands, including the ordinary rm -r build, and regex or allowlist approaches each traded misses for new costs — the allowlist stopped all 22 but also blocked harmless commands and forced Claude to rewrite its calls.
Kosuke notes the limits plainly: 26 commands are his own selection, each condition ran 3 to 15 times, and Windows, other models and sandbox behavior remain untested. The practical conclusion is that a hook is not a safety device until it has been broken and its pass count measured.
Pick your industry and the AI tools you use, and get news related to your work every day.
Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →
Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.
Cognition AI Japan said its autonomous AI software engineer Devin is in use at NTT Docomo's product technology…

Jakub Pachocki's essay "Perplexity and Intelligence" publishes five years of OpenAI base-model log-perplexity…

Cognition began offering Devin Bots on the 17th (US time)

An audit of QuantG's prior LLM mining found 72% of 1,250 candidate factors failed the first statistical test…

A Zenn guide details how to create PowerPoint materials with Microsoft 365 Copilot, including use-case-based m…

MulmoTerminal, a free MIT-licensed app for running Claude Code and Codex side by side in a browser, showed thr…
