Claude Code → OpenCode Agent Migration Tool v1.0
A Python CLI utility that scans, previews, migrates, and synchronizes your custom agents between Claude Code and OpenCode — keeping both platforms in sync with a single command.
If you use both Claude Code and OpenCode, maintaining agents across both platforms manually is tedious and error-prone. AgentMigrator automates the entire process:
- Scans your Claude Code agents (global and project-level)
- Translates tools, models, permissions, and temperature settings to OpenCode format
- Previews changes with dry-run and diff modes before writing anything
- Migrates all agents or specific ones with automatic backups
- Syncs by detecting which agents are out of date between platforms
No external dependencies required — pure Python 3.
- Download the script:
curl -o migrate_agents.py https://github.com/Arkessiah/agentsmigrator.git- Make it executable (optional):
chmod +x migrate_agents.py- Verify it works:
python migrate_agents.py --helpSee what agents are available before doing anything:
python migrate_agents.py --scanThis lists all agents found in:
| Scope | Path |
|---|---|
| Global | ~/.claude/agents/ |
| Project | .claude/agents/ (from CWD) |
Output includes: name, scope, model, tools, and description for each agent.
Simulate the migration without writing any files:
python migrate_agents.py --dry-run --migrateThis shows exactly what would be created, including file paths and sizes.
See a side-by-side comparison of the original Claude Code format vs the converted OpenCode format:
python migrate_agents.py --diff <agent-name>Example:
python migrate_agents.py --diff code-reviewerMigrate all agents at once:
python migrate_agents.py --migrateOr migrate a single agent by name:
python migrate_agents.py --migrate <agent-name>Example:
python migrate_agents.py --migrate solidity-auditorBackups are created automatically in ~/.agent-migration-backups/ whenever an existing file would be overwritten.
Check that both platforms are aligned:
python migrate_agents.py --syncOutput shows status per agent:
- ✓ Synchronized — system prompts match
- ⚠ Out of sync — prompts differ between platforms
- ✗ Only in Claude Code — not yet migrated
| Command | Description |
|---|---|
python migrate_agents.py |
Interactive menu mode |
python migrate_agents.py --scan |
List all Claude Code agents |
python migrate_agents.py --migrate |
Migrate all agents to OpenCode |
python migrate_agents.py --migrate <name> |
Migrate a specific agent |
python migrate_agents.py --sync |
Show sync status across platforms |
python migrate_agents.py --diff <name> |
Show before/after diff for an agent |
python migrate_agents.py --dry-run --migrate |
Simulate migration (no writes) |
python migrate_agents.py --migrate --force |
Overwrite existing OpenCode agents |
python migrate_agents.py --no-color |
Disable colored terminal output |
Flags can be combined:
python migrate_agents.py --dry-run --migrate --no-color
python migrate_agents.py --migrate --forceClaude Code uses a comma-separated list. OpenCode uses boolean flags with granular permissions.
| Claude Code | OpenCode |
|---|---|
Read |
read: true |
Write |
write: true |
Edit |
edit: true |
Bash |
bash: true + permission rules |
Glob |
glob: true |
Grep |
grep: true |
WebFetch |
web_fetch: true |
WebSearch |
web_search: true |
TodoRead |
read_plan: true |
TodoWrite |
update_plan: true |
Task |
task: true |
Skill |
use_skill: true |
| Claude Code | OpenCode |
|---|---|
sonnet |
anthropic/claude-sonnet-4-5-20250929 |
haiku |
anthropic/claude-haiku-4-5-20251001 |
opus |
anthropic/claude-opus-4-6 |
inherit |
(omitted — inherits from parent) |
Automatically assigned based on agent type keywords in the name/description:
| Agent Type | Temperature |
|---|---|
review, audit |
0.2 |
security |
0.1 |
test, debug |
0.2 |
architect, plan |
0.3–0.4 |
document, write |
0.5–0.6 |
creative |
0.7 |
| Default | 0.3 |
When Bash is present in Claude Code tools, AgentMigrator generates safe default permissions:
permissions:
bash:
"git *": allow
"npm *": allow
"npx *": allow
"python *": allow
"pip *": allow
"cargo *": allow
"ls *": allow
"cat *": allow
"find *": allow
"grep *": allow
"*": askTool references inside the system prompt are also translated:
| Claude Code Reference | OpenCode Replacement |
|---|---|
TodoWrite |
update_plan |
TodoRead |
read_plan |
Task tool |
subagent system (@mention) |
~/.claude/agents/*.md # Global agents
.claude/agents/*.md # Project-level agents
~/.config/opencode/agent/*.md # Global agents
.opencode/agent/*.md # Project-level agents
~/.agent-migration-backups/ # Timestamped backups
~/.agent-migration.log # Migration activity log
---
name: code-reviewer
description: Reviews code for quality and security
tools: Read, Grep, Glob, Bash
model: sonnet
---
You are a senior code reviewer...---
description: Reviews code for quality and security
mode: subagent
model: anthropic/claude-sonnet-4-5-20250929
temperature: 0.2
tools:
read: true
grep: true
glob: true
bash: true
permissions:
bash:
"git *": allow
"npm *": allow
"*": ask
edit: allow
write: allow
---
You are a senior code reviewer...Run without any flags to enter the interactive menu:
python migrate_agents.pyOptions available:
- Scan Claude Code agents
- View existing OpenCode agents
- Check synchronization status
- Migrate all agents
- Migrate a specific agent
- Preview migration (dry-run)
- View diff for an agent
- Exit
# 1. See what you have
python migrate_agents.py --scan
# 2. Preview without writing anything
python migrate_agents.py --dry-run --migrate
# 3. Inspect specific agents if needed
python migrate_agents.py --diff code-reviewer
# 4. Execute the migration
python migrate_agents.py --migrate
# 5. Confirm everything is in sync
python migrate_agents.py --syncAfter making changes to an agent in Claude Code, re-run:
python migrate_agents.py --migrate --force
python migrate_agents.py --sync- Python 3.8+
- No external dependencies
MIT
Disclaimer This tool has been tested on the author's machine and works as expected. However, use it at your own risk. The author assumes no responsibility for any data loss, file corruption, or unintended modifications that may result from running this script. Always review what you execute on your own system, inspect the --dry-run output before migrating, and ensure you have proper backups of your agents before proceeding.
Built by Arkessiah