opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[FEATURE:] Add configurable hooks for custom commands on task events (similar to Claude Code)

Open Decade-qiu opened this issue 3 weeks ago • 1 comments

Feature hasn't been suggested before.

  • [x] I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

I would like to request support for configurable hooks, similar to the Hooks feature in Claude Code: https://code.claude.com/docs/en/hooks.

Hooks would allow users to define custom commands/scripts that automatically execute at specific points during a task's lifecycle, such as:

  • On successful task completion (e.g., run a notification script, trigger a deployment, or perform cleanup)
  • On task error/failure (e.g., send an alert, log details to an external service, or attempt automatic recovery)
  • When user confirmation is required (e.g., pause execution and run a custom command to prompt the user via another tool/integration)
  • more ......

Decade-qiu avatar Jan 10 '26 13:01 Decade-qiu

This issue might be a duplicate of or closely related to existing issues. Please check:

  • #2185: Hooks for commands (Plugin Commands) - An earlier request for hooks functionality focused on plugin command interception and lifecycle

While #2185 is more specific to plugin command hooks, #7640 appears to be a broader feature request for task lifecycle hooks (like Claude Code's implementation). These two issues could potentially be consolidated or addressed as part of a comprehensive hooks system.

github-actions[bot] avatar Jan 10 '26 13:01 github-actions[bot]

I've implemented this feature using OpenCode's plugin system. My plugin opencode-message-notify (https://github.com/Decade-qiu/opencode-message-notify) provides hooks for:

  • Task completion - Sends detailed Agent messages
  • Permission requests - Notifies when confirmation is required
  • Usage statistics - Tracks cost, tokens, cache usage
  • iOS notifications - Via Bark app

Moreover, plugin docs lack detailed explanations of event types and input (output) types. I had to log events during development to understand what data was available. It would be helpful to document key events with their input/output types and field meanings more clearly.

Decade-qiu avatar Jan 11 '26 11:01 Decade-qiu