Version: 2.1 Created: 2026-01-24 Updated: 2026-02-19 Purpose: Reference document for correctly importing PAI components into PAI-OpenCode
PAI-OpenCode is a vanilla PAI implementation adapted for OpenCode's architecture. Currently synced to Algorithm v1.8.0 (upstream v3.0). This document defines the mapping rules between Daniel Miessler's PAI structure and PAI-OpenCode's conventions.
| Aspect | PAI v3.0 (Claude Code) | PAI-OpenCode |
|---|---|---|
| Root Directory | .claude/ |
.opencode/ |
| Lifecycle Events | hooks/*.hook.ts |
plugins/handlers/*.ts |
| Config Schema | Claude Code settings.json | OpenCode settings.json |
| Meta File | CLAUDE.md |
AGENTS.md |
| Path Variable | $PAI_DIR → ~/.claude |
$PAI_DIR → .opencode |
Rule: Direct copy, no structural changes.
PAI 2.4: .claude/skills/{SkillName}/
PAI-OpenCode: .opencode/skills/{SkillName}/
Structure preserved:
├── SKILL.md # Required: Skill definition
├── Workflows/ # Optional: Markdown workflows
├── Tools/ # Optional: TypeScript tools
├── Data/ # Optional: YAML/JSON data
└── README.md # Optional: Documentation
SkillName/SkillName/ structures. That pattern is only for distribution Packs, not installed skills.
Rule: Direct copy, adjust color format for OpenCode.
PAI 2.4: .claude/agents/*.md
PAI-OpenCode: .opencode/agents/*.md
OpenCode Requirement: Colors must be hex format (#00FFFF), not names (cyan).
Rule: Rewrite hooks as OpenCode plugin handlers.
| PAI 2.4 Hook | PAI-OpenCode Handler | Event |
|---|---|---|
LoadContext.hook.ts |
context-loader.ts |
SessionStart |
SecurityValidator.hook.ts |
security-validator.ts |
PreToolUse |
AgentOutputCapture.hook.ts |
agent-capture.ts |
SubagentStop |
ExplicitRatingCapture.hook.ts |
rating-capture.ts |
UserPromptSubmit |
WorkCompletionLearning.hook.ts |
learning-capture.ts |
SessionEnd |
AutoWorkCreation.hook.ts |
work-tracker.ts |
UserPromptSubmit |
Plugin Structure:
.opencode/plugins/
├── pai-unified.ts # Main orchestrator
├── handlers/ # Event handlers
│ ├── context-loader.ts
│ ├── security-validator.ts
│ └── ...
└── lib/ # Shared utilities
├── paths.ts
├── identity.ts
└── ...
Rule: PAI skill has sub-structures that must be preserved.
.opencode/skills/PAI/
├── SKILL.md # The Algorithm + Core Instructions
├── SYSTEM/ # System documentation (updatable)
│ ├── PAISYSTEMARCHITECTURE.md
│ ├── SKILLSYSTEM.md
│ ├── THEHOOKSYSTEM.md → THEPLUGINSYSTEM.md (renamed)
│ └── ...
├── USER/ # User customization (never overwrite)
│ ├── TELOS/
│ ├── SKILLCUSTOMIZATIONS/
│ └── ...
├── Tools/ # TypeScript utilities
└── Workflows/ # Workflow guides
Path References: Replace all ~/.claude/ with .opencode/ in documentation.
Rule: Direct copy, same subdirectory structure.
.opencode/MEMORY/
├── LEARNING/
│ └── ALGORITHM/
├── SECURITY/
├── STATE/
├── VOICE/
├── WISDOM/ # NEW in v1.8.0 — Domain wisdom frames
│ ├── README.md
│ ├── architecture.md
│ ├── communication.md
│ ├── deployment.md
│ ├── development.md
│ └── security.md
└── WORK/
Rule: Copy to skills/Fabric/Patterns/ ONLY. Never duplicate elsewhere.
PAI 2.4: .claude/skills/Fabric/Patterns/
PAI-OpenCode: .opencode/skills/Fabric/Patterns/
⚠️ DO NOT copy to PAI/Tools/fabric/ - that creates duplicates!
explore ≠ Explore.
OpenCode has built-in agents (part of the framework) plus custom agents (from .opencode/agents/).
These work without any agent definition file:
| subagent_type | Purpose | Notes |
|---|---|---|
general |
General-purpose multi-step tasks | Default for complex tasks |
explore |
Fast codebase exploration | Explore (TitleCase) — this WILL FAIL |
Defined by .md files in the agents directory:
| subagent_type | Purpose |
|---|---|
Algorithm |
ISC & Algorithm specialist |
Architect |
Elite system design |
Engineer |
Principal engineer, TDD |
Intern |
176 IQ genius generalist, parallel grunt work |
Designer |
Elite UX/UI specialist |
QATester |
Quality assurance validation |
Pentester |
Offensive security specialist |
Artist |
Visual content creator |
writer |
Content creation, docs, technical writing |
researcher |
Web research, source verification |
DeepResearcher |
Academic researcher (Claude WebSearch) |
GeminiResearcher |
Multi-perspective researcher (Google Gemini) |
PerplexityResearcher |
Investigative journalist (Perplexity API) |
GrokResearcher |
Contrarian researcher (xAI Grok) |
CodexResearcher |
Technical archaeologist (O3, GPT-5-Codex, GPT-4) |
| Claude Code Agent | OpenCode Equivalent | Notes |
|---|---|---|
Explore (TitleCase) |
explore (lowercase) |
Built-in — just fix the case! |
Plan |
Architect |
No direct equivalent, use Architect |
general-purpose |
general or Intern |
general is built-in |
When porting workflows:
- Replace
subagent_type: "Explore"withsubagent_type: "explore"(lowercase!) - Replace
subagent_type: "Plan"withsubagent_type: "Architect" - Replace
subagent_type: "general-purpose"withsubagent_type: "general"
These PAI 2.4 components are not applicable to OpenCode:
| Component | Reason |
|---|---|
Observability/ |
Vue dashboard - not ported |
VoiceServer/ |
macOS voice server - not ported |
lib/migration/ |
PAI version migration tools |
PAIInstallWizard.ts |
Claude Code specific installer |
statusline-command.sh |
Terminal statusline integration |
settings.json hooks section |
Different plugin architecture |
These exist in PAI-OpenCode but not in PAI 2.4:
| Component | Purpose |
|---|---|
plugins/ |
OpenCode plugin system |
profiles/ |
API provider profiles (anthropic, openai, local) |
PAISECURITYSYSTEM/ |
Security documentation (moved from PAI/SYSTEM) |
package.json |
Bun dependencies |
tsconfig.json |
TypeScript configuration |
When importing a new PAI version:
- Read PAI release notes for structural changes
- Compare skill counts (should match)
- Check for new skills to add
- Check for removed/renamed skills
- Copy skills maintaining flat structure (no nesting)
- Copy agents, convert color names to hex
- Review hook changes, update plugin handlers
- Update PAI/SYSTEM docs with new content
- Preserve PAI/USER (never overwrite)
- Verify SKILL.md count matches
- Check for duplicate Fabric patterns
- Test OpenCode startup (no ConfigFrontmatterError)
- Run skill search to verify all skills load
- Update version in documentation
Error: ConfigFrontmatterError: Failed to parse YAML frontmatter
Cause: Imported SkillName/SkillName/SKILL.md pattern from Packs
Fix: Delete inner nested directories, keep only SkillName/SKILL.md
Error: ConfigFrontmatterError at high column number
Cause: YAML description exceeds ~300 characters
Fix: Shorten description to <220 characters
Error: Invalid hex color format color
Cause: Using color names (cyan) instead of hex (#00FFFF)
Fix: Convert all agent colors to hex format
Symptom: Repo size unexpectedly large
Cause: Patterns copied to multiple locations
Fix: Keep only skills/Fabric/Patterns/, remove from PAI/Tools/
The following features were added in PAI v3.0 (Algorithm v1.2.0–v1.8.0):
| v3.0 Feature | Claude Code | OpenCode | Status |
|---|---|---|---|
| Constraint Extraction [EX-N] | In SKILL.md | In SKILL.md | ✅ Ported |
| Self-Interrogation | In SKILL.md | In SKILL.md | ✅ Ported |
| Build Drift Prevention | In SKILL.md | In SKILL.md | ✅ Ported |
| Verification Rehearsal | In SKILL.md | In SKILL.md | ✅ Ported |
| Mechanical Verification | In SKILL.md | In SKILL.md | ✅ Ported |
| 8 Effort Levels | FormatReminder hook | format-reminder.ts handler | ✅ Ported |
| 7 Quality Gates | In SKILL.md | In SKILL.md | ✅ Ported |
| 25-Capability Audit | In SKILL.md | In SKILL.md (adapted) | ✅ Ported |
| PRD System | ~/.claude/MEMORY/WORK/ | ~/.opencode/MEMORY/WORK/PRD/ | ✅ Ported |
| ISC Naming Convention | In SKILL.md | In SKILL.md | ✅ Ported |
| Anti-Criteria | In SKILL.md | In SKILL.md | ✅ Ported |
| Algorithm Reflection JSONL | In SKILL.md | In SKILL.md | ✅ Ported |
| Start Symbol ♻︎ | In SKILL.md | In SKILL.md | ✅ Ported |
| OBSERVE Hard Gate | In SKILL.md | In SKILL.md | ✅ Ported |
| AUTO-COMPRESS 150% | In SKILL.md | In SKILL.md | ✅ Ported |
| Loop Mode | algorithm.ts CLI | In SKILL.md (concept) | ✅ Ported |
| Agent Teams/Swarm | CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 | N/A | ❌ Not portable |
| Plan Mode | EnterPlanMode/ExitPlanMode | N/A | ❌ Not portable |
| StatusLine | Claude Code UI | N/A | ❌ Not portable |
| Voice Personality | settings.json personality block | settings.json personality block | ✅ Compatible |
| Feature | Version | Claude Code | OpenCode | Status |
|---|---|---|---|---|
| Self-Interrogation effort scaling | v1.3.0 | In SKILL.md | In SKILL.md | ✅ Ported |
| Constraint Extraction effort gate | v1.3.0 | In SKILL.md | In SKILL.md | ✅ Ported |
| Steps 6-8 gated to Extended+ | v1.3.0 | In SKILL.md | In SKILL.md | ✅ Ported |
| QG6/QG7 gated to Extended+ | v1.3.0 | In SKILL.md | In SKILL.md | ✅ Ported |
| ISC Scale Tiers (4-500+) | v1.3.0 | In SKILL.md | In SKILL.md | ✅ Ported |
| Constraint Fidelity System v1.3.0 | v1.3.0 | In SKILL.md | In SKILL.md | ✅ Ported |
| Phase Separation Enforcement | v1.6.0 | In SKILL.md | In SKILL.md | ✅ Ported |
| Verify Completion Gate | v1.6.0 | In SKILL.md | In SKILL.md | ✅ Ported |
| Zero-Delay Output Section | v1.6.0 | In SKILL.md | In SKILL.md | ✅ Ported |
| BUILD Capability Execution | v1.8.0 | In SKILL.md | In SKILL.md | ✅ Ported |
| Wisdom Injection (OUTPUT 1.75) | v1.8.0 | In SKILL.md | In SKILL.md | ✅ Ported |
| Wisdom Frame Update in LEARN | v1.8.0 | In SKILL.md | In SKILL.md | ✅ Ported |
| Algorithm Reflection first in LEARN | v1.8.0 | In SKILL.md | In SKILL.md | ✅ Ported |
| Wisdom Frames system | v1.8.0 | ~/.claude/MEMORY/WISDOM/ | ~/.opencode/MEMORY/WISDOM/ | ✅ Ported |
| WisdomFrameUpdater.ts | v1.8.0 | Tools/WisdomFrameUpdater.ts | Tools/WisdomFrameUpdater.ts | ✅ Ported |
| Voice_id template variable | v1.6.0 | {DAIDENTITY.ALGORITHMVOICEID} |
{DAIDENTITY.ALGORITHMVOICEID} |
✅ Ported |
| Security: env var prefix strip | #620 | SecurityValidator.hook.ts | security-validator.ts | ✅ Ported |
| Rating: 5/10 noise filter | commit | ExplicitRatingCapture.hook.ts | rating-capture.ts | ✅ Ported |
| Symlink skill support | commit | SkillIndexGenerator.hook.ts | GenerateSkillIndex.ts | ✅ Ported |
| SessionHarvester PAI_DIR | commit | SessionHarvester.ts | SessionHarvester.ts | ✅ Ported |
| PRD auto-creation hook | commit | AutoWorkCreation.hook.ts | N/A | ⏳ SHOULD-PORT |
| Dynamic version from LATEST | commit | Algorithm/LATEST | N/A | ⏳ SHOULD-PORT |
| SecurityValidator stdin fix #452 | #452 | SecurityValidator.hook.ts | N/A | ❌ Not applicable (in-process plugins) |
New hooks added in v3.0 and their OpenCode handler equivalents:
| v3.0 Hook | OpenCode Handler | Event | Status |
|---|---|---|---|
| AlgorithmTracker.hook.ts | algorithm-tracker.ts | tool.execute.after | ✅ Created |
| AgentExecutionGuard.hook.ts | agent-execution-guard.ts | tool.execute.before | ✅ Created |
| SkillGuard.hook.ts | skill-guard.ts | tool.execute.before | ✅ Created |
| CheckVersion.hook.ts | check-version.ts | event (session.start) | ✅ Created |
| IntegrityCheck.hook.ts | integrity-check.ts | event (session.end) | ✅ Created |
| FormatReminder (update) | format-reminder.ts | chat.message | ✅ Updated |
| Date | Version | Changes |
|---|---|---|
| 2026-02-19 | 2.1 | Upstream sync v1.3.0–v1.8.0: 18 features mapped, MEMORY/WISDOM added, SHOULD-PORT items tracked |
| 2026-02-17 | 2.0 | Added v3.0 Feature Mapping, Hook → Handler Mapping |
| 2026-01-24 | 1.1 | Added Model Configuration section, Agent Type Mapping |
| 2026-01-24 | 1.0 | Initial mapping guide created |
Claude Code uses short model names; OpenCode requires full provider/model format:
| Claude Code | OpenCode |
|---|---|
haiku |
anthropic/claude-haiku-4-5 |
sonnet |
anthropic/claude-sonnet-4-5 |
opus |
anthropic/claude-opus-4-5 |
The model-config.ts system supports TWO configuration formats:
Format 1: PAI-specific (preferred for full control)
{
"$schema": "https://opencode.ai/config.json",
"model": "anthropic/claude-sonnet-4-5",
"pai": {
"model_provider": "anthropic"
}
}Format 2: Standard OpenCode (auto-detects provider)
{
"$schema": "https://opencode.ai/config.json",
"model": "anthropic/claude-sonnet-4-5"
}When a provider is detected, these model mappings are used:
| Purpose | Anthropic | OpenAI | ZEN (Free) |
|---|---|---|---|
| default | claude-sonnet-4-5 | gpt-4o | grok-code |
| agents.intern | claude-haiku-4-5 | gpt-4o-mini | gpt-5-nano |
| agents.architect | claude-sonnet-4-5 | gpt-4o | big-pickle |
| agents.engineer | claude-sonnet-4-5 | gpt-4o | grok-code |
| agents.explorer | claude-sonnet-4-5 | gpt-4o | grok-code |
| agents.reviewer | claude-opus-4-5 | gpt-4o | big-pickle |
DO NOT use short model names in OpenCode documentation:
# WRONG (Claude Code style)
model: "haiku"
# RIGHT (OpenCode style)
model: "anthropic/claude-haiku-4-5"
# BEST (use model-config.ts)
Use getModel("agents.intern") from plugins/lib/model-config.ts- PAI v3.0 Source:
github.com/danielmiessler/Personal_AI_Infrastructure - PAI-OpenCode:
github.com/Steffen025/pai-opencode - OpenCode Plugin API:
@opencode-ai/plugin - Upstream Sync Spec:
docs/specs/UPSTREAM-SYNC-v1.8.0-SPEC.md
This document should be updated whenever PAI releases a new version.