This document describes the structure and component relationships of the .opencode system.
.opencode/
├── opencode.json # Schema reference for OpenCode
├── config.json # Default agent selection
├── agent/
│ └── python-expert.md # Primary agent definition
├── subagents/
│ ├── python-coder.md # Code generation (type: general)
│ ├── python-reviewer.md # Code review (type: general)
│ ├── python-tester.md # Test writing (type: general)
│ └── python-scout.md # Context discovery (type: explore)
├── skills/
│ ├── python-fundamentals/
│ │ └── SKILL.md # Core Python patterns
│ ├── python-fastapi/
│ │ ├── SKILL.md # FastAPI patterns
│ │ └── references/
│ │ └── dependency-injection-patterns.md
│ ├── python-backend/
│ │ └── SKILL.md # SQLAlchemy/database patterns
│ ├── python-testing-general/
│ │ └── SKILL.md # pytest patterns
│ ├── python-testing-deep/
│ │ └── SKILL.md # Advanced testing
│ ├── python-asyncio/
│ │ └── SKILL.md # Async programming
│ ├── python-type-hints/
│ │ ├── SKILL.md # Type system
│ │ └── references/
│ │ └── advanced-typing-patterns.md
│ ├── python-package-management/
│ │ └── SKILL.md # UV/pip/venv
│ ├── python-tooling/
│ │ └── SKILL.md # Docker/CI/CD
│ └── python-fundamentals-313/
│ └── SKILL.md # Python 3.13+ features
├── context/
│ ├── navigation.md # Quick reference
│ └── python/
│ ├── standards.md # Code quality standards
│ ├── patterns.md # Common patterns
│ └── security.md # Security patterns
├── config/
│ └── agent-metadata.json # Agent/subagent/skill registry
└── docs/ # This documentation
├── overview.md
├── architecture.md
├── agents.md
├── subagents.md
├── skills.md
├── workflow.md
├── configuration.md
├── tutorials.md
└── troubleshooting.md
| File | Purpose | Format |
|---|---|---|
config.json |
Selects default agent | JSON |
opencode.json |
OpenCode schema reference | JSON |
agent-metadata.json |
Registry of all agents, subagents, skills | JSON |
| Location | Type | Description |
|---|---|---|
agent/python-expert.md |
Primary | Main agent with skill loading protocol |
subagents/python-coder.md |
Subagent | Code generation (general) |
subagents/python-reviewer.md |
Subagent | Code review (general) |
subagents/python-tester.md |
Subagent | Testing (general) |
subagents/python-scout.md |
Subagent | Exploration (explore) |
Each skill is a folder with SKILL.md:
skills/
└── <skill-name>/
├── SKILL.md # Required: skill definition
└── references/ # Optional: additional references
└── <topic>.md
Context files provide project-specific standards:
context/
├── navigation.md # Quick reference
└── python/
├── standards.md # Code quality
├── patterns.md # Implementation patterns
└── security.md # Security guidelines
┌─────────────────────────────────────────────────────────────────┐
│ OpenCode System │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ reads ┌─────────────────┐ │
│ │ config.json │ ────────────────>│ python-expert │ │
│ └──────────────┘ │ (primary) │ │
│ └────────┬────────┘ │
│ │ │
│ ┌───────────────────┼───────────────────┐
│ │ │ │
│ ▼ ▼ ▼
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ │ skill() tool │ │ task() tool │ │ Read context │
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘
│ │ │ │
│ ▼ ▼ ▼
│ ┌───────────────────────────────────────────────────────────────┐
│ │ Skills (10) │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ │fundamentals │ │ fastapi │ │ backend │ ... │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ │
│ └───────────────────────────────────────────────────────────────┘
│ │ │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────────┐
│ │ Subagents (4) │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌──────────┐ │
│ │ │ coder │ │ reviewer │ │ tester │ │ scout │ │
│ │ │ (general) │ │ (general) │ │ (general) │ │ (explore)│ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └──────────┘ │
│ └───────────────────────────────────────────────────────────────┘
│ │
└─────────────────────────────────────────────────────────────────┘
User Request
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ python-expert (Primary Agent) │
│ │
│ 1. Parse request for keywords │
│ 2. Determine task complexity │
│ │
│ Keyword Detection: │
│ ┌─────────────────┬─────────────────────┐ │
│ │ "fastapi" │ → skill("python-fastapi") │
│ │ "sqlalchemy" │ → skill("python-backend") │
│ │ "pytest" │ → skill("python-testing-general") │
│ │ "async" │ → skill("python-asyncio") │
│ │ "type hint" │ → skill("python-type-hints") │
│ └─────────────────┴─────────────────────┘ │
│ │
│ Complexity Decision: │
│ ┌─────────────────┬─────────────────────┐ │
│ │ Simple Query │ Answer directly │ │
│ │ Complex Task │ Delegate to subagent│ │
│ └─────────────────┴─────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
├── Simple ──────────────────────────────────> Direct Response
│
└── Complex ──> Delegate to Subagent
│
▼
┌──────────────────────┐
│ python-coder │ ──> Creates/modifies files
│ python-reviewer │ ──> Returns review report
│ python-tester │ ──> Creates test files
│ python-scout │ ──> Returns context findings
└──────────────────────┘
skill(name="python-fastapi")
│
▼
┌─────────────────────────────────────┐
│ OpenCode Skill Discovery │
│ │
│ 1. Search .opencode/skills/ │
│ 2. Find python-fastapi/SKILL.md │
│ 3. Parse frontmatter │
│ 4. Load content into context │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ Skill Content Available │
│ │
│ - Project structure patterns │
│ - Pydantic schema examples │
│ - Dependency injection patterns │
│ - Error handling patterns │
│ - Production deployment config │
└─────────────────────────────────────┘
OpenCode searches for skills in these locations (in order):
- Project-local:
.opencode/skills/<name>/SKILL.md - Global:
~/.config/opencode/skills/<name>/SKILL.md
OpenCode discovers agents in:
- Project-local:
.opencode/agent/<name>.md - Global:
~/.config/opencode/agents/<name>.md
Subagents are defined in:
- Project-local:
.opencode/subagents/<name>.md - Global:
~/.config/opencode/subagents/<name>.md
- Folder name: lowercase, hyphen-separated (e.g.,
python-fastapi) - File name:
SKILL.md(all caps) - Name in frontmatter: must match folder name
Valid names:
python-fundamentals✓python-fastapi✓Python_FastAPI✗ (use lowercase)python--fastapi✗ (no consecutive hyphens)
- File name: lowercase, hyphen-separated (e.g.,
python-expert.md) - Name in frontmatter: should match file name (without extension)
- File name: lowercase, hyphen-separated (e.g.,
python-coder.md) - Mode must be set to
subagent - Type must be
generalorexplore
Agent Skills
│ │
│ skill(name="...") │
│ ──────────────────────> │
│ │
│ <────────────────────── │
│ Skill content │
Primary Agent Subagent
│ │
│ task(subagent_type, │
│ description, │
│ prompt) │
│ ──────────────────────> │
│ │
│ <────────────────────── │
│ Result/Output │
Agent Context Files
│ │
│ read context file │
│ ──────────────────────> │
│ │
│ <────────────────────── │
│ Standards/Patterns │
- Overview - System introduction
- Agents - python-expert details
- Subagents - All subagent workflows
- Skills - Complete skill documentation
- Configuration - Customization guide