Purpose: Master reference for defining files, agents, and tools in prompts that work seamlessly with OpenCode's automatic tool resolution.
| Type | Syntax | Auto-Loaded? | AI Action Required | When to Use |
|---|---|---|---|---|
| File (Initial) | @file.md |
โ Yes | โ No | User's initial prompt |
| File (Nested) | @file.md |
โ No | โ Yes (read_file) | Inside loaded files |
| Directory | @src/components/ |
โ Yes | โ No | Folder context |
| Sub-Agent (Context) | @agent-name |
โ Yes* | โ No | Reference agent info |
| Sub-Agent (Invoke) | task(subagent_type="name") |
โ No | โ Yes (task tool) | Delegate tasks |
| Shell Command | !`command` |
โ Yes | โ No | Inline command output |
| Config File | instructions: [] in opencode.json |
โ Yes | โ No | Always-needed context |
| Agent (Markdown) | .opencode/agent/**/*.md |
โ Auto-registered | โ No | Define agents |
task tool.opencode/agent/ directoryThe @ symbol only has special meaning in USER PROMPTS, not in AGENT SYSTEM PROMPTS.
Use the !`command` syntax to execute commands and inline their output into prompts:
# Example: Include git information
Current branch: !`git branch --show-current`
Recent commits: !`git log --oneline -5`
# Example: Include system information
Node version: !`node --version`
Available memory: !`free -h | grep Mem`
# Example: Include file contents
Database schema: !`cat schema.sql`
# Example: Include directory structure
Project structure:
!`tree -L 2 -I 'node_modules|dist'`
How it works:
## Current Work Context
Branch: !`git branch --show-current`
Modified files: !`git status --short`
Last commit: !`git log -1 --pretty=format:'%h - %s'`
Uncommitted changes:
!`git diff --stat`
## Project Layout
!`find src -type f -name '*.ts' | head -20`
## Component Structure
!`tree src/components -L 2`
## Environment
Node: !`node --version`
npm: !`npm --version`
OS: !`uname -a`
## Configuration
Current eslint rules:
!`cat .eslintrc.json`
Package scripts:
!`cat package.json | jq .scripts`
| Scenario | Use Shell ! Syntax |
Use run_terminal_cmd Tool |
|---|---|---|
| Static context in prompt | โ | โ |
| Git information | โ | โ |
| File contents | โ | โ |
| Interactive AI execution | โ | โ |
| Based on AI decisions | โ | โ |
| Build/test commands | โ | โ |
| Requires error handling | โ | โ |
When you type this in your prompt:
Follow guidelines in @GUIDELINES.md
Use patterns from @src/patterns/
OpenCode automatically:
GUIDELINES.mdsrc/patterns/ directoryWhen GUIDELINES.md contains:
Also see @CODE_STYLE.md and @TESTING.md
OpenCode does:
To make AI read them, use explicit instructions:
# GUIDELINES.md
โ ๏ธ **CRITICAL**: Before proceeding, read these files using read_file:
1. @CODE_STYLE.md - Coding standards (READ FIRST)
2. @TESTING.md - Testing patterns (READ FIRST)
3. @ARCHITECTURE.md - System design (READ FIRST)
[rest of your guidelines...]
Key phrases that work:
READ FIRSTuse read_file toolCRITICAL: Read these filesLoad immediately before proceedingIMPORTANT DISTINCTION: Agent Files vs Agent Names
Agent File (Documentation):
.opencode/agents/subagents/core/taskmanager.md@.opencode/agents/subagents/core/taskmanager.md to load file contentAgent Name (System Registration):
taskmanager (registered in OpenCode)task(subagent_type="taskmanager", ...) to invoke@agent-name (USUALLY NOT RECOMMENDED)When you use @agent-name in your initial prompt:
Use @reviewer agent for code review
What happens:
Result: AI knows the agent exists but doesn't execute it.
When to use: Rarely needed. Only if you want to reference agent capabilities in context.
To actually run an agent and execute tasks:
// AI must explicitly call the task tool
task(
subagent_type="CodeReviewer",
description="Review code",
prompt="Review the auth implementation for security issues"
)
Result: Agent executes and returns results.
When to use: Always - this is how you actually invoke agents.
If you have agent documentation files:
# Initial prompt
Follow guidelines in @.opencode/agents/subagents/core/taskmanager.md
What happens:
When to use: When you want to load documentation about how to use agents.
โ DON'T write this (confusing - uses @ for agents):
Use @reviewer to review code
Review with @taskmanager agent
Problems:
โ DO write this (clear and explicit):
Option 1: If you have agent documentation files
# Load agent documentation (file)
@.opencode/agents/subagents/core/taskmanager.md
# Then instruct AI how to invoke (not using @)
**Agent: `taskmanager`**
- Purpose: Task planning and breakdown
- Invoke with: task(subagent_type="taskmanager", description="Plan X", prompt="Break down feature Y")
Option 2: Direct invocation instructions (no @ at all)
**Agent: `reviewer`** - Code review agent
- Purpose: Review code for quality and security
- When: After implementing features
- Invoke with: task(subagent_type="CodeReviewer", description="Review X", prompt="Review Y for Z issues")
**DO NOT use @reviewer** - This loads metadata, not invocation
**ALWAYS use task tool** - This actually runs the agent
# Available Sub-Agents
โ ๏ธ **IMPORTANT**: These agents are NOT loaded as context. You MUST invoke them using the `task` tool:
## Code Agents
**Agent: `tester`** (DO NOT use @tester as context reference)
- **Purpose**: Test generation and execution
- **When to invoke**: After implementing features, before commits
- **Tool call**:
```javascript
task(
subagent_type="TestEngineer",
description="Test auth",
prompt="Write comprehensive tests for auth module with >80% coverage"
)
Agent: reviewer (DO NOT use @reviewer as context reference)
javascript
task(
subagent_type="CodeReviewer",
description="Review changes",
prompt="Review the authentication implementation for security vulnerabilities, code quality, and best practices"
)
Agent: planner (DO NOT use @planner as context reference)
javascript
task(
subagent_type="planner",
description="Plan feature",
prompt="Break down the payment system feature into implementable tasks with dependencies"
)
```To make the AI automatically invoke sub-agents at appropriate times:
## Agent Automation Rules
**CRITICAL**: Agents are invoked via `task` tool, NOT by referencing them with @.
**After completing code changes, ALWAYS:**
1. Invoke the `tester` agent using `task` tool to write and run tests
2. Invoke the `reviewer` agent using `task` tool to review code quality
3. Report results back to the user
**Example workflow:**
1. User requests feature
2. You implement the code
3. Automatically call:
```javascript
task(subagent_type="TestEngineer", description="Test feature", prompt="Write tests for X")
javascript
task(subagent_type="CodeReviewer", description="Review feature", prompt="Review X for quality")
Important:
@agent-name syntax to invoke agentstask tool for agent invocation
```## Available Tools
**File Operations**
- `read_file` - Read file contents (supports line ranges)
- `write_file` - Create or overwrite files
- `search_replace` - Edit files with precision
- `list_dir` - List directory contents
- `glob_file_search` - Find files by pattern
**Code Operations**
- `grep` - Search code with ripgrep
- `codebase_search` - Semantic code search
**Execution**
- `run_terminal_cmd` - Execute shell commands
- `task` - Invoke sub-agents
**Planning**
- `todo_write` - Create and manage task lists
# Task Instructions
When you need to find configuration files, use `glob_file_search` to locate them.
When analyzing code patterns, use `codebase_search` for semantic understanding.
When editing code, use `search_replace` for precision rather than rewriting entire files.
Here's a production-ready index file that works perfectly with OpenCode:
# Project Context Index
## ๐ Quick Start
**CRITICAL INSTRUCTION**: Before proceeding with ANY task:
1. Read the files marked `[READ FIRST]` using the `read_file` tool
2. Review the available sub-agents below
3. Follow the coding standards and patterns defined in these files
---
## ๐ Core Documentation [READ FIRST]
Load these files immediately using `read_file`:
- @docs/CODING_STANDARDS.md - TypeScript/React coding patterns
- @docs/TESTING_STRATEGY.md - Test requirements and patterns
- @docs/ARCHITECTURE.md - System design and component structure
- @.opencode/WORKFLOWS.md - Development workflows and CI/CD
---
## ๐ค Available Sub-Agents
Use the `task` tool to invoke these specialized agents:
### Development Agents
**@subagents/code/implementer** - Complex feature implementation
```javascript
task(
subagent_type="implementer",
description="Implement user auth",
prompt="Create complete authentication system with JWT tokens, including login, logout, and session management. Follow patterns in @docs/ARCHITECTURE.md"
)
@TestEngineer - Test generation and execution
task(
subagent_type="TestEngineer",
description="Test auth system",
prompt="Write comprehensive unit and integration tests for the authentication module. Ensure >80% coverage. Run tests and report results."
)
@CodeReviewer - Code quality and security review
task(
subagent_type="CodeReviewer",
description="Review auth code",
prompt="Review the authentication implementation for security vulnerabilities, code quality, and adherence to @docs/CODING_STANDARDS.md. Provide specific improvement suggestions."
)
@subagents/docs/technical-writer - API and code documentation
task(
subagent_type="technical-writer",
description="Document auth API",
prompt="Generate comprehensive API documentation for the authentication endpoints, including request/response examples and error codes."
)
@subagents/core/architect - System design and planning
task(
subagent_type="architect",
description="Design payment system",
prompt="Design a payment processing system architecture that integrates with Stripe. Break down into implementable tasks. Consider scalability and error handling."
)
ALWAYS execute this workflow:
@TestEngineer to validate implementation@CodeReviewer for quality checkALWAYS execute this workflow:
@subagents/core/architect for designtodo_writeFor specific implementation patterns, read these on-demand:
Reference these when setting up tools or CI/CD:
read_file directlyglob_file_search (e.g., "*.test.ts")codebase_search (e.g., "authentication logic")grep for exact text matchessearch_replace for precisionwrite_filetask toolrun_terminal_cmdtask tool# Bad: Using @ syntax for agent invocation
Use @tester when needed
Review with @reviewer after coding
# Bad: Treating agents like files
Read @tester for testing guidelines
See @reviewer documentation
# Bad: Vague agent reference
Use the tester agent when needed
# Bad: Assuming nested files are auto-loaded
See @guidelines.md (which references @other.md)
# Bad: Not specifying how to invoke
Available agents: tester, reviewer, planner
# Bad: Mixing context and invocation
Use @agent-name to run the agent
# Good: Explicit tool call for agent invocation
**Agent: `tester`** - Invoke ONLY via task tool:
task(subagent_type="TestEngineer", description="Test feature", prompt="Write comprehensive tests for X")
# Good: Clear separation of concerns
**File**: @docs/testing-guide.md - Load with read_file
**Agent**: `tester` - Invoke with task tool
# Good: Explicit read instruction for nested refs
**CRITICAL**: Read @guidelines.md, then read all files it references using read_file
# Good: Clear tool invocation
Use the `codebase_search` tool to find authentication logic
# Good: Proactive invocation instruction
After implementing code, ALWAYS invoke the tester agent:
task(subagent_type="TestEngineer", description="Test X", prompt="Write and run tests for X")
Copy this template to create your own index:
# [Project Name] Context Index
## ๐ฏ Before Starting ANY Task
**CRITICAL**: Load these files first using `read_file`:
1. @[PATH_TO_GUIDELINES]
2. @[PATH_TO_STANDARDS]
3. @[PATH_TO_ARCHITECTURE]
---
## ๐ค Sub-Agents (MUST use `task` tool to invoke)
**Agent: `[AGENT_NAME]`** (DO NOT use @[AGENT_NAME] as context)
- Purpose: [Description]
- When to invoke: [When to invoke]
- Tool call:
```javascript
task(
subagent_type="[AGENT_NAME]",
description="[SHORT_DESC]",
prompt="[DETAILED_TASK_INSTRUCTIONS]"
)
task tooltask toolExample:
// Step 1: Test
task(subagent_type="[TESTER_AGENT]", description="Test feature", prompt="Write tests for X")
// Step 2: Review
task(subagent_type="[REVIEWER_AGENT]", description="Review feature", prompt="Review X for quality")
// Step 3: Summarize results for user
---
## ๐ Verification Checklist
Before sharing your index file, verify:
- [ ] All **file** references use `@` prefix
- [ ] Agent references use `task` tool, NOT `@` syntax
- [ ] Agent names are plain text (e.g., `tester`), not `@tester`
- [ ] Nested file references have explicit "READ FIRST" instructions
- [ ] Sub-agents have complete `task()` tool call examples
- [ ] Sub-agents show when/why to invoke them
- [ ] Clear distinction between files (@file.md) and agents (task tool)
- [ ] Automated workflows use `task` tool for agents
- [ ] Tool usage instructions are specific
- [ ] No ambiguous or vague instructions
- [ ] No mixing of @ syntax for agents
---
## ๐ Quick Reference Notes
- **Files**: Use `@path/to/file.md` in prompts (auto-loaded initially, nested require read_file)
- **Agent Files**: Use `@.opencode/agents/subagents/core/agent.md` to load documentation
- **Agent Invocation**: Use `task` tool, NOT `@agent-name` syntax
- **Agent Names**: Plain text only (e.g., `taskmanager`), never `@taskmanager`
- **Shell**: Use `` !`command` `` for automatic execution in prompts
- **Key Rule**: `@` is for FILES only, `task` tool is for AGENTS
- **Rare Exception**: `@agent-name` loads agent metadata (usually not needed)
---
## ๐จ Advanced Patterns
### Combining Multiple Context Types
```markdown
# Complete Feature Context
## Files to Read [READ FIRST]
@docs/auth-spec.md
@src/auth/types.ts
## Current Implementation
!`find src/auth -type f -name '*.ts'`
## Git Context
Branch: !`git branch --show-current`
Changes: !`git diff --name-only`
## Environment
Node: !`node --version`
Dependencies: !`npm list --depth=0 | grep auth`
## Sub-Agents Available
**@subagents/code/implementer** - Use for implementation
**@TestEngineer** - Use for testing
## Task
Implement the authentication flow following @docs/auth-spec.md
# Load All Test Files
Test files in project:
!`find . -name "*.test.ts" -o -name "*.spec.ts"`
**INSTRUCTION**: Read all test files above using `read_file` to understand testing patterns.
# Database Migration Context
## Current Migration Status
!`npm run db:status 2>&1`
## Latest Migration
!`ls -t migrations/ | head -1 | xargs cat`
**If migrations are pending**: Read @docs/migration-guide.md
**If migrations are up-to-date**: Proceed with schema changes
# Component Analysis
## All React Components
!`find src -name "*.tsx" | grep -v test`
## Component Guidelines
@docs/component-patterns.md
**CRITICAL**:
1. Review the component list above
2. Read @docs/component-patterns.md using `read_file`
3. Ensure new components follow established patterns
# Current branch
!`git branch --show-current`
# Recent commits
!`git log --oneline -n 10`
# Modified files
!`git status --short`
# Diff summary
!`git diff --stat`
# Authors
!`git shortlog -sn --all`
# Current commit hash
!`git rev-parse HEAD`
# List TypeScript files
!`find src -name "*.ts" -type f`
# Count lines of code
!`find src -name "*.ts" | xargs wc -l | tail -1`
# Recent files
!`ls -lt src | head -10`
# Directory tree
!`tree -L 3 -I 'node_modules|dist|.git'`
# File size summary
!`du -sh src/*`
# Package version
!`cat package.json | jq -r .version`
# Dependencies
!`npm list --depth=0`
# Scripts
!`cat package.json | jq .scripts`
# Node version
!`node --version`
# npm version
!`npm --version`
# Find TODO comments
!`grep -r "TODO" src --include="*.ts"`
# Find FIXME comments
!`grep -r "FIXME" src --include="*.ts"`
# Find specific function
!`grep -rn "function authenticate" src`
# Count test files
!`find . -name "*.test.ts" | wc -l`
# OS info
!`uname -a`
# Memory usage
!`free -h`
# Disk usage
!`df -h .`
# Process list (filtered)
!`ps aux | grep node`
# Feature Implementation: User Authentication
## Pre-Flight Context Loading
### CRITICAL: Read These Files First
1. @docs/CODING_STANDARDS.md
2. @docs/AUTH_ARCHITECTURE.md
3. @src/auth/interfaces.ts
4. @tests/auth/auth.test.ts
### Current State
**Branch**: !`git branch --show-current`
**Modified Files**:
!`git status --short`
**Existing Auth Files**:
!`find src/auth -name "*.ts" -type f`
**Test Coverage**:
!`npm run test:coverage -- src/auth 2>&1 | tail -5`
### Dependencies
**Current Auth Libraries**:
!`npm list | grep -E "(passport|jwt|bcrypt)"`
**Node Version**: !`node --version`
## Sub-Agents Available
**@subagents/code/implementer** - Feature implementation
- Use when: Implementing new auth flows
- Example: `task(subagent_type="implementer", description="OAuth flow", prompt="Implement OAuth2 flow with Google, following patterns in @docs/AUTH_ARCHITECTURE.md")`
**@TestEngineer** - Test creation
- Use when: After implementing auth features
- Example: `task(subagent_type="TestEngineer", description="Test OAuth", prompt="Write integration tests for OAuth2 flow with >90% coverage")`
**@subagents/security/auditor** - Security review
- Use when: Before deploying auth changes
- Example: `task(subagent_type="auditor", description="Audit auth", prompt="Review auth implementation for security vulnerabilities, SQL injection, XSS, and CSRF")`
## Implementation Workflow
### Step 1: Context Loading
1. Read all files marked [READ FIRST]
2. Review current implementation: !`cat src/auth/auth.service.ts`
3. Review existing tests: !`cat tests/auth/auth.test.ts`
### Step 2: Implementation
1. Implement feature following @docs/CODING_STANDARDS.md
2. Follow patterns from @src/auth/interfaces.ts
3. Update types in @src/auth/types.ts
### Step 3: Testing
1. Invoke tester agent via `task` tool for test creation
```javascript
task(subagent_type="TestEngineer", description="Test auth", prompt="Write tests for auth module")
run_terminal_cmd for npm testtask tool
javascript
task(subagent_type="auditor", description="Security audit", prompt="Review auth for vulnerabilities")
Database Schema:
!cat migrations/latest_auth_schema.sql
Environment Variables:
!cat .env.example | grep AUTH
REMEMBER:
@filename (nested require read_file)task tool, NOT @agent-name!`cmd` executes automatically in prompttester), never @tester
```@ references in YOUR prompt (files only)@ references in loaded files@agent-name in initial prompt attaches agent info (not invocation)task tool call - NEVER use @ syntax!`command` syntax executes automatically in prompt processingrun_terminal_cmd for AI-driven execution during conversation@, Agents use task toolNeed to load a file?
@path/to/file.mdread_file@.opencode/agents/subagents/core/agent.md (file path)Need to invoke an agent?
@agent-name syntax for invocationtask(subagent_type="name", ...)taskmanager, not @taskmanager)@agent-name only loads metadata (rarely useful)Need to run a command?
!`command` in promptrun_terminal_cmd toolStructure Example:
Files (use @): Agents (use task):
@docs/guide.md task(subagent_type="CodeReviewer", ...)
@src/types.ts task(subagent_type="TestEngineer", ...)
@.opencode/agents/ [agent name without @]
taskmanager.md
Use this template to avoid ALL confusion and work seamlessly with OpenCode:
# [Task Name]
## ๐ Context Files (Load with read_file tool)
**CRITICAL**: Read these files FIRST using the `read_file` tool:
1. @docs/coding-standards.md
2. @docs/architecture.md
3. @src/types/core.ts
---
## ๐ Additional Documentation (Auto-loaded)
Current git status:
Branch: !`git branch --show-current`
Recent changes: !`git status --short`
Project structure:
!`find src -type d -maxdepth 2`
---
## ๐ค Available Agents (Invoke via task tool ONLY)
**IMPORTANT**: DO NOT use @ syntax for agents. Use the `task` tool to invoke.
### Agent: `implementer`
**Purpose**: Complex feature implementation
**When to invoke**: When implementing new features or major refactors
**How to invoke**:
```javascript
task(
subagent_type="implementer",
description="Implement feature X",
prompt="Create complete implementation of X following @docs/architecture.md patterns. Include error handling and validation."
)
testerPurpose: Test creation and execution When to invoke: After implementing features, before committing How to invoke:
task(
subagent_type="TestEngineer",
description="Test feature X",
prompt="Write comprehensive tests for X with >80% coverage. Run tests and report results."
)
reviewerPurpose: Code review and quality checks When to invoke: After code changes, before finalizing How to invoke:
task(
subagent_type="CodeReviewer",
description="Review feature X",
prompt="Review the implementation of X for code quality, security vulnerabilities, and adherence to @docs/coding-standards.md"
)
After implementing ANY code:
tester agent using task toolreviewer agent using task tool[Describe the specific task here]
@path/to/file.md syntaxtask(subagent_type="name", ...)@agent-name to invoke agentstester, reviewer, NOT @tester
```# Implement User Authentication System
## ๐ Context Files (Load FIRST)
**CRITICAL**: Use `read_file` tool to load these before starting:
1. @docs/CODING_STANDARDS.md - TypeScript coding patterns
2. @docs/AUTH_ARCHITECTURE.md - Authentication design patterns
3. @src/auth/types.ts - Existing auth type definitions
4. @tests/auth/auth.test.ts - Existing test patterns
---
## ๐ Current State (Auto-loaded)
**Git Context**:
Branch: !`git branch --show-current`
Modified: !`git status --short`
**Existing Auth Files**:
!`find src/auth -name "*.ts" -type f`
**Dependencies**:
!`npm list | grep -E "(jwt|bcrypt|passport)"`
---
## ๐ค Available Agents
### Agent: `implementer`
Purpose: Feature implementation
Invoke with:
```javascript
task(
subagent_type="implementer",
description="Implement auth flow",
prompt="Create authentication system with JWT tokens, including login, logout, and session management. Follow patterns in @docs/AUTH_ARCHITECTURE.md. Include middleware, controllers, and services."
)
testerPurpose: Test creation Invoke with:
task(
subagent_type="TestEngineer",
description="Test auth system",
prompt="Write unit and integration tests for authentication module. Cover login, logout, token refresh, and session management. Ensure >85% coverage. Run tests and report results."
)
reviewerPurpose: Security and quality review Invoke with:
task(
subagent_type="CodeReviewer",
description="Review auth implementation",
prompt="Review authentication implementation for security vulnerabilities (SQL injection, XSS, CSRF), proper token handling, password security, and adherence to @docs/CODING_STANDARDS.md"
)
You MUST follow this workflow:
tester agent via task toolreviewer agent via task toolImplement a complete authentication system with:
Requirements:
@docs/file.mdtask(subagent_type="name", ...)@agent-name to invoke agentstester, NOT @testergit status
```Use @tester and @reviewer agents to test the code.
Follow @guidelines and implement authentication.
Problems:
@ for agents (only loads metadata, doesn't invoke)# Implement Authentication
## Context Files
**Read these using read_file tool:**
- @docs/guidelines.md
## Agents
**Agent: `tester`** - Invoke with task tool:
task(subagent_type="TestEngineer", description="Test auth", prompt="...")
**Agent: `reviewer`** - Invoke with task tool:
task(subagent_type="CodeReviewer", description="Review auth", prompt="...")
## Workflow
1. Read @docs/guidelines.md
2. Implement feature
3. Invoke tester agent via task tool
4. Invoke reviewer agent via task tool
# Implement [Feature Name]
## Context
Read: @docs/standards.md
Git status: !`git status --short`
## Task
[Detailed description]
## No Agents Needed
(Simple task, no agents required)
# Implement [Complex Feature]
## Context Files (Read FIRST)
1. @docs/standards.md
2. @docs/architecture.md
## Current State
!`git status --short`
!`find src/[module] -name "*.ts"`
## Available Agents
**Agent: `implementer`**
Invoke: task(subagent_type="implementer", description="...", prompt="...")
**Agent: `tester`**
Invoke: task(subagent_type="TestEngineer", description="...", prompt="...")
## Workflow
1. Read context files
2. Implement feature
3. Invoke tester agent
4. Report results
# Review [Feature/Module]
## Context
Files to review:
!`git diff --name-only main...HEAD`
Recent changes:
!`git log --oneline -5`
## Agent
**Agent: `reviewer`**
Invoke immediately:
task(
subagent_type="CodeReviewer",
description="Review recent changes",
prompt="Review all changes in current branch for code quality, security, and adherence to standards"
)
## Task
Run code review and report findings.
# Document [Feature]
## Context
Implementation files:
!`find src/[module] -name "*.ts"`
## Agent
**Agent: `documenter`**
Invoke: task(subagent_type="documenter", description="Document X", prompt="...")
## Task
Generate comprehensive documentation for [feature].
@path/to/file.mdtask(subagent_type="name", ...)!`command` for dynamic contexttester, never @testerBased on your actual agent configurations (task-manager subagent + orchestration agent):
CRITICAL: Agents are defined in MARKDOWN files. The agent NAME comes from the FILE PATH!
.opencode/
agent/ # All agents as markdown files
subagents/
core/
task-manager.md # Agent name: "TaskManager"
orchestration-agent.md # Agent name: "orchestration-agent"
code/
reviewer.md # Agent name: "code/reviewer"
tester.md # Agent name: "code/tester"
Markdown Agent File Format:
---
description: "Brief description of agent"
mode: subagent # or "primary" or "all"
temperature: 0.2
tools:
read: true
write: true
edit: true
bash: true
task: true
permissions:
edit:
"**/*.secret": "deny"
bash:
"rm -rf *": "deny"
---
# Agent Prompt Content Here
Your agent instructions, personality, rules, etc.
All the markdown content becomes the agent's system prompt.
How OpenCode determines agent names (from source code):
.opencode/agent/**/*.md files recursively--- markers) for configagent/ directory (minus .md)Examples:
.opencode/agent/task-manager.md โ Name: task-manager.opencode/agent/TaskManager.md โ Name: TaskManager.opencode/agent/code/reviewer.md โ Name: code/reviewerNo opencode.json needed! Everything is in markdown.
Use @task-manager to break down the feature
Have @orchestration-agent coordinate the work
Problems:
@ for agent invocation (only loads metadata)TaskManager# Implement User Dashboard Feature
## ๐ Context Files (Load FIRST)
**Agent Documentation** (optional - only if you need to understand agent capabilities):
- @.opencode/agent/orchestration-agent.md - Main agent guidelines
- @.opencode/agent/TaskManager.md - Task breakdown process
**Project Documentation**:
- @docs/coding-standards.md
- @docs/architecture.md
**Current State**:
Branch: !`git branch --show-current`
Files: !`find src/dashboard -name "*.ts"`
---
## ๐ค Available Agents
### Agent: `TaskManager` (Subagent)
**IMPORTANT**: Agent is defined in a MARKDOWN file. The agent name comes from the file path!
**File location**: `.opencode/agent/TaskManager.md`
**Agent name**: `TaskManager` (path from `agent/` directory)
**Format**: Markdown with YAML frontmatter
**File structure:**
```markdown
---
description: "Breaks down complex features into subtasks"
mode: subagent
temperature: 0.1
tools: { read: true, write: true, ... }
---
# Task Manager Agent Prompt
[Your agent instructions here...]
Purpose: Break down complex features into atomic subtasks
When to invoke:
How to invoke:
task(
subagent_type="TaskManager",
description="Break down dashboard feature",
prompt="Break down the user dashboard feature into atomic subtasks. Feature includes: profile widget, activity feed, notification center, and settings panel. Create structured task files in /tasks/ directory following your two-phase workflow."
)
What it does:
tasks/subtasks/{feature}/For complex features (4+ components):
Invoke task-manager to break down the feature
task(
subagent_type="TaskManager",
description="Break down dashboard",
prompt="Analyze and break down user dashboard feature with profile, activity, notifications, and settings components. Create task files with dependencies and acceptance criteria."
)
Review the task plan (agent will request approval)
Approve and let agent create files
Implement tasks sequentially based on dependencies
Validate each task against acceptance criteria
Implement a user dashboard feature with:
Requirements:
Since this is complex (4+ components), invoke the task-manager agent first.
.md in .opencode/agents/): Use @ to load as documentationtask(subagent_type="name", ...) to actually run the agenttask-manager, NOT @task-managertask-manager when you need feature breakdown
```# Implement [Complex Feature Name]
## ๐ Context
**Read these files:**
- @docs/coding-standards.md
- @docs/architecture.md
- @.opencode/context/core/workflows/delegation.md
**Current state:**
!`git status --short`
!`find src/[module] -type f`
---
## ๐ค Agent: TaskManager
**Invoke immediately for task breakdown:**
```javascript
task(
subagent_type="TaskManager",
description="Break down [feature]",
prompt="Break down [feature description] into atomic subtasks. Include:
- Component 1: [details]
- Component 2: [details]
- Component 3: [details]
Create task files in /tasks/ with dependencies, acceptance criteria, and test requirements. Follow your two-phase workflow (plan โ approve โ create files)."
)
[Detailed feature requirements]
# [Simple Task Name]
## ๐ Context
**Read:**
- @docs/coding-standards.md
**Current state:**
!`git status --short`
---
## ๐ฏ Task
[Task description - simple, 1-3 files]
---
## โ ๏ธ Notes
- Simple task, no task-manager needed
- Execute directly
- Follow coding standards from @docs/coding-standards.md
# Coordinate [Multi-Step Feature]
## ๐ Context
**Read orchestration guidelines:**
- @.opencode/agents/orchestration-agent.md
- @.opencode/context/core/workflows/delegation.md
**Current state:**
!`git status --short`
---
## ๐ Coordination Workflow
This task requires coordination across multiple steps:
1. **Break down** feature using task-manager
2. **Implement** core components
3. **Delegate** complex subsystems if needed
4. **Validate** integration
5. **Report** completion
---
## ๐ค Agents Available
**Agent: `TaskManager`** - For feature breakdown
Invoke: task(subagent_type="TaskManager", description="...", prompt="...")
**Agent: `general`** - For delegated complex work (if needed)
Invoke: task(subagent_type="general", description="...", prompt="...")
---
## ๐ฏ Task
[Complex coordinated task description]
---
## ๐ Orchestration Rules
From @.opencode/agents/orchestration-agent.md:
- Request approval before execution
- Stop on failures (don't auto-fix)
- Report โ Propose โ Approve โ Fix
- Confirm before cleanup
tasks/subtasks/{feature}/| What | File Syntax | Agent Invocation |
|---|---|---|
| Load agent docs | @.opencode/agent/TaskManager.md |
N/A |
| Invoke task-manager | N/A | task(subagent_type="TaskManager", ...) |
| Reference in text | "the task-manager agent" or "TaskManager" | N/A |
| Load project docs | @docs/standards.md |
N/A |
KEY INSIGHT: The agent name comes from the file path structure, NOT just the filename!
Is it complex (4+ components)?
โ YES
Invoke task-manager โ Get breakdown โ Implement tasks
โ NO
Execute directly (orchestration agent handles it)
Need to understand agents?
โ YES
Load agent docs: @.opencode/agents/[agent].md
โ NO
Skip - just invoke when needed
You might ask: "Why do I need to tell the AI about subagents in my prompt when the task tool already lists them?"
You're right - it's redundant! Here's the reality:
---
tools:
task: true # AI should figure out the rest
---
# Your Agent
Delegate complex work to specialized subagents.
The AI should:
task toolCurrent AI models don't always:
So we compensate by:
Option 1: Minimal (Trust the Tool)
For complex work, use the `task` tool to delegate to specialized subagents.
Available agents are documented in the task tool description.
Option 2: Explicit (Be Redundant)
Available subagents via task tool:
- TaskManager - For feature breakdown
- TestEngineer - For testing
Invoke with: task(subagent_type="...", description="...", prompt="...")
Recommendation:
Last Updated: 2024-11-21 OpenCode Version: Latest