Skip to content

Hook Stdin Schema Reference

Status: Draft Created: 20260224, updated 20260225 Source: Claude Code hooks reference, cross-verified against hooks changelog 20260225.

Complete reference for the JSON payload Claude Code sends to hooks via stdin. Used by hookwatch to define TypeScript interfaces and Zod validation schemas.

Common Fields (All Events)

Every hook event includes these fields:

FieldTypeDescription
session_idstringUUID v4 (e.g. f8b0e97c-a19e-461a-8290-05a5c03d3d8f). Stable across resume/clear/compact within a session.
transcript_pathstringAbsolute path to conversation JSONL file
cwdstringWorking directory when hook fires
permission_modestringOne of: default, plan, acceptEdits, dontAsk, bypassPermissions
hook_event_namestringEvent name that triggered this hook (matches the key in hooks.json)

Environment Variables

These are passed to the hook process as env vars (not in stdin JSON):

VariableSinceDescription
CLAUDE_PLUGIN_ROOTAbsolute path to plugin root (plugin hooks only)
CLAUDE_PROJECT_DIR1.0.58Absolute path to the project directory

Hook Config Options

Per-hook configuration in hooks.json:

OptionTypeSinceDescription
matcherstringRegex matched against event-specific field (see Matcher Target Summary)
typestringcommand (shell command) or prompt (LLM evaluation)
commandstringShell command to execute (type=command)
onceboolean2.1.0If true, hook runs only once per session
modelstring2.0.36Model to use for prompt-based hooks (type=prompt)

Event-Specific Fields

For each event: the fields on stdin, the matcher target (what Claude Code matches against in hooks.json), and whether the matcher target is included in stdin.

SessionStart

FieldTypeRequiredValues
sourcestringyesstartup, resume, clear, compact
modelstringyesModel identifier (e.g. claude-sonnet-4-6)
agent_typestringnoOnly present if --agent flag was used
  • Matcher target: source
  • Matcher target in stdin: yes

SessionEnd

FieldTypeRequiredValues
reasonstringyesclear, logout, prompt_input_exit, bypass_permissions_disabled, other
  • Matcher target: reason
  • Matcher target in stdin: yes

UserPromptSubmit

FieldTypeRequiredValues
promptstringyesThe text the user submitted
  • Matcher target: none (always fires)

PreToolUse

FieldTypeRequiredDescription
tool_namestringyesBash, Edit, Write, Read, Glob, Grep, Task, WebFetch, WebSearch, AskUserQuestion, mcp__* (MCP tools)
tool_use_idstringyese.g. toolu_01ABC123...
tool_inputobjectyesStructure varies by tool (see Tool Input Schemas below)
  • Matcher target: tool_name
  • Matcher target in stdin: yes

PostToolUse

FieldTypeRequiredDescription
tool_namestringyesSame values as PreToolUse
tool_use_idstringyese.g. toolu_01ABC123...
tool_inputobjectyesSame structure as PreToolUse
tool_responseobjectyesTool-specific result
  • Matcher target: tool_name
  • Matcher target in stdin: yes

PostToolUseFailure

FieldTypeRequiredDescription
tool_namestringyesSame values as PreToolUse
tool_use_idstringyese.g. toolu_01ABC123...
tool_inputobjectyesSame structure as PreToolUse
errorstringyesError description
is_interruptbooleannoWhether failure was caused by user interruption
  • Matcher target: tool_name
  • Matcher target in stdin: yes

PermissionRequest

FieldTypeRequiredDescription
tool_namestringyesSame values as PreToolUse
tool_inputobjectyesSame structure as PreToolUse
permission_suggestionsarraynoe.g. [{ type: toolAlwaysAllow, tool: Bash }]
  • Matcher target: tool_name
  • Matcher target in stdin: yes
  • Note: no tool_use_id (unlike PreToolUse/PostToolUse)

Notification

FieldTypeRequiredValues
messagestringyesNotification text
titlestringnoOptional title
notification_typestringyespermission_prompt, idle_prompt, auth_success, elicitation_dialog
  • Matcher target: notification_type
  • Matcher target in stdin: yes

SubagentStart

FieldTypeRequiredDescription
agent_idstringyesUnique identifier for the subagent
agent_typestringyesBash, Explore, Plan, or custom agent names
  • Matcher target: agent_type
  • Matcher target in stdin: yes

SubagentStop

FieldTypeRequiredDescription
agent_idstringyesUnique identifier for the subagent
agent_typestringyesSame values as SubagentStart
stop_hook_activebooleanyesWhether a stop hook is already continuing
agent_transcript_pathstringyesPath to subagent's transcript in subagents/ folder
last_assistant_messagestringyesText of the subagent's final response
  • Matcher target: agent_type
  • Matcher target in stdin: yes

Stop

FieldTypeRequiredDescription
stop_hook_activebooleanyestrue when Claude is already continuing due to a stop hook
last_assistant_messagestringyesText of Claude's final response
  • Matcher target: none (always fires)

PreCompact

FieldTypeRequiredValues
triggerstringyesmanual, auto
custom_instructionsstringyesUser's /compact argument for manual; empty for auto
  • Matcher target: trigger
  • Matcher target in stdin: yes

TeammateIdle

FieldTypeRequiredDescription
teammate_namestringyesName of the teammate about to go idle
team_namestringyesName of the team
  • Matcher target: none (always fires)

TaskCompleted

FieldTypeRequiredDescription
task_idstringyesTask identifier
task_subjectstringyesTask title
task_descriptionstringnoDetailed description (may be absent)
teammate_namestringnoName of the teammate (may be absent)
team_namestringnoName of the team (may be absent)
  • Matcher target: none (always fires)

ConfigChange

FieldTypeRequiredValues
sourcestringyesuser_settings, project_settings, local_settings, policy_settings, skills
file_pathstringnoPath to the changed file
  • Matcher target: source
  • Matcher target in stdin: yes

WorktreeCreate

FieldTypeRequiredDescription
namestringyesSlug identifier for the worktree (e.g. bold-oak-a3f2)
  • Matcher target: none (always fires)

WorktreeRemove

FieldTypeRequiredDescription
worktree_pathstringyesAbsolute path to the worktree being removed
  • Matcher target: none (always fires)

InstructionsLoaded

Present in Agent SDK types (InstructionsLoadedHookInput) but not yet documented in the hooks reference.

FieldTypeRequiredValues
triggerstringyesinit, maintenance
  • Matcher target: unknown (undocumented)

Matcher Target Summary

Every matcher target field is included in the stdin payload. hookwatch uses ".*" for all matchers to capture everything.

Matcher TargetEventsIn Stdin
tool_namePreToolUse, PostToolUse, PostToolUseFailure, PermissionRequestyes
sourceSessionStartyes
reasonSessionEndyes
notification_typeNotificationyes
agent_typeSubagentStart, SubagentStopyes
triggerPreCompactyes
source (ConfigChange)ConfigChangeyes
(none — always fires)UserPromptSubmit, Stop, TeammateIdle, TaskCompleted, WorktreeCreate, WorktreeRemoven/a

Conclusion: No data is hidden behind the matcher. hookwatch receives the full payload for every event.

Tool Input Schemas (PreToolUse/PostToolUse/PostToolUseFailure)

The tool_input object varies by tool:

ToolFields
Bashcommand: string, description?: string, timeout?: number, run_in_background?: boolean
Writefile_path: string, content: string
Editfile_path: string, old_string: string, new_string: string, replace_all?: boolean
Readfile_path: string, offset?: number, limit?: number
Globpattern: string, path?: string
Greppattern: string, path?: string, glob?: string, output_mode?: string
WebFetchurl: string, prompt: string
WebSearchquery: string, allowed_domains?: string[], blocked_domains?: string[]
Taskprompt: string, description?: string, subagent_type?: string, model?: string

MCP tools (mcp__<server>__<tool>) have tool-specific input schemas defined by the MCP server.

Event Count

18 events. 17 are documented in the hooks reference. InstructionsLoaded is the 18th — present in the Agent SDK types (@anthropic-ai/claude-agent-sdk) but not yet in the hooks reference.

text
SessionStart    SessionEnd       UserPromptSubmit  PreToolUse
PostToolUse     PostToolUseFailure  PermissionRequest  Notification
SubagentStart   SubagentStop     Stop              PreCompact
TeammateIdle    TaskCompleted    ConfigChange      WorktreeCreate
WorktreeRemove  InstructionsLoaded*

* SDK-only — not in hooks reference docs.

Not events

SlashCommand and SkillStart appear in conclaude's source code but are NOT Claude Code hook events. Claude Code 2.1.0 added "hooks support for skill and slash command frontmatter" — this lets skills/commands define hooks using existing events (PreToolUse, PostToolUse, Stop), not new event types. conclaude implements them internally by parsing UserPromptSubmit prompts and SubagentStart payloads.

hookwatch's unknown-event resilience (FR-1) handles any future events gracefully if they appear.

Sources

SourceURLContent
Hooks referencehttps://code.claude.com/docs/en/hooks17 events, narrative + JSON examples
Agent SDK typeshttps://platform.claude.com/docs/en/agent-sdk/typescript18 events, TypeScript type definitions (authoritative)
Hooks changelog(removed — stale link)Version history of every hook-related change

Released under the MIT License.