
What happened
With gaurd.mjs typo'd in settings.json, the guard hook returned status 127 and the rm command deleted the fake key; adding "onFailure": "block" kept it.
Why it matters
A guard hook that never runs leaves only the appearance of protection, so the author adds a ~30-line check-hooks.mjs script that names the bad path.
Summaries like this, in your inbox every morning.
The author follows up on earlier work using a Claude Code hook to stop the tool from deleting .env or key files. That setup had a blind spot: the official hooks reference states that a path typo in settings.json means the hook never runs at all, and a broken guard hook lets everything through. In the test, Claude Code passed the command as JSON to a guard script, which exits with code 2 to block and 0 to allow; anything else counts as a non-blocking failure. A one-letter typo in the registered path produced exit status 127 (file not found), so the rm command went ahead.
The fix is a single setting, "onFailure": "block", which flips the guard from failing open to failing closed. The trade-off is deliberate: any hook failure, including a crash or timeout, blocks all Bash use until the path is corrected in settings.json and Claude Code is reopened. Because of that, the author recommends applying it only to guard hooks protecting something you would rather block than lose.
The companion ~30-line checker scans the registered commands, expands $CLAUDE_PROJECT_DIR and ~, and lists any hook file that does not exist, with exit code 1. It is a quick way to catch a misspelled path before relying on the guard, though it only tests existence, not whether the script's blocking condition is correct.
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.
Anthropic used Claude to analyze 25 open-source projects (over 5 million lines) and found 493 issues, includin…

The author details a setup where Claude Code reads an entry document called CLAUDE.md, writes results into rol…

Using atopile, KiCad, Freerouting and Claude Code, the developer automated circuit description, placement, rou…

The author ran 6 questions three to five times each with claude -p across 4 layouts

PMDesk, a macOS app for running multiple projects with AI agents, now lets users type "@" in its terminal to o…

Asymptote Labs' Justin showed Beacon, an open-source layer that captures prompts, tool calls and file changes…
