Personal AI Infrastructure for OpenCode β Bring Daniel Miessler's renowned PAI scaffolding to any AI provider.
v1.2.1 Release β Provider Profile System + Multi-Provider Research. One-command provider switching with optional multi-provider research routing. See CHANGELOG.md.
PAI-OpenCode is the complete port of Daniel Miessler's Personal AI Infrastructure (PAI) to OpenCode β an open-source, provider-agnostic AI coding assistant.
PAI is a scaffolding system that makes AI assistants work better for you. It's not about which model you use β it's about the infrastructure around it:
- Skills β Modular capabilities (code review, security testing, research, design)
- Agents β Dynamic multi-agent orchestration
- Memory β Session history, project context, learning loops
- Plugins β Lifecycle automation (session init, security validation, observability)
OpenCode is an open-source alternative to Claude Code that supports 75+ AI providers β from Anthropic and OpenAI to Google, AWS Bedrock, Ollama, and beyond.
PAI-OpenCode = The best of both worlds.
| Challenge | Solution |
|---|---|
| PAI was built for Claude Code (Anthropic only) | PAI-OpenCode works with any AI provider |
| Vendor lock-in limits your options | Switch providers freely while keeping your infrastructure |
| Generic AI assistants don't know your workflow | PAI's skills, memory, and plugins personalize to your needs |
| One-shot interactions lose context | PAI's memory system builds knowledge over time |
The scaffolding is more important than the model. PAI-OpenCode gives you:
β Provider freedom (Claude, GPT-4, Gemini, Llama, etc.) β Full PAI infrastructure (skills, agents, memory, plugins) β Real-time session sharing (OpenCode feature) β Terminal + Desktop + Web clients β Community-driven, open-source foundation
# 1. Clone PAI-OpenCode
git clone https://github.com/Steffen025/pai-opencode.git
cd pai-opencode
# 2. Run the Installation Wizard
bun run .opencode/PAIOpenCodeWizard.ts
# 3. Start OpenCode
opencodeAlready using OpenCode? If you have an existing
~/.opencodedirectory, see Existing OpenCode Users in the Installation Guide for symlink setup.
The wizard will ask you to:
- Choose your AI provider (8 options: Anthropic, OpenAI, Google, Groq, AWS Bedrock, Azure, ZEN free, Ollama)
- Configure research agents β single provider or multi-provider for diverse perspectives
- Set your name and timezone
- Name your AI assistant
Takes ~2 minutes and creates all necessary configuration files.
After running the wizard, start OpenCode and paste this prompt for full personalization:
Let's do the onboarding. Guide me through setting up my personal context -
my name, my goals, my values, and how I want you to behave. Create the TELOS
and identity files that make this AI mine.
This 10-15 minute interactive session will configure your complete TELOS framework:
| What Gets Created | Purpose |
|---|---|
| Mission & Goals | Your life purposes and specific objectives |
| Challenges & Strategies | What's blocking you and how to overcome it |
| Values & Beliefs | Core principles that guide decisions |
| Narratives | Your key talking points and messages |
| Tech Preferences | Languages, frameworks, tools you prefer |
Why TELOS matters: PAI becomes exponentially more useful when it knows your context. Generic AI gives generic advice. PAI with TELOS gives you-specific guidance.
Modular, reusable capabilities invoked by name:
- CORE β Identity, preferences, auto-loaded at session start
- Art β Excalidraw-style visual diagrams
- Browser β Code-first browser automation
- Security β Pentesting, secret scanning
- Research β Cost-aware multi-provider research system (see below)
Dynamic multi-agent composition with specialized roles:
- Agents Skill β Create custom agents with personalities
- RedTeam β 32-agent adversarial analysis
- Council β 4-perspective decision-making
Persistent context across sessions:
- Session transcripts (
.opencode/MEMORY/SESSIONS/) - Project documentation (
.opencode/MEMORY/projects/) - Learning loops (
.opencode/MEMORY/LEARNINGS/)
TypeScript lifecycle plugins with comprehensive coverage:
- Context injection at session start
- Security validation before commands
- Voice notifications (ElevenLabs + Google TTS + macOS say)
- Implicit sentiment detection from user messages
- Tab state updates for Kitty terminal
- ISC tracking and response capture
- Rating capture and learning loops
- Observability (real-time event streaming and monitoring)
Use any AI provider:
- Anthropic (Claude)
- OpenAI (GPT-4)
- Google (Gemini)
- AWS Bedrock
- Groq, Mistral, Ollama, and more...
PAI-OpenCode includes a 3-tier research system that optimizes for both quality and cost:
| Tier | Workflow | Agents | Cost | Trigger |
|---|---|---|---|---|
| Quick (DEFAULT) | QuickResearch |
1 Claude | $0 FREE | "research X" |
| Standard | StandardResearch |
3 (Claude + Gemini + Perplexity) | ~$0.01 | "standard research" |
| Extensive | ExtensiveResearch |
4-5 providers | ~$0.10-0.50 | "extensive research" |
Quick Research is FREE β ClaudeResearcher uses Claude WebSearch, which is included in your Anthropic subscription. No API keys needed, no extra cost.
Standard Research adds multi-perspective coverage with Gemini and Perplexity for ~$0.01 per query.
Extensive Research requires explicit confirmation before running (cost gate) to prevent unexpected charges.
| Agent | Model | Specialty | Cost |
|---|---|---|---|
ClaudeResearcher |
claude-sonnet-4-5 | Academic depth, scholarly synthesis | Included in subscription |
GeminiResearcher |
google/gemini-2.5-flash | Multi-perspective analysis | ~$0.002 |
GrokResearcher |
xai/grok-4-1-fast | Contrarian, social media, X access | ~$0.01 |
PerplexityResearcher |
perplexity/sonar | Real-time news, breaking events | ~$0.01 |
PerplexityProResearcher |
perplexity/sonar-pro | Deep investigation, extensive | ~$0.05 |
CodexResearcher |
openrouter/openai/gpt-4.1 | Technical, TypeScript-focused | ~$0.03 |
Option 1: Wizard β The installation wizard asks about research configuration during setup.
Option 2: CLI β Switch to multi-provider research anytime:
bun run .opencode/tools/switch-provider.ts anthropic --multi-researchRequired API keys (add to ~/.opencode/.env):
| Key | For | Where to get |
|---|---|---|
GOOGLE_API_KEY |
GeminiResearcher | https://aistudio.google.com/apikey |
XAI_API_KEY |
GrokResearcher | https://console.x.ai/ |
PERPLEXITY_API_KEY |
PerplexityResearcher | https://perplexity.ai/settings/api |
OPENROUTER_API_KEY |
CodexResearcher | https://openrouter.ai/keys |
Missing a key? No problem β that researcher falls back to your primary provider.
PAI-OpenCode includes a one-command provider switching system. Switch all 18 agent models at once:
# Switch all agents to a different provider
bun run .opencode/tools/switch-provider.ts anthropic # Claude (recommended)
bun run .opencode/tools/switch-provider.ts openai # GPT-4.1 / GPT-5.1
bun run .opencode/tools/switch-provider.ts google # Gemini 2.5
bun run .opencode/tools/switch-provider.ts zen # Free tier (no API key)
bun run .opencode/tools/switch-provider.ts local # Ollama (offline)Each profile uses a 3-tier model strategy:
| Tier | Purpose | Anthropic | OpenAI | |
|---|---|---|---|---|
| Most Capable | Algorithm (orchestration) | claude-opus-4-6 | gpt-5.1 | gemini-2.5-pro |
| Standard | Most agents (coding, research) | claude-sonnet-4-5 | gpt-4.1 | gemini-2.5-flash |
| Budget | Explore, Intern (fast tasks) | claude-haiku-4-5 | gpt-4.1-mini | gemini-2.0-flash-lite |
For richer research with diverse perspectives, enable multi-provider routing:
bun run .opencode/tools/switch-provider.ts anthropic --multi-researchThis routes each research agent to its native provider while keeping all other agents on your primary provider. Requires additional API keys in ~/.opencode/.env.
Check your setup status:
bun run .opencode/tools/switch-provider.ts --researchersPAI-OpenCode's design is documented through Architecture Decision Records (ADRs)βformal documents explaining why we made specific choices during the port from Claude Code to OpenCode.
| ADR | Decision | Why It Matters |
|---|---|---|
| ADR-001 | Hooks β Plugins | OpenCode uses in-process plugins, not subprocess hooks |
| ADR-002 | .claude/ β .opencode/ |
Platform directory convention |
| ADR-003 | Skills System Unchanged | Preserves upstream PAI compatibility |
| ADR-004 | File-Based Logging | Prevents TUI corruption from console.log |
| ADR-005 | Dual Config Files | PAI settings.json + OpenCode opencode.json |
| ADR-006 | Security Patterns Preserved | Critical security validation unchanged |
| ADR-007 | Memory Structure Preserved | File-based MEMORY/ system unchanged |
Key Principles:
- Preserve PAI's design where possible
- Adapt to OpenCode where necessary
- Document every change in ADRs
| Document | Description |
|---|---|
| CHANGELOG.md | Version history and release notes |
| docs/WHAT-IS-PAI.md | PAI fundamentals explained |
| docs/OPENCODE-FEATURES.md | OpenCode unique features |
| docs/PLUGIN-SYSTEM.md | Plugin architecture (14 handlers) |
| docs/PAI-ADAPTATIONS.md | Changes from PAI 2.5 |
| docs/MIGRATION.md | Migration from Claude Code PAI |
| ROADMAP.md | Version roadmap |
| CONTRIBUTING.md | Contribution guidelines |
For Contributors:
| Document | Description |
|---|---|
| PAI-to-OpenCode Mapping | How to correctly import PAI components |
Upstream Resources:
- Daniel Miessler's PAI β Original PAI documentation
- OpenCode Documentation β OpenCode official docs
PAI-OpenCode stands on the shoulders of giants:
The original PAI vision and architecture. Daniel's work on personalized AI scaffolding is foundational to this project. π github.com/danielmiessler/Personal_AI_Infrastructure
The open-source, provider-agnostic runtime that makes PAI-OpenCode possible. π github.com/anomalyco/opencode π docs.opencode.ai
MIT License β see LICENSE for details.
PAI-OpenCode is an independent port. Original PAI by Daniel Miessler, OpenCode by Anomaly.
git clone https://github.com/Steffen025/pai-opencode.git
cd pai-opencode && bun run .opencode/PAIOpenCodeWizard.ts && opencodeWelcome to Personal AI Infrastructure, your way.


