Quartet / Quintet

Claude Code の hook イベント一覧 — matcher と if が効く場所

公式ドキュメントは、イベントの一覧・matcher の対象・if の適用範囲を別々の節に書いています。設定を書くときに必要なのは、それを1行で見比べた表なので、ここに作りました。

イベントと matcher

イベントmatcher が当たる対象値の例
PreToolUsetool nameEdit|Write, Bash, mcp__server__.*
PostToolUsetool nameEdit|Write, Bash
PostToolUseFailuretool nameBash
PermissionRequesttool nameBash
PermissionDeniedtool nameBash
SessionStarthow the session startedstartup, resume, clear, compact, fork
Setupwhich CLI flag triggered setupinit, maintenance
SessionEndwhy the session endedclear, resume, logout, prompt_input_exit, other
Notificationnotification typepermission_prompt, idle_prompt, auth_success, agent_completed
SubagentStartagent typegeneral-purpose, Explore, Plan, custom names
SubagentStopagent typesame as SubagentStart
PreCompactwhat triggered compactionmanual, auto
PostCompactwhat triggered compactionmanual, auto
PreModelSwitchcanonical name of the target modelclaude-opus-5, .*opus.*
PostModelSwitchcanonical name of the target modelclaude-opus-5
ConfigChangeconfiguration sourceuser_settings, project_settings, local_settings, policy_settings, skills
DirectoryAddedhow the directory was addedslash_command, register_repo_root
FileChangedliteral filenames to watch.envrc|.env
StopFailureerror typerate_limit, overloaded, authentication_failed, server_error
InstructionsLoadedload reasonsession_start, nested_traversal, path_glob_match, include, compact
UserPromptExpansioncommand nameyour skill or command names
ElicitationMCP server nameyour configured MCP server names
ElicitationResultMCP server namesame as Elicitation

matcher を書いても無視されるイベント

公式にこう書かれています。“If you add a matcher field to an event without matcher support, it is silently ignored.”
エラーは出ません。絞ったつもりのハンドラが毎回走ります。

CwdChanged, UserPromptSubmit, PostToolBatch, Stop, TeammateIdle, TaskCreated, TaskCompleted, WorktreeCreate, WorktreeRemove, MessageDisplay

if が評価されるイベント

if はツール名と引数をまとめて見る絞り込みで、ツール系の5イベントでしか評価されません。それ以外で書くと、そのハンドラは一度も走りません。

PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest, PermissionDenied

ハンドラの必須フィールド

type ごとに要るものが違います。type を変えたときに前のフィールドが残るのがよくある形です。

type必須
commandcommand
httpurl
mcp_toolserver, tool
promptprompt
agentprompt

出典は Hooks(2026-09-04 時点)。この表は公式の記述から起こしたもので、公式そのものではありません。食い違いがあれば公式が正です。

この一覧をそのまま検査するツールを MIT で公開しています。.claude/ を読んで、無視される設定と非推奨の書き方を、根拠になっている公式ドキュメントへのリンク付きで指摘します。

ccheck