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
  1. CheckA matcher in the wrong case

    bash

    Tool names are case-sensitive, so bash matches nothing and the hook never fires. The tool is Bash.

  2. CheckA gate that fails open

    PreToolUse → .claude/hooks/block-rm.sh

    If 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).

  3. CheckA script path relative to the current folder

    PreToolUse → .claude/hooks/block-rm.sh

    Hooks 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.

  4. 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.

  5. CheckA timeout that looks like milliseconds

    timeout: 5000

    Claude Code reads timeout in seconds, so 5000 waits about 83 minutes. If you meant milliseconds, write 5.

  6. CheckA gate that fails open

    PreToolUse → "$CLAUDE_PROJECT_DIR"/.claude/hooks/check-push.sh

    If 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).

  7. CheckAn MCP matcher that matches no tool

    mcp__github

    Without .* 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.

  8. RiskA gate that runs in the background

    PreToolUse → node .claude/hooks/audit.js

    A 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.

  9. CheckA script path relative to the current folder

    PreToolUse → node .claude/hooks/audit.js

    Hooks 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.

  10. CheckAn event Claude Code does not have

    PretoolUse

    Event names are case-sensitive and Claude Code knows no PretoolUse, so these hooks never run. The event is PreToolUse.

  11. CheckA gate that fails open

    PretoolUse → "$CLAUDE_PROJECT_DIR"/.claude/hooks/no-env.sh

    If 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

  1. PreToolUsematcherbashNever fires

    Runs .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.
  2. PreToolUsematcherBash(git push *)Never fires

    Runs "$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.
  3. PreToolUsematchermcp__githubNever fires

    Runs node .claude/hooks/audit.js (command) for nothing.

    Any answer
    Nothing it prints applies: it runs in the background and Claude does not wait.
  4. PretoolUsematcherReadNever fires

    Runs "$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.
  5. PermissionRequestmatcherBashDecides only by its JSON answer

    Runs "$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.
  6. PostToolUsematcherEdit|WriteCannot block

    Runs 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

Each fix makes a hook fire where it was meant to, or block when it breaks. Blocking on failure is off until you tick it: on a hook that only logs, a broken script would then stop every call it matches.

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.

What the Claude Code hooks checker flags
OptionFor exampleWhat happens
Hooks that never fireFor examplebash, Bas, Bash(git push *), mcp__github, PretoolUseWhat 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 openFor exampleA PreToolUse or PermissionRequest hook without onFailureWhat 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 blockFor exampleasync: true on a gate, exit 2 on PermissionRequestWhat happensA background hook answers after the call has run. PermissionRequest reads only its JSON decision, not exit 2.
Settings that quietly change what runsFor exampletimeout: 5000, node .claude/hooks/x.js, ~ in args, disableAllHooksWhat 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.