This documentation explains how the .opencode system works for this Python backend project.
The .opencode directory contains configuration, agents, subagents, skills, and context that enable OpenCode to work effectively with this codebase. It provides:
- Specialized Agents - Primary and subagents tuned for Python/FastAPI development
- Reusable Skills - On-demand knowledge modules loaded via
skill()tool - Context Files - Project standards, patterns, and security guidelines
- Configuration - Agent behavior and permission settings
For project-level information (tech stack, commands), see AGENTS.md.
| Type | Name | Purpose |
|---|---|---|
| Primary | python-expert | Main agent for Python development |
| Subagent | python-coder | Code generation and implementation |
| Subagent | python-reviewer | Code quality and security review |
| Subagent | python-tester | Test writing and coverage |
| Subagent | python-scout | Context discovery and file finding |
Skills are loaded on-demand via the skill() tool. Each skill contains domain-specific patterns, examples, and best practices.
| Skill | Triggers | Purpose |
|---|---|---|
| python-fundamentals | *.py, python, dataclass |
Core Python patterns |
| python-fastapi | fastapi, pydantic, endpoint |
API development |
| python-backend | sqlalchemy, database, orm |
Database work |
| python-testing-general | pytest, test, mock |
Testing patterns |
| python-testing-deep | hypothesis, property-based |
Advanced testing |
| python-asyncio | async, await, asyncio |
Async programming |
| python-type-hints | typing, mypy, pyright |
Type system |
| python-package-management | uv, pip, pyproject |
Dependencies |
| python-tooling | docker, ci, cd |
DevOps tooling |
| python-fundamentals-313 | 3.13, jit, free-threading |
Python 3.13+ features |
Located in .opencode/context/:
| File | Purpose |
|---|---|
| navigation.md | Quick reference for finding context |
| python/standards.md | Code quality standards |
| python/patterns.md | Common implementation patterns |
| python/security.md | Security patterns and guidelines |
1. User opens project
↓
2. OpenCode reads config.json → Loads python-expert agent
↓
3. Agent detects .py files → Invokes skill(name="python-fundamentals")
↓
4. User request: "Create a FastAPI endpoint"
↓
5. Agent detects "fastapi" → Invokes skill(name="python-fastapi")
↓
6. Complex task? → Delegates to python-coder via task(subagent_type="general", ...)
↓
7. Implementation follows loaded skill patterns
Skills are NOT auto-loaded. They must be explicitly invoked:
skill(name="python-fastapi")The agent determines which skills to load based on:
- Keywords in the user request
- File patterns being worked with
- Task type (API, database, testing, etc.)
Complex tasks are delegated to specialized subagents:
task(
subagent_type="general", # or "explore" for python-scout
description="Create user authentication endpoint",
prompt="Detailed instructions including context and requirements..."
)-
Simple Queries: Ask directly - the agent will load appropriate skills
"How do I create a FastAPI endpoint with authentication?" -
Complex Tasks: Be specific about requirements
"Create a user registration endpoint with email validation, password hashing, and JWT token generation" -
Code Review: Request review explicitly
"Review the auth.py file for security issues"
-
Change Default Agent: Edit
.opencode/config.json{ "agent": "python-expert" } -
Add Custom Skill: Create
.opencode/skills/my-skill/SKILL.md -
Modify Agent Behavior: Edit
.opencode/agent/python-expert.md
| Document | Content |
|---|---|
| Architecture | Directory structure, component relationships |
| Agents | python-expert agent details |
| Subagents | All subagent workflows |
| Skills | Complete skill documentation |
| Workflow | Development patterns |
| Configuration | Customization guide |
| Tutorials | Step-by-step guides |
| Troubleshooting | FAQ and debugging |
- Project Context: AGENTS.md - Tech stack, commands, quick reference
- Main Agent: .opencode/agent/python-expert.md
- Agent Registry: .opencode/config/agent-metadata.json
- Navigation: .opencode/context/navigation.md