Skip to content

Hooks and events reference

This page is the canonical list of hook names, runtime event families, and externalized stream/control frames visible around tools, sessions, MCP, and agents. It keeps event lists out of broad narrative pages while preserving links to the implementation owners.

Scope and caveats

  • Hook names are source-visible in the analyzed cli.js bundle; exact input/output schemas are event-specific and may be extended by plugins or feature gates.
  • This page distinguishes hooks from frames and protocol methods. They are all event-like, but they do not share one subscription mechanism.
  • Treat tengu_* strings as telemetry or feature-signal names unless adjacent code/doc text confirms a public event contract.

Source anchors

Semantic aliasSourceApproximate locationString or symbolMeaning
ToolHookEventListcli.jsline ~185, byte 0x10b6b4PreToolUseHook event list begins.
SessionLifecycleHookcli.jsline ~185, byte 0x10b73bSessionEndSession lifecycle hook surface.
PreToolUseAuthorizationcli.jsline ~3553, byte 0x876552hookPermissionResult, PreToolUsePreToolUse can participate in authorization and input mutation.
ToolExecutionBoundarycli.jsline ~4202, byte 0x8a813afunction U85Permission/execution boundary that invokes tool decision paths.
SdkPermissionBridgecli.jsline ~9564, byte 0xcc4a2acreateCanUseTool, permission_deniedSDK/bridge permission wrapper and denial frame.
SessionStateStreamFramecli.jsline ~2004, byte 0x518f8csession_state_changedRuntime/session state stream frame.
BridgeStateStreamFramecli.jsline ~19356, byte 0xdaf5aabridge_stateRemote bridge state stream frame.
McpToolsListMethodcli.jsline ~95, byte 0x907a4tools/listMCP method schema family.

Hook names by family

FamilyHook namesTrigger summary
Tool lifecyclePreToolUse, PostToolUse, PostToolUseFailure, PostToolBatchBefore/after tool execution and tool batch completion.
Permission and elicitationPermissionRequest, PermissionDenied, Elicitation, ElicitationResultPermission prompts, denial feedback, and MCP-style elicitation completion.
Prompt/session lifecycleUserPromptSubmit, UserPromptExpansion, SessionStart, SessionEnd, SetupUser input, context expansion, startup/setup, and shutdown.
Stop and compactionStop, StopFailure, PreCompact, PostCompact, InstructionsLoadedStop requests/failures, compaction boundaries, and instruction loading.
Agent/task lifecycleSubagentStart, SubagentStop, TaskCreated, TaskCompleted, TeammateIdleSubagent/task start, completion, and background-agent idle state.
Config/worktree/fileConfigChange, WorktreeCreate, WorktreeRemove, CwdChanged, FileChangedRuntime configuration, working tree, CWD, and file-change boundaries.
NotificationNotificationExternal or internal notification delivery.

Blocking versus observational hooks

Hook typeExamplesRuntime effect
Authorization hooksPreToolUse, PermissionRequest, PermissionDeniedCan affect whether a tool runs, whether approval is requested, whether retry feedback is returned, or whether input is updated.
Lifecycle hooksSessionStart, SessionEnd, SubagentStart, SubagentStop, PreCompact, PostCompactRun at major state transitions; may record or shape boundary behavior depending on event type.
Observational hooksPostToolUse, PostToolUseFailure, PostToolBatch, TaskCompleted, NotificationObserve outcomes and emit side effects without being the primary approval gate.

Externalized stream/control frames

These are not hook names. They are serialized frames used by headless, SDK, bridge, or remote consumers.

Frame or subtypeDirectionMeaning
session_state_changedruntime → host/SDKSession state changed, such as idle/running/requires-action.
transcript_mirrorruntime → host/SDK/storeLocal transcript record mirrored to an external consumer.
bridge_stateruntime → remote hostRemote bridge connection/control state changed.
control_request / control_responseruntime ↔ hostRequest/response control-plane pair.
permission_deniedruntime → host/SDK/model result surfaceTool was denied without an interactive approval path.
can_use_toolruntime → hostAsk-style permission control request.
permission_responsehost → runtimeHost reply to a permission/control decision.
task_started, task_updated, task_progress, task_notificationruntime → host/modelTask/subagent state and progress frames.
prompt_suggestionruntime → host/SDKPredicted next-prompt suggestion when enabled.
rate_limit_eventprovider/runtime → host/SDKRate-limit/quota state surfaced to clients.
relevant_memoriesmemory subsystem → model/contextMemory recall output surfaced into a turn.
elicitation_completeMCP/runtime → host/SDKMCP URL-mode elicitation completed.

MCP protocol methods

These are JSON-RPC method names, not Claude Code hook events.

Method familyExamplesOwner
Toolstools/list, tools/callMCP server/client runtime.
Resourcesresources/list, resources/read, resources/templates/listMCP resource runtime.
Promptsprompts/list, prompts/getMCP prompt runtime.
Tasks/cancel/progresstasks/list, tasks/cancel, notifications/cancelled, progress notificationsMCP/task coordination.

Interpretation rules

  1. Use hook for in-process extension points that can observe, block, mutate, or provide feedback.
  2. Use frame for serialized headless/SDK/remote messages.
  3. Use protocol method for MCP JSON-RPC method names.
  4. Use telemetry event for tengu_* signal names; do not treat them as stable public hooks.

Created and maintained by Yingting Huang.