@fwdslsh/crosstrainOpenCode plugin that loads Claude Code extension points (skills, agents, commands, hooks) into OpenCode
2
9
近 7 天 2
16.6
生态多维模型
8 个月前
2025-12-15
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@fwdslsh/crosstrain@0.1.0"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@fwdslsh/crosstrain@0.1.0"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D @fwdslsh/crosstrainopencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
CLI tool and OpenCode plugin for converting Claude Code extensions to OpenCode format.
What It Does
Crosstrain bridges Claude Code's extension ecosystem to OpenCode:
| Claude Code | → | OpenCode |
|---|---|---|
Skills (.claude/skills/) |
→ | Plugin tools |
Agents (.claude/agents/) |
→ | Agents (.opencode/agent/) |
Commands (.claude/commands/) |
→ | Commands (.opencode/command/) |
Hooks (settings.json) |
→ | Event handlers |
MCP Servers (.mcp.json) |
→ | MCP config (opencode.json) |
Installation
Quick Install
# Install globally with bun
bun install -g @fwdslsh/crosstrain"
# Or run directly
bunx crosstrain --help
From Source
git clone https://github.com/fwdslsh/crosstrain.git
cd crosstrain
bun install
bun link # Makes 'crosstrain' available globally
CLI Usage
crosstrain <command> [path] [options]
Commands
| Command | Description |
|---|---|
command <path> |
Convert a Claude Code command (.md file) |
skill <path> |
Convert a skill to OpenCode plugin tool |
agent <path> |
Convert an agent to OpenCode format |
hook |
Display Claude Code hooks configuration |
mcp [path] |
Convert MCP servers to OpenCode config |
plugin <source> |
Convert a full plugin (local or remote) |
list <source> |
List plugins in a marketplace |
all |
Convert all Claude Code assets in project |
init |
Initialize a new skills plugin |
settings |
Import Claude Code settings to opencode.json |
Options
| Option | Description |
|---|---|
-o, --output-dir <path> |
Output directory (default: .opencode) |
-p, --prefix <prefix> |
File prefix for generated files (default: claude_) |
-v, --verbose |
Enable verbose output |
--dry-run |
Preview changes without writing files |
--no-user |
Skip user-level assets from ~/.claude |
Examples
# Convert all assets in current project
crosstrain all
# Preview changes without writing
crosstrain all --dry-run
# Convert a single command
crosstrain command .claude/commands/create-feature.md
# Convert a skill to a plugin tool
crosstrain skill .claude/skills/pdf-extractor
# Convert a plugin from GitHub
crosstrain plugin anthropics/claude-plugins/code-review
# Browse a marketplace
crosstrain list anthropics/claude-plugins
# Convert a specific version
crosstrain plugin org/repo/plugin@v1.0.0
OpenCode Plugin
Crosstrain also works as an OpenCode plugin, exposing tools that let the AI agent assist with conversion.
Plugin Installation
# Clone to your plugin directory
git clone https://github.com/fwdslsh/crosstrain.git .opencode/plugin/crosstrain
cd .opencode/plugin/crosstrain
bun install
Plugin Tools
When installed as a plugin, the AI agent can use these tools:
crosstrain- Run any CLI commandcrosstrain_convert_all- Convert all assetscrosstrain_convert_plugin- Convert a plugincrosstrain_list_marketplace- Browse marketplacescrosstrain_convert_command- Convert single commandcrosstrain_convert_skill- Convert single skillcrosstrain_convert_agent- Convert single agentcrosstrain_convert_mcp- Convert MCP serverscrosstrain_show_hooks- Display hooks configcrosstrain_init- Initialize skills plugincrosstrain_import_settings- Import Claude Code settings to opencode.json
Plugin Configuration
Optional settings in .opencode/plugin/crosstrain/settings.json:
{
"enabled": true,
"verbose": false
}
Asset Conversion Details
Skills → Plugin Tools
Claude Code skills become OpenCode plugin tools:
.claude/skills/commit-helper/SKILL.md → .opencode/plugin/crosstrain-skills/tools/skill_commit_helper.ts
Agents → Agents
.claude/agents/code-review.md → .opencode/agent/claude_code-review.md
Model mapping:
sonnet→anthropic/claude-sonnet-4-20250514opus→anthropic/claude-opus-4-20250514haiku→anthropic/claude-haiku-4-20250514
Commands → Commands
.claude/commands/run-tests.md → .opencode/command/claude_run-tests.md
Hooks → Event Handlers
Event mapping:
PreToolUse→tool.execute.beforePostToolUse→tool.execute.afterSessionStart→session.createdSessionEnd→session.idle
MCP Servers → OpenCode Config
.mcp.json → opencode.json (mcp section)
Settings → opencode.json
Claude Code settings are converted to OpenCode configuration:
# Import settings
crosstrain settings
# Preview first
crosstrain settings --dry-run
Permission mode mapping:
acceptEdits→{ edit: "allow" }bypassPermissions→{ edit: "allow", bash: "allow" }plan→{ edit: "deny", bash: "deny" }
Not converted (no direct equivalent):
hooks- Use OpenCode plugins insteadenv- Set environment variables before running OpenCodecompanyAnnouncements- Not supportedsandbox- OpenCode uses different sandboxing
Remote Plugins
Convert plugins directly from GitHub:
# GitHub shorthand
crosstrain plugin org/repo/plugin-name
# With version tag
crosstrain plugin org/repo/plugin-name@v1.0.0
# Full URL
crosstrain plugin https://github.com/org/repo
Browsing Marketplaces
List available plugins in a Claude Code marketplace:
crosstrain list anthropics/claude-plugins
Output shows plugin names, descriptions, and the command to convert each one.
Crosstrainer Configuration
Plugin authors can customize conversion by adding a crosstrainer.json or crosstrainer.js file to their plugin root.
JSON Configuration
For simple customization (model mappings, asset filtering):
{
"name": "my-plugin",
"prefix": "myplugin_",
"models": {
"sonnet": "anthropic/claude-sonnet-4-20250514"
},
"agents": {
"exclude": ["deprecated-agent"]
}
}
JavaScript Configuration
For full control with transform hooks:
export default {
name: "my-plugin",
transformAgent(agent, ctx) {
// Modify agent before conversion
agent.model = "opus"
return agent
},
transformCommand(command, ctx) {
// Return null to skip
if (command.name.startsWith("internal-")) return null
return command
},
onConversionComplete(ctx, results) {
console.log(`Converted ${results.agents.length} agents`)
}
}
Only one crosstrainer file per plugin. See CLI Reference for full documentation.
Development
bun install # Install dependencies
bun test # Run tests
bun run typecheck # Type check
bun run build # Build
Documentation
- CLI Reference - Full CLI documentation
- CLAUDE.md - Architecture and development guide
License
CC-BY-4.0