Ohmyopencode Hooks
2 min read
Oh My OpenCode Hooks
Oh My OpenCode includes a powerful Hooks System that automates workflows and enhances reliability. Hooks are event-driven functions that run at specific points in the agent's lifecycle.
Built-in Hooks
Oh My OpenCode comes with 20+ built-in hooks enabled by default. They are categorized by their function:
1. Task Management
- todo-continuation-enforcer: Monitors your todo list. If a task is marked as "in_progress" or incomplete, it prompts the agent to continue working on it, preventing the agent from getting distracted or stopping prematurely.
2. Context Management
- Context Window Management: Automatically manages the context window size, performing compaction or truncation to ensure the agent stays within token limits without losing critical information.
3. Session Management
- Session Recovery: Automatically detects if a session has crashed or encountered an error and attempts to recover it, preserving your chat history and state.
4. Code Quality
- Auto-Linting: Can automatically run linters (like Biome or ESLint) after the agent makes changes, ensuring code quality standards are met immediately.
5. Workflow Automation
- Hooks can automate repetitive tasks, such as updating documentation after a code change or running specific tests when a file is modified.
Configuration
Hooks are highly configurable via the Oh My OpenCode configuration. You can enable/disable specific hooks or tune their parameters (e.g., adjust the strictness of the todo enforcer) to match your workflow.