Check your Claude Code hooks
Paste your settings and see, for every hook, whether it fires on the tools you meant and whether it can stop a call: matchers in the wrong case, events spelled wrong, gates that let the call run when the script fails, and timeouts written in milliseconds. Then copy the file back with the fixes you pick. Nothing leaves this page.
1Paste your settings file
Everything runs in this page and nothing you paste is sent anywhere. Comments and trailing commas are fine.
2Which hooks fire, and which can block
- 1 risk
- 10 checks
CheckA matcher in the wrong case
bashTool names are case-sensitive, so bash matches nothing and the hook never fires. The tool is Bash.
CheckA gate that fails open
PreToolUse → .claude/hooks/block-rm.shIf this hook exits 1, crashes, cannot start, times out or prints broken JSON, the tool call goes ahead. If it is meant to stop calls, add "onFailure": "block" (Claude Code 2.1.295 or later).
CheckA script path relative to the current folder
PreToolUse → .claude/hooks/block-rm.shHooks run in Claude's current folder, which changes when Claude runs cd or enters a worktree, so .claude/hooks/block-rm.sh may not be found and the hook fails. Write "$CLAUDE_PROJECT_DIR"/.claude/hooks/block-rm.sh.
CheckA permission rule written as a matcher
Bash(git push *)A matcher holds tool names, not permission rules, so this one matches no tool and the hook never fires. Match Bash and put Bash(git push *) in each handler's "if" field.
CheckA timeout that looks like milliseconds
timeout: 5000Claude Code reads timeout in seconds, so 5000 waits about 83 minutes. If you meant milliseconds, write 5.
CheckA gate that fails open
PreToolUse → "$CLAUDE_PROJECT_DIR"/.claude/hooks/check-push.shIf this hook exits 1, crashes, cannot start, times out or prints broken JSON, the tool call goes ahead. If it is meant to stop calls, add "onFailure": "block" (Claude Code 2.1.295 or later).
CheckAn MCP matcher that matches no tool
mcp__githubWithout .* this is compared as an exact name, and mcp__github is a server, not a tool, so the hook never fires. Write mcp__github__.* for every tool on that server.
RiskA gate that runs in the background
PreToolUse → node .claude/hooks/audit.jsA background hook cannot block or decide anything: Claude Code does not wait for it, so the call has already gone ahead when it answers. Take out async on a PreToolUse gate.
CheckA script path relative to the current folder
PreToolUse → node .claude/hooks/audit.jsHooks run in Claude's current folder, which changes when Claude runs cd or enters a worktree, so .claude/hooks/audit.js may not be found and the hook fails. Write "$CLAUDE_PROJECT_DIR"/.claude/hooks/audit.js.
CheckAn event Claude Code does not have
PretoolUseEvent names are case-sensitive and Claude Code knows no PretoolUse, so these hooks never run. The event is PreToolUse.
CheckA gate that fails open
PretoolUse → "$CLAUDE_PROJECT_DIR"/.claude/hooks/no-env.shIf this hook exits 1, crashes, cannot start, times out or prints broken JSON, the tool call goes ahead. If it is meant to stop calls, add "onFailure": "block" (Claude Code 2.1.295 or later).
Each hook, and what its answers do
- PreToolUsematcher
bashNever firesRuns
.claude/hooks/block-rm.sh(command) for nothing.- Exit 0
- The call goes on to the permission rules, unless its JSON says deny, ask or allow.
- Exit 2
- The call is blocked, and Claude reads stderr as the reason.
- Exit 1 or any other code
- The call goes ahead, as a non-blocking error. Valid JSON it printed still decides.
- Script missing or crashes
- The call goes ahead, as a non-blocking error.
- Still running after 600 s
- The call goes ahead, as a non-blocking error.
- PreToolUsematcher
Bash(git push *)Never firesRuns
"$CLAUDE_PROJECT_DIR"/.claude/hooks/check-push.sh(command) for nothing.- Exit 0
- The call goes on to the permission rules, unless its JSON says deny, ask or allow.
- Exit 2
- The call is blocked, and Claude reads stderr as the reason.
- Exit 1 or any other code
- The call goes ahead, as a non-blocking error. Valid JSON it printed still decides.
- Script missing or crashes
- The call goes ahead, as a non-blocking error.
- Still running after 5000 s
- The call goes ahead, as a non-blocking error.
- PreToolUsematcher
mcp__githubNever firesRuns
node .claude/hooks/audit.js(command) for nothing.- Any answer
- Nothing it prints applies: it runs in the background and Claude does not wait.
- PretoolUsematcher
ReadNever firesRuns
"$CLAUDE_PROJECT_DIR"/.claude/hooks/no-env.sh(command) for Read.- Exit 0
- The call goes on to the permission rules, unless its JSON says deny, ask or allow.
- Exit 2
- The call is blocked, and Claude reads stderr as the reason.
- Exit 1 or any other code
- The call goes ahead, as a non-blocking error. Valid JSON it printed still decides.
- Script missing or crashes
- The call goes ahead, as a non-blocking error.
- Still running after 600 s
- The call goes ahead, as a non-blocking error.
- PermissionRequestmatcher
BashDecides only by its JSON answerRuns
"$CLAUDE_PROJECT_DIR"/.claude/hooks/deny-prod.sh(command) for Bash.- Exit 0
- Its JSON decision allows or denies. Without one, you are asked.
- Exit 2
- Not read as a decision: you are asked as usual. Deny with the JSON decision object instead.
- Exit 1 or any other code
- The request is denied, because onFailure is block.
- Script missing or crashes
- The request is denied, because onFailure is block.
- Still running after 600 s
- The request is denied, because onFailure is block.
- PostToolUsematcher
Edit|WriteCannot blockRuns
npx prettier --write .(command) for Edit, Write.- Exit 0
- Success. Its JSON fields apply.
- Exit 2
- Nothing is blocked on this event.
- Exit 1 or any other code
- Claude Code carries on. Valid JSON it printed still decides.
- Script missing or crashes
- Claude Code carries on.
- Still running after 600 s
- Claude Code carries on.
The hooks, fixed
The copy is plain JSON: comments and trailing commas from your paste are not in it.
What the checker looks for
The rules follow Claude Code’s hooks reference, read 27 November 2026, and we ran the cases that matter for a gate with claude -p on Claude Code 2.1.332 the same day. It reads one file: Claude Code adds the hooks of every settings file together, so check each one you use.
| Option | For example | What happens |
|---|---|---|
| Hooks that never fire | For examplebash, Bas, Bash(git push *), mcp__github, PretoolUse | What happensMatchers are exact, case-sensitive tool names unless they hold other characters. In our runs none of these started the hook, and the command ran. |
| Gates that fail open | For exampleA PreToolUse or PermissionRequest hook without onFailure | What happensExit 1, a crash, a missing script or a timeout let the call run. With onFailure: block, all of them blocked it. |
| Gates that cannot block | For exampleasync: true on a gate, exit 2 on PermissionRequest | What happensA background hook answers after the call has run. PermissionRequest reads only its JSON decision, not exit 2. |
| Settings that quietly change what runs | For exampletimeout: 5000, node .claude/hooks/x.js, ~ in args, disableAllHooks | What happensTimeouts are seconds. A relative path breaks when Claude changes folder. With args there is no shell to expand ~. disableAllHooks turns them all off. |
Two things it cannot see from the file: whether your script is executable (one that was not never started, and the call ran), and where you start Claude Code. Started in a subfolder, 2.1.332 did not load the project’s .claude/settings.json at all, so none of its hooks ran.
A gate that asks a person
A hook can only say yes or no by itself. The VariantGate hook, variantgate hook claude-code, sends the call to you instead: on your phone, by email, in Slack, Teams, Discord or Telegram, and Claude Code goes on when you answer. Give it "onFailure": "block" like any other gate. Free for one person and 100 requests a month, with no card.
Questions
Why is my Claude Code hook not running?
Usually the matcher. Tool names are case-sensitive and a matcher of plain letters is an exact name, so bash, Bas and Bash(git *) all match nothing: in our runs on Claude Code 2.1.332 none of them started the hook and the command ran. Other common causes are a misspelled event name such as PretoolUse, disableAllHooks set somewhere, a script that is not executable, and starting Claude Code in a subfolder: started there, it did not load the project's .claude/settings.json at all.
Why doesn't my PreToolUse hook block the command?
Only exit code 2, or JSON with hookSpecificOutput.permissionDecision set to deny, blocks a PreToolUse call. Exit 1 is a non-blocking error and the call goes ahead, and so does a hook that times out, crashes, cannot start or prints broken JSON. A deny written at the top level of the JSON, without hookSpecificOutput, was ignored in our test. Put the reason on stderr: with exit 2 and the reason on stdout, the call was blocked but Claude was told nothing.
How do I make a Claude Code hook fail closed?
Add "onFailure": "block" to the hook (Claude Code 2.1.295 or later). In our runs a hook with it set blocked the call when it exited 1, when its script was missing and when it ran past its timeout; without it, all three let the call run.
Is a hook's timeout in seconds or milliseconds?
In seconds. The default is 600 for command, http and mcp_tool hooks (30 on UserPromptSubmit), 30 for prompt hooks and 60 for agent hooks. A timeout of 5000 is 83 minutes, not five seconds. On PreToolUse a hook that reaches its timeout lets the call go ahead unless onFailure is block.
Does exit code 2 deny a PermissionRequest hook?
No. Claude Code reads exit code 2 as a decision on PreToolUse, but not on PermissionRequest: there it shows the usual question. To deny from a PermissionRequest hook, print the decision object with behavior set to deny.
Do hooks still run in bypass permissions mode?
Yes. With --dangerously-skip-permissions, a PreToolUse hook that exits 2 still blocked the command in our run. A hook's allow skips the prompt but not a deny rule: with Bash(touch:*) denied, a hook answering allow was still refused.
Does the checker run my hooks or send my settings anywhere?
No. It reads the text you paste in this page and nothing is sent anywhere. It cannot see your scripts, so it cannot tell whether one exits 2 or prints the right JSON; the summary says what Claude Code does with each answer.