Skip to main content

Claude Code vs OpenCode Plugin Systems

Side-by-side comparison of hook/plugin extensibility between Claude Code (Anthropic) and OpenCode (opencode.ai).

Architecture Comparison


Compaction Hook — The Key Differentiator

OpenCode’s experimental.session.compacting hook fires before the LLM generates a continuation summary. No Claude Code equivalent exists. Use case 1 — Inject domain state:
Use case 2 — Replace entire compaction prompt:
This allows implementing custom Context Compression Strategies strategies (anchored iterative summarization, opaque compression) at the harness level, not the system prompt level. Claude Code users must approximate this via CLAUDE.md instructions to the model — less reliable because the model can ignore prose instructions under context pressure.

Custom Tools

Claude Code approach: Register an MCP server, configure it in settings, start it as a separate process. Full tool available to the model. OpenCode approach: Declare a tool inside a plugin module, automatically available on next startup:
OpenCode’s approach is lower friction for simple custom tools; MCP is better for complex, reusable tool servers.

Event Coverage

Claude Code’s four events (PreToolUse, PostToolUse, Stop, Notification) cover the core tool execution loop. OpenCode’s 30+ events cover the full session lifecycle — including LSP diagnostics, TUI interactions, and permission decisions. This matters for:
  • Observability: react to session.diff to log what the agent changed
  • Security: intercept permission.asked to audit what the agent is requesting
  • Integration: fire on file.edited to trigger external sync
For most developer workflows, Claude Code’s four events are sufficient. OpenCode’s broader surface is useful for building production harnesses or complex integrations.

When to Use Each

Claude Code hooks are sufficient for:
  • Pre/post tool filtering and logging
  • Stop-event notifications
  • Simple env var injection via shell hooks
OpenCode plugins add value for:
  • Custom compaction strategies (inject task state into context summaries)
  • Custom tools without MCP overhead
  • Observability hooks (session diffs, LSP diagnostics)
  • Multi-agent session coordination via session events