Goal: Enable Claude Code plugins to work with OpenCode
Status:
Recommended Approach: Extend CodeFlow CLI with plugin conversion capabilities
Both systems use the same format!
Claude Code Command:
---
description: "Run security scan"
---
Perform security analysis...OpenCode Command:
---
description: "Run security scan"
---
Perform security analysis...Migration Steps:
# Copy Claude Code commands to OpenCode
cp -r .claude-plugin/commands/* .opencode/command/
# Or use CodeFlow CLI
codeflow convert commands --output .opencode/command/Challenge: Claude Code uses markdown agents, OpenCode doesn't have native agent support
Solution: Convert agents to custom tools
Example:
Claude Code Agent (agents/python_pro.md):
---
description: Python expert
mode: subagent
temperature: 0.1
---
You are a Python expert...Becomes OpenCode Tool:
{
name: "python_pro",
description: "Python expert",
args: z.object({ task: z.string() }),
execute: async ({ task }) => {
return await client.chat({
messages: [{ role: "user", content: agentPrompt }],
temperature: 0.1
})
}
}Similar to agents - convert to custom tools in OpenCode plugins
Challenge: Claude Code uses JSON config, OpenCode uses TypeScript event handlers
Claude Code Hook:
{
"PostToolUse": {
"command": "./scripts/validate.sh"
}
}OpenCode Hook:
tool: {
execute: {
after: async (input, output) => {
await $`./scripts/validate.sh`
}
}
}Deliverables:
- Research documentation (DONE ✓)
- Integration guide (DONE ✓)
- Update CodeFlow CLI to support
.opencode/command/output - Test command migration with real examples
Effort: 2-3 days
Deliverables:
- New
PluginConverterclass - Parse
plugin.jsonand component directories - Generate OpenCode plugin wrapper TypeScript
- Agent-to-tool conversion logic
- Hook-to-event conversion logic
- Template system for generated code
New Files:
src/converters/plugin-converter.ts
src/generators/opencode-plugin-generator.ts
src/types/plugin-types.ts
templates/opencode-plugin.template.ts
tests/plugin-converter.test.ts
CLI Command:
codeflow convert plugin \
--input ./my-claude-plugin \
--output ./my-opencode-pluginEffort: 5-7 days
Deliverables:
- Integration test suite
- Example conversions (3-5 real plugins)
- Migration guide with screenshots
- Troubleshooting documentation
- Video tutorial
Effort: 3-4 days
Deliverables:
- Update README with plugin conversion features
- Publish to npm
- Announcement blog post
- Share in Claude Code and OpenCode communities
- Create GitHub discussions for feedback
Effort: 1-2 days
// src/cli/commands/convert-plugin.ts
import { Command } from 'commander';
import { PluginConverter } from '../converters/plugin-converter';
export const convertPluginCommand = new Command('plugin')
.description('Convert Claude Code plugin to OpenCode format')
.requiredOption('-i, --input <dir>', 'Claude Code plugin directory')
.requiredOption('-o, --output <dir>', 'Output directory for OpenCode plugin')
.option('-d, --dry-run', 'Preview conversion without writing files')
.option('--skip-hooks', 'Skip hook conversion')
.option('--skip-agents', 'Skip agent conversion')
.action(async (options) => {
const converter = new PluginConverter();
const result = await converter.convertPlugin(
options.input,
options.output,
{
dryRun: options.dryRun,
skipHooks: options.skipHooks,
skipAgents: options.skipAgents
}
);
console.log(`✅ Converted: ${result.converted}`);
console.log(`❌ Failed: ${result.failed}`);
});// src/converters/plugin-converter.ts
export class PluginConverter {
async convertPlugin(
inputDir: string,
outputDir: string,
options: ConverterOptions
): Promise<ConversionResult> {
// 1. Parse plugin.json
const pluginConfig = await this.parsePluginManifest(inputDir);
// 2. Convert components
const commands = await this.convertCommands(inputDir);
const agents = await this.convertAgents(inputDir);
const hooks = await this.convertHooks(inputDir);
// 3. Generate OpenCode plugin TypeScript
const pluginCode = await this.generatePluginWrapper({
config: pluginConfig,
agents,
hooks
});
// 4. Write output files
await this.writeOpenCodePlugin(outputDir, {
pluginCode,
commands,
packageJson: this.generatePackageJson(pluginConfig)
});
return result;
}
private async generatePluginWrapper(components: PluginComponents): Promise<string> {
// Use template engine to generate TypeScript
return this.templateEngine.render('opencode-plugin', components);
}
}// templates/opencode-plugin.template.ts
export const opencodePluginTemplate = `
import type { Plugin } from "@opencode-ai/plugin"
import { z } from "zod"
export const {{pluginName}}: Plugin = async ({ client, $, directory }) => {
{{#agents}}
// Agent: {{name}}
const {{camelCase name}}Tool = {
name: "{{snakeCase name}}",
description: "{{description}}",
args: z.object({
task: z.string()
}),
execute: async ({ task }) => {
const response = await client.chat({
messages: [{ role: "user", content: \`{{prompt}}\` }],
temperature: {{temperature}}
})
return response
}
}
{{/agents}}
return {
{{#agents}}
tool: {{camelCase name}}Tool,
{{/agents}}
{{#hooks}}
// Hook: {{name}}
{{hookCode}}
{{/hooks}}
}
}
`;Input: Plugin with only commands Complexity: Low Time: < 1 minute Success Rate: 100%
Input: Plugin with 5 agents, no hooks Complexity: Medium Time: 2-3 minutes Success Rate: 90%
Input: Commands + Agents + Hooks + MCP Complexity: High Time: 5-10 minutes Success Rate: 70% (manual tweaking needed)
- Complex Hook Logic: Hooks with shell scripts requiring environment-specific setup
- MCP Server Configurations: May need manual OpenCode MCP setup
- Custom Directory Structures: Non-standard plugin layouts
- Conditional Logic in Hooks: Advanced hook conditions
- Environment Variables: May need remapping
- File Paths: Adjust for OpenCode directory structure
- Dependencies: Install npm packages for generated plugin
- Testing: Verify generated plugin works as expected
- 100% of commands migrate successfully
- Documentation complete
- CLI updated with command support
- 80%+ of agents convert without errors
- 60%+ of hooks convert without errors
- Template system supports 5+ common patterns
- 3+ real-world plugin conversions completed
- Test coverage > 80%
- Migration guide tested by 3+ users
- 100+ GitHub stars on updated repo
- 10+ community conversions
- Integration into OpenCode community resources
Mitigation: Pin to specific OpenCode version, maintain compatibility matrix
Mitigation: Start with simple plugins, gradually increase complexity, document limitations
Mitigation: Provide excellent documentation, video tutorials, responsive support
Mitigation: Automated testing, clear contribution guidelines, community involvement
- Time: 2-3 weeks (60-80 hours)
- Skills: TypeScript, OpenCode API, Template engines
- Tools: Existing CodeFlow CLI infrastructure
- Plugins: 5-10 real Claude Code plugins for testing
- Environments: Both Claude Code and OpenCode installations
- Testers: 3-5 beta testers from community
- Writer: Technical documentation skills
- Designer: Diagrams and visual aids
- Video: Screen recording and editing tools
- Bidirectional conversion (OpenCode → Claude Code)
- Plugin optimization (combine similar agents)
- Validation and linting for generated code
- Interactive conversion wizard
- Plugin diff viewer
- Automated testing generation
- Real-time plugin sync
- Plugin marketplace integration
- AI-assisted manual interventions
- Priority: Should we focus on simple plugins first or tackle complex ones?
- Naming: Keep "CodeFlow CLI" or rename to "Plugin Converter CLI"?
- Distribution: npm only or also standalone binary?
- Contribution: Open to community PRs from day 1?
Today: Copy commands manually
cp -r .claude-plugin/commands/* .opencode/command/Soon: Use CodeFlow CLI
codeflow convert plugin --input ./my-plugin --output ./convertedInterested in helping?
- Review docs/CLAUDE_TO_OPENCODE_PLUGIN_INTEGRATION.md
- Check GitHub issues labeled
plugin-conversion - Join discussions in GitHub Discussions
- Submit PRs for Phase 1 implementation
Last Updated: 2025-11-17 Status: Planning → Ready for Implementation Next Milestone: Phase 1 completion