Migrating from Claude Code PAI to PAI OpenCode
This guide helps you migrate an existing PAI 2.x installation from Claude Code to OpenCode.
Two migration paths:
- Fresh Install - Start clean with PAI-OpenCode defaults
- Migration - Transfer your customizations from Claude Code PAI
-
Bun (JavaScript runtime)
curl -fsSL https://bun.sh/install | bash -
OpenCode (AI coding assistant)
Install the standard vanilla release from opencode.ai. No custom build or fork required.
# 1. Clone repository
git clone https://github.com/Steffen025/pai-opencode.git
cd pai-opencode
# 2. Install dependencies
bun install
# 3. Run the installer
bash PAI-Install/install.sh
# 4. Start OpenCode
opencodeThat's it! PAI is now running with defaults.
Check your Claude Code PAI installation:
ls -la ~/.claude/
# Expected structure:
# ~/.claude/
# ├── skills/
# ├── agents/
# ├── hooks/
# ├── MEMORY/
# └── settings.jsongit clone https://github.com/Steffen025/pai-opencode.git
cd pai-opencodeThis normalizes your opencode.json and ~/.opencode/ before migration.
bash PAI-Install/install.shbun Tools/pai-to-opencode-converter.ts \
--source ~/.claude \
--target .opencode \
--dry-runReview the output:
- What will be copied
- What will be transformed
- What requires manual work
bun Tools/pai-to-opencode-converter.ts \
--source ~/.claude \
--target .opencode# Check structure
ls -la .opencode/
# Verify no .claude references
grep -r "\.claude" .opencode/ --exclude-dir=node_modulesopencodeVerify:
- Skills load: "What skills do I have?"
- Agents work:
@Intern hello - Security active: Check
/tmp/pai-opencode-debug.log
PAI-OpenCode required several architectural adaptations to work with OpenCode. These are documented in Architecture Decision Records (ADRs):
| Change | ADR | Impact |
|---|---|---|
| Hooks → Plugins | ADR-001 | Implementation only—logic preserved |
.claude/ → .opencode/ |
ADR-002 | Path updates only |
| File-based logging | ADR-004 | Debug workflow change |
| Dual config files | ADR-005 | settings.json + opencode.json |
What stayed the same:
- Skills System: ADR-003 - 100% identical
- Security: ADR-006 - Patterns preserved
- Memory: ADR-007 - Structure unchanged
| Component | Transfer Status | Notes |
|---|---|---|
| Skills | ✅ Full transfer | All skills work identically |
| Agents | ✅ Full transfer | Renamed to PascalCase |
v1.3 Agent Changes:
ClaudeResearcher→DeepResearcherPerplexityProResearcherremoved (usePerplexityResearcher)researcher.mdrenamed to individual researcher files | MEMORY | ✅ Full transfer | Work, Learning, State preserved | | Security Patterns | ✅ Full transfer |patterns.yamlcopied | | USER Customizations | ✅ Full transfer | TELOS, ABOUTME, etc. | | settings.json |⚠️ Partial transfer | Schema mapped | | Hooks | ❌ Manual work | Convert to plugins | | MCP Servers | ❌ Deferred | v1.x feature | | Observability | ❌ Deferred | v1.2 feature |
If you have custom hooks in ~/.claude/hooks/:
- Extract logic from hook file
- Create handler in
.opencode/plugins/handlers/ - Add event to
.opencode/plugins/pai-unified.ts
Example:
// Old hook: ~/.claude/hooks/custom-logger.ts
writeFileSync("/tmp/my-log.txt", "Tool executed");
process.exit(0);
// New plugin handler: .opencode/plugins/handlers/custom-logger.ts
import { fileLog } from "../lib/file-logger";
export async function customLog() {
fileLog("Tool executed");
}See PLUGIN-SYSTEM.md for full guide.
The installer installs OpenCode to ~/.local/bin/. Make sure it's in your PATH:
export PATH="$HOME/.local/bin:$PATH"Add to your shell config (~/.bashrc or ~/.zshrc) to make it permanent.
cat /tmp/pai-opencode-debug.log
# Should show: "PAI-OpenCode Plugin Loaded"Verify agent files are PascalCase:
ls -la .opencode/agents/
# Should be: Intern.md (not intern.md)grep "Context" /tmp/pai-opencode-debug.log
# Should show: "Context injected successfully"reset && opencodeCheck plugin code for console.log (should use fileLog).
bun Tools/pai-to-opencode-converter.ts [options]| Option | Description | Default |
|---|---|---|
--source <path> |
Source PAI directory | ~/.claude |
--target <path> |
Target OpenCode directory | .opencode |
--mode <mode> |
Migration mode (full or selective) |
full |
--dry-run |
Preview changes without applying | false |
Copies everything from your Claude Code PAI:
bun Tools/pai-to-opencode-converter.ts --mode full| What Gets Copied | Description |
|---|---|
| Skills | All skill definitions |
| Agents | All agent personalities |
| MEMORY | Projects, sessions, learning history |
| USER | TELOS, identity, preferences |
| Security patterns | Custom security rules |
| Settings | Environment variables |
Best for: Starting fresh with your complete PAI history.
Copies only system components, preserving your existing USER customizations:
bun Tools/pai-to-opencode-converter.ts --mode selective| What Gets Copied | What's Preserved |
|---|---|
| Skills (system) | USER/TELOS.md |
| Agents (system) | USER/ABOUTME.md |
| Security patterns | USER/Contacts.md |
| Settings (schema only) | Custom USER files |
Best for:
- Updating to a new PAI-OpenCode version
- Preserving personal customizations while getting new skills
- Merging multiple PAI installations
Preview full migration (dry run):
bun Tools/pai-to-opencode-converter.ts --dry-runFull migration:
bun Tools/pai-to-opencode-converter.ts --mode fullSelective migration (preserve USER customizations):
bun Tools/pai-to-opencode-converter.ts --mode selectiveCustom source and target:
bun Tools/pai-to-opencode-converter.ts \
--source ~/backup/.claude \
--target .opencode \
--mode selectiveAfter migration, verify:
- OpenCode starts without errors
- CORE skill loads (check first response)
- Agents work (
@Intern hello) - Security blocks dangerous commands
- MEMORY preserved (check
.opencode/MEMORY/) - USER customizations intact (check
.opencode/skills/PAI/USER/) - Debug log shows plugin loaded
If migration fails:
# Delete failed migration
rm -rf .opencode/
# Re-clone fresh
git clone https://github.com/Steffen025/pai-opencode.gitYour original PAI (Claude Code) is never modified during migration.
- PAI-to-OpenCode Mapping Guide - Component mapping rules and common errors
- PLUGIN-SYSTEM.md - Plugin development
- PAI-ADAPTATIONS.md - What changed from PAI 2.4
- GitHub Issues: https://github.com/Steffen025/pai-opencode/issues
After successful migration:
- Customize - Edit
.opencode/settings.json - Explore - Try all skills and agents
- Secure - Review
.opencode/PAISECURITYSYSTEM/patterns.yaml - Learn - Read skill documentation in
.opencode/skills/*/SKILL.md
PAI OpenCode - Your PAI, your way
