Create and refine OpenCode agents via guided Q&A...
Create and refine opencode agents through a guided Q&A process.
Agent creation is conversational, not transactional.
The goal is to help users create agents that fit their needs, not to dump every possible configuration option on them.
Batching: Use the question tool for 2+ related questions. Single questions → plain text.
Syntax: header ≤12 chars, label 1-5 words, add "(Recommended)" to default.
CRITICAL Permission Logic:
bash, read, write, edit permissions. Rely on system defaults."*": "deny" and explicit allows, regardless of tool permissions.| Scope | Path |
|---|---|
| Project | .opencode/agent/<name>.md |
| Global | ~/.config/opencode/agent/<name>.md |
---
description: When to use this agent. Include trigger examples.
model: anthropic/claude-sonnet-4-20250514 # Optional
mode: subagent # Optional (defaults to undefined/standard)
permission:
skill: { "*": "deny", "my-skill": "allow" }
bash: { "*": "ask", "git *": "allow" }
---
System prompt in markdown body (second person).
Full schema: See references/opencode-config.md
| Mode | Description |
|---|---|
(undefined) |
Standard agent, visible to user and tools (Default) |
subagent |
specialized task tool agent, hidden from main list |
Ask these first—they shape everything else:
"What should this agent do?"
"What should trigger this agent?"
description field"What expertise/persona should it have?"
MUST NOT assume knowledge is current. After understanding the broad strokes:
This research informs better questions in Phase 2 and produces a more capable agent.
Example: User wants an agent for "Next.js deployments" → Research current Next.js deployment patterns, Vercel vs self-hosted, App Router vs Pages Router, common pitfalls, etc.
"What permissions does this agent need?" (Use Question Tool)
bash, read, write, edit to config. Rely on defaults.* if needed."Should this agent use any skills?"
permission.skill with "*": "deny" and explicit allows."Is this a subagent?"
mode: subagentmode undefined (standard)Key principle: Start broad, get specific only where the user shows interest. MUST NOT overwhelm with options like top_p unless asked.
Be flexible: If the user provides lots of info upfront, adapt—MUST NOT rigidly follow the phases. If they say "I want a code review agent that can't run shell commands", you already have answers to multiple questions.
# Role and Objective
[Agent purpose and scope]
# Instructions
- Core behavioral rules
- What to always/never do
## Sub-instructions (optional)
More detailed guidance for specific areas.
# Workflow
1. First, [step]
2. Then, [step]
3. Finally, [step]
# Output Format
Specify exact format expected.
# Examples (optional)
<examples>
<example>
<input>User request</input>
<output>Expected response</output>
</example>
</examples>
XML tags improve clarity and parseability across all models:
| Tag | Purpose |
|---|---|
<instructions> |
Core behavioral rules |
<context> |
Background information |
<examples> |
Few-shot demonstrations |
<thinking> |
Chain-of-thought reasoning |
<output> |
Final response format |
Best practices:
<outer><inner></inner></outer><context> tags..."Example:
<instructions>
1. Analyze the code in <code> tags
2. List issues in <findings> tags
3. Suggest fixes in <recommendations> tags
</instructions>
The description determines when the agent triggers.
Primary Agents: Keep it extremely concise (PRECISELY 3 words). The user selects these manually or via very clear intent.
Any Other Agents: Must be specific and exhaustive to ensure correct routing by the task tool.
Template (Any Other Agents): [Role/Action]. Use when [triggers]. Examples: - user: "trigger" -> action
Good (Primary):
Code review expert.
Good (Any Other Agents):
Code review specialist. Use when user says "review this PR", "check my code",
"find bugs".
Examples:
- user: "review" -> check code
- user: "scan" -> check code
Find the balance between too rigid and too vague:
| ❌ Too Rigid | ✅ Right Altitude | ❌ Too Vague |
|---|---|---|
| Hardcoded if-else logic | Clear heuristics + flexibility | "Be helpful" |
| "If X then always Y" | "Generally prefer X, but use judgment" | No guidance |
For agents that use tools in a loop, SHOULD include these reminders:
# Persistence
Keep working until the user's request is fully resolved. Only yield
control when you're confident the task is complete.
# Tool Usage
If unsure about something, use tools to gather information.
Do NOT guess or make up answers.
# Planning (optional)
Think step-by-step before each action. Reflect on results before
proceeding.
Control what agents can access.
CRITICAL: Avoid Overengineering
read, write, edit, bash) unless the user explicitly asks for restrictions or non-standard access.permission.skill to whitelist specific skills and deny others.# Standard Agent (minimal config)
permission:
skill:
"*": "deny"
"my-skill": "allow"
# Restricted Agent (explicit config)
permission:
edit: "ask"
bash:
"*": "deny"
skill:
"*": "deny"
Full reference: See references/opencode-config.md
Agents may occasionally work on legacy projects using outdated frontmatter (e.g., tools:, maxSteps:). You MUST correct these to the modern permission: and steps: fields when encountered.
When improving an agent, diagnose through questions:
Then propose targeted fixes:
| Symptom | Likely Cause | Fix |
|---|---|---|
| Triggers too often | Description too broad | Add specific contexts |
| Misses triggers | Description too narrow | Add trigger phrases |
| Wrong outputs | Prompt ambiguous | Add explicit instructions |
| Executes dangerous commands | Loose bash permissions | Restrict with patterns |
| Uses wrong skills | No skill restrictions | Configure permission.skill |
MUST show proposed changes and ask for confirmation before applying.
---
description: Safe code reviewer.
mode: primary
permission:
edit: "ask"
bash: "deny"
write: "deny"
external_directory: "deny"
---
You are a code review specialist. Analyze code for bugs, security issues,
and improvements. Never modify files directly.
---
description: |-
Deployment helper. Use when user says "deploy to staging", "push to prod",
"release version".
Examples:
- user: "deploy" -> run deployment
- user: "release" -> run deployment
mode: subagent
permission:
bash:
"*": "deny"
"git *": "allow"
"npm run build": "allow"
"npm run deploy:*": "ask"
skill:
"*": "deny"
"deploy-checklist": "allow"
---
You are a deployment specialist...
Before showing the final agent to the user:
description has concrete trigger examplesmode discussed and set appropriatelyreferences/agent-patterns.md - Design patterns and prompt engineeringreferences/opencode-config.md - Full frontmatter schema, tools, permissions