Agent Architect
Create and refine OpenCode agents via guided Q&A. Use when creating an agent file, improving an existing agent, configuring AGENTS.md frontmatter, setting subagent_type, defining allowed-tools, restricting permissions, designing agent routing, writing a system prompt, configuring mode: subagent, setting a permission block, or working with the Task tool delegation pattern. Examples: 'Create an agent for code reviews', 'My agent ignores context', 'Add a database expert subagent', 'Make my agent faster', 'Agent triggers on wrong requests'.
npx skills add github:pantheon-org/tekhne --skill agentic-harness--opencode-toolkit--design-agentsCreate and refine OpenCode agents through a guided Q&A process.
Quick Start
Create .opencode/agents/<name>.md:
---
description: Code review specialist. Use when user says "review", "check my code", "find bugs".
---
You are an expert code reviewer. Analyze code for bugs, security issues, and performance problems.
Provide specific, actionable feedback with line references.
For subagents (Task tool only), add mode: subagent. For permission restrictions, add a permission: block:
---
mode: subagent
permission:
bash:
"*": "ask"
"npm test": "allow"
---
Run bun run opencode and type /agents to confirm the new agent appears in the list.
Mindset
An agent is a markdown file with YAML frontmatter. Three decisions drive every design:
| Decision | Why it matters |
|---|---|
Scope (description) |
Controls when the agent triggers — too vague = never fires, too broad = fires on everything |
Mode (mode:) |
all = visible everywhere; subagent = Task-tool only; primary = main list only |
Permissions (permission:) |
Standard tools need no config; skills ALWAYS need explicit allowlists |
When to use: You need a distinct scope, persona, or permission set that differs from the default.
When NOT to use: Do not create an agent just to run a single command — use a slash command instead. Do not create a subagent when you just need a custom system prompt — use AGENTS.md.
Creation Workflow
Ask questions first. Follow phases in references/agent-patterns.md:
- Phase 1 — Core Purpose: What does it do? What triggers it? What persona?
- Phase 1.5 — Research: Look up current best practices for the domain.
- Phase 2 — Capabilities: Permissions, skills, mode (subagent vs primary vs all).
- Phase 3 — Review: Show draft, iterate until user approves.
Anti-Patterns
NEVER use bash: { "*": "allow" }. WHY: Allows destructive commands like rm -rf. Use "*": "ask" plus an explicit allowlist.
# BAD
permission:
bash:
"*": "allow"
# GOOD
permission:
bash:
"*": "ask"
"npm test": "allow"
"git status": "allow"
NEVER write system prompts in third person. WHY: The model reads its own system prompt — third person is confusing and degrades instruction-following.
# BAD — "The assistant analyzes code..."
# GOOD — "You analyze code for bugs, security issues, and performance problems."
NEVER add permission: block for standard tools. WHY: It creates noise and can accidentally restrict access to built-in capabilities. Only use permission: when you need to restrict or explicitly allow skills.
| Anti-Pattern | Fix |
|---|---|
Vague description |
Add concrete trigger examples |
Missing mode: subagent on subagents |
Set it explicitly |
skill: { "my-skill": "allow" } without "*": "deny" |
Deny "*" first |
Eval Scenarios
- Scenario 0: Create specialized agent with permissions
- Scenario 1: Configure skill permission allowlist
- Scenario 2: Fix broken agent triggers and system prompt
References
references/agent-patterns.md— Creation phases, patterns, prompt engineering, enhancement/troubleshootingreferences/opencode-config.md— Full frontmatter schema, tools, permissions reference
Explicit NEVER/WHY/consequence triplets with side-by-side bad/good examples. Generic warnings score low — concrete failure modes with real impact (security, correctness, performance) score high.
Runtime validation via eval scenarios proving the skill actually changes agent behaviour. Requires evals/ directory, instructions.json, ≥3 scenarios, and ≥80% instruction coverage in summary.json.
Appropriate rigidity for the skill type: strict rules for critical/security skills, balanced steps for process skills, flexible options for tool skills. Mismatched calibration (too rigid or too loose) reduces score.
Expert-only knowledge the AI couldn't derive on its own — domain-specific patterns, production gotchas, decision frameworks, and non-obvious tool behaviour. High scores mean <5% redundancy with what the model already knows.
A clear philosophy plus numbered step-by-step workflows with explicit entry/exit points. Should answer: what is the core principle, how to execute it, and when (and when not) to apply it.
Rich activation keywords and trigger scenarios in the description so the skill fires when needed. Best descriptions read like an exhaustive list of the tasks and concepts that should invoke this skill.
Copy-paste-ready code, complete runnable examples, real file paths and commands. Pseudocode and abstract descriptions score low — concrete, executable content scores high.
SKILL.md as a <100-line navigation hub pointing to focused references/ files. Content should be lazy-loaded on demand, not front-loaded. Includes actionable 'When to Use' conditions per reference.
Proper frontmatter, single-task focus, activation keywords, and cross-harness portability. Skills must work across 40+ agentic harnesses without hardcoded paths or agent-specific references.
Expert-only knowledge the AI couldn't derive on its own — domain-specific patterns, production gotchas, decision frameworks, and non-obvious tool behaviour. High scores mean <5% redundancy with what the model already knows.
A clear philosophy plus numbered step-by-step workflows with explicit entry/exit points. Should answer: what is the core principle, how to execute it, and when (and when not) to apply it.
Explicit NEVER/WHY/consequence triplets with side-by-side bad/good examples. Generic warnings score low — concrete failure modes with real impact (security, correctness, performance) score high.
Proper frontmatter, single-task focus, activation keywords, and cross-harness portability. Skills must work across 40+ agentic harnesses without hardcoded paths or agent-specific references.
SKILL.md as a <100-line navigation hub pointing to focused references/ files. Content should be lazy-loaded on demand, not front-loaded. Includes actionable 'When to Use' conditions per reference.
Appropriate rigidity for the skill type: strict rules for critical/security skills, balanced steps for process skills, flexible options for tool skills. Mismatched calibration (too rigid or too loose) reduces score.
Rich activation keywords and trigger scenarios in the description so the skill fires when needed. Best descriptions read like an exhaustive list of the tasks and concepts that should invoke this skill.
Copy-paste-ready code, complete runnable examples, real file paths and commands. Pseudocode and abstract descriptions score low — concrete, executable content scores high.
Runtime validation via eval scenarios proving the skill actually changes agent behaviour. Requires evals/ directory, instructions.json, ≥3 scenarios, and ≥80% instruction coverage in summary.json.
Expert-only knowledge the AI couldn't derive on its own — domain-specific patterns, production gotchas, decision frameworks, and non-obvious tool behaviour. High scores mean <5% redundancy with what the model already knows.
A clear philosophy plus numbered step-by-step workflows with explicit entry/exit points. Should answer: what is the core principle, how to execute it, and when (and when not) to apply it.
Explicit NEVER/WHY/consequence triplets with side-by-side bad/good examples. Generic warnings score low — concrete failure modes with real impact (security, correctness, performance) score high.
Proper frontmatter, single-task focus, activation keywords, and cross-harness portability. Skills must work across 40+ agentic harnesses without hardcoded paths or agent-specific references.
SKILL.md as a <100-line navigation hub pointing to focused references/ files. Content should be lazy-loaded on demand, not front-loaded. Includes actionable 'When to Use' conditions per reference.
Appropriate rigidity for the skill type: strict rules for critical/security skills, balanced steps for process skills, flexible options for tool skills. Mismatched calibration (too rigid or too loose) reduces score.
Rich activation keywords and trigger scenarios in the description so the skill fires when needed. Best descriptions read like an exhaustive list of the tasks and concepts that should invoke this skill.
Copy-paste-ready code, complete runnable examples, real file paths and commands. Pseudocode and abstract descriptions score low — concrete, executable content scores high.
Runtime validation via eval scenarios proving the skill actually changes agent behaviour. Requires evals/ directory, instructions.json, ≥3 scenarios, and ≥80% instruction coverage in summary.json.
Expert-only knowledge the AI couldn't derive on its own — domain-specific patterns, production gotchas, decision frameworks, and non-obvious tool behaviour. High scores mean <5% redundancy with what the model already knows.
A clear philosophy plus numbered step-by-step workflows with explicit entry/exit points. Should answer: what is the core principle, how to execute it, and when (and when not) to apply it.
Explicit NEVER/WHY/consequence triplets with side-by-side bad/good examples. Generic warnings score low — concrete failure modes with real impact (security, correctness, performance) score high.
Proper frontmatter, single-task focus, activation keywords, and cross-harness portability. Skills must work across 40+ agentic harnesses without hardcoded paths or agent-specific references.
SKILL.md as a <100-line navigation hub pointing to focused references/ files. Content should be lazy-loaded on demand, not front-loaded. Includes actionable 'When to Use' conditions per reference.
Appropriate rigidity for the skill type: strict rules for critical/security skills, balanced steps for process skills, flexible options for tool skills. Mismatched calibration (too rigid or too loose) reduces score.
Rich activation keywords and trigger scenarios in the description so the skill fires when needed. Best descriptions read like an exhaustive list of the tasks and concepts that should invoke this skill.
Copy-paste-ready code, complete runnable examples, real file paths and commands. Pseudocode and abstract descriptions score low — concrete, executable content scores high.
Runtime validation via eval scenarios proving the skill actually changes agent behaviour. Requires evals/ directory, instructions.json, ≥3 scenarios, and ≥80% instruction coverage in summary.json.
No eval scenarios available.
Agent Design Patterns
Creation Phases
Phase 1: Core Purpose (Required)
Ask these first — they shape everything else:
- “What should this agent do?” — Get the core task/domain
- “What should trigger this agent?” — Specific phrases, contexts, file types → becomes
description - “What expertise/persona should it have?” — Tone, boundaries, specialization → shapes system prompt
Phase 1.5: Research the Domain
MUST NOT assume knowledge is current. After understanding the broad strokes:
- Search for current best practices in the domain
- Check for updates to frameworks, tools, or APIs the agent will work with
- Look up documentation for any unfamiliar technologies mentioned
- Find examples of how experts approach similar tasks
Example: User wants an agent for “Next.js deployments” → Research current deployment patterns, Vercel vs self-hosted, App Router vs Pages Router, common pitfalls, etc.
Phase 2: Capabilities
-
“What permissions does this agent need?”
- Standard: Omit
permissionblock entirely — rely on system defaults - Read-Only: Explicitly deny
write,edit,bash - Full Access: Allow
bash: "*"only if needed - Custom: Ask follow-ups
- Standard: Omit
-
“Should this agent use any skills?”
- If yes: ALWAYS configure
permission.skillwith"*": "deny"and explicit allows
- If yes: ALWAYS configure
-
“Is this a subagent?”
- If yes: set
mode: subagent - If no: omit
mode(defaults toall) or setmode: primaryfor main-list only
- If yes: set
Phase 3: Details (Optional — user MAY skip)
- Specific model preference
- Custom temperature/sampling
- Maximum steps before stopping
Phase 4: Review & Refine
- Show the draft config and prompt, ask for feedback
- Iterate until user is satisfied
Key principle: Start broad, get specific only where the user shows interest. Be flexible: If the user provides lots of info upfront, skip phases that are already answered.
Permission Configuration
CRITICAL: Avoid Overengineering
- Do NOT list permissions for standard tools (
read,write,edit,bash) unless the user requests restrictions or non-standard access - Rely on system defaults for most agents
- Skills are the exception: ALWAYS configure
permission.skillto whitelist specific skills
# Standard Agent (minimal config)
permission:
skill:
"*": "deny"
"my-skill": "allow"
# Restricted Agent (explicit config)
permission:
edit: "ask"
bash:
"*": "deny"
skill:
"*": "deny"
Agent Locations
| Scope | Path |
|---|---|
| Project | .opencode/agents/<name>.md |
| Global | ~/.config/opencode/agents/<name>.md |
Common Agent Patterns
Use these as starting points. Each maps a common use case to the right configuration choices.
Read-Only Analyst
Use when the agent should inspect code but NEVER modify files:
---
description: Code quality analyst. Use when user says "review", "analyze", "check my code".
mode: all
permission:
edit: "deny"
bash: "deny"
---
You analyze code for quality, security, and performance issues.
You NEVER modify files directly. Provide specific, actionable findings.
Background Subagent
Use for specialized tasks invoked by other agents via the Task tool:
---
description: Test runner specialist. Use for parallel test execution during CI workflows.
mode: subagent
permission:
bash:
"*": "ask"
"npm test": "allow"
"npx jest": "allow"
skill:
"*": "deny"
---
You run test suites and report results. Focus on speed and clear failure summaries.
Skill-Gated Expert
Use when the agent should only access specific skills:
---
description: |-
Database migration expert. Use when user says "write migration", "alter table",
"create schema", "database change".
Examples:
- user: "add column" -> generate migration
- user: "index performance" -> suggest index migration
permission:
skill:
"*": "deny"
"supabase-postgres-best-practices": "allow"
"conventional-commits": "allow"
---
You design safe, reversible database migrations following best practices.
Deployment Gatekeeper
Use when the agent must run shell commands but only specific, safe ones:
---
description: |-
Deployment helper. Use when user says "deploy to staging", "push to prod", "release".
Examples:
- user: "deploy" -> run deployment pipeline
- user: "rollback" -> revert last deployment
mode: subagent
permission:
bash:
"*": "deny"
"git tag *": "allow"
"npm run build": "allow"
"npm run deploy:staging": "allow"
"npm run deploy:production": "ask"
skill:
"*": "deny"
---
You handle deployments safely. Always confirm before production deploys.
Prompt Engineering
Recommended System Prompt Structure
# 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 (Recommended)
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 |
<instructions>
1. Analyze the code in <code> tags
2. List issues in <findings> tags
3. Suggest fixes in <recommendations> tags
</instructions>
Description Field (Critical)
The description determines when the agent triggers.
- Primary Agents: Keep extremely concise (3 words max). User selects manually.
- Any Other Agents: Must be specific and exhaustive for correct routing.
Template: [Role/Action]. Use when [triggers]. Examples: - user: "trigger" -> action
Prompt Altitude
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 |
Agentic Reminders
For agents that use tools in a loop, SHOULD include:
# 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.
Single-Agent Patterns
| Pattern | How it works | Best for |
|---|---|---|
| ReAct | Reason → Act → Observe → Repeat | Tool use with reasoning |
| Self-Refine | Generate → Critique → Refine | Quality-focused (writing, review) |
| Reflexion | Reflect on failures → Improve | Adaptive/learning tasks |
Multi-Agent Patterns
| Pattern | How it works | Best for |
|---|---|---|
| Lead Agent | Orchestrator delegates to specialists | Multiple expertise domains |
| Router | Analyze request → Route to right agent | Diverse request types |
| Subagents | Main agent spawns focused sub-agents | Long-horizon tasks, parallel exploration |
Enhancement & Troubleshooting
- “What’s not working well?” — Get specific symptoms
- “Can you show me an example where it failed?” — Understand the gap
- “What should it have done instead?” — Define success
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.
Quality Checklist
Before showing the final agent to the user:
- Asked about core purpose and triggers
- Researched the domain (MUST NOT assume knowledge is current)
-
descriptionhas concrete trigger examples -
modediscussed and set appropriately - System prompt uses second person
- Asked about tool/permission needs (MUST NOT assume)
- Output format is specified if relevant
- Showed draft to user and got feedback
- User confirmed they’re happy with result
Legacy Configuration
Agents may occasionally use outdated frontmatter (e.g., tools:, maxSteps:). Correct these to modern permission: and steps: fields when encountered.
OpenCode Agent Configuration Reference
file_locations
Agent definitions are markdown files in:
.opencode/agents/<name>.md(project)~/.config/opencode/agents/<name>.md(global)
frontmatter_schema
---
# Core Configuration
model: "provider/model-id" # Model override
temperature: 0.7 # Sampling temperature
top_p: 0.9 # Nucleus sampling
prompt: "Custom system prompt" # Or use markdown body
description: "Agent description" # Shown in listings, triggers agent
mode: "subagent" | "primary" | "all" # Agent availability
color: "#FF5733" # UI color
maxSteps: 25 # Max tool call steps
disable: false # Disable agent
# Tool Access Control
tools:
edit: true
write: true
bash: true
read: true
glob: true
grep: true
webfetch: true
task: true
skill: true
# Permissions
permission:
edit: "ask" | "allow" | "deny"
bash:
"*": "allow"
"git *": "deny"
skill:
"*": "allow"
"my-skill": "deny"
webfetch: "ask" | "allow" | "deny"
doom_loop: "ask" | "allow" | "deny"
external_directory: "ask" | "allow" | "deny"
---
agent_modes
| Mode | Description |
|---|---|
primary |
User-selectable, can be default, spawns subagents |
subagent |
Only callable via task tool by other agents |
all |
Both primary and subagent (default) |
permissions
Permission Values
| Value | Behavior |
|---|---|
"allow" |
Automatically permit |
"ask" |
Prompt user for approval |
"deny" |
Automatically reject |
Permission Categories
edit
Controls edit and write tools.
bash
Controls command execution. Supports wildcard patterns:
bash:
"*": "ask" # Ask for everything by default
"git *": "allow" # Allow all git commands
"npm *": "allow" # Allow npm commands
"rm *": "deny" # Block deletion
skill
Controls skill access:
skill:
"*": "deny" # Deny all by default
"my-skill": "allow" # Allow specific skill
webfetch
Controls web fetching. "ask" prompts for each URL.
doom_loop
Controls doom loop detection (agent stuck in repetitive patterns).
external_directory
Controls access to files outside working directory. Affects:
- bash commands referencing external paths
- read/edit/write for external files
Default Permissions
If not specified, agents inherit from global config:
permission:
edit: "allow"
bash: { "*": "allow" }
skill: { "*": "allow" }
webfetch: "allow"
doom_loop: "ask"
external_directory: "ask"
available_tools
File Operations
| Tool | Purpose | Key Parameters |
|---|---|---|
read |
Read file contents | filePath, offset, limit |
edit |
String replacement in files | filePath, oldString, newString, replaceAll |
write |
Create/overwrite files | filePath, content |
Search & Navigation
| Tool | Purpose | Key Parameters |
|---|---|---|
glob |
Find files by pattern | pattern, path |
grep |
Search file contents (regex) | pattern, path, include |
list |
List directory contents | path |
Command Execution
| Tool | Purpose | Key Parameters |
|---|---|---|
bash |
Execute shell commands | command, timeout, workdir, description |
Default timeout: 120000ms. Permissions: bash, external_directory.
Web & External
| Tool | Purpose | Key Parameters |
|---|---|---|
webfetch |
Fetch web content | url, format (text/markdown/html), timeout |
websearch |
Web search via Exa AI | query, numResults |
codesearch |
Code/SDK documentation search | query, tokensNum |
Task Management
| Tool | Purpose | Key Parameters |
|---|---|---|
task |
Launch subagents | description, prompt, subagent_type, session_id |
todowrite |
Update todo list | todos array |
todoread |
Read todo list | (none) |
Other Tools
| Tool | Purpose | Notes |
|---|---|---|
skill |
Load skill instructions | Parameter: name |
batch |
Parallel tool execution | Experimental: config.experimental.batch_tool |
lsp |
Language Server Protocol | Experimental: OPENCODE_EXPERIMENTAL_LSP_TOOL |
tool_access_control
Disable specific tools for an agent:
tools:
bash: false # No shell access
webfetch: false # No web access
task: false # Cannot spawn subagents
All tools inherit from global config.tools by default.
examples
Restricted Code Review Agent (Primary)
---
description: Safe code reviewer.
mode: primary
permission:
edit: "ask"
bash: "deny"
external_directory: "deny"
---
You are a code review specialist...
Research Agent (Subagent)
---
description: |-
Web research agent. Use when user says "research topic", "find info".
Examples:
- user: "research" -> search web
mode: subagent
permission:
skill:
"*": "deny"
"web-research": "allow"
---
You are a research specialist...
Deployment Agent (Standard/Undefined)
---
description: Deployment helper.
permission:
skill:
"*": "deny"
"deploy-checklist": "allow"
---
You are a deployment specialist...