|
2 | 2 | globs: "**/*.sh,**/settings.json,**/settings.json.partial" |
3 | 3 | description: "Hook system design patterns and safety requirements" |
4 | 4 | domain: claude-code-engineering |
5 | | -last_verified: 2026-04-07 |
| 5 | +last_verified: 2026-04-15 |
6 | 6 | --- |
7 | 7 |
|
8 | 8 | # Hook Architecture |
9 | 9 |
|
10 | | -## Events (27 total, verified v2.1.92) |
11 | | - |
12 | | -Core: SessionStart, SessionEnd, Stop, StopFailure |
13 | | -Tool lifecycle: PreToolUse, PostToolUse, PostToolUseFailure |
14 | | -User: UserPromptSubmit |
15 | | -Permissions: PermissionRequest, PermissionDenied |
16 | | -Elicitation: Elicitation, ElicitationResult |
17 | | -Agent: SubagentStart, SubagentStop, TeammateIdle, TaskCreated, TaskCompleted |
18 | | -Context: PreCompact, PostCompact, CwdChanged, FileChanged, InstructionsLoaded |
19 | | -System: ConfigChange, Notification |
20 | | -Worktree: WorktreeCreate, WorktreeRemove |
| 10 | +## Events (31 total, verified v2.1.108 — code.claude.com/docs/en/hooks) |
| 11 | + |
| 12 | +Three lifecycle cadences: |
| 13 | + |
| 14 | +**Session-level** (once per session): SessionStart, SessionEnd, InstructionsLoaded |
| 15 | +**Turn-level** (once per user prompt): UserPromptSubmit, Stop, StopFailure |
| 16 | +**Tool-loop** (every tool call): PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest, PermissionDenied |
| 17 | +**Async/side**: Notification, SubagentStart, SubagentStop, TaskCreated, TaskCompleted, TeammateIdle, ConfigChange, CwdChanged, FileChanged, WorktreeCreate, WorktreeRemove, PreCompact, PostCompact, Elicitation, ElicitationResult |
| 18 | + |
| 19 | +`InstructionsLoaded` fires when CLAUDE.md or `.claude/rules/*.md` loads. `load_reason` field: `session_start`, `nested_traversal`, `path_glob_match`, `include`, `compact`. Observability-only — no decision control. |
| 20 | + |
| 21 | +`PreCompact` is **blockable** since v2.1.105 (exit 2 prevents compaction). Was non-blocking before. |
| 22 | + |
| 23 | +`Elicitation`/`ElicitationResult` fire during MCP tool execution when an MCP server requests structured user input. Support `accept`/`decline`/`cancel` actions and field overrides. |
21 | 24 |
|
22 | 25 | ## Exit codes, types, and decisions |
23 | 26 |
|
|
0 commit comments