Discover all Claude Code hooks across every settings file in scope, validate each one against the filesystem and hook semantics, then run an interactive session to confirm or improve them.
The goal is not just to score; it is to leave every hook working, correctly scoped, and safe to run.
| Event | When it fires | Can block? (exit 2) |
|---|---|---|
PreToolUse |
Before any tool call | Yes |
PermissionRequest |
When a permission dialog appears | Yes |
PostToolUse |
After tool completes successfully | No (shows stderr to Claude) |
PostToolUseFailure |
After a tool fails | No |
PostToolBatch |
After a full batch of parallel tool calls resolves | Yes (stops agentic loop) |
UserPromptSubmit |
When user submits a prompt | Yes |
UserPromptExpansion |
When a slash command expands | Yes |
Stop |
When Claude finishes responding | Yes (continues the turn) |
SubagentStop |
When a subagent finishes | Yes (continues the subagent) |
TeammateIdle |
When an agent team teammate goes idle | Yes |
TaskCreated |
When a task is being created | Yes |
TaskCompleted |
When a task is being marked as completed | Yes |
PreCompact |
Before context compaction | Yes |
ConfigChange |
When a configuration file changes | Yes (except policy_settings) |
PermissionDenied |
When auto-mode classifier denies a tool call | No |
SessionStart |
When a session starts or resumes | No |
Setup |
On --init-only or -p --init/--maintenance | No |
StopFailure |
When the turn ends due to API error | No |
Notification |
When Claude sends a notification | No |
MessageDisplay |
While assistant message streams | No |
SubagentStart |
When a subagent is spawned | No |
InstructionsLoaded |
When a CLAUDE.md or rules file is loaded | No |
CwdChanged |
When working directory changes | No |
FileChanged |
When a watched file changes on disk | No |
WorktreeCreate |
When a worktree is created (replaces default git behavior) | Yes (any non-zero fails) |
WorktreeRemove |
When a worktree is removed | No |
PostCompact |
After compaction completes | No |
SessionEnd |
When a session terminates | No |
ElicitationResult |
After user responds to MCP elicitation | Yes |
Elicitation |
When MCP server requests user input | Yes |
Events that do NOT support matchers: UserPromptSubmit, PostToolBatch, Stop, TeammateIdle, TaskCreated, TaskCompleted, WorktreeCreate, WorktreeRemove, CwdChanged, MessageDisplay.
Warning: only exit code 2 blocks. Exit code 1 is a non-blocking error and proceeds with the action. Use exit 2 for policy enforcement.
| Hook type | Default timeout |
|---|---|
command, http, mcp_tool |
600s |
UserPromptSubmit (command/http/mcp_tool) |
30s |
MessageDisplay (command/http/mcp_tool) |
10s |
prompt |
30s |
agent |
60s |
SessionEnd |
1.5s (overall budget) |
{ "ok": true/false } decisionFor PreToolUse, PostToolUse, and related tool events, the matcher filters on tool name:
Edit|Write)mcp__memory__.*)"*", "", or absent: matches all tool callsOther events match different fields (e.g. SessionStart matches on source: startup|resume|clear|compact). For the complete per-event matcher field reference, see guide/core/hooks-events-reference.md.
if field (v2.1.85+)The if field narrows a handler further by tool name AND arguments together, using permission rule syntax. Evaluated per handler (not per matcher group), so the process only spawns when both match.
{
"matcher": "Bash",
"hooks": [
{ "type": "command", "if": "Bash(git *)", "command": "my-git-policy.sh" }
]
}
Flag: if only works on tool events (PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest, PermissionDenied). Adding it to any other event type prevents the hook from running.
| File | Scope | Committed? |
|---|---|---|
~/.claude/settings.json |
Global user | No |
~/.claude/settings.local.json |
Global local | No |
.claude/settings.json |
Project | Yes |
.claude/settings.local.json |
Project local | No |
Plugin hooks/hooks.json |
Per plugin | Yes (in plugin) |
Skill/agent frontmatter hooks: |
Per component | Yes |
If an argument is provided (e.g. /eval-hooks .claude/settings.local.json), audit only that file. Otherwise scan the four standard locations.
| # | Criterion | Max | What is checked |
|---|---|---|---|
| 1 | valid event type | 1 | Type is one of the 30 known event types listed above |
| 2 | matcher | 2 | Absent for events that don't support matchers (1pt); not an overly broad pattern with a heavy command (1pt) |
| 3 | command | 3 | Non-empty (1pt); referenced script or binary resolves on disk (1pt); script is executable (chmod +x) (1pt) |
| 4 | timeout | 2 | Blocking hooks (PreToolUse, UserPromptSubmit) have explicit timeout field (1pt); value is ≤ 30s for interactive hooks (1pt) |
| 5 | blocking awareness | 2 | Blocking hooks: exit 2 used (not exit 1) for policy enforcement (1pt); no interactive commands that would hang (1pt) |
| Bonus | hygiene | +1 | No duplicate (event + matcher + command) combination found across all scanned files |
Thresholds:
Non-blocking events (PostToolUse, SessionEnd, Notification, etc.): skip criterion 5 (blocking awareness). Score on 8 pts max. Flag with 🔵.
Parse each settings file found:
ls ~/.claude/settings.json ~/.claude/settings.local.json \
.claude/settings.json .claude/settings.local.json 2>/dev/null
For each file that exists, extract the hooks object. Parse every entry across all event types.
Build a flat list of hook records:
source_file: which settings file it came fromevent_type: e.g. PreToolUse
matcher: string or absenttype: command / http / mcp_tool / prompt / agentcommand: shell command string (command hooks only)timeout: seconds or absent (note: JSON uses seconds, not ms)async: booleanIf no hooks are found in any file, report it and stop.
For each command hook, resolve the first token to a binary or script:
CMD=$(echo "$command" | awk '{print $1}')
CMD="${CMD/#\~/$HOME}"
which "$CMD" 2>/dev/null || test -f "$CMD" && echo "found" || echo "not found"
test -x "$CMD" && echo "executable" || echo "not executable"
Flag:
chmod +x was never run (most common source of silent failures)~ (usually safe since hooks run via shell, but absolute paths are preferred)/ or ~ (resolves from working directory, which may vary)Also flag patterns that indicate the hook will hang:
read, fzf, gum, any interactive TUI command: flag as ❌ (hangs the agent, hooks run without a controlling terminal since v2.1.139)For PreToolUse, UserPromptSubmit, UserPromptExpansion, Stop, SubagentStop hooks whose command is a local script:
exit 2 statements vs exit 1 or generic exit $?
Flag any PreToolUse script that contains slow operations (curl, sleep, network calls) without a surrounding timeout guard.
Compare all hook records by (event_type + matcher + command). Report exact duplicates across files: they fire twice and consume double the latency.
Also flag: a matcher field on an event that doesn't support matchers (silently ignored by Claude Code).
Process hooks one by one. Do not batch and skip the interaction.
For each hook:
Show:
Hook: PreToolUse → Bash [~/.claude/settings.json]
type: command
command: /Users/me/.claude/hooks/confirm-git-push.sh
timeout: (none, default 600s)
Script: found (executable ✅)
Exit strategy: uses exit 2 ✅
Ask three questions:
For lifecycle hooks (no matcher):
Show:
Hook: SessionEnd [~/.claude/settings.local.json]
type: command
command: ~/.claude/hooks/session-summary.sh
timeout: (none, default 1.5s for SessionEnd, very short!)
Script: found (executable ✅)
Ask:
If the user provides changes during the interaction: apply them using Edit, confirm each change, then move to the next hook.
After all hooks are reviewed:
# Hooks Audit: [project or global]
Date: [today] | Scanned: N hooks across M settings files
## Summary
| Status | Count |
|--------|-------|
| ✅ Good (≥80%) | N |
| ⚠️ Needs work (50-79%) | N |
| ❌ Fix (<50%) | N |
| 🔵 Non-blocking event | N |
| ✅ User confirmed useful | N |
| ⚠️ User flagged for update | N |
| 🗑️ User marked as stale | N |
---
## Per-Hook Results
### PreToolUse → Bash [~/.claude/settings.json] (7/10 ⚠️)
type: command
command: `~/.claude/hooks/confirm-git-push.sh`
timeout: (none)
| Criterion | Score | Notes |
|-----------|-------|-------|
| valid event type | ✅ 1/1 | PreToolUse |
| matcher | ✅ 2/2 | scoped to Bash |
| command | ✅ 3/3 | found, executable, absolute path |
| timeout | ❌ 0/2 | no timeout (UserPromptSubmit default is 30s, others 600s) |
| blocking awareness | ✅ 2/2 | exit 2 used for blocking ✅ |
**Priority fixes:**
1. Add `"timeout": 10` to cap blocking time
2. Verify script doesn't block on network calls without internal timeout
User feedback: ✅ scope correct
Content: timeout added ✅
---
### PostToolUse → Edit|Write [~/.claude/settings.json] (10/10 ✅) 🔵
type: command
command: `~/.claude/hooks/anti-ai-markers.sh`
timeout: 2
Non-blocking event: exit 2 shows stderr to Claude but doesn't prevent the action. All criteria pass. User confirmed still useful.
---
## What Changed This Session
confirm-git-push.sh hook:
- Added timeout: 10
session-summary.sh hook:
- User confirmed useful, no changes
rtk-baseline.sh hook:
- User flagged as stale (awaiting explicit deletion confirmation)
---
N hooks audited · N edits applied · N flagged as stale · N duplicates found
For any hook the user marked as stale: ask for explicit confirmation before removing it from the settings file. Never delete without a clear "yes, remove it".
rtk hook claude): skip script-level checks, verify the binary rtk exists in PATHbash -c '...' inline: parse the inner script string for interactive commands and exit code logicexit 1 in a PreToolUse hook: flag as ⚠️ (exit 1 is a non-blocking error, the tool call will proceed even if the intent was to block)timeout: 0: flag as likely invalid (may be treated as no timeout)PreToolCall typo): flag as ❌, report exact string, suggest the correct namechmod +x immediatelyUserPromptSubmit with a matcher): flag as silently ignored, suggest removing itasync: true hook returning decision: "block": flag as ⚠️ (async hooks cannot block, decision fields have no effect)asyncRewake: true hook: implies async: true but additionally wakes Claude when the background process exits with code 2. The hook's stderr (or stdout if stderr is empty) is shown to Claude as a system reminder. Flag hooks that need to signal background failures back to Claude but use async instead of asyncRewake
prompt or agent type hook: these don't have a command to resolve; check that the prompt field is present and non-emptytimeout: 30, it may be cut off. Flag any SessionEnd hook without an explicit timeout, and warn that heavy work here risks being killed/hooks menu in Claude Code to verify configuration, and checking ~/.claude/logs/ or running with --debug
PermissionRequest hook in -p mode: these hooks don't fire in non-interactive mode. Flag and suggest migrating to PreToolUse insteadif field on non-tool event: hook never runs silently. Flag and suggest removing if or changing the event typeupdatedInput: when several hooks modify tool input, the last to finish wins (execution is parallel, order is non-deterministic). Flag when more than one PreToolUse hook on the same matcher returns updatedInput
stop_hook_active check: a Stop hook that always blocks will hit the 8-consecutive-blocks cap and be overridden. Check that the script reads the stop_hook_active field from stdin JSON and exits 0 when it is true, to let Claude stop once it has already continued$CLAUDE_PROJECT_DIR in command: preferred over hardcoded absolute paths for project scripts. Flag any command containing an absolute path that looks project-local and suggest replacing with ${CLAUDE_PROJECT_DIR}/...