ace-handbook 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.ace-defaults/handbook/config.yml +4 -0
- data/.ace-defaults/nav/protocols/guide-sources/ace-handbook.yml +19 -0
- data/.ace-defaults/nav/protocols/tmpl-sources/ace-handbook.yml +10 -0
- data/.ace-defaults/nav/protocols/wfi-sources/ace-handbook.yml +19 -0
- data/CHANGELOG.md +362 -0
- data/LICENSE +21 -0
- data/README.md +42 -0
- data/Rakefile +12 -0
- data/exe/ace-handbook +6 -0
- data/handbook/guides/ai-agent-integration.g.md +625 -0
- data/handbook/guides/atom-pattern.g.md +371 -0
- data/handbook/guides/changelog.g.md +333 -0
- data/handbook/guides/cli-dry-cli.g.md +276 -0
- data/handbook/guides/cli-support-cli.g.md +277 -0
- data/handbook/guides/coding-standards/ruby.md +41 -0
- data/handbook/guides/coding-standards/rust.md +19 -0
- data/handbook/guides/coding-standards/typescript.md +20 -0
- data/handbook/guides/coding-standards.g.md +134 -0
- data/handbook/guides/debug-troubleshooting.g.md +62 -0
- data/handbook/guides/error-handling/ruby.md +29 -0
- data/handbook/guides/error-handling/rust.md +59 -0
- data/handbook/guides/error-handling/typescript.md +38 -0
- data/handbook/guides/error-handling.g.md +207 -0
- data/handbook/guides/meta/agents-definition.g.md +823 -0
- data/handbook/guides/meta/guides-definition.g.md +322 -0
- data/handbook/guides/meta/markdown-definition.g.md +210 -0
- data/handbook/guides/meta/tools-definition.g.md +159 -0
- data/handbook/guides/meta/workflow-instructions-definition.g.md +367 -0
- data/handbook/guides/mono-repo-patterns.g.md +92 -0
- data/handbook/guides/multi-agent-research.g.md +251 -0
- data/handbook/guides/performance/ruby.md +25 -0
- data/handbook/guides/performance/rust.md +48 -0
- data/handbook/guides/performance/typescript.md +32 -0
- data/handbook/guides/performance.g.md +211 -0
- data/handbook/guides/prompt-caching.g.md +83 -0
- data/handbook/guides/quality-assurance/ruby.md +33 -0
- data/handbook/guides/quality-assurance/rust.md +41 -0
- data/handbook/guides/quality-assurance/typescript.md +49 -0
- data/handbook/guides/quality-assurance.g.md +222 -0
- data/handbook/guides/strategic-planning.g.md +69 -0
- data/handbook/guides/troubleshooting/ruby.md +21 -0
- data/handbook/guides/troubleshooting/rust.md +20 -0
- data/handbook/guides/troubleshooting/typescript.md +36 -0
- data/handbook/guides/workflow-context-embedding.g.md +286 -0
- data/handbook/skills/as-handbook-init-project/SKILL.md +34 -0
- data/handbook/skills/as-handbook-manage-agents/SKILL.md +35 -0
- data/handbook/skills/as-handbook-manage-guides/SKILL.md +35 -0
- data/handbook/skills/as-handbook-manage-workflows/SKILL.md +35 -0
- data/handbook/skills/as-handbook-parallel-research/SKILL.md +29 -0
- data/handbook/skills/as-handbook-perform-delivery/SKILL.md +35 -0
- data/handbook/skills/as-handbook-review-guides/SKILL.md +32 -0
- data/handbook/skills/as-handbook-review-workflows/SKILL.md +32 -0
- data/handbook/skills/as-handbook-synthesize-research/SKILL.md +29 -0
- data/handbook/skills/as-handbook-update-docs/SKILL.md +35 -0
- data/handbook/skills/as-release/SKILL.md +50 -0
- data/handbook/skills/as-release-bump-version/SKILL.md +28 -0
- data/handbook/skills/as-release-rubygems-publish/SKILL.md +58 -0
- data/handbook/skills/as-release-update-changelog/SKILL.md +28 -0
- data/handbook/templates/completed-work-documentation.md +59 -0
- data/handbook/templates/cookbooks/cookbook.template.md +237 -0
- data/handbook/templates/research-comparison.template.md +175 -0
- data/handbook/workflow-instructions/handbook/init-project.wf.md +629 -0
- data/handbook/workflow-instructions/handbook/manage-agents.wf.md +379 -0
- data/handbook/workflow-instructions/handbook/manage-guides.wf.md +294 -0
- data/handbook/workflow-instructions/handbook/manage-workflows.wf.md +292 -0
- data/handbook/workflow-instructions/handbook/parallel-research.wf.md +328 -0
- data/handbook/workflow-instructions/handbook/perform-delivery.wf.md +267 -0
- data/handbook/workflow-instructions/handbook/research.wf.md +247 -0
- data/handbook/workflow-instructions/handbook/review-guides.wf.md +348 -0
- data/handbook/workflow-instructions/handbook/review-workflows.wf.md +299 -0
- data/handbook/workflow-instructions/handbook/synthesize-research.wf.md +429 -0
- data/handbook/workflow-instructions/handbook/update-docs.wf.md +338 -0
- data/lib/ace/handbook/atoms/provider_registry.rb +70 -0
- data/lib/ace/handbook/cli/commands/status.rb +36 -0
- data/lib/ace/handbook/cli/commands/sync.rb +36 -0
- data/lib/ace/handbook/cli.rb +51 -0
- data/lib/ace/handbook/models/skill_document.rb +25 -0
- data/lib/ace/handbook/molecules/skill_projection.rb +54 -0
- data/lib/ace/handbook/organisms/provider_syncer.rb +106 -0
- data/lib/ace/handbook/organisms/skill_inventory.rb +54 -0
- data/lib/ace/handbook/organisms/status_collector.rb +181 -0
- data/lib/ace/handbook/version.rb +7 -0
- data/lib/ace/handbook.rb +28 -0
- metadata +227 -0
|
@@ -0,0 +1,823 @@
|
|
|
1
|
+
---
|
|
2
|
+
doc-type: guide
|
|
3
|
+
title: Writing Agent Definitions
|
|
4
|
+
purpose: Documentation for ace-handbook/handbook/guides/meta/agents-definition.g.md
|
|
5
|
+
ace-docs:
|
|
6
|
+
last-updated: 2026-01-17
|
|
7
|
+
last-checked: 2026-03-21
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Writing Agent Definitions
|
|
11
|
+
|
|
12
|
+
This guide outlines best practices for creating and maintaining agent definitions located within the `.claude/agents/` directory. These agents serve as specialized task handlers that can be invoked directly by Claude Code or enhanced through the MCP proxy system.
|
|
13
|
+
|
|
14
|
+
## Goal of Agents
|
|
15
|
+
|
|
16
|
+
The primary goal of agents is to:
|
|
17
|
+
- Provide specialized, context-aware assistance for specific development tasks
|
|
18
|
+
- Minimize context window usage through efficient data loading strategies
|
|
19
|
+
- Enable both direct Claude Code usage and enhanced MCP proxy features
|
|
20
|
+
- Standardize task execution patterns across different domains
|
|
21
|
+
- Facilitate autonomous operation with minimal human intervention
|
|
22
|
+
|
|
23
|
+
## File Naming Convention
|
|
24
|
+
|
|
25
|
+
All agent files must use the `.ag.md` suffix to distinguish them from other documentation types. This convention enables proper identification and tooling support.
|
|
26
|
+
|
|
27
|
+
### Naming Pattern
|
|
28
|
+
- **Format:** `<agent-name>.ag.md`
|
|
29
|
+
- **Style:** Use descriptive names that indicate the agent's primary function
|
|
30
|
+
- **Examples:**
|
|
31
|
+
- `git-commit.ag.md` (not `git-commit-manager.md`)
|
|
32
|
+
- `task-manager.ag.md` (not `task-manager-agent.md`)
|
|
33
|
+
- `code-review.ag.md` (not `code-reviewer.md`)
|
|
34
|
+
- `search.ag.md` (not `search-agent.md`)
|
|
35
|
+
|
|
36
|
+
### File Type Suffixes
|
|
37
|
+
The project uses consistent suffixes to identify different content types:
|
|
38
|
+
- **`.ag.md`** - Agent definitions (this guide)
|
|
39
|
+
- **`.g.md`** - Development guides
|
|
40
|
+
- **`.wf.md`** - Workflow instructions
|
|
41
|
+
- **`.md`** - General documentation
|
|
42
|
+
|
|
43
|
+
This naming distinction helps both humans and tools quickly identify agent definitions versus other documentation types.
|
|
44
|
+
|
|
45
|
+
## Core Principles
|
|
46
|
+
|
|
47
|
+
### 1. Start Minimal
|
|
48
|
+
**Principle:** Agents don't need all data, just enough to make informed decisions.
|
|
49
|
+
|
|
50
|
+
**Implementation:**
|
|
51
|
+
- Load metadata instead of full file contents when possible
|
|
52
|
+
- Use command outputs over file reading
|
|
53
|
+
- Start with 5-6 essential commands maximum
|
|
54
|
+
- Add complexity only based on actual usage patterns
|
|
55
|
+
|
|
56
|
+
**Example from task-manager-agent:**
|
|
57
|
+
```yaml
|
|
58
|
+
# Minimal context - just commands, no file content
|
|
59
|
+
commands:
|
|
60
|
+
- release-manager current
|
|
61
|
+
- task-manager list
|
|
62
|
+
- task-manager next --limit 5
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2. Dynamic Discovery Over Hard-Coded Values
|
|
66
|
+
**Principle:** Use commands to discover current state rather than embedding static paths.
|
|
67
|
+
|
|
68
|
+
**Implementation:**
|
|
69
|
+
- Query for current release/branch/status dynamically
|
|
70
|
+
- Use relative paths resolved at runtime
|
|
71
|
+
- Leverage existing tools for navigation
|
|
72
|
+
- Avoid hard-coding version numbers or release names
|
|
73
|
+
|
|
74
|
+
**Example:**
|
|
75
|
+
```bash
|
|
76
|
+
# Good: Dynamic discovery
|
|
77
|
+
release-manager current # Discovers current release
|
|
78
|
+
|
|
79
|
+
# Bad: Hard-coded path
|
|
80
|
+
cd dev-taskflow/current/v.0.5.0-insights/ # Version will change
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 3. Work at Metadata Level
|
|
84
|
+
**Principle:** Operate on file lists and metadata rather than loading full content.
|
|
85
|
+
|
|
86
|
+
**Implementation:**
|
|
87
|
+
- Use file listings to understand structure
|
|
88
|
+
- Extract metadata from filenames and paths
|
|
89
|
+
- Load content only when transformation is needed
|
|
90
|
+
- Batch metadata operations for efficiency
|
|
91
|
+
|
|
92
|
+
### 4. Research Before Designing
|
|
93
|
+
**Principle:** Analyze actual usage patterns before creating agent workflows.
|
|
94
|
+
|
|
95
|
+
**Implementation:**
|
|
96
|
+
- Study how humans perform the task
|
|
97
|
+
- Identify common command sequences
|
|
98
|
+
- Document discovered patterns
|
|
99
|
+
- Test with real scenarios
|
|
100
|
+
|
|
101
|
+
### 5. Single Source of Truth
|
|
102
|
+
**Principle:** Maintain agents in one canonical location with clear versioning.
|
|
103
|
+
|
|
104
|
+
**Implementation:**
|
|
105
|
+
- All agents in `.claude/agents/` directory
|
|
106
|
+
- Use `last_modified` field for versioning
|
|
107
|
+
- Document migration paths for updates
|
|
108
|
+
- Avoid duplicate agent definitions
|
|
109
|
+
|
|
110
|
+
### 6. Single Purpose Design
|
|
111
|
+
**Principle:** Each agent should have exactly ONE primary purpose.
|
|
112
|
+
|
|
113
|
+
**Implementation:**
|
|
114
|
+
- Split complex agents into focused, single-purpose agents
|
|
115
|
+
- Clear separation between "execute" vs "analyze" agents
|
|
116
|
+
- Each agent does one thing exceptionally well
|
|
117
|
+
|
|
118
|
+
**Anti-pattern:** Multi-purpose agent
|
|
119
|
+
```yaml
|
|
120
|
+
name: git-manager
|
|
121
|
+
description: Handles commits, reviews, staging, and history
|
|
122
|
+
# TOO BROAD - will be used incorrectly
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Good pattern:** Focused agents
|
|
126
|
+
```yaml
|
|
127
|
+
name: git-fast-commit
|
|
128
|
+
description: FAST direct commit execution - NO analysis
|
|
129
|
+
|
|
130
|
+
name: git-review-commit
|
|
131
|
+
description: ANALYZE and REVIEW changes before committing
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Agent Naming and Description Guidelines
|
|
135
|
+
|
|
136
|
+
### Naming Patterns
|
|
137
|
+
**Action-First Names:**
|
|
138
|
+
- `fast-commit` - Immediate execution
|
|
139
|
+
- `review-commit` - Analysis first
|
|
140
|
+
- `fix-tests` - Direct action
|
|
141
|
+
- `analyze-tests` - Investigation first
|
|
142
|
+
|
|
143
|
+
**Avoid:**
|
|
144
|
+
- Generic names (`manager`, `helper`, `assistant`)
|
|
145
|
+
- Similar names that differ only slightly
|
|
146
|
+
- Names that don't indicate the action
|
|
147
|
+
|
|
148
|
+
### Description Format
|
|
149
|
+
```
|
|
150
|
+
[ACTION_KEYWORD] [specific purpose] - [what it does NOT do]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Examples:
|
|
154
|
+
- "FAST direct commit execution - NO analysis or review"
|
|
155
|
+
- "ANALYZE and REVIEW changes - does NOT auto-commit"
|
|
156
|
+
- "FIX failing tests immediately - NO investigation"
|
|
157
|
+
|
|
158
|
+
### Keywords to Use
|
|
159
|
+
- **Execution**: FAST, DIRECT, IMMEDIATE, EXECUTE
|
|
160
|
+
- **Analysis**: ANALYZE, REVIEW, INSPECT, INVESTIGATE
|
|
161
|
+
- **Scope limiters**: ONLY, NO, WITHOUT, JUST
|
|
162
|
+
|
|
163
|
+
## Agent Format Specification
|
|
164
|
+
|
|
165
|
+
### File Structure
|
|
166
|
+
Agents use Markdown with YAML frontmatter for metadata and embedded context definitions.
|
|
167
|
+
|
|
168
|
+
```markdown
|
|
169
|
+
---
|
|
170
|
+
# Core metadata (required for all agents)
|
|
171
|
+
name: agent-name
|
|
172
|
+
description: When to use this agent (clear, specific triggers)
|
|
173
|
+
# tools: [optional - often better to omit]
|
|
174
|
+
expected_params: # Document expected inputs (optional)
|
|
175
|
+
optional:
|
|
176
|
+
- param_name: "Description of parameter"
|
|
177
|
+
required:
|
|
178
|
+
- param_name: "Description of required parameter"
|
|
179
|
+
last_modified: 'YYYY-MM-DD'
|
|
180
|
+
type: agent
|
|
181
|
+
|
|
182
|
+
# MCP proxy enhancements (optional, ignored by Claude Code)
|
|
183
|
+
mcp:
|
|
184
|
+
model: provider:model-name
|
|
185
|
+
tools_mapping:
|
|
186
|
+
tool-name:
|
|
187
|
+
expose: true
|
|
188
|
+
methods: [allowed, methods]
|
|
189
|
+
resources: [mcp, resources]
|
|
190
|
+
prompts: [prompt, templates]
|
|
191
|
+
security:
|
|
192
|
+
allowed_paths: [path, patterns]
|
|
193
|
+
rate_limit: requests/hour
|
|
194
|
+
|
|
195
|
+
# Context configuration
|
|
196
|
+
bundle:
|
|
197
|
+
auto_inject: true|false
|
|
198
|
+
template: embedded|path/to/template
|
|
199
|
+
cache_ttl: seconds
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
# Agent Instructions
|
|
203
|
+
|
|
204
|
+
Natural language instructions for the agent...
|
|
205
|
+
|
|
206
|
+
## Context Definition
|
|
207
|
+
|
|
208
|
+
```yaml
|
|
209
|
+
files:
|
|
210
|
+
- path/patterns/*.md
|
|
211
|
+
commands:
|
|
212
|
+
- command-to-execute
|
|
213
|
+
- another-command --with-flags
|
|
214
|
+
format: markdown-xml
|
|
215
|
+
```
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Metadata Fields
|
|
219
|
+
|
|
220
|
+
#### Required Fields
|
|
221
|
+
- **name**: Unique identifier for the agent (kebab-case)
|
|
222
|
+
- **description**: Clear description of when to use this agent
|
|
223
|
+
- **last_modified**: ISO date of last significant update
|
|
224
|
+
- **type**: Always "agent" for agent definitions
|
|
225
|
+
|
|
226
|
+
#### Optional Fields
|
|
227
|
+
- **tools**: (Often better to omit)
|
|
228
|
+
- If specified: Comma-separated list like `Read, Edit` (no brackets)
|
|
229
|
+
- **BEST PRACTICE**: Omit this field to inherit permissions from settings.json
|
|
230
|
+
- This ensures agents respect tool restrictions and wrapper enforcement
|
|
231
|
+
- Only specify if you need to explicitly limit agent to specific tools
|
|
232
|
+
- **expected_params**: Document expected inputs for the agent
|
|
233
|
+
- `required`: List of parameters that must be provided
|
|
234
|
+
- `optional`: List of parameters with defaults
|
|
235
|
+
- Format: `- param_name: "Description"`
|
|
236
|
+
- Helps users understand what inputs the agent expects
|
|
237
|
+
|
|
238
|
+
#### Optional MCP Fields
|
|
239
|
+
- **mcp.model**: Preferred model for this agent's tasks
|
|
240
|
+
- **mcp.tools_mapping**: Fine-grained tool access control
|
|
241
|
+
- **mcp.security**: Path restrictions and rate limiting
|
|
242
|
+
- **mcp.resources**: MCP-specific resources
|
|
243
|
+
- **mcp.prompts**: Reusable prompt templates
|
|
244
|
+
|
|
245
|
+
#### Context Configuration
|
|
246
|
+
- **context.auto_inject**: Whether to auto-load context
|
|
247
|
+
- **context.template**: Location of context template
|
|
248
|
+
- **context.cache_ttl**: Cache duration in seconds
|
|
249
|
+
|
|
250
|
+
## Context Optimization Strategies
|
|
251
|
+
|
|
252
|
+
### 1. Command-Based Context
|
|
253
|
+
Prefer commands that return structured data over file reading:
|
|
254
|
+
|
|
255
|
+
```yaml
|
|
256
|
+
# Efficient: Commands return just what's needed
|
|
257
|
+
commands:
|
|
258
|
+
- task-manager list --filter status:pending
|
|
259
|
+
- git-status --short
|
|
260
|
+
|
|
261
|
+
# Inefficient: Loading entire files
|
|
262
|
+
files:
|
|
263
|
+
- dev-taskflow/**/*.md # Too much content
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### 2. Progressive Context Loading
|
|
267
|
+
Start with minimal context, expand based on need:
|
|
268
|
+
|
|
269
|
+
```yaml
|
|
270
|
+
# Level 1: Discovery
|
|
271
|
+
commands:
|
|
272
|
+
- release-manager current
|
|
273
|
+
|
|
274
|
+
# Level 2: Listing (if needed)
|
|
275
|
+
commands:
|
|
276
|
+
- task-manager list
|
|
277
|
+
|
|
278
|
+
# Level 3: Details (only if required)
|
|
279
|
+
files:
|
|
280
|
+
- specific/file.md
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### 3. Metadata Extraction Patterns
|
|
284
|
+
Use commands that provide metadata without content:
|
|
285
|
+
|
|
286
|
+
```yaml
|
|
287
|
+
commands:
|
|
288
|
+
- ls -la directory/ # File metadata
|
|
289
|
+
- git log --oneline -10 # Commit metadata
|
|
290
|
+
- grep -l "pattern" *.md # Files containing pattern
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### 4. Context Templates
|
|
294
|
+
Create reusable context templates for common patterns:
|
|
295
|
+
|
|
296
|
+
```yaml
|
|
297
|
+
# Embedded template
|
|
298
|
+
bundle:
|
|
299
|
+
template: embedded
|
|
300
|
+
|
|
301
|
+
# External template (reusable)
|
|
302
|
+
bundle:
|
|
303
|
+
template: .claude/contexts/project-overview.yaml
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Agent Response Format
|
|
307
|
+
|
|
308
|
+
### Standardized Response Structure
|
|
309
|
+
Agents should provide clear, structured responses back to their parent (user or calling agent):
|
|
310
|
+
|
|
311
|
+
```markdown
|
|
312
|
+
## Summary
|
|
313
|
+
[1-2 sentence overview of what was accomplished]
|
|
314
|
+
|
|
315
|
+
## Results
|
|
316
|
+
[Main findings, actions taken, or items discovered]
|
|
317
|
+
- Key result 1
|
|
318
|
+
- Key result 2
|
|
319
|
+
- Key result 3
|
|
320
|
+
|
|
321
|
+
## Next Steps (if applicable)
|
|
322
|
+
[Suggested follow-up actions or delegations]
|
|
323
|
+
|
|
324
|
+
## Issues (if any)
|
|
325
|
+
[Any problems encountered or limitations]
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Response Guidelines
|
|
329
|
+
|
|
330
|
+
1. **Be Concise**: Keep responses focused and actionable
|
|
331
|
+
2. **Highlight Key Information**: Use formatting to emphasize important results
|
|
332
|
+
3. **Suggest Delegations**: When appropriate, suggest which agent to use next
|
|
333
|
+
4. **Report Errors Clearly**: Explain what failed and potential solutions
|
|
334
|
+
5. **Include Metrics**: When relevant, include counts, statistics, or measurements
|
|
335
|
+
|
|
336
|
+
### Example Response Patterns
|
|
337
|
+
|
|
338
|
+
#### Success Response (task-finder)
|
|
339
|
+
```markdown
|
|
340
|
+
## Summary
|
|
341
|
+
Found 5 pending high-priority tasks in the current release.
|
|
342
|
+
|
|
343
|
+
## Results
|
|
344
|
+
- Task 001: Implement authentication (HIGH)
|
|
345
|
+
- Task 003: Fix database migration (HIGH)
|
|
346
|
+
- Task 007: Update API documentation (MEDIUM)
|
|
347
|
+
|
|
348
|
+
## Next Steps
|
|
349
|
+
Use task-creator agent if you need to add more tasks.
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
#### Delegation Response (task-creator)
|
|
353
|
+
```markdown
|
|
354
|
+
## Summary
|
|
355
|
+
Need current release context before creating task.
|
|
356
|
+
|
|
357
|
+
## Delegating
|
|
358
|
+
Invoking release-navigator to get current release...
|
|
359
|
+
[After delegation completes]
|
|
360
|
+
Created task v.0.5.0+task.042 in current release.
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
#### Error Response
|
|
364
|
+
```markdown
|
|
365
|
+
## Summary
|
|
366
|
+
Unable to complete the requested operation.
|
|
367
|
+
|
|
368
|
+
## Issue
|
|
369
|
+
No current release found in dev-taskflow.
|
|
370
|
+
|
|
371
|
+
## Suggested Solution
|
|
372
|
+
1. Check if dev-taskflow is properly initialized
|
|
373
|
+
2. Use release-navigator to see all available releases
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Common Patterns
|
|
377
|
+
|
|
378
|
+
### Task Management Agent Pattern
|
|
379
|
+
Focuses on task discovery and navigation without content loading:
|
|
380
|
+
|
|
381
|
+
```yaml
|
|
382
|
+
commands:
|
|
383
|
+
- release-manager current
|
|
384
|
+
- task-manager list
|
|
385
|
+
- task-manager next --limit 5
|
|
386
|
+
- task-manager recent --limit 3
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Code Review Agent Pattern
|
|
390
|
+
Loads specific files for review with structured output:
|
|
391
|
+
|
|
392
|
+
```yaml
|
|
393
|
+
files:
|
|
394
|
+
- ${review_target}/**/*.rb
|
|
395
|
+
commands:
|
|
396
|
+
- git diff --cached
|
|
397
|
+
- rubocop --format json ${review_target}
|
|
398
|
+
format: markdown-xml
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### Search Agent Pattern
|
|
402
|
+
Combines multiple search strategies efficiently:
|
|
403
|
+
|
|
404
|
+
```yaml
|
|
405
|
+
commands:
|
|
406
|
+
- grep -r "${search_term}" . --include="*.md"
|
|
407
|
+
- find . -name "*${search_term}*" -type f
|
|
408
|
+
- git log --grep="${search_term}" --oneline
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
## Anti-Patterns to Avoid
|
|
412
|
+
|
|
413
|
+
### 1. Loading Everything Upfront
|
|
414
|
+
**Bad:**
|
|
415
|
+
```yaml
|
|
416
|
+
files:
|
|
417
|
+
- /**/*.md # Loads entire project
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
**Good:**
|
|
421
|
+
```yaml
|
|
422
|
+
commands:
|
|
423
|
+
- find . -name "*.md" -type f | head -20 # Just listings
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### 2. Hard-Coded Paths
|
|
427
|
+
**Bad:**
|
|
428
|
+
```yaml
|
|
429
|
+
files:
|
|
430
|
+
- dev-taskflow/current/v.0.5.0/tasks/*.md # Version-specific
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
**Good:**
|
|
434
|
+
```yaml
|
|
435
|
+
commands:
|
|
436
|
+
- release-manager current # Discover current version
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### 3. Redundant Context
|
|
440
|
+
**Bad:**
|
|
441
|
+
```yaml
|
|
442
|
+
files:
|
|
443
|
+
- README.md
|
|
444
|
+
- docs/README.md
|
|
445
|
+
- project/README.md # Multiple similar files
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
**Good:**
|
|
449
|
+
```yaml
|
|
450
|
+
files:
|
|
451
|
+
- README.md # Just the essential one
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### 4. Missing Error Handling
|
|
455
|
+
**Bad:**
|
|
456
|
+
```bash
|
|
457
|
+
cd specific/directory
|
|
458
|
+
cat required-file.md # Assumes file exists
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
**Good:**
|
|
462
|
+
```bash
|
|
463
|
+
if [ -f "required-file.md" ]; then
|
|
464
|
+
cat required-file.md
|
|
465
|
+
else
|
|
466
|
+
echo "File not found, using defaults"
|
|
467
|
+
fi
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
## Testing and Validation
|
|
471
|
+
|
|
472
|
+
### 1. Dual Compatibility Testing
|
|
473
|
+
Test agents in both environments:
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
# Direct Claude Code test
|
|
477
|
+
# 1. Open Claude Code
|
|
478
|
+
# 2. Invoke agent directly
|
|
479
|
+
# 3. Verify core functionality works
|
|
480
|
+
|
|
481
|
+
# MCP Proxy test
|
|
482
|
+
mcp-proxy --config test-config.yaml
|
|
483
|
+
# Invoke agent through proxy
|
|
484
|
+
# Verify enhanced features work
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### 2. Context Efficiency Testing
|
|
488
|
+
Measure and optimize context usage:
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
# Measure context size
|
|
492
|
+
context .claude/agents/agent-name.md | wc -c
|
|
493
|
+
|
|
494
|
+
# Target: <10KB for simple agents, <50KB for complex
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
### 3. Performance Validation
|
|
498
|
+
Ensure agents respond quickly:
|
|
499
|
+
|
|
500
|
+
- Initial response: <2 seconds
|
|
501
|
+
- Context loading: <500ms
|
|
502
|
+
- Command execution: <1 second per command
|
|
503
|
+
|
|
504
|
+
### 4. Error Resilience Testing
|
|
505
|
+
Verify graceful degradation:
|
|
506
|
+
|
|
507
|
+
- Missing files: Agent continues with available data
|
|
508
|
+
- Failed commands: Clear error reporting
|
|
509
|
+
- Unavailable tools: Fallback strategies work
|
|
510
|
+
|
|
511
|
+
## Agent Creation Workflow
|
|
512
|
+
|
|
513
|
+
### 1. Research Phase
|
|
514
|
+
```bash
|
|
515
|
+
# Analyze how task is currently done
|
|
516
|
+
task-manager recent --limit 10
|
|
517
|
+
git log --oneline -20
|
|
518
|
+
|
|
519
|
+
# Document command patterns
|
|
520
|
+
echo "Common commands:" > agent-research.md
|
|
521
|
+
history | grep "relevant-pattern" >> agent-research.md
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### 2. Prototype Phase
|
|
525
|
+
Create minimal agent with core functionality:
|
|
526
|
+
|
|
527
|
+
```yaml
|
|
528
|
+
---
|
|
529
|
+
name: prototype-agent
|
|
530
|
+
description: Testing new agent pattern
|
|
531
|
+
# tools: omitted to inherit from settings
|
|
532
|
+
last_modified: '2025-08-14'
|
|
533
|
+
type: agent
|
|
534
|
+
---
|
|
535
|
+
|
|
536
|
+
Basic instructions...
|
|
537
|
+
|
|
538
|
+
## Context Definition
|
|
539
|
+
```yaml
|
|
540
|
+
commands:
|
|
541
|
+
- single-test-command
|
|
542
|
+
```
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
### 3. Enhancement Phase
|
|
546
|
+
Add features based on usage:
|
|
547
|
+
|
|
548
|
+
- Observe actual usage patterns
|
|
549
|
+
- Add commonly needed commands
|
|
550
|
+
- Introduce MCP enhancements if beneficial
|
|
551
|
+
- Document common workflows
|
|
552
|
+
|
|
553
|
+
### 4. Optimization Phase
|
|
554
|
+
Reduce context and improve efficiency:
|
|
555
|
+
|
|
556
|
+
- Replace file loads with commands
|
|
557
|
+
- Remove redundant context
|
|
558
|
+
- Add caching where appropriate
|
|
559
|
+
- Optimize command sequences
|
|
560
|
+
|
|
561
|
+
## Tool Access and Permissions
|
|
562
|
+
|
|
563
|
+
### Custom Tool Wrappers
|
|
564
|
+
When agents need to use custom executables (like git wrapper tools):
|
|
565
|
+
|
|
566
|
+
1. **Agent Definition**: Omit the `tools:` field entirely (best practice)
|
|
567
|
+
2. **Permission Configuration**: Use settings.json to enforce tool restrictions
|
|
568
|
+
3. **Result**: Agent inherits all permissions, ensuring wrapper tools are used
|
|
569
|
+
|
|
570
|
+
Example for git wrapper tools:
|
|
571
|
+
```json
|
|
572
|
+
{
|
|
573
|
+
"permissions": {
|
|
574
|
+
"deny": [
|
|
575
|
+
"Bash(git status*)", // Deny native git commands
|
|
576
|
+
"Bash(git commit*)",
|
|
577
|
+
"Bash(git add*)"
|
|
578
|
+
],
|
|
579
|
+
"allow": [
|
|
580
|
+
"Bash(git-status*)", // Allow wrapper tools only
|
|
581
|
+
"Bash(git-commit*)",
|
|
582
|
+
"Bash(git-add*)"
|
|
583
|
+
]
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
This pattern:
|
|
589
|
+
- Forces use of enhanced wrapper tools
|
|
590
|
+
- Prevents accidental use of native commands
|
|
591
|
+
- Provides security through permission boundaries
|
|
592
|
+
- Works with Claude Code's existing permission system
|
|
593
|
+
|
|
594
|
+
## Best Practices Summary
|
|
595
|
+
|
|
596
|
+
1. **Start Simple**: Begin with 5-6 essential commands
|
|
597
|
+
2. **Iterate Based on Usage**: Add complexity only when needed
|
|
598
|
+
3. **Prefer Commands**: Use commands over file loading
|
|
599
|
+
4. **Dynamic Discovery**: Avoid hard-coded values
|
|
600
|
+
5. **Document Workflows**: Include common usage patterns
|
|
601
|
+
6. **Test Both Modes**: Ensure Claude Code and MCP compatibility
|
|
602
|
+
7. **Optimize Context**: Minimize token usage
|
|
603
|
+
8. **Handle Errors**: Graceful degradation is essential
|
|
604
|
+
9. **Version Properly**: Update last_modified on changes
|
|
605
|
+
10. **Single Source**: Maintain agents in .claude/agents/ only
|
|
606
|
+
11. **Secure Tool Access**: Use permission rules for custom tools
|
|
607
|
+
|
|
608
|
+
## Migration Guide
|
|
609
|
+
|
|
610
|
+
### From Old Format to Enhanced Format
|
|
611
|
+
When updating existing agents:
|
|
612
|
+
|
|
613
|
+
1. Add YAML frontmatter with required fields
|
|
614
|
+
2. Move context to Context Definition section
|
|
615
|
+
3. Add MCP metadata (optional)
|
|
616
|
+
4. Test in both environments
|
|
617
|
+
5. Update last_modified date
|
|
618
|
+
|
|
619
|
+
### Example Migration
|
|
620
|
+
**Before:**
|
|
621
|
+
```markdown
|
|
622
|
+
# Git Commit Agent
|
|
623
|
+
|
|
624
|
+
You help with commits...
|
|
625
|
+
|
|
626
|
+
Load these files:
|
|
627
|
+
- file1.md
|
|
628
|
+
- file2.md
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
**After:**
|
|
632
|
+
```markdown
|
|
633
|
+
---
|
|
634
|
+
name: git-commit-manager
|
|
635
|
+
description: Intelligent git commit assistance
|
|
636
|
+
# tools: omitted to respect git wrapper enforcement
|
|
637
|
+
last_modified: '2025-08-14'
|
|
638
|
+
type: agent
|
|
639
|
+
---
|
|
640
|
+
|
|
641
|
+
You help with commits...
|
|
642
|
+
|
|
643
|
+
## Context Definition
|
|
644
|
+
```yaml
|
|
645
|
+
files:
|
|
646
|
+
- file1.md
|
|
647
|
+
- file2.md
|
|
648
|
+
```
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
## References
|
|
652
|
+
|
|
653
|
+
- Task 013: Context Loading Tool Implementation
|
|
654
|
+
- Task 014: MCP Proxy Server Architecture
|
|
655
|
+
- Task 015: Enhanced Markdown Agents Specification
|
|
656
|
+
- Existing Agents: `.claude/agents/` directory
|
|
657
|
+
- Original Idea: `dev-taskflow/backlog/ideas/20250814-1859-*.md`
|
|
658
|
+
|
|
659
|
+
---
|
|
660
|
+
|
|
661
|
+
*This guide should be updated as new patterns emerge and agent capabilities evolve. Focus on maintaining efficiency, clarity, and dual compatibility as core values.*
|
|
662
|
+
|
|
663
|
+
<documents>
|
|
664
|
+
<template path="tmpl://meta/agent">
|
|
665
|
+
---
|
|
666
|
+
# Core metadata (both Claude Code and MCP proxy compatible)
|
|
667
|
+
name: #{agent_name}
|
|
668
|
+
description: #{agent_description}
|
|
669
|
+
# tools: [optional - consider omitting]
|
|
670
|
+
last_modified: '#{date}'
|
|
671
|
+
type: agent
|
|
672
|
+
|
|
673
|
+
# MCP proxy enhancements (optional - remove if not needed)
|
|
674
|
+
mcp:
|
|
675
|
+
model: #{mcp_model} # e.g., google:gemini-2.5-flash
|
|
676
|
+
tools_mapping:
|
|
677
|
+
#{tool_name}:
|
|
678
|
+
expose: true
|
|
679
|
+
methods: [#{allowed_methods}]
|
|
680
|
+
security:
|
|
681
|
+
allowed_paths:
|
|
682
|
+
- "#{path_pattern}"
|
|
683
|
+
rate_limit: #{rate}/hour
|
|
684
|
+
|
|
685
|
+
# Context configuration
|
|
686
|
+
bundle:
|
|
687
|
+
auto_inject: #{auto_inject} # true or false
|
|
688
|
+
template: embedded # or path to external template
|
|
689
|
+
cache_ttl: #{cache_seconds} # e.g., 300 for 5 minutes
|
|
690
|
+
---
|
|
691
|
+
|
|
692
|
+
You are a #{agent_role} focused on #{agent_focus}.
|
|
693
|
+
|
|
694
|
+
## Core Responsibilities
|
|
695
|
+
|
|
696
|
+
#{agent_responsibilities}
|
|
697
|
+
|
|
698
|
+
## Key Commands
|
|
699
|
+
|
|
700
|
+
```bash
|
|
701
|
+
# Primary operations
|
|
702
|
+
#{primary_commands}
|
|
703
|
+
|
|
704
|
+
# Discovery and navigation
|
|
705
|
+
#{discovery_commands}
|
|
706
|
+
|
|
707
|
+
# Status and reporting
|
|
708
|
+
#{status_commands}
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
## Common Workflows
|
|
712
|
+
|
|
713
|
+
### Workflow 1: #{workflow_1_name}
|
|
714
|
+
```bash
|
|
715
|
+
#{workflow_1_commands}
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
### Workflow 2: #{workflow_2_name}
|
|
719
|
+
```bash
|
|
720
|
+
#{workflow_2_commands}
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
## Best Practices
|
|
724
|
+
|
|
725
|
+
1. **#{practice_1_title}**: #{practice_1_description}
|
|
726
|
+
2. **#{practice_2_title}**: #{practice_2_description}
|
|
727
|
+
3. **#{practice_3_title}**: #{practice_3_description}
|
|
728
|
+
|
|
729
|
+
## Context Definition
|
|
730
|
+
|
|
731
|
+
```yaml
|
|
732
|
+
# Minimal context - prefer commands over file loading
|
|
733
|
+
commands:
|
|
734
|
+
# Discovery commands (get current state)
|
|
735
|
+
- #{discovery_command_1}
|
|
736
|
+
- #{discovery_command_2}
|
|
737
|
+
|
|
738
|
+
# Primary operations
|
|
739
|
+
- #{operation_command_1}
|
|
740
|
+
- #{operation_command_2}
|
|
741
|
+
|
|
742
|
+
# Status checks
|
|
743
|
+
- #{status_command_1}
|
|
744
|
+
|
|
745
|
+
# Only load files if absolutely necessary
|
|
746
|
+
files:
|
|
747
|
+
- #{essential_file_pattern} # Only if content needed
|
|
748
|
+
|
|
749
|
+
format: markdown-xml
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
## Input Validation and Parameter Handling
|
|
753
|
+
|
|
754
|
+
### Expected Parameters Pattern
|
|
755
|
+
Agents should clearly document and validate expected inputs:
|
|
756
|
+
|
|
757
|
+
```yaml
|
|
758
|
+
expected_params:
|
|
759
|
+
required:
|
|
760
|
+
- files: "List of files to commit"
|
|
761
|
+
- action: "Action to perform"
|
|
762
|
+
optional:
|
|
763
|
+
- intention: "Description of changes (auto-generated if not provided)"
|
|
764
|
+
- verbose: "Enable verbose output (default: false)"
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
### Validation Rules in Agent Prompt
|
|
768
|
+
```markdown
|
|
769
|
+
**VALIDATION RULES**:
|
|
770
|
+
1. Required inputs MUST be provided - STOP if missing
|
|
771
|
+
2. Do NOT generate missing required inputs
|
|
772
|
+
3. Optional inputs can use defaults
|
|
773
|
+
4. Validate inputs before execution
|
|
774
|
+
|
|
775
|
+
**EXPECTED PARAMETERS**:
|
|
776
|
+
- `files` (OPTIONAL): List of files to process
|
|
777
|
+
- `intention` (OPTIONAL): User's description of changes
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
### Handling Missing Parameters
|
|
781
|
+
- **Required missing**: Stop and ask user to provide
|
|
782
|
+
- **Optional missing**: Use sensible defaults or proceed without
|
|
783
|
+
- **Never**: Generate or guess required parameters
|
|
784
|
+
|
|
785
|
+
## Response Format
|
|
786
|
+
|
|
787
|
+
When reporting results back to the parent:
|
|
788
|
+
|
|
789
|
+
### Success Response
|
|
790
|
+
```markdown
|
|
791
|
+
## Summary
|
|
792
|
+
[Brief overview of what was accomplished]
|
|
793
|
+
|
|
794
|
+
## Results
|
|
795
|
+
[Key findings or actions taken]
|
|
796
|
+
|
|
797
|
+
## Next Steps
|
|
798
|
+
[Suggested follow-up actions or agent delegations]
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
### Error Response
|
|
802
|
+
```markdown
|
|
803
|
+
## Summary
|
|
804
|
+
[What went wrong]
|
|
805
|
+
|
|
806
|
+
## Issue
|
|
807
|
+
[Specific error details]
|
|
808
|
+
|
|
809
|
+
## Suggested Solution
|
|
810
|
+
[How to resolve the issue]
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
## Error Handling
|
|
814
|
+
|
|
815
|
+
- **Missing resources**: #{missing_resource_strategy}
|
|
816
|
+
- **Failed commands**: #{failed_command_strategy}
|
|
817
|
+
- **Invalid inputs**: #{invalid_input_strategy}
|
|
818
|
+
|
|
819
|
+
## Notes
|
|
820
|
+
|
|
821
|
+
#{additional_notes}
|
|
822
|
+
</template>
|
|
823
|
+
</documents>
|