What Are Hooks?
Hooks are lifecycle event handlers that run at specific points during execution:- Before/after tool execution
- On session events (created, deleted, idle, error)
- On message transformations
- On continuation/compaction
Hook Tiers
Hooks are organized into three tiers:Tier 1: Session Hooks (23)
Run during session lifecycle events:context-window-monitor— Track context usagesession-recovery— Auto-recover from crashessession-notification— OS notifications for session eventsthink-mode— Extended thinking mode detectionmodel-fallback— Legacy model fallback (useruntime-fallbackinstead)anthropic-context-window-limit-recovery— Auto-compact on context limitpreemptive-compaction— Proactive context compressionbackground-notification— Notifications for background tasksauto-update-checker— Check for plugin updatesstartup-toast— Show startup notificationkeyword-detector— Detect special keywordsagent-usage-reminder— Remind about available agentsnon-interactive-env— Detect non-interactive environmentsinteractive-bash-session— Manage bash sessionsralph-loop— Ralph loop preventionno-sisyphus-gpt— Auto-switch Sisyphus from GPT to Hephaestusno-hephaestus-non-gpt— Block non-GPT models for Hephaestusstart-work— Start work command integrationatlas— Atlas agent integrationunstable-agent-babysitter— Monitor unstable agentstask-resume-info— Task resumption informationruntime-fallback— Auto-switch models on API errorsanthropic-effort— Anthropic effort level adjustment
Tier 2: Tool Guard Hooks (10)
Run before/after tool execution:comment-checker— Detect AI-generated comment patternstool-output-truncator— Truncate long tool outputsquestion-label-truncator— Truncate question labelsdirectory-agents-injector— Inject AGENTS.md content (deprecated on OpenCode 1.1.37+)directory-readme-injector— Inject README.md contentrules-injector— Inject project ruleswrite-existing-file-guard— Prevent accidental overwritesedit-error-recovery— Recover from edit errorsjson-error-recovery— Recover from JSON parse errorshashline-read-enhancer— Annotate Read output with hash anchors
Tier 3: Transform Hooks (4)
Run on message transformations:thinking-block-validator— Validate thinking blocksclaude-code-hooks— Claude Code compatibilitycompaction-context-injector— Inject context during compactionread-image-resizer— Resize images for multimodal models
Continuation Hooks (7)
Run during task continuation:todo-continuation-enforcer— Enforce todo completionempty-task-response-detector— Detect empty task responsesdelegate-task-retry— Retry failed task delegationsprometheus-md-only— Markdown-only mode for Prometheussisyphus-junior-notepad— Notepad for Sisyphus Juniorstop-continuation-guard— Prevent infinite continuationstasks-todowrite-disabler— Disable todowrite for task systemcompaction-todo-preserver— Preserve todos during compaction
Skill Hooks (2)
Run for skill system:category-skill-reminder— Remind about category-specific skillsauto-slash-command— Auto-detect slash commands
Disabling Hooks
Disable hooks using thedisabled_hooks array:
Hook-Specific Configuration
Some hooks have dedicated configuration options:Comment Checker
Customize the AI-generated comment detection:Custom prompt for comment quality checking. Use
{{comments}} placeholder.Startup Toast
The startup toast is a sub-feature ofauto-update-checker. Disable just the toast:
Directory Agents Injector
Auto-disabled on OpenCode 1.1.37+ which has native AGENTS.md support.
Hashline Read Enhancer
Whenhashline_edit is enabled, two companion hooks activate:
hashline-read-enhancer— Annotates Read output withLINE#IDanchorshashline-edit-diff-enhancer— Shows diffs for hashline edits
Tool Output Truncator
Enabled by default. Truncates long tool outputs to manage context. Disable:Runtime Fallback
Auto-switches models on API errors. See Runtime Fallback for full configuration. Disable:Ralph Loop
Prevents infinite agent loops. Configure:All Available Hooks
Complete list of 46 hooks:Hook Migration
Legacy hook names are automatically migrated:| Legacy Name | Current Name |
|---|---|
anthropic-auto-compact | anthropic-context-window-limit-recovery |
grep-output-truncator | (removed, merged into tool-output-truncator) |
Safe Hook Creation
Hooks are wrapped in try/catch by default to prevent plugin crashes:Common Configurations
Minimal Hooks
Disable most hooks for a lightweight experience:Performance-Optimized
Disable hooks that add overhead:Silent Mode
Disable all notifications:Next Steps
MCPs
Configure built-in MCPs and skill-embedded MCPs
Advanced
Runtime fallback, hashline edit, and experimental features