# OpenCode Features and Practical Usage
🤖 The era of dumping everything on one AI is over. With OpenCode's agents, you split planning, exploration, and review into dedicated roles — each with tightly scoped permissions for safe collaboration.
🏷️ Title: Primary / Subagents
🔗 URL:
📘 Overview
OpenCode agents come in two kinds: primary agents you interact with directly, and specialized subagents that primary agents call on. Separating roles and tool permissions lets you move through tasks both safely and efficiently.
⚙️ How It Works
・Primary: Build has full tool access for development, while Plan is for planning with edits and bash restricted to "ask" by default. Switch with `Tab`.
・Subagents: built-ins include General for multi-step research, Explore for read-only codebase exploration, and Scout for external docs and dependency research. Invoke them explicitly with `@`, e.g. `@/general ...`, or let a primary agent launch them automatically.
・Custom definitions: define your own agents in JSON (`opencode.json`) or Markdown front matter (`.opencode/agents/*.md`). Key fields include `description` (required), `mode` (`primary`/`subagent`/`all`), `model`, `prompt`, `temperature`, `permission` (`allow`/`deny`/`ask`), `steps`, and `hidden`.
🛠️ Practical Usage
Define an audit-only agent with edits disabled to delegate reviews while preventing accidental changes. The `bash` permission supports glob patterns for fine-grained control. For example, a security-audit subagent sets `temperature: 0.1` and `permission` with both `edit: deny` and `bash: deny`, then states the review scope in its body.
Running `opencode agent create` walks you through location, purpose, and permissions interactively and generates a Markdown definition.
💡 Use Cases
For a large feature, you can divide labor: have Explore survey the relevant code read-only, lock the approach in Plan, implement in Build, and finally inspect with an edit-disabled review agent.
⚠️ Caveats
・Default `permission` differs per agent (Plan sets edit/bash to ask). Setting them explicitly is safer to avoid unintended changes.
・`bash` permissions accept globs, so you can deny dangerous commands individually, e.g. `"rm *": "deny"`.
・Use `hidden` to keep a subagent out of the `@` menu.
#
OpenCode# #
AIAgents#