agent-architect

Expert guide for creating OpenCode agents and subagents. Use when: (1) Creating specialized agents, (2) Designing multi-agent workflows, (3) Optimizing context with subagent delegation, (4) Setting tool permissions.

$ Installer

git clone https://github.com/walcon/opencode-example /tmp/opencode-example && cp -r /tmp/opencode-example/.opencode/skills/agent-architect ~/.claude/skills/opencode-example

// tip: Run this command in your terminal to install the skill


name: agent-architect description: > Expert guide for creating OpenCode agents and subagents. Use when: (1) Creating specialized agents, (2) Designing multi-agent workflows, (3) Optimizing context with subagent delegation, (4) Setting tool permissions.

Agent Architect

Create specialized OpenCode agents and subagents.

Quick Start

GoalAction
Create a new agentnpx tsx scripts/init.ts <name>
Validate existing agentnpx tsx scripts/validate.ts <path>

What is an Agent?

Agents are specialized AI personas with custom prompts, models, and tool access:

---
description: What this agent does and when to use it
mode: subagent
tools:
  write: false
  bash: false
---

You are a [role] specialized in [domain]...

Location: .opencode/agent/<name>.md

Primary vs Subagent

AspectPrimary AgentSubagent
Modemode: primarymode: subagent
InvocationTab to switch@agent-name or auto-delegation
ContextMain conversationOwn isolated context
Use caseMain workflowsDelegated tasks

Why Subagents Matter

Subagents run in isolated context windows. This means:

  1. Context efficiency - Heavy analysis doesn't bloat main conversation
  2. Focused expertise - Specialized prompts for specific tasks
  3. Parallel execution - Multiple subagents can run concurrently
  4. Clean results - Returns only summary to orchestrator

When to Use Subagents

TaskMain ContextSubagent
Quick question
Deep code analysis
Multi-file research
Content generation
Validation/review
Simple edits

Creating an Agent

Step 1: Define Purpose

What specialized task will this agent perform? Be specific:

  • "Review code for security vulnerabilities"
  • "Write user-facing copy in brand voice"
  • "Research technical topics without making changes"

Step 2: Choose Mode

mode: primary    # Tab-switchable main agent
mode: subagent   # Invoked via @name or delegation

Omit mode to make agent available as both.

Step 3: Select Tools

Grant only necessary tools (principle of least privilege):

Agent TypeToolsRationale
Reviewerread, grep, globAnalyze without modifying
Researcherread, grep, glob, webfetchGather information
Writerread, write, editCreate content
Executorread, write, edit, bashFull access
tools:
  write: false
  edit: false
  bash: false

Step 4: Configure Model (Optional)

model: anthropic/claude-haiku-4-5    # Fast, cheap
model: anthropic/claude-sonnet-4-5   # Balanced
model: anthropic/claude-opus-4-5     # Complex reasoning
temperature: 0.3                      # Lower = consistent

Step 5: Write the Prompt

The markdown body becomes the system prompt:

# Role
You are a [specific role] specialized in [domain].

# Behavior
When given a task:
1. [First action]
2. [Second action]

# Output Format
Return results as:
- Summary: [one line]
- Details: [findings]
- Recommendations: [actions]

# Constraints
- [What NOT to do]

Step 6: Scaffold

npx tsx scripts/init.ts <name>

Step 7: Validate

npx tsx scripts/validate.ts .opencode/agent/<name>.md

Agent Patterns

Pattern 1: Specialist Team

Multiple focused agents orchestrated by main thread:

  • @code-reviewer - Quality and security review
  • @architect - Design decisions
  • @tester - Test creation and validation

Pattern 2: Research Delegation

Offload context-heavy research:

@explore Find all authentication-related files in the codebase

Subagent searches extensively; returns only relevant paths.

Pattern 3: Content Generation

Delegate writing to specialized voice:

@copywriter Write a product description for the new feature

Pattern 4: Parallel Analysis

Fan out for independent checks:

Run @security-checker and @style-checker in parallel

Each returns findings; main thread aggregates.


Output Format

Always specify structured output in agent prompts:

# Output Format

Return results as:

## Summary
[One-line finding]

## Issues
- [Issue 1]
- [Issue 2]

## Recommendations
- [Action 1]
- [Action 2]

This ensures the orchestrator receives minimal, actionable data.


Common Mistakes

Over-broad Agents

# BAD
description: Helps with code

# GOOD
description: >
  Reviews code for security vulnerabilities. Use PROACTIVELY 
  after code changes to check for injection, auth, and data exposure.

Too Many Tools

# BAD - grants everything "just in case"
tools: {}

# GOOD - minimal for the task
tools:
  write: false
  edit: false
  bash: false

Missing Output Format

# BAD - returns unstructured prose
You are a code reviewer. Review the code.

# GOOD - structured response
You are a code reviewer.

Return findings as:
- Summary: [one line]
- Issues: [list with severity]
- Suggested fixes: [actionable items]

Vague Description

# BAD - won't auto-delegate correctly
description: Reviews things

# GOOD - clear triggers
description: >
  Security-focused code review. Use PROACTIVELY after changes
  to authentication, authorization, or data handling code.

Scripts Reference

init.ts

npx tsx scripts/init.ts code-reviewer

Creates .opencode/agent/code-reviewer.md with template.

validate.ts

npx tsx scripts/validate.ts .opencode/agent/code-reviewer.md

Errors: Missing description, invalid frontmatter Warnings: Weak description, missing output format


Permission Patterns

OpenCode supports granular bash command permissions. Use these patterns for fine-grained control.

Permission Levels

LevelBehavior
allowExecute without approval
askPrompt for approval
denyBlock the command entirely

Read-Only Agent

---
description: Code analyzer that never modifies files
mode: subagent
tools:
  write: false
  edit: false
  bash: false
---

Git-Allowed Agent

Allow git read commands, require approval for writes:

---
description: Git operations specialist
mode: subagent
permission:
  bash:
    "git status": allow
    "git diff": allow
    "git log*": allow
    "git show*": allow
    "git branch*": ask
    "git checkout*": ask
    "git push*": ask
    "git commit*": ask
    "*": deny
---

Package Management Agent

---
description: Dependency analyzer
mode: subagent
permission:
  bash:
    "npm list*": allow
    "npm outdated*": allow
    "npm audit*": allow
    "npm install*": ask
    "npm update*": ask
    "*": deny
---

Security-Conscious Agent

Maximum restrictions for audit tasks:

---
description: Security auditor with minimal permissions
mode: subagent
tools:
  write: false
  edit: false
  bash: false
  webfetch: false
permission:
  edit: deny
  bash: deny
---

MCP Tools Configuration

When MCP servers are configured, agents can access external services.

Enabling MCP Tools

---
description: GitHub integration specialist
mode: subagent
tools:
  mymcp_github_create_issue: true
  mymcp_github_list_prs: true
  mymcp_slack_post_message: false
---

Common MCP Patterns

MCP ServerToolsUse Case
githubmymcp_github_*Issue/PR management
slackmymcp_slack_*Notifications
notionmymcp_notion_*Documentation
linearmymcp_linear_*Project tracking

Per-Agent MCP Access

In opencode.json, configure MCP access per agent:

{
  "agent": {
    "github-helper": {
      "tools": {
        "mymcp_github_create_issue": true,
        "mymcp_github_create_pr": true
      }
    }
  }
}

Integration with prompt-engineer

For complex agents requiring high-quality system prompts, use the prompt-engineer skill.

Workflow

1. Invoke agent-architect for agent creation
2. agent-architect invokes prompt-engineer for system prompt
3. prompt-engineer runs 5-phase methodology:
   - Requirements gathering
   - Structure design  
   - Prompt construction
   - Validation
   - Output generation
4. prompt-engineer returns optimized prompt body
5. agent-architect wraps with agent frontmatter
6. Final agent.md created

When to Use prompt-engineer

Agent ComplexityApproach
Simple agentUse template directly
Standard agentFollow Step 5 guidelines
Complex/critical agentInvoke prompt-engineer skill

Invoking prompt-engineer

When you need a high-quality system prompt:

Use the prompt-engineer skill to create a system prompt for this agent.

Requirements:
- Task: [what the agent does]
- Input: [what it receives]
- Output: [expected format]
- Constraints: [limitations]

Agent Quality Metrics

Evaluate agents against these criteria:

CriterionWeightDescription
Single Responsibility25%Does one thing well
Minimal Permissions25%Only necessary tool access
Clear Triggers20%Description enables auto-invocation
Documented Scope15%Boundaries clearly defined
Structured Output15%Consistent, parseable responses

Quality Checklist

Before deploying an agent:

  • Description clearly states when to use
  • Tools are minimal for the task
  • Output format is specified
  • Edge cases are handled
  • Constraints are explicit
  • No conflicting instructions

Examples

See references/examples/ for annotated agents:

  • code-reviewer.md - Read-only analysis agent
  • researcher.md - Research with web access

See references/patterns.md for additional archetypes:

  • Orchestrator - Coordinates multiple agents
  • Permission patterns - Granular bash control
  • MCP integration - External service access