Skip to content

Arkessiah/agentsmigrator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AgentMigrator

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.


Overview

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.


Installation

  1. Download the script:
curl -o migrate_agents.py https://github.com/Arkessiah/agentsmigrator.git
  1. Make it executable (optional):
chmod +x migrate_agents.py
  1. Verify it works:
python migrate_agents.py --help

Quick Start

Step 1 — Scan your Claude Code agents

See what agents are available before doing anything:

python migrate_agents.py --scan

This 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.

Step 2 — Preview the migration (dry-run)

Simulate the migration without writing any files:

python migrate_agents.py --dry-run --migrate

This shows exactly what would be created, including file paths and sizes.

Step 3 — Inspect a specific agent diff (optional)

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-reviewer

Step 4 — Run the migration

Migrate all agents at once:

python migrate_agents.py --migrate

Or migrate a single agent by name:

python migrate_agents.py --migrate <agent-name>

Example:

python migrate_agents.py --migrate solidity-auditor

Backups are created automatically in ~/.agent-migration-backups/ whenever an existing file would be overwritten.

Step 5 — Verify synchronization

Check that both platforms are aligned:

python migrate_agents.py --sync

Output shows status per agent:

  • Synchronized — system prompts match
  • Out of sync — prompts differ between platforms
  • Only in Claude Code — not yet migrated

Command Reference

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 --force

What Gets Translated

Tools

Claude 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

Models

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)

Temperature

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

Bash Permissions

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
    "*": ask

System Prompt References

Tool references inside the system prompt are also translated:

Claude Code Reference OpenCode Replacement
TodoWrite update_plan
TodoRead read_plan
Task tool subagent system (@mention)

File Structure

Source paths (Claude Code)

~/.claude/agents/*.md          # Global agents
.claude/agents/*.md            # Project-level agents

Target paths (OpenCode)

~/.config/opencode/agent/*.md  # Global agents
.opencode/agent/*.md           # Project-level agents

Backups and logs

~/.agent-migration-backups/    # Timestamped backups
~/.agent-migration.log         # Migration activity log

Agent Format Comparison

Claude Code format

---
name: code-reviewer
description: Reviews code for quality and security
tools: Read, Grep, Glob, Bash
model: sonnet
---

You are a senior code reviewer...

OpenCode format (after migration)

---
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...

Interactive Mode

Run without any flags to enter the interactive menu:

python migrate_agents.py

Options available:

  1. Scan Claude Code agents
  2. View existing OpenCode agents
  3. Check synchronization status
  4. Migrate all agents
  5. Migrate a specific agent
  6. Preview migration (dry-run)
  7. View diff for an agent
  8. Exit

Recommended Workflow

# 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 --sync

After making changes to an agent in Claude Code, re-run:

python migrate_agents.py --migrate --force
python migrate_agents.py --sync

Requirements

  • Python 3.8+
  • No external dependencies

License

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

About

Local-first Python CLI to migrate and synchronize agents and skills between Claude Code and OpenCode, without vendor lock-in.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages