Each subagent runs in its own session with its own context window. You can assign a different model per subagent — e.g. use Gemini for research, Claude for implementation, GPT for review — all in one workflow.
Agents with write access can modify files even when invoked as subagents. Use "write": false, "edit": false on research-only agents. Subagents with web access (Perplexity) should always be read-only on your filesystem.
OpenCode reads AGENTS.md from your project root (or ~/.config/opencode/AGENTS.md for global rules). Run /init to auto-generate from your codebase. Also reads CLAUDE.md as a fallback.
| Pattern | Conditions | Example |
|---|---|---|
| @ parallel | ALL must be true 3+ unrelated tasks No shared state Clear file scope per agent |
@general explore frontend, @explore scan api/, @general check tests |
| Sequential | ANY triggers it B depends on A's output Shared file targets Scope unclear upfront |
plan agent → build agent → review agent |
| Task tool | Primary agent auto-delegates Based on description match No manual @ needed |
Build agent spawns @code-reviewer automatically |
| Hidden agents | Set hidden: trueInvoked by Task tool only Not in @ autocomplete |
Internal orchestration agents |
## Sub-agent routing **Parallel dispatch** (@ multiple agents simultaneously) — ALL must be true: - 3+ independent tasks with no shared state - Each agent owns distinct files/directories - Results can be merged after all complete **Sequential dispatch** — ANY condition triggers: - Output of agent A feeds into agent B - Multiple agents would write the same files - Scope needs to be understood before acting **Task tool (auto-delegation)**: - Primary agent decides based on agent descriptions - No @ mention needed — automatic based on task type - Use for specialist subagents (security, docs, tests) **Hidden subagents**: - Set hidden: true for internal-only orchestration agents - Only reachable via Task tool, not from @ autocomplete **Agent invocation requirements**: 1. Specify scope: exact files, directories, or patterns 2. Specify output: file path, format, or summary expected 3. Specify model if non-default is needed 4. Agents with write access can modify files — scope carefully
OpenCode reads CLAUDE.md as a fallback if no AGENTS.md exists. Migrating from Claude Code? Your existing rules file will work immediately. Disable this with OPENCODE_DISABLE_CLAUDE_CODE=1.
{
"$schema": "https://opencode.ai/config.json",
"agent": {
"code-reviewer": {
"description": "Reviews code for security, performance, and best practices. Invoke after implementation.",
"mode": "subagent",
"model": "anthropic/claude-sonnet-4-20250514",
"temperature": 0.1,
"steps": 20,
"permissions": {
"write": false,
"edit": false,
"bash": false
}
},
"researcher": {
"description": "Research agent using Perplexity for real-time web search. Never modifies files.",
"mode": "subagent",
"model": "perplexity/sonar-pro",
"temperature": 0.8,
"permissions": {
"write": false,
"edit": false,
"bash": false
}
}
}
}
--- description: Security auditor. Reviews code for vulnerabilities, injection risks, auth issues, and secrets exposure. Invoke after any auth or data-handling changes. mode: subagent model: anthropic/claude-sonnet-4-20250514 temperature: 0.1 permissions: write: false edit: false bash: false --- You are a security auditor. Review the provided code for: - SQL/command injection vulnerabilities - Authentication and authorisation bypasses - Hardcoded secrets or API keys - Insecure direct object references - Missing input validation Return a structured report: CRITICAL / HIGH / MEDIUM / LOW findings. Do not modify any files.
OpenCode lets each agent use a different model. Set model: "perplexity/sonar-pro" on a researcher, model: "anthropic/claude-haiku-4-20250514" on a boilerplate agent, and model: "anthropic/claude-sonnet-4-20250514" on your primary build agent. This cuts costs dramatically on large fan-outs.
| Feature | Claude Code | OpenCode |
|---|---|---|
| Primary agents | Orchestrator (general) built-in | build + plan — switch with Tab |
| Subagents | explore, custom via .claude/agents/ |
general, explore, custom via .opencode/agents/ |
| Invoke subagent | Prompt: "use N parallel sub-agents" | @agent-name mention or Task tool auto-dispatch |
| Per-agent model | Specify model in agent .md file | First-class: model: field, any of 75+ providers |
| Per-agent temperature | Not supported | First-class: temperature: field per agent |
| Max steps limit | Not available | steps: field — stops & summarises at limit |
| Hidden agents | hidden: true in .md frontmatter |
hidden: true — hides from @ autocomplete |
| Rules file | CLAUDE.md |
AGENTS.md (reads CLAUDE.md as fallback) |
| Config format | Markdown frontmatter only | JSON (opencode.json) or Markdown |
| Session navigation | Not applicable | Parent/child sessions — navigate with Leader+Down/Up |
| Model providers | Anthropic Claude only | 75+ providers: Anthropic, OpenAI, Gemini, Ollama, etc. |
| Non-interactive mode | claude -p "prompt" |
opencode -p "prompt" · JSON output with -f json |
| Parallel sessions | Run multiple terminal instances | Multi-session built-in: opencode -c /path |
OpenCode reads CLAUDE.md and ~/.claude/CLAUDE.md as fallbacks. Your existing agent definitions in .claude/agents/ won't auto-load, but the format is similar — rename the folder to .opencode/agents/ and update model: to use provider-prefixed names like anthropic/claude-sonnet-4-20250514.