claudecode

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package claudecode provides types for Claude Code hook inputs and outputs.

Claude Code invokes hooks as subprocesses, passing a JSON payload on stdin and reading a JSON response from stdout. The types in this package model those payloads for every hook event type.

See https://docs.anthropic.com/en/docs/claude-code/hooks for the full specification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackgroundTask added in v0.4.0

type BackgroundTask struct {
	ID          string `json:"id"`
	Type        string `json:"type"`
	Status      string `json:"status"`
	Description string `json:"description"`
	Command     string `json:"command,omitempty"`    // shell tasks only
	AgentType   string `json:"agent_type,omitempty"` // subagent tasks only
	Server      string `json:"server,omitempty"`     // monitor and MCP tasks only
	Tool        string `json:"tool,omitempty"`       // monitor and MCP tasks only
	Name        string `json:"name,omitempty"`       // workflow tasks only
}

BackgroundTask describes one in-flight background task in a Stop or SubagentStop event. Type-specific fields are present only for the task types noted in their comments.

type BaseOutput

type BaseOutput struct {
	Continue         *bool   `json:"continue,omitempty"`
	StopReason       *string `json:"stopReason,omitempty"`
	SuppressOutput   *bool   `json:"suppressOutput,omitempty"`
	SystemMessage    *string `json:"systemMessage,omitempty"`
	TerminalSequence *string `json:"terminalSequence,omitempty"`
}

BaseOutput contains fields that any hook response may include.

type CompactTrigger

type CompactTrigger string

CompactTrigger describes what initiated context compaction.

const (
	CompactManual CompactTrigger = "manual"
	CompactAuto   CompactTrigger = "auto"
)

type ConfigChangeInput

type ConfigChangeInput struct {
	Input
	Source   ConfigSource `json:"source"`
	FilePath string       `json:"file_path,omitempty"`
}

ConfigChangeInput is sent when a configuration file changes.

type ConfigChangeOutput

type ConfigChangeOutput struct {
	BaseOutput
	Decision *Decision `json:"decision,omitempty"`
}

ConfigChangeOutput is the response for a ConfigChange hook.

type ConfigSource

type ConfigSource string

ConfigSource identifies which configuration layer changed.

const (
	ConfigUserSettings    ConfigSource = "user_settings"
	ConfigProjectSettings ConfigSource = "project_settings"
	ConfigLocalSettings   ConfigSource = "local_settings"
	ConfigPolicySettings  ConfigSource = "policy_settings"
	ConfigSkills          ConfigSource = "skills"
)

type CwdChangedInput

type CwdChangedInput struct {
	Input
	OldCWD string `json:"old_cwd"`
	NewCWD string `json:"new_cwd"`
}

CwdChangedInput is sent when the working directory changes.

type Decision

type Decision string

Decision is a general-purpose block/allow decision used by several output types.

const (
	DecisionBlock Decision = "block"
)

type Effort added in v0.3.3

type Effort struct {
	Level EffortLevel `json:"level"`
}

Effort describes the active model effort for hook events that run in a tool-use context.

type EffortLevel added in v0.3.3

type EffortLevel string

EffortLevel describes the active model effort level for a turn.

const (
	EffortLow    EffortLevel = "low"
	EffortMedium EffortLevel = "medium"
	EffortHigh   EffortLevel = "high"
	EffortXHigh  EffortLevel = "xhigh"
	EffortMax    EffortLevel = "max"
)

type ElicitationAction

type ElicitationAction string

ElicitationAction is the hook's ruling on an MCP elicitation.

const (
	ElicitationAccept  ElicitationAction = "accept"
	ElicitationDecline ElicitationAction = "decline"
	ElicitationCancel  ElicitationAction = "cancel"
)

type ElicitationHookOutput

type ElicitationHookOutput struct {
	HookEventName EventName         `json:"hookEventName"`
	Action        ElicitationAction `json:"action"`
	Content       json.RawMessage   `json:"content,omitempty"`
}

ElicitationHookOutput contains Elicitation-specific output fields.

type ElicitationInput

type ElicitationInput struct {
	Input
	MCPServerName   string          `json:"mcp_server_name"`
	Message         string          `json:"message"`
	Mode            ElicitationMode `json:"mode,omitempty"`
	URL             string          `json:"url,omitempty"`
	ElicitationID   string          `json:"elicitation_id,omitempty"`
	RequestedSchema json.RawMessage `json:"requested_schema,omitempty"`
}

ElicitationInput is sent when an MCP server requests user input. RequestedSchema is set in form mode; URL is set in url mode.

type ElicitationMode added in v0.4.0

type ElicitationMode string

ElicitationMode distinguishes form-based from browser-based elicitation.

const (
	ElicitationModeForm ElicitationMode = "form"
	ElicitationModeURL  ElicitationMode = "url"
)

type ElicitationOutput

type ElicitationOutput struct {
	BaseOutput
	HookSpecificOutput ElicitationHookOutput `json:"hookSpecificOutput"`
}

ElicitationOutput is the response for an Elicitation hook.

type ElicitationResultInput

type ElicitationResultInput struct {
	Input
	MCPServerName string            `json:"mcp_server_name"`
	Action        ElicitationAction `json:"action"`
	Mode          ElicitationMode   `json:"mode,omitempty"`
	ElicitationID string            `json:"elicitation_id,omitempty"`
	Content       json.RawMessage   `json:"content,omitempty"`
}

ElicitationResultInput is sent after the user responds to an MCP elicitation.

type ElicitationResultOutput

type ElicitationResultOutput struct {
	BaseOutput
	HookSpecificOutput *ElicitationHookOutput `json:"hookSpecificOutput,omitempty"`
}

ElicitationResultOutput is the response for an ElicitationResult hook. HookSpecificOutput overrides the user's action and form values.

type EventName

type EventName string

EventName identifies which hook event fired.

const (
	EventSetup               EventName = "Setup"
	EventSessionStart        EventName = "SessionStart"
	EventSessionEnd          EventName = "SessionEnd"
	EventInstructionsLoaded  EventName = "InstructionsLoaded"
	EventUserPromptSubmit    EventName = "UserPromptSubmit"
	EventUserPromptExpansion EventName = "UserPromptExpansion"
	EventMessageDisplay      EventName = "MessageDisplay"
	EventPreToolUse          EventName = "PreToolUse"
	EventPostToolUse         EventName = "PostToolUse"
	EventPostToolUseFailure  EventName = "PostToolUseFailure"
	EventPostToolBatch       EventName = "PostToolBatch"
	EventPermissionRequest   EventName = "PermissionRequest"
	EventPermissionDenied    EventName = "PermissionDenied"
	EventNotification        EventName = "Notification"
	EventSubagentStart       EventName = "SubagentStart"
	EventSubagentStop        EventName = "SubagentStop"
	EventStop                EventName = "Stop"
	EventStopFailure         EventName = "StopFailure"
	EventTaskCreated         EventName = "TaskCreated"
	EventTaskCompleted       EventName = "TaskCompleted"
	EventTeammateIdle        EventName = "TeammateIdle"
	EventConfigChange        EventName = "ConfigChange"
	EventCwdChanged          EventName = "CwdChanged"
	EventFileChanged         EventName = "FileChanged"
	EventWorktreeCreate      EventName = "WorktreeCreate"
	EventWorktreeRemove      EventName = "WorktreeRemove"
	EventPreCompact          EventName = "PreCompact"
	EventPostCompact         EventName = "PostCompact"
	EventElicitation         EventName = "Elicitation"
	EventElicitationResult   EventName = "ElicitationResult"
)

type ExpansionType added in v0.2.0

type ExpansionType string

ExpansionType describes the source of a prompt expansion.

const (
	ExpansionSlashCommand ExpansionType = "slash_command"
	ExpansionMCPPrompt    ExpansionType = "mcp_prompt"
)

type FileChangeEvent added in v0.4.0

type FileChangeEvent string

FileChangeEvent describes how a watched file changed.

const (
	FileChangeAdd    FileChangeEvent = "add"
	FileChangeChange FileChangeEvent = "change"
	FileChangeUnlink FileChangeEvent = "unlink"
)

type FileChangedInput

type FileChangedInput struct {
	Input
	FilePath string          `json:"file_path"`
	Event    FileChangeEvent `json:"event"`
}

FileChangedInput is sent when a watched file changes on disk.

type Input

type Input struct {
	SessionID      string         `json:"session_id"`
	TranscriptPath string         `json:"transcript_path"`
	CWD            string         `json:"cwd"`
	HookEventName  EventName      `json:"hook_event_name"`
	PermissionMode PermissionMode `json:"permission_mode"`
	Effort         *Effort        `json:"effort,omitempty"`
	AgentID        string         `json:"agent_id,omitempty"`
	AgentType      string         `json:"agent_type,omitempty"`
}

Input contains fields present on every hook invocation.

type InstructionsLoadedInput

type InstructionsLoadedInput struct {
	Input
	FilePath        string     `json:"file_path"`
	MemoryType      MemoryType `json:"memory_type"`
	LoadReason      LoadReason `json:"load_reason"`
	Globs           []string   `json:"globs,omitempty"`
	TriggerFilePath string     `json:"trigger_file_path,omitempty"`
	ParentFilePath  string     `json:"parent_file_path,omitempty"`
}

InstructionsLoadedInput is sent when a CLAUDE.md or rules file is loaded.

type LoadReason

type LoadReason string

LoadReason describes why an instructions file was loaded.

const (
	LoadReasonSessionStart    LoadReason = "session_start"
	LoadReasonNestedTraversal LoadReason = "nested_traversal"
	LoadReasonPathGlobMatch   LoadReason = "path_glob_match"
	LoadReasonInclude         LoadReason = "include"
	LoadReasonCompact         LoadReason = "compact"
)

type MemoryType

type MemoryType string

MemoryType describes the origin of a loaded instructions file.

const (
	MemoryUser    MemoryType = "User"
	MemoryProject MemoryType = "Project"
	MemoryLocal   MemoryType = "Local"
	MemoryManaged MemoryType = "Managed"
)

type MessageDisplayHookOutput added in v0.4.0

type MessageDisplayHookOutput struct {
	HookEventName  EventName `json:"hookEventName"`
	DisplayContent *string   `json:"displayContent,omitempty"`
}

MessageDisplayHookOutput contains MessageDisplay-specific output fields.

type MessageDisplayInput added in v0.4.0

type MessageDisplayInput struct {
	Input
	TurnID    string `json:"turn_id"`
	MessageID string `json:"message_id"`
	Index     int    `json:"index"`
	Final     bool   `json:"final"`
	Delta     string `json:"delta"`
}

MessageDisplayInput is sent as assistant message text streams to the display.

type MessageDisplayOutput added in v0.4.0

type MessageDisplayOutput struct {
	BaseOutput
	HookSpecificOutput *MessageDisplayHookOutput `json:"hookSpecificOutput,omitempty"`
}

MessageDisplayOutput is the response for a MessageDisplay hook.

type NotificationInput

type NotificationInput struct {
	Input
	Message          string           `json:"message"`
	Title            string           `json:"title,omitempty"`
	NotificationType NotificationType `json:"notification_type"`
}

NotificationInput is sent when Claude Code emits a notification.

type NotificationOutput

type NotificationOutput struct {
	BaseOutput
	AdditionalContext *string `json:"additionalContext,omitempty"`
}

NotificationOutput is the response for a Notification hook.

type NotificationType

type NotificationType string

NotificationType categorizes a notification event.

const (
	NotificationPermissionPrompt    NotificationType = "permission_prompt"
	NotificationIdlePrompt          NotificationType = "idle_prompt"
	NotificationAuthSuccess         NotificationType = "auth_success"
	NotificationElicitationDialog   NotificationType = "elicitation_dialog"
	NotificationElicitationComplete NotificationType = "elicitation_complete"
	NotificationElicitationResponse NotificationType = "elicitation_response"
)

type PermissionBehavior

type PermissionBehavior string

PermissionBehavior describes the intended behavior of a permission rule.

const (
	BehaviorAllow PermissionBehavior = "allow"
	BehaviorDeny  PermissionBehavior = "deny"
	BehaviorAsk   PermissionBehavior = "ask"
)

type PermissionDecision

type PermissionDecision string

PermissionDecision is the hook's ruling on a tool call.

const (
	PermissionAllow PermissionDecision = "allow"
	PermissionDeny  PermissionDecision = "deny"
	PermissionAsk   PermissionDecision = "ask"
	PermissionDefer PermissionDecision = "defer"
)

type PermissionDeniedHookOutput added in v0.2.0

type PermissionDeniedHookOutput struct {
	HookEventName EventName `json:"hookEventName"`
	Retry         *bool     `json:"retry,omitempty"`
}

PermissionDeniedHookOutput contains PermissionDenied-specific output fields.

type PermissionDeniedInput added in v0.2.0

type PermissionDeniedInput struct {
	Input
	ToolName  string          `json:"tool_name"`
	ToolUseID string          `json:"tool_use_id"`
	ToolInput json.RawMessage `json:"tool_input"`
	Reason    string          `json:"reason"`
}

PermissionDeniedInput is sent when auto mode denies a tool call.

type PermissionDeniedOutput added in v0.2.0

type PermissionDeniedOutput struct {
	BaseOutput
	HookSpecificOutput *PermissionDeniedHookOutput `json:"hookSpecificOutput,omitempty"`
}

PermissionDeniedOutput is the response for a PermissionDenied hook.

type PermissionDestination

type PermissionDestination string

PermissionDestination identifies which settings layer to persist a permission change to.

const (
	DestinationSession         PermissionDestination = "session"
	DestinationLocalSettings   PermissionDestination = "localSettings"
	DestinationProjectSettings PermissionDestination = "projectSettings"
	DestinationUserSettings    PermissionDestination = "userSettings"
)

type PermissionMode

type PermissionMode string

PermissionMode describes the active permission mode for the session.

const (
	PermissionDefault           PermissionMode = "default"
	PermissionPlan              PermissionMode = "plan"
	PermissionAcceptEdits       PermissionMode = "acceptEdits"
	PermissionAuto              PermissionMode = "auto"
	PermissionDontAsk           PermissionMode = "dontAsk"
	PermissionBypassPermissions PermissionMode = "bypassPermissions"
)

type PermissionRequestDecision

type PermissionRequestDecision struct {
	Behavior           PermissionBehavior `json:"behavior"`
	UpdatedInput       json.RawMessage    `json:"updatedInput,omitempty"`
	UpdatedPermissions []PermissionUpdate `json:"updatedPermissions,omitempty"`
	Message            *string            `json:"message,omitempty"`
	Interrupt          *bool              `json:"interrupt,omitempty"`
}

PermissionRequestDecision is the hook's ruling on a permission request.

type PermissionRequestHookOutput

type PermissionRequestHookOutput struct {
	HookEventName EventName                 `json:"hookEventName"`
	Decision      PermissionRequestDecision `json:"decision"`
}

PermissionRequestHookOutput contains PermissionRequest-specific output fields.

type PermissionRequestInput

type PermissionRequestInput struct {
	Input
	ToolName              string                 `json:"tool_name"`
	ToolInput             json.RawMessage        `json:"tool_input"`
	PermissionSuggestions []PermissionSuggestion `json:"permission_suggestions"`
}

PermissionRequestInput is sent when a permission dialog is about to appear.

type PermissionRequestOutput

type PermissionRequestOutput struct {
	BaseOutput
	HookSpecificOutput PermissionRequestHookOutput `json:"hookSpecificOutput"`
}

PermissionRequestOutput is the response for a PermissionRequest hook.

type PermissionRule

type PermissionRule struct {
	ToolName    string `json:"toolName"`
	RuleContent string `json:"ruleContent,omitempty"`
}

PermissionRule describes a single permission rule in a suggestion.

type PermissionSuggestion

type PermissionSuggestion struct {
	Type        PermissionSuggestionType `json:"type"`
	Rules       []PermissionRule         `json:"rules,omitempty"`
	Behavior    PermissionBehavior       `json:"behavior,omitempty"`
	Destination PermissionDestination    `json:"destination,omitempty"`
}

PermissionSuggestion is a proposed permission change offered with a PermissionRequest.

type PermissionSuggestionType

type PermissionSuggestionType string

PermissionSuggestionType categorizes a suggested permission change.

const (
	SuggestionAddRules          PermissionSuggestionType = "addRules"
	SuggestionReplaceRules      PermissionSuggestionType = "replaceRules"
	SuggestionRemoveRules       PermissionSuggestionType = "removeRules"
	SuggestionSetMode           PermissionSuggestionType = "setMode"
	SuggestionAddDirectories    PermissionSuggestionType = "addDirectories"
	SuggestionRemoveDirectories PermissionSuggestionType = "removeDirectories"
)

type PermissionUpdate

type PermissionUpdate struct {
	Type        PermissionSuggestionType `json:"type"`
	Mode        *string                  `json:"mode,omitempty"`
	Rules       []PermissionRule         `json:"rules,omitempty"`
	Destination PermissionDestination    `json:"destination"`
}

PermissionUpdate describes a permission change to apply.

type PostCompactInput

type PostCompactInput struct {
	Input
	Trigger        CompactTrigger `json:"trigger"`
	CompactSummary string         `json:"compact_summary"`
}

PostCompactInput is sent after context compaction completes.

type PostToolBatchHookOutput added in v0.2.0

type PostToolBatchHookOutput struct {
	HookEventName     EventName `json:"hookEventName"`
	AdditionalContext *string   `json:"additionalContext,omitempty"`
}

PostToolBatchHookOutput contains PostToolBatch-specific output fields.

type PostToolBatchInput added in v0.2.0

type PostToolBatchInput struct {
	Input
	ToolCalls []ToolCall `json:"tool_calls"`
}

PostToolBatchInput is sent after a batch of parallel tool calls resolves.

type PostToolBatchOutput added in v0.2.0

type PostToolBatchOutput struct {
	BaseOutput
	Decision           *Decision                `json:"decision,omitempty"`
	Reason             *string                  `json:"reason,omitempty"`
	HookSpecificOutput *PostToolBatchHookOutput `json:"hookSpecificOutput,omitempty"`
}

PostToolBatchOutput is the response for a PostToolBatch hook.

type PostToolUseFailureInput

type PostToolUseFailureInput struct {
	Input
	ToolName    string          `json:"tool_name"`
	ToolUseID   string          `json:"tool_use_id"`
	ToolInput   json.RawMessage `json:"tool_input"`
	Error       string          `json:"error"`
	IsInterrupt *bool           `json:"is_interrupt,omitempty"`
	DurationMS  int64           `json:"duration_ms,omitempty"`
}

PostToolUseFailureInput is sent after a tool call fails.

type PostToolUseFailureOutput

type PostToolUseFailureOutput struct {
	BaseOutput
	AdditionalContext *string `json:"additionalContext,omitempty"`
}

PostToolUseFailureOutput is the response for a PostToolUseFailure hook.

type PostToolUseHookOutput

type PostToolUseHookOutput struct {
	HookEventName        EventName       `json:"hookEventName"`
	AdditionalContext    *string         `json:"additionalContext,omitempty"`
	UpdatedToolOutput    json.RawMessage `json:"updatedToolOutput,omitempty"`
	UpdatedMCPToolOutput json.RawMessage `json:"updatedMCPToolOutput,omitempty"`
}

PostToolUseHookOutput contains PostToolUse-specific output fields. UpdatedMCPToolOutput replaces output for MCP tools only; prefer UpdatedToolOutput, which works for all tools.

type PostToolUseInput

type PostToolUseInput struct {
	Input
	ToolName     string          `json:"tool_name"`
	ToolUseID    string          `json:"tool_use_id"`
	ToolInput    json.RawMessage `json:"tool_input"`
	ToolResponse json.RawMessage `json:"tool_response"`
	DurationMS   int64           `json:"duration_ms,omitempty"`
}

PostToolUseInput is sent after a tool call succeeds.

func (*PostToolUseInput) FilePath

func (in *PostToolUseInput) FilePath() string

FilePath extracts the file_path field from ToolInput. Returns an empty string if the field is absent, empty, or not a string.

type PostToolUseOutput

type PostToolUseOutput struct {
	BaseOutput
	Decision             *Decision              `json:"decision,omitempty"`
	Reason               *string                `json:"reason,omitempty"`
	AdditionalContext    *string                `json:"additionalContext,omitempty"`
	UpdatedMCPToolOutput json.RawMessage        `json:"updatedMCPToolOutput,omitempty"`
	HookSpecificOutput   *PostToolUseHookOutput `json:"hookSpecificOutput,omitempty"`
}

PostToolUseOutput is the response for a PostToolUse hook.

type PreCompactInput

type PreCompactInput struct {
	Input
	Trigger            CompactTrigger `json:"trigger"`
	CustomInstructions string         `json:"custom_instructions"`
}

PreCompactInput is sent before context compaction. CustomInstructions holds what the user passed to /compact for manual triggers and is empty for auto.

type PreToolUseHookOutput

type PreToolUseHookOutput struct {
	HookEventName            EventName          `json:"hookEventName"`
	PermissionDecision       PermissionDecision `json:"permissionDecision"`
	PermissionDecisionReason *string            `json:"permissionDecisionReason,omitempty"`
	UpdatedInput             json.RawMessage    `json:"updatedInput,omitempty"`
	AdditionalContext        *string            `json:"additionalContext,omitempty"`
}

PreToolUseHookOutput contains PreToolUse-specific output fields.

type PreToolUseInput

type PreToolUseInput struct {
	Input
	ToolName  string          `json:"tool_name"`
	ToolUseID string          `json:"tool_use_id"`
	ToolInput json.RawMessage `json:"tool_input"`
}

PreToolUseInput is sent before a tool call executes.

type PreToolUseOutput

type PreToolUseOutput struct {
	BaseOutput
	HookSpecificOutput PreToolUseHookOutput `json:"hookSpecificOutput"`
}

PreToolUseOutput is the response for a PreToolUse hook.

type SessionCron added in v0.4.0

type SessionCron struct {
	ID        string `json:"id"`
	Schedule  string `json:"schedule"`
	Recurring bool   `json:"recurring"`
	Prompt    string `json:"prompt"`
}

SessionCron describes one session-scoped scheduled wakeup in a Stop or SubagentStop event.

type SessionEndInput

type SessionEndInput struct {
	Input
	Reason SessionEndReason `json:"reason"`
}

SessionEndInput is sent when a session terminates.

type SessionEndReason

type SessionEndReason string

SessionEndReason describes why a session ended.

const (
	SessionEndClear                     SessionEndReason = "clear"
	SessionEndResume                    SessionEndReason = "resume"
	SessionEndLogout                    SessionEndReason = "logout"
	SessionEndPromptInputExit           SessionEndReason = "prompt_input_exit"
	SessionEndBypassPermissionsDisabled SessionEndReason = "bypass_permissions_disabled"
	SessionEndOther                     SessionEndReason = "other"
)

type SessionSource

type SessionSource string

SessionSource describes what triggered a SessionStart event.

const (
	SessionSourceStartup SessionSource = "startup"
	SessionSourceResume  SessionSource = "resume"
	SessionSourceClear   SessionSource = "clear"
	SessionSourceCompact SessionSource = "compact"
)

type SessionStartHookOutput added in v0.4.0

type SessionStartHookOutput struct {
	HookEventName      EventName `json:"hookEventName"`
	AdditionalContext  *string   `json:"additionalContext,omitempty"`
	InitialUserMessage *string   `json:"initialUserMessage,omitempty"`
	SessionTitle       *string   `json:"sessionTitle,omitempty"`
	WatchPaths         []string  `json:"watchPaths,omitempty"`
	ReloadSkills       *bool     `json:"reloadSkills,omitempty"`
}

SessionStartHookOutput contains SessionStart-specific output fields.

type SessionStartInput

type SessionStartInput struct {
	Input
	Source       SessionSource `json:"source"`
	Model        string        `json:"model"`
	SessionTitle string        `json:"session_title,omitempty"`
}

SessionStartInput is sent when a session begins or resumes.

type SessionStartOutput

type SessionStartOutput struct {
	BaseOutput
	AdditionalContext  *string                 `json:"additionalContext,omitempty"`
	HookSpecificOutput *SessionStartHookOutput `json:"hookSpecificOutput,omitempty"`
}

SessionStartOutput is the response for a SessionStart hook.

type SetupInput added in v0.2.0

type SetupInput struct {
	Input
	Trigger SetupTrigger `json:"trigger"`
}

SetupInput is sent by explicit setup and maintenance invocations.

type SetupTrigger added in v0.4.0

type SetupTrigger string

SetupTrigger describes what invoked a Setup event.

const (
	SetupTriggerInit        SetupTrigger = "init"
	SetupTriggerMaintenance SetupTrigger = "maintenance"
)

type StatusLineAgent

type StatusLineAgent struct {
	Name string `json:"name"`
}

StatusLineAgent holds agent info. Only present with --agent flag.

type StatusLineContext

type StatusLineContext struct {
	TotalInputTokens    int                     `json:"total_input_tokens"`
	TotalOutputTokens   int                     `json:"total_output_tokens"`
	ContextWindowSize   int                     `json:"context_window_size"`
	UsedPercentage      *float64                `json:"used_percentage"`
	RemainingPercentage *float64                `json:"remaining_percentage"`
	CurrentUsage        *StatusLineContextUsage `json:"current_usage"`
}

StatusLineContext tracks context window consumption.

type StatusLineContextUsage

type StatusLineContextUsage struct {
	InputTokens              int `json:"input_tokens"`
	OutputTokens             int `json:"output_tokens"`
	CacheCreationInputTokens int `json:"cache_creation_input_tokens"`
	CacheReadInputTokens     int `json:"cache_read_input_tokens"`
}

StatusLineContextUsage holds token counts from the most recent API call.

type StatusLineCost

type StatusLineCost struct {
	TotalCostUSD       float64 `json:"total_cost_usd"`
	TotalDurationMS    int64   `json:"total_duration_ms"`
	TotalAPIDurationMS int64   `json:"total_api_duration_ms"`
	TotalLinesAdded    int     `json:"total_lines_added"`
	TotalLinesRemoved  int     `json:"total_lines_removed"`
}

StatusLineCost tracks session cost and duration.

type StatusLineInput

type StatusLineInput struct {
	CWD            string                 `json:"cwd"`
	SessionID      string                 `json:"session_id"`
	TranscriptPath string                 `json:"transcript_path"`
	Version        string                 `json:"version"`
	Model          StatusLineModel        `json:"model"`
	Workspace      StatusLineWorkspace    `json:"workspace"`
	Cost           StatusLineCost         `json:"cost"`
	ContextWindow  StatusLineContext      `json:"context_window"`
	Exceeds200K    bool                   `json:"exceeds_200k_tokens"`
	RateLimits     *StatusLineRateLimits  `json:"rate_limits,omitempty"`
	OutputStyle    *StatusLineOutputStyle `json:"output_style,omitempty"`
	Vim            *StatusLineVim         `json:"vim,omitempty"`
	Agent          *StatusLineAgent       `json:"agent,omitempty"`
	Worktree       *StatusLineWorktree    `json:"worktree,omitempty"`
}

StatusLineInput is the JSON payload Claude Code pipes to the status line command. Unlike hook inputs, this is not an event — it is a periodic snapshot of the session state, sent after each assistant message (debounced at 300ms).

See https://code.claude.com/docs/en/statusline for the full specification.

type StatusLineModel

type StatusLineModel struct {
	ID          string `json:"id"`
	DisplayName string `json:"display_name"`
}

StatusLineModel identifies the active model.

type StatusLineOutputStyle

type StatusLineOutputStyle struct {
	Name string `json:"name"`
}

StatusLineOutputStyle holds the current output style.

type StatusLineRateLimits

type StatusLineRateLimits struct {
	FiveHour *StatusLineRateWindow `json:"five_hour,omitempty"`
	SevenDay *StatusLineRateWindow `json:"seven_day,omitempty"`
}

StatusLineRateLimits holds rate limit windows. Only present for Claude.ai subscribers.

type StatusLineRateWindow

type StatusLineRateWindow struct {
	UsedPercentage float64 `json:"used_percentage"`
	ResetsAt       int64   `json:"resets_at"`
}

StatusLineRateWindow holds usage data for a single rate limit window.

type StatusLineVim

type StatusLineVim struct {
	Mode string `json:"mode"`
}

StatusLineVim holds vim mode state. Only present when vim mode is enabled.

type StatusLineWorkspace

type StatusLineWorkspace struct {
	CurrentDir string `json:"current_dir"`
	ProjectDir string `json:"project_dir"`
}

StatusLineWorkspace carries directory context.

type StatusLineWorktree

type StatusLineWorktree struct {
	Name           string `json:"name"`
	Path           string `json:"path"`
	Branch         string `json:"branch,omitempty"`
	OriginalCWD    string `json:"original_cwd,omitempty"`
	OriginalBranch string `json:"original_branch,omitempty"`
}

StatusLineWorktree holds worktree info. Only present during --worktree sessions.

type StopError

type StopError string

StopError categorizes the failure in a StopFailure event.

const (
	StopErrorRateLimit            StopError = "rate_limit"
	StopErrorOverloaded           StopError = "overloaded"
	StopErrorAuthenticationFailed StopError = "authentication_failed"
	StopErrorOAuthOrgNotAllowed   StopError = "oauth_org_not_allowed"
	StopErrorBillingError         StopError = "billing_error"
	StopErrorInvalidRequest       StopError = "invalid_request"
	StopErrorModelNotFound        StopError = "model_not_found"
	StopErrorServerError          StopError = "server_error"
	StopErrorMaxOutputTokens      StopError = "max_output_tokens"
	StopErrorUnknown              StopError = "unknown"
)

type StopFailureInput

type StopFailureInput struct {
	Input
	Error                StopError `json:"error"`
	ErrorDetails         string    `json:"error_details,omitempty"`
	LastAssistantMessage string    `json:"last_assistant_message"`
}

StopFailureInput is sent when a turn ends due to an API error.

type StopHookOutput added in v0.4.0

type StopHookOutput struct {
	HookEventName     EventName `json:"hookEventName"`
	AdditionalContext *string   `json:"additionalContext,omitempty"`
}

StopHookOutput contains Stop- and SubagentStop-specific output fields. AdditionalContext keeps the conversation going as non-error hook feedback, unlike decision "block" which surfaces as a hook error.

type StopInput

type StopInput struct {
	Input
	StopHookActive       *bool            `json:"stop_hook_active"`
	LastAssistantMessage string           `json:"last_assistant_message"`
	BackgroundTasks      []BackgroundTask `json:"background_tasks,omitempty"`
	SessionCrons         []SessionCron    `json:"session_crons,omitempty"`
}

StopInput is sent when Claude finishes responding.

type StopOutput

type StopOutput struct {
	BaseOutput
	Decision           *Decision       `json:"decision,omitempty"`
	Reason             *string         `json:"reason,omitempty"`
	HookSpecificOutput *StopHookOutput `json:"hookSpecificOutput,omitempty"`
}

StopOutput is the response for a Stop hook.

type SubagentStartInput

type SubagentStartInput struct {
	Input
}

SubagentStartInput is sent when a subagent is spawned.

type SubagentStartOutput

type SubagentStartOutput struct {
	BaseOutput
	AdditionalContext *string `json:"additionalContext,omitempty"`
}

SubagentStartOutput is the response for a SubagentStart hook.

type SubagentStopInput

type SubagentStopInput struct {
	Input
	StopHookActive       *bool            `json:"stop_hook_active"`
	AgentTranscriptPath  string           `json:"agent_transcript_path"`
	LastAssistantMessage string           `json:"last_assistant_message"`
	BackgroundTasks      []BackgroundTask `json:"background_tasks,omitempty"`
	SessionCrons         []SessionCron    `json:"session_crons,omitempty"`
}

SubagentStopInput is sent when a subagent finishes.

type SubagentStopOutput

type SubagentStopOutput struct {
	BaseOutput
	Decision           *Decision       `json:"decision,omitempty"`
	Reason             *string         `json:"reason,omitempty"`
	HookSpecificOutput *StopHookOutput `json:"hookSpecificOutput,omitempty"`
}

SubagentStopOutput is the response for a SubagentStop hook.

type TaskCompletedInput

type TaskCompletedInput struct {
	Input
	TaskID          string `json:"task_id"`
	TaskSubject     string `json:"task_subject"`
	TaskDescription string `json:"task_description,omitempty"`
	TeammateName    string `json:"teammate_name,omitempty"`
	TeamName        string `json:"team_name,omitempty"`
}

TaskCompletedInput is sent when a task is marked as completed.

type TaskCreatedInput

type TaskCreatedInput struct {
	Input
	TaskID          string `json:"task_id"`
	TaskSubject     string `json:"task_subject"`
	TaskDescription string `json:"task_description,omitempty"`
	TeammateName    string `json:"teammate_name,omitempty"`
	TeamName        string `json:"team_name,omitempty"`
}

TaskCreatedInput is sent when a task is created.

type TaskOutput

type TaskOutput struct {
	BaseOutput
}

TaskOutput is the response for TaskCreated and TaskCompleted hooks.

type TeammateIdleInput

type TeammateIdleInput struct {
	Input
	TeammateName string `json:"teammate_name"`
	TeamName     string `json:"team_name"`
}

TeammateIdleInput is sent when a teammate is about to go idle.

type TeammateIdleOutput

type TeammateIdleOutput struct {
	BaseOutput
}

TeammateIdleOutput is the response for a TeammateIdle hook.

type ToolCall added in v0.2.0

type ToolCall struct {
	ToolName     string          `json:"tool_name"`
	ToolUseID    string          `json:"tool_use_id"`
	ToolInput    json.RawMessage `json:"tool_input"`
	ToolResponse json.RawMessage `json:"tool_response"`
}

ToolCall describes one tool result in a PostToolBatch event.

type UserPromptExpansionInput added in v0.2.0

type UserPromptExpansionInput struct {
	Input
	ExpansionType ExpansionType `json:"expansion_type"`
	CommandName   string        `json:"command_name"`
	CommandArgs   string        `json:"command_args"`
	CommandSource string        `json:"command_source"`
	Prompt        string        `json:"prompt"`
}

UserPromptExpansionInput is sent when a typed command expands into a prompt.

type UserPromptExpansionOutput added in v0.2.0

type UserPromptExpansionOutput struct {
	BaseOutput
	Decision           *Decision             `json:"decision,omitempty"`
	Reason             *string               `json:"reason,omitempty"`
	AdditionalContext  *string               `json:"additionalContext,omitempty"`
	HookSpecificOutput *UserPromptHookOutput `json:"hookSpecificOutput,omitempty"`
}

UserPromptExpansionOutput is the response for a UserPromptExpansion hook.

type UserPromptHookOutput added in v0.2.0

type UserPromptHookOutput struct {
	HookEventName     EventName `json:"hookEventName"`
	AdditionalContext *string   `json:"additionalContext,omitempty"`
	SessionTitle      *string   `json:"sessionTitle,omitempty"`
}

UserPromptHookOutput contains context fields for prompt events.

type UserPromptSubmitInput

type UserPromptSubmitInput struct {
	Input
	Prompt string `json:"prompt"`
}

UserPromptSubmitInput is sent when the user submits a prompt.

type UserPromptSubmitOutput

type UserPromptSubmitOutput struct {
	BaseOutput
	Decision               *Decision             `json:"decision,omitempty"`
	Reason                 *string               `json:"reason,omitempty"`
	AdditionalContext      *string               `json:"additionalContext,omitempty"`
	SessionTitle           *string               `json:"sessionTitle,omitempty"`
	SuppressOriginalPrompt *bool                 `json:"suppressOriginalPrompt,omitempty"`
	HookSpecificOutput     *UserPromptHookOutput `json:"hookSpecificOutput,omitempty"`
}

UserPromptSubmitOutput is the response for a UserPromptSubmit hook.

type WorktreeCreateHookOutput

type WorktreeCreateHookOutput struct {
	WorktreePath *string `json:"worktreePath,omitempty"`
}

WorktreeCreateHookOutput contains WorktreeCreate-specific output fields.

type WorktreeCreateInput

type WorktreeCreateInput struct {
	Input
	Name string `json:"name"`
}

WorktreeCreateInput is sent when a worktree is being created. Name is a slug identifier for the new worktree, user-specified or auto-generated.

type WorktreeCreateOutput

type WorktreeCreateOutput struct {
	BaseOutput
	HookSpecificOutput WorktreeCreateHookOutput `json:"hookSpecificOutput,omitzero"`
}

WorktreeCreateOutput is the response for a WorktreeCreate hook.

type WorktreeRemoveInput

type WorktreeRemoveInput struct {
	Input
	WorktreePath string `json:"worktree_path"`
}

WorktreeRemoveInput is sent when a worktree is being removed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL