Skip to main content

Classic Events

Each settings hook event is also an event named classic.<Event> for a mod. The event e is the stdin JSON of the settings hook, with the base fields. The chain is the managed settings hooks, then the hooks modules, then the other settings hooks as core. A managed block ends the chain above every module.

Remove the on call to turn a hook off. disableAllHooks stops installed mods. The same events come from hooks in settings.

Official pages: Hooks Reference, React to Events. Source: the program (the *HookInput types of types-2.1.304.d.ts). For what each event means, see Hook Events.

Example​

export function register(on) {
on('classic.PreToolUse', { tool_name: 'Bash' }, async ($, e, next) => next(e))
on('classic.Stop', async ($, e, next) => next(e))
}

Events​

Most results include block, preventContinuation, and stopReason. The table lists extra result fields when there are any.

ItemStatusInput type and fieldsResult
classic.ConfigChangeDocumentedConfigChangeHookInput: hook_event_name, source, file_pathBase
classic.CwdChangedDocumentedCwdChangedHookInput: hook_event_name, old_cwd, new_cwdBase
classic.DirectoryAddedDocumentedDirectoryAddedHookInput: hook_event_name, directory, sourceBase
classic.ElicitationDocumentedElicitationHookInput: hook_event_name, mcp_server_name, message, mode, url, elicitation_id, requested_schema. Fires when an MCP server asks for user input. Hooks can auto-respond (accept or decline) instead of showing the dialog.Base
classic.ElicitationResultDocumentedElicitationResultHookInput: hook_event_name, mcp_server_name, elicitation_id, mode, action, content. Fires after the user answers an MCP elicitation. Hooks can observe or override the answer before it goes to the server.Base
classic.FileChangedDocumentedFileChangedHookInput: hook_event_name, file_path, eventBase
classic.InstructionsLoadedDocumentedInstructionsLoadedHookInput: file_path, memory_type, load_reason, globs, trigger_file_path, parent_file_pathBase
classic.MessageDisplayDocumentedMessageDisplayHookInput: hook_event_name, turn_id, message_id, index, final, delta. Fires with each batch of newly finished lines while an assistant message streams. Display only: the stored message and what the model sees stay as they are.Base plus displayContent
classic.NotificationDocumentedNotificationHookInput: hook_event_name, message, title, notification_typeBase
classic.PermissionDeniedDocumentedPermissionDeniedHookInput: hook_event_name, tool_name, tool_input, tool_use_id, reason, mcp_serverBase plus retry
classic.PermissionRequestDocumentedPermissionRequestHookInput: hook_event_name, tool_name, tool_input, permission_suggestions, mcp_serverBase plus decision
classic.PostCompactDocumentedPostCompactHookInput: hook_event_name, trigger, compact_summaryBase
classic.PostModelSwitchDocumentedPostModelSwitchHookInput: includes from_model, to_model, context_tokens, pricingBase plus additionalContext
classic.PostToolBatchDocumentedPostToolBatchHookInput: hook_event_name, tool_calls. Fires once after every tool call in a batch has resolved, before the next model request.Base plus additionalContext
classic.PostToolUseFailureDocumentedPostToolUseFailureHookInput: includes tool_name, tool_input, error, is_interruptBase plus additionalContext
classic.PostToolUseDocumentedPostToolUseHookInput: includes tool_name, tool_input, tool_response, duration_msBase plus additionalContext, updatedToolOutput, updatedMCPToolOutput
classic.PreCompactDocumentedPreCompactHookInput: hook_event_name, trigger, custom_instructionsBase
classic.PreModelSwitchDocumentedPreModelSwitchHookInput: includes from_model, to_model, context_tokens, pricingBase plus permissionDecision, permissionDecisionReason
classic.PreToolUseDocumentedToolCallEnvelope (from PreToolUseHookInput)PreToolUseResult: allow, ask, or deny
classic.SessionEndDocumentedSessionEndHookInput: hook_event_name, reasonBase
classic.SessionStartDocumentedSessionStartHookInput: includes source, agent_type, modelBase plus additionalContext, initialUserMessage, sessionTitle, watchPaths, reloadSkills
classic.SetupDocumentedSetupHookInput: hook_event_name, triggerBase plus additionalContext
classic.StopFailureDocumentedStopFailureHookInput: hook_event_name, error, error_details, last_assistant_messageBase
classic.StopDocumentedStopHookInput: includes stop_hook_active, last_assistant_messageBase plus additionalContext
classic.SubagentStartDocumentedSubagentStartHookInput: hook_event_name, agent_id, agent_typeBase plus additionalContext
classic.SubagentStopDocumentedSubagentStopHookInput: includes agent_id, agent_type, last_assistant_messageBase plus additionalContext
classic.TaskCompletedDocumentedTaskCompletedHookInput: hook_event_name, task_id, task_subject, task_description, teammate_name, team_nameBase
classic.TaskCreatedDocumentedTaskCreatedHookInput: same fields as TaskCompletedBase
classic.TeammateIdleDocumentedTeammateIdleHookInput: hook_event_name, teammate_name, team_nameBase
classic.UserPromptExpansionDocumentedUserPromptExpansionHookInput: includes expansion_type, command_name, command_args, promptBase plus additionalContext, suppressOriginalPrompt
classic.UserPromptSubmitDocumentedUserPromptSubmitHookInput: includes prompt, source, session_titleBase plus additionalContext, sessionTitle, suppressOriginalPrompt
classic.WorktreeCreateDocumentedWorktreeCreateHookInput: hook_event_name, nameBase plus worktreePath
classic.WorktreeRemoveDocumentedWorktreeRemoveHookInput: hook_event_name, worktree_pathBase

In this table, "Base" means block, preventContinuation, and stopReason.