PROMPT GUIDELINES FOR AGENTS
PHILOSOPHY
- Goal: Eliminate ambiguity. Preserve flexibility.
- Model: Task_Understanding → Capability_Map → Behavior_Design → Safety_Integration → Instruction_Clarity.
- Mantra: "Explicit > Implicit. Constrain > Enable. Safe == Default."
AGENT ARCHITECTURE
Configuration
- Format:
.md with YAML frontmatter.
- Fields:
mode: subagent (Specialist) || primary (Generalist) || all (Hybrid: both subagent and primary).
temperature: 0.0-0.2 (Deterministic) || 0.3-0.5 (Balanced) || 0.6-0.8 (Creative).
tools: read, search, context7 (Base). write, edit, bash (Privileged).
permission: {} (None) || ask (Confirm) || allow (Trust).
Instruction Layers
- Identity: Role + Core Competency.
- Scope:
✓ CAN (Capabilities) && ✗ CANNOT (Boundaries).
- Methodology: Phased execution steps.
- Quality: Specificity × Actionability × Completeness × Safety.
- Constraints: Negative rules + Safety guardrails.
AGENT ARCHETYPES (Quick Reference)
| Archetype |
Mode |
Temp |
Base Tools |
Permission |
Focus |
| Auditor |
sub |
0.1 |
read, search |
{} |
Security/Bugs |
| Reviewer |
sub |
0.2 |
read, search |
{} |
Quality/Clean |
| DocGen |
sub |
0.6 |
write, read |
ask |
Documentation |
| TestGen |
sub |
0.3 |
write, bash |
ask |
Coverage |
| Refactor |
sub |
0.3 |
edit, bash |
ask |
Optimization |
| Builder |
prim |
0.4 |
all |
ask |
Features |
| Fixer |
prim |
0.3 |
edit, bash |
ask |
Debugging |
| Advisor |
all |
0.2 |
read, search |
{} |
Advisory/Planning |
Mode Types
subagent: Specialist agent invoked via task tool for specific tasks
primary: Generalist agent for broad feature work and complex multi-step operations
all: Hybrid agent capable of functioning as both subagent (specialized advisory) and primary (general planning/scoping) depending on context
Example Agent Configurations
Read-Only Auditor Agent
---
mode: sub
temperature: 0.1
tools:
read: true
search: true
permission: {}
description: >
Security auditor for codebases and configurations.
Scope: vulnerability detection, compliance checking, secret scanning.
---
Development Advisor Agent
---
mode: all
temperature: 0.3
tools:
read: true
glob: true
grep: true
context7: true
permission: {}
description: >
General purpose development advisor.
Scope: code review, architecture planning, debugging assistance.
---
Documentation Generator Agent
---
mode: sub
temperature: 0.6
tools:
read: true
write: true
permission:
write: ask
description: >
Technical documentation generator.
Scope: API docs, README creation, code annotation.
---
SECURITY & GUARDRAILS
Permission Tiers
- Read-Only:
write: false, edit: false, bash: false. (Analysis).
- Balanced:
write: ask, edit: ask, bash: ask/safe-only. (Dev).
- Autonomous:
write: allow, edit: allow (Trusted). NEVER rm -rf, sudo, push -f.
- Syntax Variations:
permission: {} (None) OR permission: {write: ask, edit: ask} (Selective).
Threat Controls
- Data Loss:
rm *, rm -rf, git push -f, :> → DENY.
- Privilege:
sudo, chmod 777, chown → DENY.
- Secrets:
echo *SECRET*, print credentials, log tokens → DENY.
Input Validation (MANDATORY)
- Sanitization: Strip shell metacharacters (
;, &, |, $, `, (, ), \, <, >).
- Path Traversal: Reject
../, absolute paths unless explicit allow.
- Command Injection: Reject arbitrary command execution strings.
- Pattern:
Input → sanitize() → validate_schema() → safe_execute().
Output Security
- Secret Redaction: Never output secrets, tokens, passwords, API keys.
- Error Messages: Sanitized, no stack traces with secrets.
- Validation: Verify output matches expected schema/type.
INTEGRATION
- Rule: Scan
~/.config/opencode/ → Map capabilities → Reference precisely.
- Ref Syntax:
skills_[name], @agent-name.
AGENT ORCHESTRATION PATTERNS
- Subagent Invocation:
@agent-name syntax for agent-to-agent calls
- Task Tool: Use
task tool with subagent_type: "agent-name" parameter
- Sequential Execution:
Agent_A → Output → Agent_B → Final_Result
- Conditional Delegation:
Task_Type → Specialist_Agent OR Generalist_Agent
- Pattern: Analyze → Delegate → Monitor → Aggregate
- Syntax: Execute
@quality/code-reviewer on [files]
- Example:
Execute @development/backend-developer for database tasks
AGENT TEMPLATE
---
mode: all
temperature: 0.2
tools:
read: true
glob: true
grep: true
context7: true
permission: {}
description: >
[One-line purpose]
Scope: [key areas]
---
# AGENT_NAME
## ROUTING_PROTOCOL
### Mode Detection
IF "analyze" OR "explain" OR "show" detected THEN
READ FILE: @references/modes/analyse.md
END
IF "create" OR "write" OR "edit" OR "update" detected THEN
READ FILE: @references/modes/write.md
END
IF "review" OR "check" OR "audit" OR "validate" OR "compliance" detected THEN
READ FILE: @references/modes/review.md
END
IF "plan" OR "design" OR "breakdown" OR "estimate" detected THEN
READ FILE: @references/modes/plan.md
END
IF "teach" OR "explain" OR "guide" OR "tutorial" detected THEN
READ FILE: @references/modes/teach.md
END
### Domain-Specific Routing
IF [domain keyword 1] detected THEN
READ FILE: @references/domains/[domain1].md
END
### Security Context
IF destructive OR "sudo" OR "rm" OR "security" detected THEN
READ FILE: @references/core/security.md
READ FILE: @references/core/validation.md
END
## IDENTITY [MANDATORY]
**Role**: [Agent role]
**Goal**: [Agent goal]
## CAPABILITIES [OPTIONAL]
✓ CAN: [Capability 1, Capability 2]
✗ CANNOT: [Limitation 1, Limitation 2]
## DEPENDENCIES [OPTIONAL]
### Skills
- skill(skill-id): [purpose]
### Tools
- tool-name: [purpose]
### Dependency Validation
IF skill required THEN
Load skill(skill-id)
Verify skill availability
Error if skill not found
END
IF tool required THEN
Check tool availability
Verify tool version
Warn if version mismatch
END
IF dependency missing THEN
Error(Dependency not available)
List missing dependency
Abort operation
END
## GLOSSARY [RECOMMENDED when abbreviations exist]
**TERM1**: [Definition]
**TERM2**: [Definition]
1---2name: prompt-guidelines-agents3description: Agent creation guidelines and protocols for eliminating ambiguity while preserving flexibility. Provides agent architecture patterns, security guardrails, permission tiers, and orchestration patterns. Includes agent archetypes and integration guidelines. Scope: agent creation, agent structure, security patterns, orchestration. Excludes: skill creation, command creation (handled by component-specific skills). Triggers: agent, create agent, orchestrate, new agent.4---5
6# PROMPT GUIDELINES FOR AGENTS
7
8## PHILOSOPHY
9- **Goal**: Eliminate ambiguity. Preserve flexibility.
10- **Model**: Task_Understanding → Capability_Map → Behavior_Design → Safety_Integration → Instruction_Clarity.
11- **Mantra**: "Explicit > Implicit. Constrain > Enable. Safe == Default."
12
13## AGENT ARCHITECTURE
14
15### Configuration
16- **Format**: `.md` with YAML frontmatter.
17- **Fields**:
18 - `mode`: `subagent` (Specialist) || `primary` (Generalist) || `all` (Hybrid: both subagent and primary).
19 - `temperature`: `0.0-0.2` (Deterministic) || `0.3-0.5` (Balanced) || `0.6-0.8` (Creative).
20 - `tools`: `read`, `search`, `context7` (Base). `write`, `edit`, `bash` (Privileged).
21 - `permission`: `{}` (None) || `ask` (Confirm) || `allow` (Trust).
22
23### Instruction Layers
241. **Identity**: Role + Core Competency.
252. **Scope**: `✓ CAN` (Capabilities) && `✗ CANNOT` (Boundaries).
263. **Methodology**: Phased execution steps.
274. **Quality**: Specificity × Actionability × Completeness × Safety.
285. **Constraints**: Negative rules + Safety guardrails.
29
30## AGENT ARCHETYPES (Quick Reference)
31
32| Archetype | Mode | Temp | Base Tools | Permission | Focus |
33|-----------|------|------|------------|------------|-------|
34| Auditor | sub | 0.1 | read, search | {} | Security/Bugs |
35| Reviewer | sub | 0.2 | read, search | {} | Quality/Clean |
36| DocGen | sub | 0.6 | write, read | ask | Documentation |
37| TestGen | sub | 0.3 | write, bash | ask | Coverage |
38| Refactor | sub | 0.3 | edit, bash | ask | Optimization |
39| Builder | prim | 0.4 | all | ask | Features |
40| Fixer | prim | 0.3 | edit, bash | ask | Debugging |
41| Advisor | all | 0.2 | read, search | {} | Advisory/Planning |
42
43### Mode Types
44- **`subagent`**: Specialist agent invoked via task tool for specific tasks
45- **`primary`**: Generalist agent for broad feature work and complex multi-step operations
46- **`all`**: Hybrid agent capable of functioning as both subagent (specialized advisory) and primary (general planning/scoping) depending on context
47
48### Example Agent Configurations
49
50#### Read-Only Auditor Agent
51```yaml
52---
53mode: sub
54temperature: 0.1
55tools:
56 read: true
57 search: true
58permission: {}
59description: >
60 Security auditor for codebases and configurations.
61 Scope: vulnerability detection, compliance checking, secret scanning.
62---
63```
64
65#### Development Advisor Agent
66```yaml
67---
68mode: all
69temperature: 0.3
70tools:
71 read: true
72 glob: true
73 grep: true
74 context7: true
75permission: {}
76description: >
77 General purpose development advisor.
78 Scope: code review, architecture planning, debugging assistance.
79---
80```
81
82#### Documentation Generator Agent
83```yaml
84---
85mode: sub
86temperature: 0.6
87tools:
88 read: true
89 write: true
90permission:
91 write: ask
92description: >
93 Technical documentation generator.
94 Scope: API docs, README creation, code annotation.
95---
96```
97
98## SECURITY & GUARDRAILS
99
100### Permission Tiers
101- **Read-Only**: `write: false`, `edit: false`, `bash: false`. (Analysis).
102- **Balanced**: `write: ask`, `edit: ask`, `bash: ask/safe-only`. (Dev).
103- **Autonomous**: `write: allow`, `edit: allow` (Trusted). **NEVER** `rm -rf`, `sudo`, `push -f`.
104- **Syntax Variations**: `permission: {}` (None) OR `permission: {write: ask, edit: ask}` (Selective).
105
106### Threat Controls
107- **Data Loss**: `rm *`, `rm -rf`, `git push -f`, `:>` → **DENY**.
108- **Privilege**: `sudo`, `chmod 777`, `chown` → **DENY**.
109- **Secrets**: `echo *SECRET*`, print credentials, log tokens → **DENY**.
110
111### Input Validation (MANDATORY)
112- **Sanitization**: Strip shell metacharacters (`;`, `&`, `|`, `$`, `` ` ``, `(`, `)`, `\`, `<`, `>`).
113- **Path Traversal**: Reject `../`, absolute paths unless explicit allow.
114- **Command Injection**: Reject arbitrary command execution strings.
115- **Pattern**: `Input → sanitize() → validate_schema() → safe_execute()`.
116
117### Output Security
118- **Secret Redaction**: Never output secrets, tokens, passwords, API keys.
119- **Error Messages**: Sanitized, no stack traces with secrets.
120- **Validation**: Verify output matches expected schema/type.
121
122## INTEGRATION
123- **Rule**: Scan `~/.config/opencode/` → Map capabilities → Reference precisely.
124- **Ref Syntax**: `skills_[name]`, `@agent-name`.
125
126## AGENT ORCHESTRATION PATTERNS
127- **Subagent Invocation**: `@agent-name` syntax for agent-to-agent calls
128- **Task Tool**: Use `task` tool with `subagent_type: "agent-name"` parameter
129- **Sequential Execution**: `Agent_A → Output → Agent_B → Final_Result`
130- **Conditional Delegation**: `Task_Type → Specialist_Agent OR Generalist_Agent`
131- **Pattern**: Analyze → Delegate → Monitor → Aggregate
132- **Syntax**: Execute `@quality/code-reviewer` on `[files]`
133- **Example**: `Execute @development/backend-developer for database tasks`
134
135## AGENT TEMPLATE
136
137```yaml
138---
139mode: all
140temperature: 0.2
141tools:
142 read: true
143 glob: true
144 grep: true
145 context7: true
146permission: {}
147description: >
148 [One-line purpose]
149 Scope: [key areas]
150---
151
152# AGENT_NAME
153
154## ROUTING_PROTOCOL
155
156### Mode Detection
157IF "analyze" OR "explain" OR "show" detected THEN
158 READ FILE: @references/modes/analyse.md
159END
160
161IF "create" OR "write" OR "edit" OR "update" detected THEN
162 READ FILE: @references/modes/write.md
163END
164
165IF "review" OR "check" OR "audit" OR "validate" OR "compliance" detected THEN
166 READ FILE: @references/modes/review.md
167END
168
169IF "plan" OR "design" OR "breakdown" OR "estimate" detected THEN
170 READ FILE: @references/modes/plan.md
171END
172
173IF "teach" OR "explain" OR "guide" OR "tutorial" detected THEN
174 READ FILE: @references/modes/teach.md
175END
176
177### Domain-Specific Routing
178IF [domain keyword 1] detected THEN
179 READ FILE: @references/domains/[domain1].md
180END
181
182### Security Context
183IF destructive OR "sudo" OR "rm" OR "security" detected THEN
184 READ FILE: @references/core/security.md
185 READ FILE: @references/core/validation.md
186END
187
188## IDENTITY [MANDATORY]
189**Role**: [Agent role]
190**Goal**: [Agent goal]
191
192## CAPABILITIES [OPTIONAL]
193✓ CAN: [Capability 1, Capability 2]
194✗ CANNOT: [Limitation 1, Limitation 2]
195
196## DEPENDENCIES [OPTIONAL]
197
198### Skills
199- skill(skill-id): [purpose]
200
201### Tools
202- tool-name: [purpose]
203
204### Dependency Validation
205
206IF skill required THEN
207 Load skill(skill-id)
208 Verify skill availability
209 Error if skill not found
210END
211
212IF tool required THEN
213 Check tool availability
214 Verify tool version
215 Warn if version mismatch
216END
217
218IF dependency missing THEN
219 Error(Dependency not available)
220 List missing dependency
221 Abort operation
222END
223
224## GLOSSARY [RECOMMENDED when abbreviations exist]
225
226**TERM1**: [Definition]
227**TERM2**: [Definition]
228```