Claude-skill-registry convertSubagents
Atlas skill for converting Claude Code Subagents to OpenCode Agents format. USE WHEN migrating from Claude Code to OpenCode or when you have existing subagent definitions to port.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/converting-claude-subagents" ~/.claude/skills/majiayu000-claude-skill-registry-convertsubagents && rm -rf "$T"
skills/data/converting-claude-subagents/SKILL.mdConverting Claude Code Subagents to OpenCode Agents
This skill helps you convert Claude Code Subagent definitions (from
.claude/agents/ or ~/.claude/agents/) to OpenCode Agent format (.opencode/agent/ or ~/.config/opencode/agent/).
Note: When running from a personal config that symlinks to
~/.config/opencode/, the agent files will be available globally.
Quick Reference
Source formats:
- Claude Code:
or.claude/agents/*.md~/.claude/agents/*.md - JSON via CLI:
flag with JSON object--agents
Target formats:
- OpenCode Markdown:
or.opencode/agent/*.md~/.config/opencode/agent/*.md - OpenCode JSON:
config fileopencode.json
Key differences:
- Tools: Comma-separated string → Object with boolean values
- Mode: Implicit → Explicit
field (mode
,primary
,subagent
)all - Permissions: Via tools only → Explicit
fieldpermission - New fields:
,temperature
,disablemode
Conversion Workflow
Step 1: Locate Source Subagents
Find Claude Code subagents to convert:
# Project-level subagents ls .claude/agents/ # User-level subagents ls ~/.claude/agents/
Step 2: Read Source File
Read the subagent definition to understand its configuration:
cat .claude/agents/code-reviewer.md
Step 3: Map Configuration Fields
Convert each field from Claude Code format to OpenCode format:
Frontmatter mapping:
| Claude Code | OpenCode | Notes |
|---|---|---|
| filename or in JSON | Filename becomes agent name in markdown |
| | Keep identical |
| | Convert format (see below) |
| | Keep identical, adjust defaults |
| n/a | | Add explicit mode: (default), , or |
| n/a | | Optional: Set 0.0-1.0 for response variability |
| n/a | | Optional: Set to disable agent |
| n/a | | Optional: Set granular permissions |
Tool format conversion:
Claude Code (comma-separated or omitted):
tools: Read, Grep, Glob, Bash
OpenCode (object with booleans):
tools: read: true grep: true glob: true bash: true write: false edit: false
If tools field is omitted in Claude Code: It inherits all tools. In OpenCode, either omit the
tools field entirely or set all desired tools to true.
Model mapping:
Claude Code models:
,sonnet
,opus
(aliases)haiku
(use main conversation model)'inherit'
OpenCode models:
- Full provider/model format:
anthropic/claude-sonnet-4-20250514 - Can use same aliases if configured in OpenCode
Step 4: Add OpenCode-Specific Features
Consider adding these optional fields:
Temperature:
temperature: 0.1 # Lower = more focused, higher = more creative
Mode:
mode: subagent # or 'primary' or 'all'
Permissions:
permission: edit: ask # Options: ask, allow, deny bash: "git push": ask "git status": allow "*": ask webfetch: deny
Step 5: Create Target File
Option A: Markdown format (recommended for easy editing)
Create file at
.opencode/agent/<agent-name>.md:
--- description: Expert code reviewer focusing on quality and security mode: subagent model: anthropic/claude-sonnet-4-20250514 temperature: 0.1 tools: read: true grep: true glob: true bash: true write: false edit: false permission: edit: deny bash: ask --- [System prompt content from original Claude Code subagent]
Option B: JSON format (for programmatic access)
Add to
opencode.json:
{ "agent": { "code-reviewer": { "description": "Expert code reviewer focusing on quality and security", "mode": "subagent", "model": "anthropic/claude-sonnet-4-20250514", "temperature": 0.1, "prompt": "{file:./prompts/code-review.txt}", "tools": { "read": true, "grep": true, "glob": true, "bash": true, "write": false, "edit": false }, "permission": { "edit": "deny", "bash": "ask" } } } }
Step 6: Validate Conversion
Check the converted agent:
-
Verify file location:
- Project agent:
directory exists and file is present.opencode/agent/ - Global agent:
directory exists and file is present~/.config/opencode/agent/
- Project agent:
-
Verify frontmatter:
- Description is clear and specific
- Mode is set appropriately
- Tools are properly formatted as object with booleans
- Model string is valid
-
Verify system prompt:
- All content from original agent is preserved
- No YAML frontmatter markers in the prompt body
-
Test the agent:
- Use
to invoke the agent@agent-name - Verify it behaves as expected
- Use
Conversion Examples
For detailed step-by-step examples with before/after comparisons, see:
cat EXAMPLES.md
The EXAMPLES.md file includes:
- Code Reviewer (read-only agent)
- Debugger (with edit access)
- Test Runner (with bash permissions)
- Documentation Writer (write-only)
- Security Auditor (analysis only)
- Data Analyst (with BigQuery)
- Primary Build Agent (full access)
- Batch conversion scripts
- Complex permission examples
Quick example snippet:
Claude Code format:
--- name: code-reviewer description: Reviews code for quality and security tools: Read, Grep, Glob model: sonnet ---
OpenCode format:
--- description: Reviews code for quality and security mode: subagent model: anthropic/claude-sonnet-4-20250514 temperature: 0.1 tools: read: true grep: true glob: true write: false edit: false permission: edit: deny ---
Common Conversion Patterns
Pattern 1: Read-Only Analysis Agent
Claude Code:
tools: Read, Grep, Glob
OpenCode:
mode: subagent tools: read: true grep: true glob: true write: false edit: false bash: false permission: edit: deny bash: deny
Pattern 2: Development Agent with Full Access
Claude Code:
tools: # Omitted = inherits all
OpenCode:
mode: subagent # Omit tools field to inherit all, or: tools: read: true write: true edit: true bash: true grep: true glob: true permission: bash: "rm *": ask "git push": ask "*": allow
Pattern 3: Selective Bash Permissions
Claude Code:
tools: Bash, Read
OpenCode:
mode: subagent tools: bash: true read: true write: false edit: false permission: bash: "git status": allow "git diff*": allow "git log*": allow "npm test": allow "npm run*": allow "*": ask # All other commands require approval
Special Considerations
Built-in Agents
Claude Code has built-in agents like the "Plan" subagent. OpenCode also has built-in agents:
- Build: Primary agent with all tools (equivalent to Claude Code default)
- Plan: Primary agent with restricted tools (similar to Claude Code Plan subagent)
- General: Subagent for complex research (similar to Claude Code general-purpose usage)
Don't convert built-in agents - they already exist in OpenCode with similar functionality.
CLI-Defined Agents
Claude Code supports CLI-defined agents via
--agents flag:
claude --agents '{ "code-reviewer": { "description": "...", "prompt": "...", "tools": ["Read", "Grep"], "model": "sonnet" } }'
OpenCode equivalent: Pass configuration via environment or config file. No direct CLI equivalent, but you can:
- Define in
for persistenceopencode.json - Use project-specific
files.opencode/agent/ - Use global
files~/.config/opencode/agent/
Tool Name Differences
Most tools have the same names, but watch for:
- Claude Code:
,Bash
,Read
,Write
,Edit
,GrepGlob - OpenCode:
,bash
,read
,write
,edit
,grep
(lowercase in YAML)glob
In OpenCode markdown frontmatter, use lowercase. In JSON, also lowercase.
MCP Tools
Both systems support MCP (Model Context Protocol) tools:
- Claude Code: Subagents inherit MCP tools when
field is omittedtools - OpenCode: Same behavior, plus wildcard control:
mymcp_*: false
When converting, if the Claude Code agent uses MCP tools:
# OpenCode - allow specific MCP server tools tools: read: true myserver_*: true # All tools from 'myserver' MCP write: false
Resumable Agents
Claude Code supports resumable subagents via
agentId and resume parameter. OpenCode uses session-based continuity with parent/child session navigation:
- Ctrl+Right: Cycle forward through sessions
- Ctrl+Left: Cycle backward through sessions
Conversion strategy:
- Claude Code's resumable agents → OpenCode's session continuity (automatic)
- No configuration changes needed
- Sessions are tracked automatically in OpenCode
Validation Checklist
After conversion, verify:
- File is in correct location (
or.opencode/agent/
)~/.config/opencode/agent/ - Frontmatter has
(required)description -
is set tomode
,subagent
, orprimary
(defaults toall
if omitted)all -
field uses object format with booleans (or omitted to inherit all)tools -
string is valid for your OpenCode provider configurationmodel - System prompt is preserved exactly from original
- No
field in frontmatter (filename is the name)name -
is set if behavioral control is importanttemperature -
is configured for potentially destructive toolspermission - Test agent invocation with
@agent-name
Troubleshooting
Issue: Agent not appearing in OpenCode
- Check file is in correct directory (
or.opencode/agent/
)~/.config/opencode/agent/ - Verify frontmatter YAML is valid
- Ensure
field is presentdescription - Check for
in frontmatterdisable: true
Issue: Tools not working as expected
- Verify
object format (not comma-separated string)tools - Check permissions aren't blocking tool usage
- Ensure tool names are lowercase
Issue: Agent behaves differently than in Claude Code
- Review
setting (may need adjustment)temperature - Check
settings (may be blocking operations)permission - Verify system prompt is identical to original
Issue: Model errors
- Verify model string format:
provider/model-name - Check provider is configured in OpenCode
- Try using
if main model should be usedinherit
Best Practices
- Start with read-only agents: Convert agents without write access first to minimize risk
- Use markdown format: Easier to edit and maintain than JSON
- Set explicit permissions: Don't rely on tool restrictions alone
- Test incrementally: Convert one agent at a time and test before converting more
- Document changes: Note any behavioral differences in agent comments
- Use temperature: Set appropriate temperature for agent's task type
- Leverage wildcards: Use glob patterns for tool and permission management
- Keep system prompts identical: Don't modify the prompt during conversion
- Use project agents: Place in
for team sharing.opencode/agent/ - Version control: Commit converted agents to git for team consistency
Related Commands
- Create a new agent with guided setupopencode agent create- View agents: Check
or.opencode/agent/~/.config/opencode/agent/ - Test agent: Use
in OpenCode conversation@agent-name - Switch primary agents: Use Tab key or configured keybind