florianbruniaux/claude-code-ultimate-guide/eval-hooks
Claude Code and agent skill by florianbruniaux/claude-code-ultimate-guide
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"},{"type":"config","description":"Configuration overrides"}]
Checking that the SKILL.md file is still in the repository.
Audit Claude Code and Codex hooks for validity, safety, and correctness across settings.json, hooks.json, config.toml, plugin, and skill or agent frontmatter hooks. Resolves each command, checks event names, handler types, matchers, exit-code and JSON decision strategy, and timeouts against each host's documented rules, then reviews hooks one by one. Use when setting up hooks, debugging a hook that never fires, never blocks, or hangs the agent, or doing a periodic hooks hygiene pass. Not for wr…
Install
npx vskill@latest install florianbruniaux/claude-code-ultimate-guide/eval-hooksSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as florianbruniaux/claude-code-ultimate-guide/eval-hooks.
Hooks evaluator
Discover every Claude Code and Codex hook in scope, validate each one against the filesystem and the host's documented 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.
Sources of truth: the official Claude Code hooks reference (https://code.claude.com/docs/en/hooks) and the Codex hooks documentation (https://developers.openai.com/codex/hooks). When a rule below and the live documentation disagree, the documentation wins; report the disagreement instead of scoring against stale text.
When to use
- First time adding hooks (validate before committing)
- A hook never fires, or fires on every tool call
- The agent hangs noticeably before executing a tool
- A policy hook is supposed to block but doesn't
- After copying hooks from another project, machine, or host
- Periodic hygiene: "are all these hooks still doing something useful?"
Scope
| Argument | Audit | |
|---|---|---|
| none | Every Claude Code and Codex location listed below that exists | |
claude or codex | That host only | |
| a file path | That file only (settings JSON, hooks.json, config.toml, skill or agent file) | |
audit-only, or the user asks for no changes | Steps 1-4 and 6 only: list each proposed change instead of asking or editing, and omit the user-feedback lines from the report |
Audit each host with its own rules. Never score a Codex hook against Claude Code semantics or the reverse.
When a ctxharness doctor --format json report generated during this task is available, reconcile against it: every hook-layer finding it reports must appear in the audit, and every extra finding needs file:line evidence.
Claude Code: Key concepts
Event types (33)
| Event | When it fires | Exit 2 effect | |
|---|---|---|---|
SessionStart | Session begins or resumes | Stderr to user only | |
Setup | --init-only, or --init / --maintenance in -p mode | Ignored | |
UserPromptSubmit | Prompt submitted, before processing | Blocks and erases the prompt | |
UserPromptExpansion | A typed command expands into a prompt | Blocks the expansion | |
PreToolUse | Before a tool call executes | Blocks the tool call | |
PermissionRequest | A tool call needs a permission decision | Not honored: deny through the JSON decision object | |
PermissionDenied | Auto mode denies a tool call | Ignored (only hookSpecificOutput.retry is read) | |
PostToolUse | After a tool call succeeds | Stderr to Claude; the tool already ran | |
PostToolUseFailure | After a tool call fails | Stderr to Claude | |
PostToolBatch | After a full batch of parallel tool calls | Stops the agentic loop | |
Notification | Claude Code sends a notification | Ignored | |
MessageDisplay | While assistant text is displayed | Original text displayed | |
SubagentStart | A subagent is spawned | Stderr to user only | |
SubagentStop | A subagent finishes | Prevents the subagent from stopping | |
TaskCreated | A task is being created | Rolls back the creation | |
TaskCompleted | A task is being marked completed | Prevents completion | |
Stop | Claude finishes responding | Prevents stopping, continues the turn | |
StopFailure | The turn ends on an API error | Ignored (except terminalSequence) | |
TeammateIdle | An agent team teammate is about to go idle | Keeps the teammate working | |
InstructionsLoaded | A CLAUDE.md or .claude/rules/*.md file loads | Ignored | |
ConfigChange | A configuration file changes mid-session | Blocks the change (except policy_settings) | |
CwdChanged | The working directory changes | Stderr to user only | |
DirectoryAdded | A directory is added via /add-dir or SDK register_repo_root | Stderr to debug log; already added | |
FileChanged | A watched file changes on disk | Stderr to user only | |
WorktreeCreate | A worktree is being created | Any non-zero exit fails creation | |
WorktreeRemove | A worktree is being removed | Any non-zero exit fails removal if the directory remains | |
PreCompact | Before compaction | Blocks compaction | |
PostCompact | After compaction | Stderr to user only | |
PreModelSwitch | Before a requested model switch | Blocks the switch | |
PostModelSwitch | After the session model changes | Stderr to user only | |
Elicitation | An MCP server requests user input | Denies the elicitation | |
ElicitationResult | After the user answers an elicitation | Blocks the response (becomes decline) | |
SessionEnd | Session terminates | Stderr to user only |
Exit codes and JSON output
- Exit 2 blocks on the events whose row says so. No JSON can override it, not even
permissionDecision: "allow". - JSON is read on every exit code, not only 0. For events with a standard decision model, a valid JSON decision takes effect on exit 0 or any other non-2 code:
hookSpecificOutput.permissionDecision: "deny"(PreToolUse, PreModelSwitch),hookSpecificOutput.decision.behavior: "deny"(PermissionRequest), top-leveldecision: "block"(UserPromptSubmit, UserPromptExpansion, PostToolUse, PostToolUseFailure, PostToolBatch, Stop, SubagentStop, ConfigChange, PreCompact, TaskCreated, PreModelSwitch). - Any other non-zero code without valid JSON is a non-blocking error: the action proceeds and the transcript shows the first stderr line. A missing or non-executable script exits with a code like 127 and lands in this bucket, so a mistyped path silently disables a policy gate.
- Exit 0 stdout becomes context only on
UserPromptSubmit,UserPromptExpansion,SessionStart, andPostModelSwitch; elsewhere it goes to the debug log.
A policy hook is correctly built when it uses either exit 2 or a JSON decision supported by its event. Exit 1 alone is the defect.
Timeout defaults (seconds)
| Handler | Default | |
|---|---|---|
command, http, mcp_tool | 600 | |
same, on UserPromptSubmit, PreModelSwitch, PostModelSwitch | 30 | |
same, on MessageDisplay | 10 | |
prompt | 30 | |
agent | 60 | |
SessionEnd | 1.5 total budget; a per-hook timeout raises it to the highest configured value, up to 60. Plugin hook timeouts do not raise it. CLAUDE_CODE_SESSIONEND_HOOKS_TIMEOUT_MS overrides it |
A timed-out command, http, or mcp_tool hook on PreToolUse does not block the tool call; on PreModelSwitch it blocks the switch. timeout is not enforced on a running async: true hook; it is enforced with asyncRewake.
Handler types and where they are allowed
| Handler type | Allowed on | |
|---|---|---|
command, mcp_tool | Every event | |
http | Every event except SessionStart and Setup | |
prompt | PermissionDenied, PostToolBatch, PostToolUse, PostToolUseFailure, PreToolUse, Stop, SubagentStop, TaskCompleted, TaskCreated, TeammateIdle, UserPromptExpansion, UserPromptSubmit, PermissionRequest | |
agent (experimental) | Same as prompt, except PermissionRequest, where an agent hook is skipped |
On PermissionDenied, prompt and agent hooks run but their output is discarded.
Handler fields
| Field | Applies to | Notes | |
|---|---|---|---|
type | all | command, http, mcp_tool, prompt, agent | |
if | all | One permission rule, such as Bash(git *). Evaluated only on PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest, PermissionDenied; on any other event the hook never runs. Best-effort filter, not an enforcement mechanism | |
timeout | all | Seconds | |
statusMessage | all | Spinner text | |
once | all | Honored only in skill frontmatter; ignored in settings files and agent frontmatter | |
command | command | Shell string, or the executable when args is set | |
args | command | Exec form: no shell, each element one argument. Preferred when referencing ${CLAUDE_PROJECT_DIR} or ${CLAUDE_PLUGIN_ROOT} | |
shell | command | bash or powershell; ignored when args is set | |
async | command | Runs in the background; cannot block or decide | |
asyncRewake | command | Background, and wakes Claude when the process exits 2 | |
url, headers, allowedEnvVars | http | Blocks only through a 2xx JSON body; status codes alone never block | |
server, tool, input | mcp_tool | Uses an already connected server | |
prompt, model | prompt, agent | $ARGUMENTS receives the hook input |
Matchers
| Matcher value | Evaluated as | |||
|---|---|---|---|---|
"*", "", or omitted | Match all | |||
Only letters, digits, _, -, spaces, ,, `\ | ` | Exact string, or a list separated by `\ | or ,` (hyphens need v2.1.195+) | |
| Any other character | Unanchored JavaScript regex (Edit.* also matches NotebookEdit; anchor with ^...$) |
FileChanged and StopFailure use a narrower exact set (letters, digits, _, |). Each event filters a different field:
| Event | Matcher filters | ||
|---|---|---|---|
PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest, PermissionDenied | tool name (Bash, `Edit\ | Write, mcp__server__.*`) | |
SessionStart | startup, resume, clear, compact, fork | ||
Setup | init, maintenance | ||
SessionEnd | clear, resume, logout, prompt_input_exit, other | ||
Notification | notification type | ||
SubagentStart, SubagentStop | agent type | ||
PreCompact, PostCompact | manual, auto | ||
PreModelSwitch, PostModelSwitch | canonical target model name | ||
ConfigChange | configuration source | ||
DirectoryAdded | slash_command, register_repo_root | ||
FileChanged | literal filenames to watch | ||
StopFailure | error type | ||
InstructionsLoaded | load reason | ||
UserPromptExpansion | command name | ||
Elicitation, ElicitationResult | MCP server name |
No matcher support (a matcher is silently ignored): UserPromptSubmit, PostToolBatch, Stop, TeammateIdle, TaskCreated, TaskCompleted, WorktreeCreate, WorktreeRemove, CwdChanged, MessageDisplay.
Execution model
- All matching hooks run in parallel.
- The same handler defined in more than one settings file runs once. A plugin's or a skill's copy of the same handler stays separate.
PermissionRequesthooks also run in sessions that cannot show a prompt, such as background subagents in-pmode; if no hook decides, the call is denied.- Several
PreToolUsedecisions resolve asdeny > defer > ask > allow. The documentation does not define whichupdatedInputwins when several hooks rewrite the same call. StopandSubagentStopcontinuations, throughdecision: "block"oradditionalContext, are bounded by thestop_hook_activeinput and an 8-consecutive-continuation cap.- Command hooks run without a controlling terminal: interactive commands (
read,fzf,gum, any TUI) cannot get input. UseterminalSequencein JSON output for notifications.
Claude Code: Locations scanned
| Location | Scope | Notes | |
|---|---|---|---|
| Managed policy settings | Organization | Cannot be disabled by user, project, or local disableAllHooks | |
~/.claude/settings.json | User | Not read by cloud sessions | |
.claude/settings.json | Project, committed | ||
.claude/settings.local.json | Project, personal | ||
Plugin hooks/hooks.json | While the plugin is enabled | ||
Skill frontmatter hooks: | Rest of the session once the skill is invoked | once: true honored here only | |
Subagent frontmatter hooks: | While that subagent runs | Stop becomes SubagentStop. Project subagent hooks run only after workspace trust is accepted, including in -p |
~/.claude/settings.local.json is not a documented settings location. If it exists, report it as undocumented and do not score its hooks as active.
Also record, from the effective settings:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingexamples/skills/eval-hooks/SKILL.md
Popularity
- Repository stars
- 6,306
- Repository forks
- 821
- 7-day trend score
- 43
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooksconfigConfiguration overrides
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/florianbruniaux/claude-code-ultimate-guide/eval-hooks)