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’sexperimental.session.compacting hook fires before the LLM generates a continuation summary. No Claude Code equivalent exists.
Use case 1 — Inject domain state:
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: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.diffto log what the agent changed - Security: intercept
permission.askedto audit what the agent is requesting - Integration: fire on
file.editedto trigger external sync
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
- 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
Related Pages
- OpenCode — OpenCode entity page
- Claude Code Plugins — Claude Code plugin system detail
- Context Compression Strategies — what compaction hooks extend
- Agent Harness — both systems are harness implementations