Menu

7 mistakes that make Claude Code hooks fail silently
📰

7 mistakes that make Claude Code hooks fail silently

DEV Community: security·Brie Lab·about 7 hours ago
#OfT8CCnU
#devtosecurity#devto#dev#exit#enter
Long article (484 words) — no AI summary yet.
Reading 0:00
15s threshold

Claude Code hooks are the only rules an agent can't forget in a long session. But a hook that never fires fails silently: no error, no warning, just an agent doing the thing you thought you'd blocked. Here are seven mistakes I see most in .claude/settings.json , and one in .mcp.json .

1. A lower-case matcher

{ "matcher" : "bash" , "hooks" : [ ... ] }

Enter fullscreen mode

Exit fullscreen mode

Tool names are case-sensitive. bash matches nothing; it has to be Bash . Same for Edit , Write , Read .

2. The hook object without its wrapper

"PostToolUse" : [ { "type" : "command" , "command" : "npx prettier --write" } ]

Enter fullscreen mode

Exit fullscreen mode

Each event takes an array of groups , and each group has its own hooks array:

"PostToolUse" : [ { "matcher" : "Edit|Write|MultiEdit" , "hooks" : [ { "type" : "command" , "command" : "npx prettier --write" } ] } ]

Enter fullscreen mode

Exit fullscreen mode

3.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.