The existing .opencode/plugins/entire.ts in this project is a perfect example -- it's an opencode plugin that bridges the "entire" CLI's hooks into opencode's event system, mapping events like session.created -> session-start hook, message.part.updated -> turn-start hook, session.status idle -> turn-end hook, etc.
2d. Custom Tools (.opencode/tools/)
What they are: TypeScript/JavaScript files that define functions the LLM can call. These are equivalent to Claude Code's MCP tool definitions.
Structure:
typescript
import { tool } from "@opencode-ai/plugin"
export default tool({
description: "Tool description",
args: {
query: tool.schema.string().describe("SQL query"),
},
async execute(args, context) {
const { agent, sessionID, messageID, directory, worktree } = context
// Can call any external CLI/process here
return result
},
})
Filename becomes tool name (e.g., database.ts creates tool database)
Tools can be written in any language -- TypeScript just defines the interface, but can shell out to Python, bash, etc.
2e. Commands (Slash Commands)
Equivalent of Claude Code's commands/*.md -- near-identical concept.
markdown
---
description: Run tests with coverage
agent: build
model: anthropic/claude-sonnet-4-5
subtask: false
---
Run the full test suite with coverage report.
Focus on the failing tests and suggest fixes.
Place markdown files in .opencode/commands/
Filename becomes command name (test.md -> /test)
Supports $ARGUMENTS, $1, $2 placeholders
Supports !shell_command`` to inject shell output
Supports @filename to include file content
Can be defined in opencode.json under command key
Can override built-in commands
2f. Agent Skills (SKILL.md)
Equivalent of Claude Code's skills system -- opencode is explicitly compatible with Claude Code's skill paths.
Skills are loaded on-demand via a native skill tool. The agent sees available skills and calls skill({ name: "git-release" }) to load the full content.
Important: The skills currently in /Users/ubuntu/.agents/skills/ are loaded because opencode reads .agents/skills/*/SKILL.md paths. This is the Claude Code / Agent-compatible skill system.
Built-in:build (primary), plan (primary, read-only), general (subagent), explore (subagent)
Custom agents: Define in opencode.json or as .opencode/agents/<name>.md
Modes:primary, subagent, all
Permissions: Fine-grained control over edit, bash, webfetch, skill, task
Invocation: Tab key to cycle primary agents; @mention for subagents
2i. Rules / Instructions (AGENTS.md)
AGENTS.md in project root (primary)
CLAUDE.md fallback for Claude Code compatibility
~/.config/opencode/AGENTS.md global
~/.claude/CLAUDE.md global fallback
Additional instruction files via instructions array in opencode.json
Supports relative paths and glob patterns
3. Direct Mapping: Claude Code vs. OpenCode
Claude Code Concept
OpenCode Equivalent
Notes
.claude-plugin/plugin.json
N/A
OpenCode has no plugin marketplace concept. Plugins are loaded from filesystem or npm.
commands/*.md (slash commands)
.opencode/commands/*.md
Nearly identical markdown-based format with YAML frontmatter
hooks/hooks.json
.opencode/plugins/*.ts (event system)
Different approach. OpenCode uses TypeScript event handlers, not JSON-defined shell hooks. However, plugins CAN spawn shell commands.
.mcp.json (tool definitions)
.opencode/tools/*.ts + opencode.jsonmcp field
Two approaches: (1) MCP servers via mcp config, (2) custom tools via .opencode/tools/
CLAUDE.md / AGENTS.md
AGENTS.md
Same concept, same file. OpenCode also reads CLAUDE.md as fallback.
.claude/skills/*/SKILL.md
.opencode/skills/*/SKILL.md (also reads .agents/skills/ and .claude/skills/)
Fully compatible
Background task management
Subagents + subtask: true
OpenCode has native subagent orchestration
allowed-tools in command frontmatter
Agent-level permission config
Different mechanism but same intent
.codex/hooks.json
Same plugin event system
Codex and OpenCode share similar plugin architecture
4. Key Architectural Differences
Hooks/Events:
Claude Code: Declarative JSON (hooks.json) mapping lifecycle events to shell commands. Simple but rigid.
OpenCode: Programmatic TypeScript plugins with 40+ granular event types. Much more powerful -- can intercept tool calls, inject env vars, modify context, etc.
Critical insight: The existing .opencode/plugins/entire.ts demonstrates that OpenCode plugins can achieve the same thing as Claude Code hooks by:
Subscribing to events like session.created, message.part.updated, session.status
So Claude Code hooks CAN be ported to OpenCode plugins, but must be rewritten as TypeScript event handlers.
Custom Tools:
Claude Code: Uses .mcp.json with JSON Schema definitions that wrap shell commands
OpenCode: Uses .opencode/tools/*.ts with the tool() helper (Zod schemas) OR mcp config for MCP servers
OpenCode can ALSO run MCP servers from the config, so .mcp.json content can be ported to opencode.jsonmcp field for true MCP servers, or to .opencode/tools/ for shell-wrapped tools
Plugin Marketplace:
Claude Code has .claude-plugin/marketplace.json for plugin distribution
OpenCode has no built-in marketplace. Plugins are distributed via npm or placed in the project's .opencode/plugins/ directory. There's a community ecosystem page at opencode.ai/docs/ecosystem.
5. Can trae-plugin-cc Port to OpenCode?
Yes, but it requires adaptation. Here's the detailed mapping of what needs to change:
What transfers directly (minimal changes):
trae-plugin-cc
OpenCode
Effort
commands/*.md (10 files)
.opencode/commands/*.md
Low -- nearly identical format, just adapt frontmatter fields
AGENTS.md / CLAUDE.md
AGENTS.md
None -- same file
Skills system
.opencode/skills/
None -- OpenCode reads .agents/skills/ already
Core logic (dist/index.js)
.opencode/tools/ TypeScript wrappers
Medium -- wrap the Node.js CLI calls in tool() definitions
Medium -- convert JSON Schema to Zod, wrap CLI calls
.claude-plugin/plugin.json
Remove -- not needed in OpenCode
None
.claude-plugin/marketplace.json
Remove -- not needed in OpenCode
None
Recommended porting strategy:
Create .opencode/commands/ -- copy all 10 command files from commands/, adapting frontmatter:
description stays the same
allowed-tools maps to agent-level permission in opencode.json
# /trae:run becomes /run (or use subdirectory for namespacing)
Create .opencode/tools/trae-run.ts, .opencode/tools/trae-review.ts, etc. -- these replace .mcp.json tool definitions, wrapping the existing dist/index.js logic:
Native subagent orchestration -- OpenCode's subtask: true on commands and @mention subagent dispatch replace manual background task management
Plugin event system -- 40+ granular events vs. 4-5 hooks in Claude Code
Type-safe custom tools -- Zod schema validation vs. manual JSON Schema in .mcp.json
MCP support -- If Trae ever exposes a proper MCP server, it can be configured with a single mcp block
Cross-editor -- OpenCode has TUI, web UI, desktop app, VS Code, Neovim -- the plugin would work in all of them automatically
7. What OpenCode Lacks Compared to Claude Code
Plugin marketplace -- no marketplace.json equivalent. Distribution is npm-only or manual file placement.
allowed-tools in command frontmatter -- OpenCode handles this at the agent level, not per-command (though commands can specify which agent to use)
${CLAUDE_PLUGIN_ROOT} environment variable -- OpenCode has directory in plugin context but no direct equivalent env var. Commands would need path resolution.
8. Final Verdict
Porting is feasible and well-supported. The trae-plugin-cc should be adapted as an opencode plugin package with:
.opencode/commands/ for slash commands (direct copy + frontmatter tweaks)
.opencode/tools/ for MCP-style tool definitions (TypeScript wrappers around existing CLI)
.opencode/plugins/ for hook lifecycle replacements (TypeScript event handlers)
opencode.json for configuration
Core dist/index.js and scripts/ remain unchanged
The plugin would NOT need a plugin.json or marketplace.json -- those are Claude Code-specific. Instead, it should be structured as a TypeScript package that exports the plugin, tools, and commands, installable via npm or by copying files into .opencode/.
Create opencode.json in project root with:
Plugin reference
Agent definitions (e.g., trae-reviewer subagent)
Permission configurations
Keep dist/, scripts/, package.json -- the core CLI logic is platform-agnostic.