claude-code-orchestrator-kit 1.0.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.
- package/.claude/agents/database/workers/api-builder.md +155 -0
- package/.claude/agents/database/workers/database-architect.md +193 -0
- package/.claude/agents/database/workers/supabase-auditor.md +1070 -0
- package/.claude/agents/development/workers/code-reviewer.md +968 -0
- package/.claude/agents/development/workers/cost-calculator-specialist.md +683 -0
- package/.claude/agents/development/workers/llm-service-specialist.md +999 -0
- package/.claude/agents/development/workers/skill-builder-v2.md +480 -0
- package/.claude/agents/development/workers/typescript-types-specialist.md +649 -0
- package/.claude/agents/development/workers/utility-builder.md +582 -0
- package/.claude/agents/documentation/workers/technical-writer.md +152 -0
- package/.claude/agents/frontend/workers/fullstack-nextjs-specialist.md +206 -0
- package/.claude/agents/frontend/workers/visual-effects-creator.md +159 -0
- package/.claude/agents/health/orchestrators/bug-orchestrator.md +1045 -0
- package/.claude/agents/health/orchestrators/dead-code-orchestrator.md +1045 -0
- package/.claude/agents/health/orchestrators/dependency-orchestrator.md +1045 -0
- package/.claude/agents/health/orchestrators/security-orchestrator.md +1045 -0
- package/.claude/agents/health/workers/bug-fixer.md +525 -0
- package/.claude/agents/health/workers/bug-hunter.md +649 -0
- package/.claude/agents/health/workers/dead-code-hunter.md +446 -0
- package/.claude/agents/health/workers/dead-code-remover.md +437 -0
- package/.claude/agents/health/workers/dependency-auditor.md +379 -0
- package/.claude/agents/health/workers/dependency-updater.md +436 -0
- package/.claude/agents/health/workers/security-scanner.md +700 -0
- package/.claude/agents/health/workers/vulnerability-fixer.md +524 -0
- package/.claude/agents/infrastructure/workers/infrastructure-specialist.md +156 -0
- package/.claude/agents/infrastructure/workers/orchestration-logic-specialist.md +1260 -0
- package/.claude/agents/infrastructure/workers/qdrant-specialist.md +503 -0
- package/.claude/agents/infrastructure/workers/quality-validator-specialist.md +984 -0
- package/.claude/agents/meta/workers/meta-agent-v3.md +503 -0
- package/.claude/agents/research/workers/problem-investigator.md +507 -0
- package/.claude/agents/research/workers/research-specialist.md +423 -0
- package/.claude/agents/testing/workers/accessibility-tester.md +813 -0
- package/.claude/agents/testing/workers/integration-tester.md +188 -0
- package/.claude/agents/testing/workers/mobile-fixes-implementer.md +252 -0
- package/.claude/agents/testing/workers/mobile-responsiveness-tester.md +180 -0
- package/.claude/agents/testing/workers/performance-optimizer.md +262 -0
- package/.claude/agents/testing/workers/test-writer.md +800 -0
- package/.claude/commands/health-bugs.md +297 -0
- package/.claude/commands/health-cleanup.md +297 -0
- package/.claude/commands/health-deps.md +297 -0
- package/.claude/commands/health-metrics.md +747 -0
- package/.claude/commands/health-security.md +297 -0
- package/.claude/commands/push.md +21 -0
- package/.claude/commands/speckit.analyze.md +184 -0
- package/.claude/commands/speckit.checklist.md +294 -0
- package/.claude/commands/speckit.clarify.md +178 -0
- package/.claude/commands/speckit.constitution.md +78 -0
- package/.claude/commands/speckit.implement.md +182 -0
- package/.claude/commands/speckit.plan.md +87 -0
- package/.claude/commands/speckit.specify.md +250 -0
- package/.claude/commands/speckit.tasks.md +137 -0
- package/.claude/commands/translate-doc.md +95 -0
- package/.claude/commands/worktree-cleanup.md +382 -0
- package/.claude/commands/worktree-create.md +287 -0
- package/.claude/commands/worktree-list.md +239 -0
- package/.claude/commands/worktree-remove.md +339 -0
- package/.claude/schemas/base-plan.schema.json +82 -0
- package/.claude/schemas/bug-plan.schema.json +71 -0
- package/.claude/schemas/dead-code-plan.schema.json +71 -0
- package/.claude/schemas/dependency-plan.schema.json +74 -0
- package/.claude/schemas/security-plan.schema.json +71 -0
- package/.claude/scripts/gates/check-bundle-size.sh +47 -0
- package/.claude/scripts/gates/check-coverage.sh +67 -0
- package/.claude/scripts/gates/check-security.sh +46 -0
- package/.claude/scripts/release.sh +740 -0
- package/.claude/settings.local.json +21 -0
- package/.claude/settings.local.json.example +20 -0
- package/.claude/skills/calculate-priority-score/SKILL.md +229 -0
- package/.claude/skills/calculate-priority-score/scoring-matrix.json +83 -0
- package/.claude/skills/extract-version/SKILL.md +228 -0
- package/.claude/skills/format-commit-message/SKILL.md +189 -0
- package/.claude/skills/format-commit-message/template.md +64 -0
- package/.claude/skills/format-markdown-table/SKILL.md +202 -0
- package/.claude/skills/format-markdown-table/examples.md +84 -0
- package/.claude/skills/format-todo-list/SKILL.md +222 -0
- package/.claude/skills/format-todo-list/template.json +30 -0
- package/.claude/skills/generate-changelog/SKILL.md +258 -0
- package/.claude/skills/generate-changelog/commit-mapping.json +47 -0
- package/.claude/skills/generate-report-header/SKILL.md +228 -0
- package/.claude/skills/generate-report-header/template.md +66 -0
- package/.claude/skills/parse-error-logs/SKILL.md +286 -0
- package/.claude/skills/parse-error-logs/patterns.json +26 -0
- package/.claude/skills/parse-git-status/SKILL.md +164 -0
- package/.claude/skills/parse-package-json/SKILL.md +151 -0
- package/.claude/skills/parse-package-json/schema.json +43 -0
- package/.claude/skills/render-template/SKILL.md +245 -0
- package/.claude/skills/rollback-changes/SKILL.md +582 -0
- package/.claude/skills/rollback-changes/changes-log-schema.json +101 -0
- package/.claude/skills/run-quality-gate/SKILL.md +404 -0
- package/.claude/skills/run-quality-gate/gate-mappings.json +97 -0
- package/.claude/skills/validate-plan-file/SKILL.md +327 -0
- package/.claude/skills/validate-plan-file/schema.json +35 -0
- package/.claude/skills/validate-report-file/SKILL.md +256 -0
- package/.claude/skills/validate-report-file/schema.json +67 -0
- package/.env.example +49 -0
- package/.github/BRANCH_PROTECTION.md +137 -0
- package/.github/workflows/build.yml +70 -0
- package/.github/workflows/claude-code-review.yml +255 -0
- package/.github/workflows/claude.yml +79 -0
- package/.github/workflows/deploy-staging.yml +90 -0
- package/.github/workflows/test.yml +104 -0
- package/.gitignore +116 -0
- package/CLAUDE.md +137 -0
- package/LICENSE +72 -0
- package/README.md +1098 -0
- package/docs/ARCHITECTURE.md +746 -0
- package/docs/Agents Ecosystem/AGENT-ORCHESTRATION.md +568 -0
- package/docs/Agents Ecosystem/AI-AGENT-ECOSYSTEM-README.md +658 -0
- package/docs/Agents Ecosystem/ARCHITECTURE.md +606 -0
- package/docs/Agents Ecosystem/QUALITY-GATES-SPECIFICATION.md +1315 -0
- package/docs/Agents Ecosystem/REPORT-TEMPLATE-STANDARD.md +1324 -0
- package/docs/Agents Ecosystem/spec-kit-comprehensive-updates.md +478 -0
- package/docs/FAQ.md +572 -0
- package/docs/MIGRATION-GUIDE.md +542 -0
- package/docs/PERFORMANCE-OPTIMIZATION.md +494 -0
- package/docs/ROADMAP.md +439 -0
- package/docs/TUTORIAL-CUSTOM-AGENTS.md +2041 -0
- package/docs/USE-CASES.md +706 -0
- package/index.js +96 -0
- package/mcp/.mcp.base.json +21 -0
- package/mcp/.mcp.frontend.json +29 -0
- package/mcp/.mcp.full.json +67 -0
- package/mcp/.mcp.local.example.json +7 -0
- package/mcp/.mcp.local.json +7 -0
- package/mcp/.mcp.n8n.json +45 -0
- package/mcp/.mcp.supabase-full.json +35 -0
- package/mcp/.mcp.supabase-only.json +28 -0
- package/package.json +78 -0
- package/postinstall.js +71 -0
- package/switch-mcp.sh +101 -0
|
@@ -0,0 +1,2041 @@
|
|
|
1
|
+
# 🎓 Tutorial: Creating Custom Agents
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [Introduction](#introduction)
|
|
6
|
+
- [Prerequisites](#prerequisites)
|
|
7
|
+
- [Quick Start with Meta Agent](#quick-start-with-meta-agent)
|
|
8
|
+
- [Manual Agent Creation](#manual-agent-creation)
|
|
9
|
+
- [Tutorial 1: Simple Agent](#tutorial-1-simple-agent)
|
|
10
|
+
- [Tutorial 2: Worker Agent](#tutorial-2-worker-agent)
|
|
11
|
+
- [Tutorial 3: Orchestrator Agent](#tutorial-3-orchestrator-agent)
|
|
12
|
+
- [Tutorial 4: Creating a Skill](#tutorial-4-creating-a-skill)
|
|
13
|
+
- [Best Practices](#best-practices)
|
|
14
|
+
- [Testing Your Agent](#testing-your-agent)
|
|
15
|
+
- [Troubleshooting](#troubleshooting)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Introduction
|
|
20
|
+
|
|
21
|
+
This tutorial teaches you how to create custom agents for Claude Code Orchestrator Kit. You'll learn:
|
|
22
|
+
|
|
23
|
+
- The difference between agent types (Simple, Worker, Orchestrator)
|
|
24
|
+
- How to use the meta-agent for automated creation
|
|
25
|
+
- How to manually create agents following ARCHITECTURE.md patterns
|
|
26
|
+
- Best practices for agent design
|
|
27
|
+
- How to test and debug your agents
|
|
28
|
+
|
|
29
|
+
**Time to complete**: 30-60 minutes per tutorial
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Prerequisites
|
|
34
|
+
|
|
35
|
+
### Required Knowledge
|
|
36
|
+
|
|
37
|
+
- Basic understanding of Markdown
|
|
38
|
+
- Familiarity with Claude Code
|
|
39
|
+
- Understanding of your project's domain
|
|
40
|
+
|
|
41
|
+
### Optional Knowledge (Helpful)
|
|
42
|
+
|
|
43
|
+
- TypeScript/JavaScript (for quality gates)
|
|
44
|
+
- Git workflows
|
|
45
|
+
- Testing concepts
|
|
46
|
+
|
|
47
|
+
### Setup
|
|
48
|
+
|
|
49
|
+
Ensure you have:
|
|
50
|
+
```bash
|
|
51
|
+
# 1. Claude Code Orchestrator Kit installed
|
|
52
|
+
ls .claude/agents/
|
|
53
|
+
|
|
54
|
+
# 2. MCP configuration active
|
|
55
|
+
cat .mcp.json
|
|
56
|
+
|
|
57
|
+
# 3. CLAUDE.md and ARCHITECTURE.md available
|
|
58
|
+
ls CLAUDE.md docs/Agents\ Ecosystem/ARCHITECTURE.md
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Quick Start with Meta Agent
|
|
64
|
+
|
|
65
|
+
The **fastest way** to create agents is using the meta-agent:
|
|
66
|
+
|
|
67
|
+
### Step-by-Step
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
1. Ask Claude Code:
|
|
71
|
+
"Create a worker agent for linting TypeScript files with ESLint"
|
|
72
|
+
|
|
73
|
+
2. Meta-agent will ask:
|
|
74
|
+
- Agent type? (worker/orchestrator/simple)
|
|
75
|
+
- Domain category? (health/development/testing/etc)
|
|
76
|
+
- Additional details specific to type
|
|
77
|
+
|
|
78
|
+
3. Meta-agent will:
|
|
79
|
+
- Read ARCHITECTURE.md patterns
|
|
80
|
+
- Generate agent file with proper structure
|
|
81
|
+
- Validate against checklist
|
|
82
|
+
- Write to .claude/agents/{category}/{type}/{name}.md
|
|
83
|
+
|
|
84
|
+
4. Review generated agent:
|
|
85
|
+
- Check YAML frontmatter
|
|
86
|
+
- Verify phases/instructions
|
|
87
|
+
- Customize domain logic if needed
|
|
88
|
+
|
|
89
|
+
5. Test agent:
|
|
90
|
+
"Use eslint-worker to lint src/ directory"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Example Interaction
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
User: Create a worker agent for formatting code with Prettier
|
|
97
|
+
|
|
98
|
+
Meta-agent: I'll create a code-formatter worker agent. Let me gather requirements:
|
|
99
|
+
|
|
100
|
+
1. Agent type: Worker
|
|
101
|
+
2. Domain: development
|
|
102
|
+
3. Purpose: Format code with Prettier
|
|
103
|
+
4. Input: File paths or directories
|
|
104
|
+
5. Output: Formatted files + report
|
|
105
|
+
6. Validation: Check formatting is consistent
|
|
106
|
+
|
|
107
|
+
[Generates agent following worker pattern...]
|
|
108
|
+
|
|
109
|
+
✅ Worker Created: .claude/agents/development/workers/prettier-formatter.md
|
|
110
|
+
|
|
111
|
+
Components:
|
|
112
|
+
- YAML frontmatter ✓
|
|
113
|
+
- 5-phase structure ✓
|
|
114
|
+
- MCP integration (Context7 for config best practices) ✓
|
|
115
|
+
- Error handling ✓
|
|
116
|
+
|
|
117
|
+
Next Steps:
|
|
118
|
+
1. Review .claude/agents/development/workers/prettier-formatter.md
|
|
119
|
+
2. Customize Prettier options if needed
|
|
120
|
+
3. Test with: "Use prettier-formatter on src/"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Manual Agent Creation
|
|
126
|
+
|
|
127
|
+
For full control, create agents manually following these steps.
|
|
128
|
+
|
|
129
|
+
### Step 1: Choose Agent Type
|
|
130
|
+
|
|
131
|
+
| Type | Use When | Complexity |
|
|
132
|
+
|------|----------|------------|
|
|
133
|
+
| **Simple Agent** | Single task, no coordination needed | Low |
|
|
134
|
+
| **Worker** | Execute specific task from plan file | Medium |
|
|
135
|
+
| **Orchestrator** | Coordinate multi-phase workflow | High |
|
|
136
|
+
|
|
137
|
+
**Decision tree:**
|
|
138
|
+
|
|
139
|
+
```mermaid
|
|
140
|
+
graph TD
|
|
141
|
+
Start{What do you need?}
|
|
142
|
+
|
|
143
|
+
Start -->|Single standalone task| Simple[Simple Agent]
|
|
144
|
+
Start -->|Execute from plan| Worker[Worker Agent]
|
|
145
|
+
Start -->|Coordinate workflow| Orch[Orchestrator]
|
|
146
|
+
|
|
147
|
+
Simple --> Examples1[Examples:<br/>Code formatter<br/>File converter<br/>Simple validator]
|
|
148
|
+
Worker --> Examples2[Examples:<br/>Bug hunter<br/>Security scanner<br/>Test runner]
|
|
149
|
+
Orch --> Examples3[Examples:<br/>Bug workflow<br/>Release process<br/>Deployment pipeline]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Step 2: Create File
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Simple agent
|
|
156
|
+
touch .claude/agents/my-agent.md
|
|
157
|
+
|
|
158
|
+
# Worker agent
|
|
159
|
+
mkdir -p .claude/agents/{domain}/workers/
|
|
160
|
+
touch .claude/agents/{domain}/workers/my-worker.md
|
|
161
|
+
|
|
162
|
+
# Orchestrator
|
|
163
|
+
mkdir -p .claude/agents/{domain}/orchestrators/
|
|
164
|
+
touch .claude/agents/{domain}/orchestrators/my-orchestrator.md
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Step 3: Add YAML Frontmatter
|
|
168
|
+
|
|
169
|
+
```yaml
|
|
170
|
+
---
|
|
171
|
+
name: my-agent-name
|
|
172
|
+
description: Use proactively for {task}. Expert in {domain}. Handles {scenarios}.
|
|
173
|
+
model: sonnet
|
|
174
|
+
color: cyan
|
|
175
|
+
---
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Color codes by domain:**
|
|
179
|
+
- `blue` - Health/Quality
|
|
180
|
+
- `cyan` - Meta/Tools
|
|
181
|
+
- `green` - Success/Validation
|
|
182
|
+
- `purple` - Infrastructure
|
|
183
|
+
- `orange` - Development
|
|
184
|
+
|
|
185
|
+
### Step 4: Follow Pattern
|
|
186
|
+
|
|
187
|
+
See tutorials below for specific patterns.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Tutorial 1: Simple Agent
|
|
192
|
+
|
|
193
|
+
**Goal**: Create a code formatter agent that runs Prettier on specified files.
|
|
194
|
+
|
|
195
|
+
### Step 1: Plan the Agent
|
|
196
|
+
|
|
197
|
+
**Requirements:**
|
|
198
|
+
- Input: File paths or directories
|
|
199
|
+
- Action: Run prettier with project config
|
|
200
|
+
- Output: Formatted files + summary
|
|
201
|
+
- Error handling: Report files that failed
|
|
202
|
+
|
|
203
|
+
### Step 2: Create File
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
touch .claude/agents/prettier-formatter.md
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Step 3: Write Agent
|
|
210
|
+
|
|
211
|
+
```markdown
|
|
212
|
+
---
|
|
213
|
+
name: prettier-formatter
|
|
214
|
+
description: Use proactively for code formatting with Prettier. Expert in consistent code style. Handles JavaScript, TypeScript, JSON, Markdown files.
|
|
215
|
+
model: sonnet
|
|
216
|
+
color: orange
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
# Prettier Formatter
|
|
220
|
+
|
|
221
|
+
Simple agent that formats code files using Prettier with project configuration.
|
|
222
|
+
|
|
223
|
+
## When to Use
|
|
224
|
+
|
|
225
|
+
- Before committing code
|
|
226
|
+
- After refactoring
|
|
227
|
+
- When code style is inconsistent
|
|
228
|
+
- When onboarding new team members
|
|
229
|
+
|
|
230
|
+
## Input
|
|
231
|
+
|
|
232
|
+
User specifies:
|
|
233
|
+
- **Files**: Specific file paths (e.g., `src/utils/helper.ts`)
|
|
234
|
+
- **Directories**: Format all files in directory (e.g., `src/`)
|
|
235
|
+
- **Glob patterns**: Pattern matching (e.g., `src/**/*.ts`)
|
|
236
|
+
|
|
237
|
+
## Instructions
|
|
238
|
+
|
|
239
|
+
1. **Verify Prettier is available**
|
|
240
|
+
```bash
|
|
241
|
+
which prettier || npx prettier --version
|
|
242
|
+
```
|
|
243
|
+
If not found, use `npx prettier`.
|
|
244
|
+
|
|
245
|
+
2. **Check for Prettier config**
|
|
246
|
+
- Look for `.prettierrc`, `.prettierrc.json`, `prettier.config.js`
|
|
247
|
+
- If found, use project config
|
|
248
|
+
- If not found, use defaults
|
|
249
|
+
|
|
250
|
+
3. **Format files**
|
|
251
|
+
```bash
|
|
252
|
+
npx prettier --write {files or directories}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
4. **Check for errors**
|
|
256
|
+
- If formatting succeeds → Report success
|
|
257
|
+
- If syntax errors → Report which files failed
|
|
258
|
+
|
|
259
|
+
5. **Generate summary**
|
|
260
|
+
```
|
|
261
|
+
✅ Code Formatting Complete
|
|
262
|
+
|
|
263
|
+
Formatted: 42 files
|
|
264
|
+
Failed: 2 files (syntax errors)
|
|
265
|
+
|
|
266
|
+
Files formatted:
|
|
267
|
+
- src/utils/helper.ts
|
|
268
|
+
- src/components/Button.tsx
|
|
269
|
+
- ...
|
|
270
|
+
|
|
271
|
+
Files with errors:
|
|
272
|
+
- src/broken.ts (SyntaxError: Unexpected token)
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Output Format
|
|
276
|
+
|
|
277
|
+
**Success:**
|
|
278
|
+
```
|
|
279
|
+
✅ Formatted {N} files successfully
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**Partial success:**
|
|
283
|
+
```
|
|
284
|
+
⚠️ Formatted {N} files, {M} failed
|
|
285
|
+
See details above for errors
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Failure:**
|
|
289
|
+
```
|
|
290
|
+
❌ Formatting failed
|
|
291
|
+
Prettier not found or configuration error
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Error Handling
|
|
295
|
+
|
|
296
|
+
- **Prettier not installed**: Install via `npm install -D prettier`
|
|
297
|
+
- **Syntax errors**: Report files, don't halt (format others)
|
|
298
|
+
- **Config errors**: Use defaults with warning
|
|
299
|
+
- **Permission errors**: Report inaccessible files
|
|
300
|
+
|
|
301
|
+
## Examples
|
|
302
|
+
|
|
303
|
+
### Format single file
|
|
304
|
+
```
|
|
305
|
+
Use prettier-formatter on src/utils/helper.ts
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Format directory
|
|
309
|
+
```
|
|
310
|
+
Use prettier-formatter on src/components/
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Format with glob
|
|
314
|
+
```
|
|
315
|
+
Use prettier-formatter on "src/**/*.{ts,tsx}"
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
**This is a Simple Agent**: No plan files, no reports, direct execution.
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Step 4: Test Agent
|
|
324
|
+
|
|
325
|
+
```
|
|
326
|
+
# Test with single file
|
|
327
|
+
Ask Claude Code: "Use prettier-formatter on src/index.ts"
|
|
328
|
+
|
|
329
|
+
# Test with directory
|
|
330
|
+
Ask Claude Code: "Use prettier-formatter on src/"
|
|
331
|
+
|
|
332
|
+
# Verify output
|
|
333
|
+
Check that files are formatted correctly
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Key Takeaways
|
|
337
|
+
|
|
338
|
+
**Simple agents:**
|
|
339
|
+
- ✅ Standalone, no coordination
|
|
340
|
+
- ✅ Direct input from user
|
|
341
|
+
- ✅ Immediate execution
|
|
342
|
+
- ✅ Simple output format
|
|
343
|
+
- ❌ No plan files
|
|
344
|
+
- ❌ No structured reports
|
|
345
|
+
- ❌ No quality gates
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Tutorial 2: Worker Agent
|
|
350
|
+
|
|
351
|
+
**Goal**: Create a test coverage worker that analyzes test coverage from plan file.
|
|
352
|
+
|
|
353
|
+
### Step 1: Plan the Worker
|
|
354
|
+
|
|
355
|
+
**Requirements:**
|
|
356
|
+
- Input: Plan file (`.test-coverage-plan.json`)
|
|
357
|
+
- Plan contains: Threshold (%), directories to check
|
|
358
|
+
- Action: Run coverage tool, analyze results
|
|
359
|
+
- Output: Structured report with pass/fail
|
|
360
|
+
- Quality gates: Coverage must meet threshold
|
|
361
|
+
|
|
362
|
+
### Step 2: Create File
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
mkdir -p .claude/agents/testing/workers/
|
|
366
|
+
touch .claude/agents/testing/workers/test-coverage-analyzer.md
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Step 3: Write Worker
|
|
370
|
+
|
|
371
|
+
```markdown
|
|
372
|
+
---
|
|
373
|
+
name: test-coverage-analyzer
|
|
374
|
+
description: Use proactively for test coverage analysis. Expert in code coverage metrics. Analyzes coverage reports and validates against thresholds.
|
|
375
|
+
model: sonnet
|
|
376
|
+
color: green
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
# Test Coverage Analyzer
|
|
380
|
+
|
|
381
|
+
Worker agent that analyzes test coverage from coverage reports and validates against thresholds specified in plan file.
|
|
382
|
+
|
|
383
|
+
## Purpose
|
|
384
|
+
|
|
385
|
+
Invoked by orchestrators to validate test coverage meets quality standards during:
|
|
386
|
+
- Bug fixing workflows
|
|
387
|
+
- Feature development
|
|
388
|
+
- Release validation
|
|
389
|
+
- CI/CD pipelines
|
|
390
|
+
|
|
391
|
+
## Phase 1: Read Plan File
|
|
392
|
+
|
|
393
|
+
**Location**: `.tmp/current/plans/.test-coverage-plan.json`
|
|
394
|
+
|
|
395
|
+
**Expected structure:**
|
|
396
|
+
```json
|
|
397
|
+
{
|
|
398
|
+
"phase": 1,
|
|
399
|
+
"config": {
|
|
400
|
+
"threshold": 80,
|
|
401
|
+
"directories": ["src/", "lib/"],
|
|
402
|
+
"excludePatterns": ["**/*.test.ts", "**/*.spec.ts"]
|
|
403
|
+
},
|
|
404
|
+
"validation": {
|
|
405
|
+
"required": ["coverage-check"],
|
|
406
|
+
"optional": []
|
|
407
|
+
},
|
|
408
|
+
"nextAgent": "test-coverage-analyzer"
|
|
409
|
+
}
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
**Steps:**
|
|
413
|
+
1. Read plan file from `.tmp/current/plans/.test-coverage-plan.json`
|
|
414
|
+
2. Extract `threshold` (minimum % required)
|
|
415
|
+
3. Extract `directories` (paths to check)
|
|
416
|
+
4. Extract `excludePatterns` (files to ignore)
|
|
417
|
+
5. Validate plan has required fields
|
|
418
|
+
|
|
419
|
+
**If plan missing:**
|
|
420
|
+
- Create default plan:
|
|
421
|
+
```json
|
|
422
|
+
{
|
|
423
|
+
"threshold": 70,
|
|
424
|
+
"directories": ["src/"],
|
|
425
|
+
"excludePatterns": []
|
|
426
|
+
}
|
|
427
|
+
```
|
|
428
|
+
- Log warning: "Plan file missing, using defaults"
|
|
429
|
+
|
|
430
|
+
## Phase 2: Generate Coverage Report
|
|
431
|
+
|
|
432
|
+
**Steps:**
|
|
433
|
+
|
|
434
|
+
1. **Run coverage tool**
|
|
435
|
+
```bash
|
|
436
|
+
npm run test:coverage
|
|
437
|
+
# Or: npx jest --coverage
|
|
438
|
+
# Or: npx vitest run --coverage
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
2. **Locate coverage report**
|
|
442
|
+
- Look for: `coverage/coverage-summary.json`
|
|
443
|
+
- Or: `coverage/lcov.info`
|
|
444
|
+
- Parse coverage data
|
|
445
|
+
|
|
446
|
+
3. **Extract metrics**
|
|
447
|
+
- **Lines**: % of lines covered
|
|
448
|
+
- **Branches**: % of branches covered
|
|
449
|
+
- **Functions**: % of functions covered
|
|
450
|
+
- **Statements**: % of statements covered
|
|
451
|
+
|
|
452
|
+
4. **Calculate by directory**
|
|
453
|
+
- Group files by directory from plan config
|
|
454
|
+
- Calculate coverage per directory
|
|
455
|
+
- Identify low-coverage files
|
|
456
|
+
|
|
457
|
+
## Phase 3: Analyze Coverage
|
|
458
|
+
|
|
459
|
+
**Steps:**
|
|
460
|
+
|
|
461
|
+
1. **Compare against threshold**
|
|
462
|
+
```
|
|
463
|
+
If coverage >= threshold:
|
|
464
|
+
Status = PASS
|
|
465
|
+
Else:
|
|
466
|
+
Status = FAIL
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
2. **Identify coverage gaps**
|
|
470
|
+
- Files below threshold
|
|
471
|
+
- Uncovered branches
|
|
472
|
+
- Untested functions
|
|
473
|
+
|
|
474
|
+
3. **Calculate coverage trend**
|
|
475
|
+
- Compare to previous run (if available)
|
|
476
|
+
- Identify improvement or regression
|
|
477
|
+
|
|
478
|
+
## Phase 4: Validate Work
|
|
479
|
+
|
|
480
|
+
**Validation criteria:**
|
|
481
|
+
|
|
482
|
+
1. **Coverage report generated?**
|
|
483
|
+
- Check `coverage/` directory exists
|
|
484
|
+
- Check report files present
|
|
485
|
+
|
|
486
|
+
2. **Coverage meets threshold?**
|
|
487
|
+
- Compare total coverage vs threshold
|
|
488
|
+
- Check per-directory coverage
|
|
489
|
+
|
|
490
|
+
3. **Report is parsable?**
|
|
491
|
+
- JSON is valid
|
|
492
|
+
- All expected fields present
|
|
493
|
+
|
|
494
|
+
**Validation status:**
|
|
495
|
+
- ✅ PASSED: Coverage >= threshold, report valid
|
|
496
|
+
- ⚠️ PARTIAL: Coverage < threshold but report valid
|
|
497
|
+
- ❌ FAILED: Coverage tool failed or report invalid
|
|
498
|
+
|
|
499
|
+
## Phase 5: Generate Report
|
|
500
|
+
|
|
501
|
+
**Use `generate-report-header` Skill** for header.
|
|
502
|
+
|
|
503
|
+
**Report structure:**
|
|
504
|
+
|
|
505
|
+
````markdown
|
|
506
|
+
# Test Coverage Analysis Report
|
|
507
|
+
|
|
508
|
+
**Generated**: 2025-01-11T14:30:00Z
|
|
509
|
+
**Worker**: test-coverage-analyzer
|
|
510
|
+
**Phase**: 1
|
|
511
|
+
**Status**: ✅ PASSED
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
## Executive Summary
|
|
516
|
+
|
|
517
|
+
Test coverage meets quality standards.
|
|
518
|
+
|
|
519
|
+
**Key Metrics**:
|
|
520
|
+
- Total Coverage: 84.5%
|
|
521
|
+
- Threshold: 80%
|
|
522
|
+
- Files Analyzed: 127
|
|
523
|
+
- Directories: src/, lib/
|
|
524
|
+
|
|
525
|
+
**Validation Status**: ✅ PASSED
|
|
526
|
+
|
|
527
|
+
**Critical Findings**:
|
|
528
|
+
- Coverage exceeds threshold by 4.5%
|
|
529
|
+
- 3 files below 60% coverage (see details)
|
|
530
|
+
|
|
531
|
+
---
|
|
532
|
+
|
|
533
|
+
## Coverage Metrics
|
|
534
|
+
|
|
535
|
+
### Overall Coverage
|
|
536
|
+
|
|
537
|
+
| Metric | Coverage | Status |
|
|
538
|
+
|--------|----------|--------|
|
|
539
|
+
| Lines | 84.5% | ✅ Pass |
|
|
540
|
+
| Branches | 78.2% | ⚠️ Near Threshold |
|
|
541
|
+
| Functions | 89.1% | ✅ Pass |
|
|
542
|
+
| Statements | 84.3% | ✅ Pass |
|
|
543
|
+
|
|
544
|
+
### By Directory
|
|
545
|
+
|
|
546
|
+
| Directory | Coverage | Status |
|
|
547
|
+
|-----------|----------|--------|
|
|
548
|
+
| src/utils/ | 92.3% | ✅ Excellent |
|
|
549
|
+
| src/components/ | 81.7% | ✅ Pass |
|
|
550
|
+
| lib/helpers/ | 75.4% | ⚠️ Near Threshold |
|
|
551
|
+
|
|
552
|
+
---
|
|
553
|
+
|
|
554
|
+
## Low Coverage Files
|
|
555
|
+
|
|
556
|
+
Files below 70% coverage:
|
|
557
|
+
|
|
558
|
+
1. **src/utils/legacy.ts** - 45.2%
|
|
559
|
+
- 23/51 lines uncovered
|
|
560
|
+
- Recommend: Add tests for edge cases
|
|
561
|
+
|
|
562
|
+
2. **lib/helpers/parser.ts** - 58.9%
|
|
563
|
+
- 18/44 lines uncovered
|
|
564
|
+
- Recommend: Test error handling paths
|
|
565
|
+
|
|
566
|
+
3. **src/api/client.ts** - 62.1%
|
|
567
|
+
- 15/40 lines uncovered
|
|
568
|
+
- Recommend: Test async error cases
|
|
569
|
+
|
|
570
|
+
---
|
|
571
|
+
|
|
572
|
+
## Validation Results
|
|
573
|
+
|
|
574
|
+
### Check 1: Coverage Report Generated
|
|
575
|
+
- **Command**: `npm run test:coverage`
|
|
576
|
+
- **Result**: ✅ PASSED
|
|
577
|
+
- **Details**: Report generated at coverage/coverage-summary.json
|
|
578
|
+
|
|
579
|
+
### Check 2: Coverage Meets Threshold
|
|
580
|
+
- **Threshold**: 80%
|
|
581
|
+
- **Actual**: 84.5%
|
|
582
|
+
- **Result**: ✅ PASSED
|
|
583
|
+
- **Details**: Exceeds threshold by 4.5%
|
|
584
|
+
|
|
585
|
+
**Overall Validation**: ✅ PASSED
|
|
586
|
+
|
|
587
|
+
---
|
|
588
|
+
|
|
589
|
+
## Metrics
|
|
590
|
+
|
|
591
|
+
- **Total Duration**: ~2m 15s
|
|
592
|
+
- **Files Analyzed**: 127
|
|
593
|
+
- **Validation Checks**: 2/2 passed
|
|
594
|
+
|
|
595
|
+
---
|
|
596
|
+
|
|
597
|
+
## Errors Encountered
|
|
598
|
+
|
|
599
|
+
✅ No errors encountered
|
|
600
|
+
|
|
601
|
+
---
|
|
602
|
+
|
|
603
|
+
## Next Steps
|
|
604
|
+
|
|
605
|
+
1. Orchestrator can proceed to next phase
|
|
606
|
+
2. Consider adding tests for low-coverage files
|
|
607
|
+
3. Monitor branch coverage (near threshold)
|
|
608
|
+
|
|
609
|
+
---
|
|
610
|
+
|
|
611
|
+
## Artifacts
|
|
612
|
+
|
|
613
|
+
- Plan file: `.tmp/current/plans/.test-coverage-plan.json`
|
|
614
|
+
- This report: `.tmp/current/reports/test-coverage-report.md`
|
|
615
|
+
- Coverage data: `coverage/coverage-summary.json`
|
|
616
|
+
|
|
617
|
+
---
|
|
618
|
+
|
|
619
|
+
**Test Coverage Analyzer execution complete.**
|
|
620
|
+
|
|
621
|
+
✅ Ready for orchestrator validation and next phase.
|
|
622
|
+
````
|
|
623
|
+
|
|
624
|
+
**If validation FAILED:**
|
|
625
|
+
```markdown
|
|
626
|
+
❌ Work failed validation. Coverage below threshold (84.5% < 90%).
|
|
627
|
+
|
|
628
|
+
## Recovery Steps
|
|
629
|
+
|
|
630
|
+
1. Review low-coverage files above
|
|
631
|
+
2. Add tests to increase coverage
|
|
632
|
+
3. Re-run coverage analysis
|
|
633
|
+
4. Alternative: Lower threshold with justification
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
## Phase 6: Return Control
|
|
637
|
+
|
|
638
|
+
**Steps:**
|
|
639
|
+
|
|
640
|
+
1. **Report summary to user**
|
|
641
|
+
```
|
|
642
|
+
✅ Test Coverage Analysis Complete
|
|
643
|
+
|
|
644
|
+
Coverage: 84.5% (threshold: 80%)
|
|
645
|
+
Status: PASSED
|
|
646
|
+
|
|
647
|
+
See full report: .tmp/current/reports/test-coverage-report.md
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
2. **Exit** (orchestrator resumes)
|
|
651
|
+
|
|
652
|
+
**DO NOT:**
|
|
653
|
+
- ❌ Invoke other agents
|
|
654
|
+
- ❌ Continue without orchestrator
|
|
655
|
+
- ❌ Skip report generation
|
|
656
|
+
|
|
657
|
+
---
|
|
658
|
+
|
|
659
|
+
## Error Handling
|
|
660
|
+
|
|
661
|
+
### Coverage Tool Failed
|
|
662
|
+
|
|
663
|
+
**Symptoms**: `npm run test:coverage` exits with error
|
|
664
|
+
|
|
665
|
+
**Actions:**
|
|
666
|
+
1. Log error to report
|
|
667
|
+
2. Check if test:coverage script exists in package.json
|
|
668
|
+
3. Try alternative: `npx jest --coverage`
|
|
669
|
+
4. If all fail: Report FAILED status with error details
|
|
670
|
+
|
|
671
|
+
### Plan File Invalid
|
|
672
|
+
|
|
673
|
+
**Symptoms**: Plan file missing required fields
|
|
674
|
+
|
|
675
|
+
**Actions:**
|
|
676
|
+
1. Log validation errors
|
|
677
|
+
2. Use default values for missing fields
|
|
678
|
+
3. Log warning in report
|
|
679
|
+
4. Continue with defaults
|
|
680
|
+
|
|
681
|
+
### Coverage Below Threshold
|
|
682
|
+
|
|
683
|
+
**Symptoms**: Coverage < threshold from plan
|
|
684
|
+
|
|
685
|
+
**Actions:**
|
|
686
|
+
1. Mark status as ⚠️ PARTIAL
|
|
687
|
+
2. List low-coverage files
|
|
688
|
+
3. Provide recommendations
|
|
689
|
+
4. Ask orchestrator: continue or fix?
|
|
690
|
+
|
|
691
|
+
---
|
|
692
|
+
|
|
693
|
+
## MCP Integration
|
|
694
|
+
|
|
695
|
+
**Recommended MCP servers:** None required for coverage analysis.
|
|
696
|
+
|
|
697
|
+
**Optional:** `mcp__context7__*` for best practices on testing frameworks.
|
|
698
|
+
|
|
699
|
+
---
|
|
700
|
+
|
|
701
|
+
**This worker follows:**
|
|
702
|
+
- ARCHITECTURE.md worker pattern (5 phases)
|
|
703
|
+
- REPORT-TEMPLATE-STANDARD.md format
|
|
704
|
+
- CLAUDE.md Prime Directives (PD-1, PD-3, PD-6)
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
### Step 4: Test Worker
|
|
708
|
+
|
|
709
|
+
**Test with orchestrator:**
|
|
710
|
+
|
|
711
|
+
1. Create test plan file:
|
|
712
|
+
```json
|
|
713
|
+
{
|
|
714
|
+
"phase": 1,
|
|
715
|
+
"config": {
|
|
716
|
+
"threshold": 80,
|
|
717
|
+
"directories": ["src/"]
|
|
718
|
+
},
|
|
719
|
+
"validation": {
|
|
720
|
+
"required": ["coverage-check"]
|
|
721
|
+
},
|
|
722
|
+
"nextAgent": "test-coverage-analyzer"
|
|
723
|
+
}
|
|
724
|
+
```
|
|
725
|
+
Save to `.tmp/current/plans/.test-coverage-plan.json`
|
|
726
|
+
|
|
727
|
+
2. Invoke worker:
|
|
728
|
+
```
|
|
729
|
+
Ask Claude Code: "Invoke test-coverage-analyzer worker"
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
3. Verify:
|
|
733
|
+
- Report generated at `.tmp/current/reports/test-coverage-report.md`
|
|
734
|
+
- Contains all required sections
|
|
735
|
+
- Status is accurate (PASSED/PARTIAL/FAILED)
|
|
736
|
+
|
|
737
|
+
### Key Takeaways
|
|
738
|
+
|
|
739
|
+
**Worker agents:**
|
|
740
|
+
- ✅ Read plan file FIRST
|
|
741
|
+
- ✅ Execute specific task
|
|
742
|
+
- ✅ Log changes (PD-3)
|
|
743
|
+
- ✅ Generate structured report (PD-6)
|
|
744
|
+
- ✅ Return control (PD-1)
|
|
745
|
+
- ✅ 5-phase structure
|
|
746
|
+
- ❌ No agent invocation
|
|
747
|
+
- ❌ No skipping report
|
|
748
|
+
|
|
749
|
+
---
|
|
750
|
+
|
|
751
|
+
## Tutorial 3: Orchestrator Agent
|
|
752
|
+
|
|
753
|
+
**Goal**: Create an orchestrator for test coverage workflow (detection → improvement → verification).
|
|
754
|
+
|
|
755
|
+
### Step 1: Plan the Orchestrator
|
|
756
|
+
|
|
757
|
+
**Requirements:**
|
|
758
|
+
- Phase 0: Pre-flight (setup)
|
|
759
|
+
- Phase 1: Analyze coverage (invoke test-coverage-analyzer)
|
|
760
|
+
- Quality Gate 1: Validate analysis report
|
|
761
|
+
- Phase 2: Improve coverage (invoke test-improvement-worker)
|
|
762
|
+
- Quality Gate 2: Validate improvements
|
|
763
|
+
- Phase 3: Verification (invoke test-coverage-analyzer again)
|
|
764
|
+
- Final: Summary
|
|
765
|
+
|
|
766
|
+
### Step 2: Create File
|
|
767
|
+
|
|
768
|
+
```bash
|
|
769
|
+
mkdir -p .claude/agents/testing/orchestrators/
|
|
770
|
+
touch .claude/agents/testing/orchestrators/test-coverage-orchestrator.md
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
### Step 3: Write Orchestrator
|
|
774
|
+
|
|
775
|
+
```markdown
|
|
776
|
+
---
|
|
777
|
+
name: test-coverage-orchestrator
|
|
778
|
+
description: Use proactively for comprehensive test coverage improvement workflow. Expert in orchestrating coverage analysis, test generation, and validation. Handles iterative improvement cycles.
|
|
779
|
+
model: sonnet
|
|
780
|
+
color: green
|
|
781
|
+
---
|
|
782
|
+
|
|
783
|
+
# Test Coverage Orchestrator
|
|
784
|
+
|
|
785
|
+
Coordinates multi-phase test coverage improvement workflow with quality gates and iterative refinement.
|
|
786
|
+
|
|
787
|
+
## Purpose
|
|
788
|
+
|
|
789
|
+
Automates the complete test coverage improvement process:
|
|
790
|
+
1. Analyze current coverage
|
|
791
|
+
2. Identify gaps
|
|
792
|
+
3. Generate/improve tests
|
|
793
|
+
4. Validate improvements
|
|
794
|
+
5. Iterate until threshold met
|
|
795
|
+
|
|
796
|
+
## Workflow Overview
|
|
797
|
+
|
|
798
|
+
```
|
|
799
|
+
Phase 0: Pre-Flight
|
|
800
|
+
↓
|
|
801
|
+
Phase 1: Initial Analysis
|
|
802
|
+
↓
|
|
803
|
+
Quality Gate 1: Validate Analysis
|
|
804
|
+
↓
|
|
805
|
+
Phase 2: Test Generation
|
|
806
|
+
↓
|
|
807
|
+
Quality Gate 2: Validate Generation
|
|
808
|
+
↓
|
|
809
|
+
Phase 3: Verification Analysis
|
|
810
|
+
↓
|
|
811
|
+
Quality Gate 3: Check Coverage Met
|
|
812
|
+
↓
|
|
813
|
+
Final: Summary (or iterate if coverage < threshold)
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
**Max iterations**: 3
|
|
817
|
+
|
|
818
|
+
---
|
|
819
|
+
|
|
820
|
+
## Phase 0: Pre-Flight Validation
|
|
821
|
+
|
|
822
|
+
**Purpose**: Setup environment and validate prerequisites.
|
|
823
|
+
|
|
824
|
+
**Steps:**
|
|
825
|
+
|
|
826
|
+
1. **Create directory structure**
|
|
827
|
+
```bash
|
|
828
|
+
mkdir -p .tmp/current/plans/
|
|
829
|
+
mkdir -p .tmp/current/reports/
|
|
830
|
+
mkdir -p .tmp/current/changes/
|
|
831
|
+
mkdir -p .tmp/current/backups/
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
2. **Validate environment**
|
|
835
|
+
- Check test framework exists (Jest, Vitest, etc.)
|
|
836
|
+
- Check coverage tool configured
|
|
837
|
+
- Verify `package.json` has test:coverage script
|
|
838
|
+
|
|
839
|
+
3. **Initialize tracking**
|
|
840
|
+
```
|
|
841
|
+
Use TodoWrite:
|
|
842
|
+
- Phase 0: Pre-Flight (in_progress)
|
|
843
|
+
- Phase 1: Initial Analysis (pending)
|
|
844
|
+
- Phase 2: Test Generation (pending)
|
|
845
|
+
- Phase 3: Verification (pending)
|
|
846
|
+
- Phase 4: Summary (pending)
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
4. **Parse user input**
|
|
850
|
+
- Coverage threshold (default: 80%)
|
|
851
|
+
- Directories to analyze (default: src/)
|
|
852
|
+
- Max iterations (default: 3)
|
|
853
|
+
|
|
854
|
+
5. **Mark Phase 0 complete**
|
|
855
|
+
```
|
|
856
|
+
Update TodoWrite: Phase 0: Pre-Flight (completed)
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
---
|
|
860
|
+
|
|
861
|
+
## Phase 1: Initial Coverage Analysis
|
|
862
|
+
|
|
863
|
+
**Purpose**: Analyze current test coverage.
|
|
864
|
+
|
|
865
|
+
**Steps:**
|
|
866
|
+
|
|
867
|
+
1. **Update progress**
|
|
868
|
+
```
|
|
869
|
+
TodoWrite: Phase 1: Initial Analysis (in_progress)
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
2. **Create plan file**
|
|
873
|
+
|
|
874
|
+
Save to `.tmp/current/plans/.test-coverage-plan.json`:
|
|
875
|
+
```json
|
|
876
|
+
{
|
|
877
|
+
"phase": 1,
|
|
878
|
+
"workflow": "test-coverage",
|
|
879
|
+
"config": {
|
|
880
|
+
"threshold": 80,
|
|
881
|
+
"directories": ["src/", "lib/"],
|
|
882
|
+
"excludePatterns": ["**/*.test.ts", "**/*.spec.ts"]
|
|
883
|
+
},
|
|
884
|
+
"validation": {
|
|
885
|
+
"required": ["coverage-check"],
|
|
886
|
+
"optional": []
|
|
887
|
+
},
|
|
888
|
+
"mcpGuidance": {
|
|
889
|
+
"recommended": ["mcp__context7__*"],
|
|
890
|
+
"library": "jest",
|
|
891
|
+
"reason": "Check current Jest best practices for coverage configuration"
|
|
892
|
+
},
|
|
893
|
+
"nextAgent": "test-coverage-analyzer"
|
|
894
|
+
}
|
|
895
|
+
```
|
|
896
|
+
|
|
897
|
+
3. **Validate plan file**
|
|
898
|
+
```
|
|
899
|
+
Use validate-plan-file Skill to ensure schema is correct
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
4. **Signal readiness**
|
|
903
|
+
```
|
|
904
|
+
Tell user:
|
|
905
|
+
"✅ Ready for test-coverage-analyzer
|
|
906
|
+
|
|
907
|
+
Plan file created: .tmp/current/plans/.test-coverage-plan.json
|
|
908
|
+
Next: Invoke test-coverage-analyzer worker"
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
5. **EXIT** (Return Control - PD-1)
|
|
912
|
+
|
|
913
|
+
**WAIT FOR USER** to invoke test-coverage-analyzer.
|
|
914
|
+
|
|
915
|
+
---
|
|
916
|
+
|
|
917
|
+
## Quality Gate 1: Validate Initial Analysis
|
|
918
|
+
|
|
919
|
+
**When**: After test-coverage-analyzer completes Phase 1.
|
|
920
|
+
|
|
921
|
+
**Steps:**
|
|
922
|
+
|
|
923
|
+
1. **Check report exists**
|
|
924
|
+
```bash
|
|
925
|
+
ls .tmp/current/reports/test-coverage-report.md
|
|
926
|
+
```
|
|
927
|
+
If missing → HALT, report error
|
|
928
|
+
|
|
929
|
+
2. **Validate report completeness**
|
|
930
|
+
```
|
|
931
|
+
Use validate-report-file Skill to check:
|
|
932
|
+
- Has Executive Summary
|
|
933
|
+
- Has Coverage Metrics
|
|
934
|
+
- Has Validation Results
|
|
935
|
+
- Has status (PASSED/PARTIAL/FAILED)
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
3. **Run quality gate**
|
|
939
|
+
```
|
|
940
|
+
Use run-quality-gate Skill with:
|
|
941
|
+
- required: ["coverage-report-exists"]
|
|
942
|
+
- optional: []
|
|
943
|
+
```
|
|
944
|
+
|
|
945
|
+
4. **Evaluate result**
|
|
946
|
+
- ✅ PASS: Report valid, continue to Phase 2
|
|
947
|
+
- ❌ FAIL: HALT, report error, ask user to fix/skip
|
|
948
|
+
|
|
949
|
+
5. **Check coverage vs threshold**
|
|
950
|
+
```
|
|
951
|
+
Read report, extract coverage percentage
|
|
952
|
+
If coverage >= threshold:
|
|
953
|
+
Skip Phase 2 (no improvement needed)
|
|
954
|
+
Jump to Final Summary
|
|
955
|
+
Else:
|
|
956
|
+
Continue to Phase 2
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
---
|
|
960
|
+
|
|
961
|
+
## Phase 2: Test Generation/Improvement
|
|
962
|
+
|
|
963
|
+
**Purpose**: Generate or improve tests for low-coverage files.
|
|
964
|
+
|
|
965
|
+
**Steps:**
|
|
966
|
+
|
|
967
|
+
1. **Update progress**
|
|
968
|
+
```
|
|
969
|
+
TodoWrite: Phase 2: Test Generation (in_progress)
|
|
970
|
+
```
|
|
971
|
+
|
|
972
|
+
2. **Extract low-coverage files**
|
|
973
|
+
- Read test-coverage-report.md
|
|
974
|
+
- Find "Low Coverage Files" section
|
|
975
|
+
- Extract file paths and coverage %
|
|
976
|
+
|
|
977
|
+
3. **Create test generation plan**
|
|
978
|
+
|
|
979
|
+
Save to `.tmp/current/plans/.test-generation-plan.json`:
|
|
980
|
+
```json
|
|
981
|
+
{
|
|
982
|
+
"phase": 2,
|
|
983
|
+
"workflow": "test-coverage",
|
|
984
|
+
"config": {
|
|
985
|
+
"targetFiles": [
|
|
986
|
+
"src/utils/legacy.ts",
|
|
987
|
+
"lib/helpers/parser.ts"
|
|
988
|
+
],
|
|
989
|
+
"currentCoverage": 45.2,
|
|
990
|
+
"targetCoverage": 80,
|
|
991
|
+
"testFramework": "jest"
|
|
992
|
+
},
|
|
993
|
+
"validation": {
|
|
994
|
+
"required": ["test-syntax-check"],
|
|
995
|
+
"optional": ["test-execution"]
|
|
996
|
+
},
|
|
997
|
+
"mcpGuidance": {
|
|
998
|
+
"recommended": ["mcp__context7__*"],
|
|
999
|
+
"library": "jest",
|
|
1000
|
+
"reason": "Get current Jest testing patterns and best practices"
|
|
1001
|
+
},
|
|
1002
|
+
"nextAgent": "test-generation-worker"
|
|
1003
|
+
}
|
|
1004
|
+
```
|
|
1005
|
+
|
|
1006
|
+
4. **Validate plan**
|
|
1007
|
+
```
|
|
1008
|
+
Use validate-plan-file Skill
|
|
1009
|
+
```
|
|
1010
|
+
|
|
1011
|
+
5. **Signal readiness**
|
|
1012
|
+
```
|
|
1013
|
+
Tell user:
|
|
1014
|
+
"✅ Ready for test-generation-worker
|
|
1015
|
+
|
|
1016
|
+
Plan file created: .tmp/current/plans/.test-generation-plan.json
|
|
1017
|
+
Target files: 2 (src/utils/legacy.ts, lib/helpers/parser.ts)
|
|
1018
|
+
Next: Invoke test-generation-worker"
|
|
1019
|
+
```
|
|
1020
|
+
|
|
1021
|
+
6. **EXIT** (Return Control)
|
|
1022
|
+
|
|
1023
|
+
**WAIT FOR USER** to invoke test-generation-worker.
|
|
1024
|
+
|
|
1025
|
+
---
|
|
1026
|
+
|
|
1027
|
+
## Quality Gate 2: Validate Test Generation
|
|
1028
|
+
|
|
1029
|
+
**When**: After test-generation-worker completes Phase 2.
|
|
1030
|
+
|
|
1031
|
+
**Steps:**
|
|
1032
|
+
|
|
1033
|
+
1. **Check report exists**
|
|
1034
|
+
```bash
|
|
1035
|
+
ls .tmp/current/reports/test-generation-report.md
|
|
1036
|
+
```
|
|
1037
|
+
|
|
1038
|
+
2. **Validate report**
|
|
1039
|
+
```
|
|
1040
|
+
Use validate-report-file Skill
|
|
1041
|
+
```
|
|
1042
|
+
|
|
1043
|
+
3. **Run quality gate**
|
|
1044
|
+
```
|
|
1045
|
+
Use run-quality-gate Skill with:
|
|
1046
|
+
- required: ["type-check", "test-syntax-check"]
|
|
1047
|
+
- optional: ["test-execution"]
|
|
1048
|
+
```
|
|
1049
|
+
|
|
1050
|
+
4. **Evaluate result**
|
|
1051
|
+
- ✅ PASS: Tests generated and valid, continue to Phase 3
|
|
1052
|
+
- ⚠️ PARTIAL: Some tests generated, log warning, continue
|
|
1053
|
+
- ❌ FAIL: HALT, initiate rollback
|
|
1054
|
+
|
|
1055
|
+
5. **If FAIL:**
|
|
1056
|
+
```
|
|
1057
|
+
Use rollback-changes Skill to restore files
|
|
1058
|
+
Report failure to user
|
|
1059
|
+
Ask: Fix tests manually or skip Phase 2?
|
|
1060
|
+
```
|
|
1061
|
+
|
|
1062
|
+
---
|
|
1063
|
+
|
|
1064
|
+
## Phase 3: Verification Analysis
|
|
1065
|
+
|
|
1066
|
+
**Purpose**: Re-analyze coverage to verify improvement.
|
|
1067
|
+
|
|
1068
|
+
**Steps:**
|
|
1069
|
+
|
|
1070
|
+
1. **Update progress**
|
|
1071
|
+
```
|
|
1072
|
+
TodoWrite: Phase 3: Verification (in_progress)
|
|
1073
|
+
```
|
|
1074
|
+
|
|
1075
|
+
2. **Create verification plan**
|
|
1076
|
+
|
|
1077
|
+
Save to `.tmp/current/plans/.test-coverage-plan.json`:
|
|
1078
|
+
```json
|
|
1079
|
+
{
|
|
1080
|
+
"phase": 3,
|
|
1081
|
+
"workflow": "test-coverage",
|
|
1082
|
+
"config": {
|
|
1083
|
+
"threshold": 80,
|
|
1084
|
+
"directories": ["src/", "lib/"],
|
|
1085
|
+
"isVerification": true
|
|
1086
|
+
},
|
|
1087
|
+
"validation": {
|
|
1088
|
+
"required": ["coverage-check"],
|
|
1089
|
+
"optional": []
|
|
1090
|
+
},
|
|
1091
|
+
"nextAgent": "test-coverage-analyzer"
|
|
1092
|
+
}
|
|
1093
|
+
```
|
|
1094
|
+
|
|
1095
|
+
3. **Signal readiness**
|
|
1096
|
+
```
|
|
1097
|
+
Tell user:
|
|
1098
|
+
"✅ Ready for test-coverage-analyzer (verification)
|
|
1099
|
+
|
|
1100
|
+
Plan file created: .tmp/current/plans/.test-coverage-plan.json
|
|
1101
|
+
Next: Invoke test-coverage-analyzer worker"
|
|
1102
|
+
```
|
|
1103
|
+
|
|
1104
|
+
4. **EXIT** (Return Control)
|
|
1105
|
+
|
|
1106
|
+
**WAIT FOR USER** to invoke test-coverage-analyzer.
|
|
1107
|
+
|
|
1108
|
+
---
|
|
1109
|
+
|
|
1110
|
+
## Quality Gate 3: Check Coverage Met
|
|
1111
|
+
|
|
1112
|
+
**When**: After verification coverage analysis completes.
|
|
1113
|
+
|
|
1114
|
+
**Steps:**
|
|
1115
|
+
|
|
1116
|
+
1. **Check report exists**
|
|
1117
|
+
```bash
|
|
1118
|
+
ls .tmp/current/reports/test-coverage-report.md
|
|
1119
|
+
```
|
|
1120
|
+
|
|
1121
|
+
2. **Extract coverage percentage**
|
|
1122
|
+
- Read verification report
|
|
1123
|
+
- Extract total coverage %
|
|
1124
|
+
|
|
1125
|
+
3. **Compare to threshold**
|
|
1126
|
+
```
|
|
1127
|
+
If coverage >= threshold:
|
|
1128
|
+
Status = SUCCESS
|
|
1129
|
+
Proceed to Final Summary
|
|
1130
|
+
Else if iteration < maxIterations:
|
|
1131
|
+
Status = CONTINUE
|
|
1132
|
+
iteration++
|
|
1133
|
+
Return to Phase 2 (generate more tests)
|
|
1134
|
+
Else:
|
|
1135
|
+
Status = PARTIAL_SUCCESS
|
|
1136
|
+
Proceed to Final Summary with warning
|
|
1137
|
+
```
|
|
1138
|
+
|
|
1139
|
+
4. **Update tracking**
|
|
1140
|
+
```json
|
|
1141
|
+
{
|
|
1142
|
+
"iteration": 1,
|
|
1143
|
+
"maxIterations": 3,
|
|
1144
|
+
"coverageHistory": [
|
|
1145
|
+
{"iteration": 0, "coverage": 75.2},
|
|
1146
|
+
{"iteration": 1, "coverage": 82.5}
|
|
1147
|
+
]
|
|
1148
|
+
}
|
|
1149
|
+
```
|
|
1150
|
+
|
|
1151
|
+
---
|
|
1152
|
+
|
|
1153
|
+
## Final Phase: Summary
|
|
1154
|
+
|
|
1155
|
+
**Purpose**: Generate comprehensive summary of workflow.
|
|
1156
|
+
|
|
1157
|
+
**Steps:**
|
|
1158
|
+
|
|
1159
|
+
1. **Collect all reports**
|
|
1160
|
+
```bash
|
|
1161
|
+
ls .tmp/current/reports/
|
|
1162
|
+
- test-coverage-report.md (initial)
|
|
1163
|
+
- test-generation-report.md
|
|
1164
|
+
- test-coverage-report.md (verification)
|
|
1165
|
+
```
|
|
1166
|
+
|
|
1167
|
+
2. **Calculate metrics**
|
|
1168
|
+
- Initial coverage: X%
|
|
1169
|
+
- Final coverage: Y%
|
|
1170
|
+
- Improvement: (Y - X)%
|
|
1171
|
+
- Tests generated: N
|
|
1172
|
+
- Iterations: M
|
|
1173
|
+
|
|
1174
|
+
3. **Generate summary report**
|
|
1175
|
+
|
|
1176
|
+
````markdown
|
|
1177
|
+
# Test Coverage Workflow Summary
|
|
1178
|
+
|
|
1179
|
+
**Generated**: 2025-01-11T15:45:00Z
|
|
1180
|
+
**Orchestrator**: test-coverage-orchestrator
|
|
1181
|
+
**Status**: ✅ SUCCESS
|
|
1182
|
+
|
|
1183
|
+
---
|
|
1184
|
+
|
|
1185
|
+
## Executive Summary
|
|
1186
|
+
|
|
1187
|
+
Test coverage improvement workflow completed successfully.
|
|
1188
|
+
|
|
1189
|
+
**Key Results**:
|
|
1190
|
+
- Initial Coverage: 75.2%
|
|
1191
|
+
- Final Coverage: 82.5%
|
|
1192
|
+
- Improvement: +7.3%
|
|
1193
|
+
- Target Threshold: 80%
|
|
1194
|
+
- Iterations: 1
|
|
1195
|
+
|
|
1196
|
+
**Validation Status**: ✅ PASSED
|
|
1197
|
+
|
|
1198
|
+
---
|
|
1199
|
+
|
|
1200
|
+
## Workflow Phases
|
|
1201
|
+
|
|
1202
|
+
### Phase 1: Initial Analysis
|
|
1203
|
+
- **Status**: ✅ Complete
|
|
1204
|
+
- **Coverage**: 75.2%
|
|
1205
|
+
- **Files Analyzed**: 127
|
|
1206
|
+
- **Report**: .tmp/current/reports/test-coverage-report.md
|
|
1207
|
+
|
|
1208
|
+
### Phase 2: Test Generation
|
|
1209
|
+
- **Status**: ✅ Complete
|
|
1210
|
+
- **Tests Generated**: 15
|
|
1211
|
+
- **Files Covered**: 2 (src/utils/legacy.ts, lib/helpers/parser.ts)
|
|
1212
|
+
- **Report**: .tmp/current/reports/test-generation-report.md
|
|
1213
|
+
|
|
1214
|
+
### Phase 3: Verification
|
|
1215
|
+
- **Status**: ✅ Complete
|
|
1216
|
+
- **Final Coverage**: 82.5%
|
|
1217
|
+
- **Threshold Met**: Yes
|
|
1218
|
+
- **Report**: .tmp/current/reports/test-coverage-report.md
|
|
1219
|
+
|
|
1220
|
+
---
|
|
1221
|
+
|
|
1222
|
+
## Coverage Progress
|
|
1223
|
+
|
|
1224
|
+
| Iteration | Coverage | Status |
|
|
1225
|
+
|-----------|----------|--------|
|
|
1226
|
+
| Initial | 75.2% | ⚠️ Below Threshold |
|
|
1227
|
+
| After Tests | 82.5% | ✅ Above Threshold |
|
|
1228
|
+
|
|
1229
|
+
**Improvement**: +7.3% (75.2% → 82.5%)
|
|
1230
|
+
|
|
1231
|
+
---
|
|
1232
|
+
|
|
1233
|
+
## Quality Gates
|
|
1234
|
+
|
|
1235
|
+
All quality gates passed:
|
|
1236
|
+
- ✅ Initial Analysis Report Valid
|
|
1237
|
+
- ✅ Test Generation Successful
|
|
1238
|
+
- ✅ Type Check Passed
|
|
1239
|
+
- ✅ Verification Coverage Meets Threshold
|
|
1240
|
+
|
|
1241
|
+
---
|
|
1242
|
+
|
|
1243
|
+
## Artifacts
|
|
1244
|
+
|
|
1245
|
+
- **Plans**: .tmp/current/plans/
|
|
1246
|
+
- .test-coverage-plan.json (initial)
|
|
1247
|
+
- .test-generation-plan.json
|
|
1248
|
+
- .test-coverage-plan.json (verification)
|
|
1249
|
+
|
|
1250
|
+
- **Reports**: .tmp/current/reports/
|
|
1251
|
+
- test-coverage-report.md (initial)
|
|
1252
|
+
- test-generation-report.md
|
|
1253
|
+
- test-coverage-report.md (verification)
|
|
1254
|
+
|
|
1255
|
+
- **Changes**: .tmp/current/changes/
|
|
1256
|
+
- test-generation-changes.json
|
|
1257
|
+
|
|
1258
|
+
---
|
|
1259
|
+
|
|
1260
|
+
## Next Steps
|
|
1261
|
+
|
|
1262
|
+
1. Review generated tests for quality
|
|
1263
|
+
2. Consider adding edge case tests
|
|
1264
|
+
3. Monitor coverage in CI/CD
|
|
1265
|
+
4. Run `/health-bugs` to check for regressions
|
|
1266
|
+
|
|
1267
|
+
---
|
|
1268
|
+
|
|
1269
|
+
**Test Coverage Orchestrator workflow complete.**
|
|
1270
|
+
✅ Coverage improved from 75.2% to 82.5% (+7.3%)
|
|
1271
|
+
````
|
|
1272
|
+
|
|
1273
|
+
4. **Archive run**
|
|
1274
|
+
```bash
|
|
1275
|
+
timestamp=$(date +"%Y-%m-%d-%H%M%S")
|
|
1276
|
+
mkdir -p .tmp/archive/$timestamp/
|
|
1277
|
+
cp -r .tmp/current/* .tmp/archive/$timestamp/
|
|
1278
|
+
```
|
|
1279
|
+
|
|
1280
|
+
5. **Cleanup**
|
|
1281
|
+
```bash
|
|
1282
|
+
rm -rf .tmp/current/*
|
|
1283
|
+
```
|
|
1284
|
+
|
|
1285
|
+
6. **Report to user**
|
|
1286
|
+
```
|
|
1287
|
+
✅ Test Coverage Workflow Complete!
|
|
1288
|
+
|
|
1289
|
+
Initial Coverage: 75.2%
|
|
1290
|
+
Final Coverage: 82.5%
|
|
1291
|
+
Improvement: +7.3%
|
|
1292
|
+
|
|
1293
|
+
Full summary: docs/reports/test-coverage-summary.md
|
|
1294
|
+
Archived run: .tmp/archive/2025-01-11-154500/
|
|
1295
|
+
```
|
|
1296
|
+
|
|
1297
|
+
---
|
|
1298
|
+
|
|
1299
|
+
## Error Handling
|
|
1300
|
+
|
|
1301
|
+
### Worker Report Missing
|
|
1302
|
+
|
|
1303
|
+
**Symptoms**: Expected report not found after worker invocation.
|
|
1304
|
+
|
|
1305
|
+
**Actions:**
|
|
1306
|
+
1. HALT workflow
|
|
1307
|
+
2. Check .tmp/current/reports/ for any reports
|
|
1308
|
+
3. Report error to user: "Worker did not generate report"
|
|
1309
|
+
4. Ask user: retry worker or abort workflow?
|
|
1310
|
+
|
|
1311
|
+
### Quality Gate FAIL (Blocking)
|
|
1312
|
+
|
|
1313
|
+
**Symptoms**: Type-check or build fails after worker changes.
|
|
1314
|
+
|
|
1315
|
+
**Actions:**
|
|
1316
|
+
1. STOP workflow immediately
|
|
1317
|
+
2. Use rollback-changes Skill to restore files
|
|
1318
|
+
3. Report error details to user
|
|
1319
|
+
4. Ask user: fix manually or abort?
|
|
1320
|
+
|
|
1321
|
+
### Max Iterations Reached
|
|
1322
|
+
|
|
1323
|
+
**Symptoms**: iteration >= maxIterations and coverage < threshold.
|
|
1324
|
+
|
|
1325
|
+
**Actions:**
|
|
1326
|
+
1. Generate summary with PARTIAL_SUCCESS status
|
|
1327
|
+
2. Report final coverage vs threshold
|
|
1328
|
+
3. List remaining gaps
|
|
1329
|
+
4. Recommend: manual test writing or lower threshold
|
|
1330
|
+
|
|
1331
|
+
---
|
|
1332
|
+
|
|
1333
|
+
## Iteration Control
|
|
1334
|
+
|
|
1335
|
+
**Max iterations**: 3
|
|
1336
|
+
|
|
1337
|
+
**Iteration state tracking**:
|
|
1338
|
+
```json
|
|
1339
|
+
{
|
|
1340
|
+
"iteration": 1,
|
|
1341
|
+
"maxIterations": 3,
|
|
1342
|
+
"coverageHistory": [
|
|
1343
|
+
{"iteration": 0, "coverage": 75.2, "phase": "initial"},
|
|
1344
|
+
{"iteration": 1, "coverage": 82.5, "phase": "after-generation"}
|
|
1345
|
+
],
|
|
1346
|
+
"completedPhases": ["initial-analysis", "test-generation", "verification"]
|
|
1347
|
+
}
|
|
1348
|
+
```
|
|
1349
|
+
|
|
1350
|
+
**Exit conditions:**
|
|
1351
|
+
- ✅ Coverage >= threshold (success)
|
|
1352
|
+
- ⛔ Max iterations reached (partial success)
|
|
1353
|
+
- ❌ Blocking quality gate failed (failure)
|
|
1354
|
+
|
|
1355
|
+
---
|
|
1356
|
+
|
|
1357
|
+
## MCP Integration
|
|
1358
|
+
|
|
1359
|
+
**Recommended MCP servers**:
|
|
1360
|
+
- `mcp__context7__*` - For test framework best practices
|
|
1361
|
+
- Optional: `mcp__supabase__*` if testing database code
|
|
1362
|
+
|
|
1363
|
+
**MCP guidance in plan files**: See Phase 1, Phase 2 examples above.
|
|
1364
|
+
|
|
1365
|
+
---
|
|
1366
|
+
|
|
1367
|
+
## TodoWrite Progress Tracking
|
|
1368
|
+
|
|
1369
|
+
**Initial state:**
|
|
1370
|
+
```json
|
|
1371
|
+
[
|
|
1372
|
+
{"content": "Phase 0: Pre-Flight", "status": "pending", "activeForm": "Setting up environment"},
|
|
1373
|
+
{"content": "Phase 1: Initial Analysis", "status": "pending", "activeForm": "Analyzing coverage"},
|
|
1374
|
+
{"content": "Phase 2: Test Generation", "status": "pending", "activeForm": "Generating tests"},
|
|
1375
|
+
{"content": "Phase 3: Verification", "status": "pending", "activeForm": "Verifying improvements"},
|
|
1376
|
+
{"content": "Phase 4: Summary", "status": "pending", "activeForm": "Generating summary"}
|
|
1377
|
+
]
|
|
1378
|
+
```
|
|
1379
|
+
|
|
1380
|
+
**Update as phases complete:**
|
|
1381
|
+
- in_progress → completed
|
|
1382
|
+
- Keep EXACTLY ONE task in_progress at a time
|
|
1383
|
+
|
|
1384
|
+
---
|
|
1385
|
+
|
|
1386
|
+
**This orchestrator follows:**
|
|
1387
|
+
- ARCHITECTURE.md orchestrator pattern
|
|
1388
|
+
- CLAUDE.md Prime Directives (PD-1: Return Control, PD-2: Quality Gates)
|
|
1389
|
+
- Return Control pattern (NO Task tool for worker invocation)
|
|
1390
|
+
- Quality gates with blocking logic
|
|
1391
|
+
- Iterative workflow with max iterations
|
|
1392
|
+
- TodoWrite progress tracking
|
|
1393
|
+
```
|
|
1394
|
+
|
|
1395
|
+
### Step 4: Test Orchestrator
|
|
1396
|
+
|
|
1397
|
+
**End-to-end test:**
|
|
1398
|
+
|
|
1399
|
+
1. Start workflow:
|
|
1400
|
+
```
|
|
1401
|
+
Ask Claude Code: "Run test-coverage-orchestrator to improve coverage to 80%"
|
|
1402
|
+
```
|
|
1403
|
+
|
|
1404
|
+
2. Follow orchestrator signals:
|
|
1405
|
+
- Phase 1: Orchestrator signals "Ready for test-coverage-analyzer"
|
|
1406
|
+
- You invoke: "Invoke test-coverage-analyzer worker"
|
|
1407
|
+
- Phase 2: Orchestrator signals "Ready for test-generation-worker"
|
|
1408
|
+
- You invoke: "Invoke test-generation-worker"
|
|
1409
|
+
- etc.
|
|
1410
|
+
|
|
1411
|
+
3. Verify:
|
|
1412
|
+
- Each phase completes successfully
|
|
1413
|
+
- Quality gates validate correctly
|
|
1414
|
+
- Final summary shows coverage improvement
|
|
1415
|
+
- Artifacts archived properly
|
|
1416
|
+
|
|
1417
|
+
### Key Takeaways
|
|
1418
|
+
|
|
1419
|
+
**Orchestrator agents:**
|
|
1420
|
+
- ✅ Coordinate multi-phase workflows
|
|
1421
|
+
- ✅ Create plan files for workers
|
|
1422
|
+
- ✅ Return control (PD-1): NO Task tool
|
|
1423
|
+
- ✅ Validate at quality gates
|
|
1424
|
+
- ✅ Track progress via TodoWrite
|
|
1425
|
+
- ✅ Handle iterations with max limit
|
|
1426
|
+
- ❌ NO implementation work
|
|
1427
|
+
- ❌ NO skip quality gates
|
|
1428
|
+
|
|
1429
|
+
---
|
|
1430
|
+
|
|
1431
|
+
## Tutorial 4: Creating a Skill
|
|
1432
|
+
|
|
1433
|
+
**Goal**: Create a `parse-coverage-report` skill that parses coverage JSON into structured data.
|
|
1434
|
+
|
|
1435
|
+
### Step 1: Plan the Skill
|
|
1436
|
+
|
|
1437
|
+
**Requirements:**
|
|
1438
|
+
- Input: Coverage JSON file path
|
|
1439
|
+
- Output: Structured data (lines %, branches %, functions %, statements %)
|
|
1440
|
+
- Pure function, no side effects
|
|
1441
|
+
- < 100 lines logic
|
|
1442
|
+
|
|
1443
|
+
### Step 2: Decide: Agent or Skill?
|
|
1444
|
+
|
|
1445
|
+
**Decision criteria:**
|
|
1446
|
+
- ✅ Stateless utility function → **Skill**
|
|
1447
|
+
- ✅ < 100 lines → **Skill**
|
|
1448
|
+
- ✅ Reusable across agents → **Skill**
|
|
1449
|
+
- ✅ No coordination needed → **Skill**
|
|
1450
|
+
|
|
1451
|
+
**Answer**: This should be a **Skill**.
|
|
1452
|
+
|
|
1453
|
+
### Step 3: Create Skill Directory
|
|
1454
|
+
|
|
1455
|
+
```bash
|
|
1456
|
+
mkdir -p .claude/skills/parse-coverage-report/
|
|
1457
|
+
touch .claude/skills/parse-coverage-report/SKILL.md
|
|
1458
|
+
```
|
|
1459
|
+
|
|
1460
|
+
### Step 4: Write Skill
|
|
1461
|
+
|
|
1462
|
+
```markdown
|
|
1463
|
+
---
|
|
1464
|
+
name: parse-coverage-report
|
|
1465
|
+
description: Parse test coverage reports (JSON format) into structured data. Use when you need to extract coverage percentages, file-level metrics, or aggregate statistics from coverage tools.
|
|
1466
|
+
allowed-tools: Read
|
|
1467
|
+
---
|
|
1468
|
+
|
|
1469
|
+
# Parse Coverage Report
|
|
1470
|
+
|
|
1471
|
+
Parses test coverage reports (coverage-summary.json format) into structured data for analysis and reporting.
|
|
1472
|
+
|
|
1473
|
+
## When to Use
|
|
1474
|
+
|
|
1475
|
+
- Extract coverage percentages from coverage reports
|
|
1476
|
+
- Aggregate coverage across multiple files/directories
|
|
1477
|
+
- Compare coverage against thresholds
|
|
1478
|
+
- Generate coverage summaries
|
|
1479
|
+
- Identify low-coverage files
|
|
1480
|
+
|
|
1481
|
+
## Instructions
|
|
1482
|
+
|
|
1483
|
+
### Step 1: Read Coverage Report
|
|
1484
|
+
|
|
1485
|
+
**Input**: Path to coverage report (typically `coverage/coverage-summary.json`)
|
|
1486
|
+
|
|
1487
|
+
Use Read tool to load report:
|
|
1488
|
+
```
|
|
1489
|
+
Read coverage/coverage-summary.json
|
|
1490
|
+
```
|
|
1491
|
+
|
|
1492
|
+
### Step 2: Parse JSON Structure
|
|
1493
|
+
|
|
1494
|
+
Expected format:
|
|
1495
|
+
```json
|
|
1496
|
+
{
|
|
1497
|
+
"total": {
|
|
1498
|
+
"lines": {"total": 1000, "covered": 850, "skipped": 0, "pct": 85},
|
|
1499
|
+
"statements": {"total": 1200, "covered": 1020, "skipped": 0, "pct": 85},
|
|
1500
|
+
"functions": {"total": 150, "covered": 135, "skipped": 0, "pct": 90},
|
|
1501
|
+
"branches": {"total": 300, "covered": 240, "skipped": 0, "pct": 80}
|
|
1502
|
+
},
|
|
1503
|
+
"src/file1.ts": {
|
|
1504
|
+
"lines": {"total": 100, "covered": 85, "skipped": 0, "pct": 85},
|
|
1505
|
+
...
|
|
1506
|
+
},
|
|
1507
|
+
"src/file2.ts": { ... }
|
|
1508
|
+
}
|
|
1509
|
+
```
|
|
1510
|
+
|
|
1511
|
+
### Step 3: Extract Total Coverage
|
|
1512
|
+
|
|
1513
|
+
```
|
|
1514
|
+
totalCoverage = {
|
|
1515
|
+
lines: report.total.lines.pct,
|
|
1516
|
+
statements: report.total.statements.pct,
|
|
1517
|
+
functions: report.total.functions.pct,
|
|
1518
|
+
branches: report.total.branches.pct
|
|
1519
|
+
}
|
|
1520
|
+
```
|
|
1521
|
+
|
|
1522
|
+
### Step 4: Calculate Per-File Coverage
|
|
1523
|
+
|
|
1524
|
+
For each file in report (excluding "total"):
|
|
1525
|
+
```
|
|
1526
|
+
fileData[filepath] = {
|
|
1527
|
+
lines: report[filepath].lines.pct,
|
|
1528
|
+
statements: report[filepath].statements.pct,
|
|
1529
|
+
functions: report[filepath].functions.pct,
|
|
1530
|
+
branches: report[filepath].branches.pct
|
|
1531
|
+
}
|
|
1532
|
+
```
|
|
1533
|
+
|
|
1534
|
+
### Step 5: Identify Low Coverage Files
|
|
1535
|
+
|
|
1536
|
+
```
|
|
1537
|
+
lowCoverageFiles = fileData.filter(file => file.lines < threshold)
|
|
1538
|
+
Sort by coverage (lowest first)
|
|
1539
|
+
```
|
|
1540
|
+
|
|
1541
|
+
### Step 6: Calculate Averages by Directory
|
|
1542
|
+
|
|
1543
|
+
```
|
|
1544
|
+
Group files by directory prefix
|
|
1545
|
+
Calculate average coverage per directory
|
|
1546
|
+
```
|
|
1547
|
+
|
|
1548
|
+
## Input Format
|
|
1549
|
+
|
|
1550
|
+
**Path to coverage report file**:
|
|
1551
|
+
```
|
|
1552
|
+
coverage/coverage-summary.json
|
|
1553
|
+
```
|
|
1554
|
+
|
|
1555
|
+
**Optional threshold for low-coverage filter**:
|
|
1556
|
+
```
|
|
1557
|
+
threshold: 70 # Files below 70% considered low coverage
|
|
1558
|
+
```
|
|
1559
|
+
|
|
1560
|
+
## Output Format
|
|
1561
|
+
|
|
1562
|
+
Return structured object:
|
|
1563
|
+
|
|
1564
|
+
```json
|
|
1565
|
+
{
|
|
1566
|
+
"total": {
|
|
1567
|
+
"lines": 85.0,
|
|
1568
|
+
"statements": 85.0,
|
|
1569
|
+
"functions": 90.0,
|
|
1570
|
+
"branches": 80.0
|
|
1571
|
+
},
|
|
1572
|
+
"byDirectory": {
|
|
1573
|
+
"src/utils/": {
|
|
1574
|
+
"lines": 92.3,
|
|
1575
|
+
"statements": 91.7,
|
|
1576
|
+
"functions": 94.1,
|
|
1577
|
+
"branches": 88.2
|
|
1578
|
+
},
|
|
1579
|
+
"src/components/": {
|
|
1580
|
+
"lines": 81.5,
|
|
1581
|
+
"statements": 82.1,
|
|
1582
|
+
"functions": 87.3,
|
|
1583
|
+
"branches": 75.4
|
|
1584
|
+
}
|
|
1585
|
+
},
|
|
1586
|
+
"lowCoverageFiles": [
|
|
1587
|
+
{
|
|
1588
|
+
"path": "src/utils/legacy.ts",
|
|
1589
|
+
"lines": 45.2,
|
|
1590
|
+
"statements": 44.8,
|
|
1591
|
+
"functions": 50.0,
|
|
1592
|
+
"branches": 40.1
|
|
1593
|
+
},
|
|
1594
|
+
{
|
|
1595
|
+
"path": "lib/helpers/parser.ts",
|
|
1596
|
+
"lines": 58.9,
|
|
1597
|
+
"statements": 59.2,
|
|
1598
|
+
"functions": 65.0,
|
|
1599
|
+
"branches": 52.3
|
|
1600
|
+
}
|
|
1601
|
+
],
|
|
1602
|
+
"filesCount": 127,
|
|
1603
|
+
"directoriesCount": 8
|
|
1604
|
+
}
|
|
1605
|
+
```
|
|
1606
|
+
|
|
1607
|
+
## Examples
|
|
1608
|
+
|
|
1609
|
+
### Example 1: Parse and display total coverage
|
|
1610
|
+
|
|
1611
|
+
**Input:**
|
|
1612
|
+
```
|
|
1613
|
+
Use parse-coverage-report skill on coverage/coverage-summary.json
|
|
1614
|
+
```
|
|
1615
|
+
|
|
1616
|
+
**Output:**
|
|
1617
|
+
```json
|
|
1618
|
+
{
|
|
1619
|
+
"total": {
|
|
1620
|
+
"lines": 85.0,
|
|
1621
|
+
"statements": 85.0,
|
|
1622
|
+
"functions": 90.0,
|
|
1623
|
+
"branches": 80.0
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
```
|
|
1627
|
+
|
|
1628
|
+
### Example 2: Find low-coverage files (threshold 70%)
|
|
1629
|
+
|
|
1630
|
+
**Input:**
|
|
1631
|
+
```
|
|
1632
|
+
Use parse-coverage-report skill on coverage/coverage-summary.json with threshold 70
|
|
1633
|
+
```
|
|
1634
|
+
|
|
1635
|
+
**Output:**
|
|
1636
|
+
```json
|
|
1637
|
+
{
|
|
1638
|
+
"total": { ... },
|
|
1639
|
+
"lowCoverageFiles": [
|
|
1640
|
+
{"path": "src/utils/legacy.ts", "lines": 45.2},
|
|
1641
|
+
{"path": "lib/helpers/parser.ts", "lines": 58.9}
|
|
1642
|
+
]
|
|
1643
|
+
}
|
|
1644
|
+
```
|
|
1645
|
+
|
|
1646
|
+
### Example 3: Coverage by directory
|
|
1647
|
+
|
|
1648
|
+
**Input:**
|
|
1649
|
+
```
|
|
1650
|
+
Use parse-coverage-report skill on coverage/coverage-summary.json, group by directory
|
|
1651
|
+
```
|
|
1652
|
+
|
|
1653
|
+
**Output:**
|
|
1654
|
+
```json
|
|
1655
|
+
{
|
|
1656
|
+
"total": { ... },
|
|
1657
|
+
"byDirectory": {
|
|
1658
|
+
"src/utils/": {"lines": 92.3},
|
|
1659
|
+
"src/components/": {"lines": 81.5},
|
|
1660
|
+
"lib/": {"lines": 75.2}
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
```
|
|
1664
|
+
|
|
1665
|
+
## Error Handling
|
|
1666
|
+
|
|
1667
|
+
### Report file not found
|
|
1668
|
+
|
|
1669
|
+
**Error**: Coverage report doesn't exist at specified path
|
|
1670
|
+
|
|
1671
|
+
**Action**: Return error object:
|
|
1672
|
+
```json
|
|
1673
|
+
{
|
|
1674
|
+
"error": "Coverage report not found",
|
|
1675
|
+
"path": "coverage/coverage-summary.json",
|
|
1676
|
+
"suggestion": "Run test:coverage first"
|
|
1677
|
+
}
|
|
1678
|
+
```
|
|
1679
|
+
|
|
1680
|
+
### Invalid JSON format
|
|
1681
|
+
|
|
1682
|
+
**Error**: File exists but isn't valid JSON
|
|
1683
|
+
|
|
1684
|
+
**Action**:
|
|
1685
|
+
```json
|
|
1686
|
+
{
|
|
1687
|
+
"error": "Invalid JSON format",
|
|
1688
|
+
"details": "Unexpected token at line 5"
|
|
1689
|
+
}
|
|
1690
|
+
```
|
|
1691
|
+
|
|
1692
|
+
### Missing expected fields
|
|
1693
|
+
|
|
1694
|
+
**Error**: JSON structure doesn't match expected format
|
|
1695
|
+
|
|
1696
|
+
**Action**:
|
|
1697
|
+
```json
|
|
1698
|
+
{
|
|
1699
|
+
"error": "Unexpected coverage format",
|
|
1700
|
+
"details": "Missing 'total' field",
|
|
1701
|
+
"suggestion": "Check if coverage tool is supported (Jest, Vitest, Istanbul)"
|
|
1702
|
+
}
|
|
1703
|
+
```
|
|
1704
|
+
|
|
1705
|
+
## Notes
|
|
1706
|
+
|
|
1707
|
+
- **Tool restriction**: Only Read tool allowed (stateless parsing)
|
|
1708
|
+
- **Performance**: Fast, no external commands
|
|
1709
|
+
- **Compatibility**: Supports Istanbul/NYC coverage format (Jest, Vitest)
|
|
1710
|
+
- **Pure function**: No side effects, same input = same output
|
|
1711
|
+
|
|
1712
|
+
---
|
|
1713
|
+
|
|
1714
|
+
**This skill follows SKILL.md format and best practices.**
|
|
1715
|
+
```
|
|
1716
|
+
|
|
1717
|
+
### Step 5: Test Skill
|
|
1718
|
+
|
|
1719
|
+
```
|
|
1720
|
+
# Test with actual coverage report
|
|
1721
|
+
Ask Claude Code: "Use parse-coverage-report skill on coverage/coverage-summary.json"
|
|
1722
|
+
|
|
1723
|
+
# Verify output
|
|
1724
|
+
- Should return structured data
|
|
1725
|
+
- Total coverage percentages should match report
|
|
1726
|
+
- Low-coverage files should be identified correctly
|
|
1727
|
+
```
|
|
1728
|
+
|
|
1729
|
+
### Key Takeaways
|
|
1730
|
+
|
|
1731
|
+
**Skills:**
|
|
1732
|
+
- ✅ Stateless utility functions
|
|
1733
|
+
- ✅ < 100 lines logic
|
|
1734
|
+
- ✅ Invoked via Skill tool
|
|
1735
|
+
- ✅ No context isolation
|
|
1736
|
+
- ✅ Can restrict tools via `allowed-tools`
|
|
1737
|
+
- ✅ Reusable across multiple agents
|
|
1738
|
+
- ❌ No stateful workflows
|
|
1739
|
+
- ❌ No agent coordination
|
|
1740
|
+
|
|
1741
|
+
---
|
|
1742
|
+
|
|
1743
|
+
## Best Practices
|
|
1744
|
+
|
|
1745
|
+
### 1. Follow ARCHITECTURE.md Patterns
|
|
1746
|
+
|
|
1747
|
+
Always reference ARCHITECTURE.md when creating agents:
|
|
1748
|
+
```
|
|
1749
|
+
Read docs/Agents Ecosystem/ARCHITECTURE.md
|
|
1750
|
+
```
|
|
1751
|
+
|
|
1752
|
+
Key patterns:
|
|
1753
|
+
- Orchestrators use Return Control (PD-1)
|
|
1754
|
+
- Workers have 5 phases
|
|
1755
|
+
- Simple agents are minimal
|
|
1756
|
+
- Skills are stateless utilities
|
|
1757
|
+
|
|
1758
|
+
### 2. Use Meta-Agent When Possible
|
|
1759
|
+
|
|
1760
|
+
Unless you need heavy customization, use meta-agent:
|
|
1761
|
+
```
|
|
1762
|
+
"Create a worker agent for {task}"
|
|
1763
|
+
```
|
|
1764
|
+
|
|
1765
|
+
Meta-agent ensures:
|
|
1766
|
+
- ✅ Correct structure
|
|
1767
|
+
- ✅ YAML frontmatter
|
|
1768
|
+
- ✅ Proper patterns
|
|
1769
|
+
- ✅ Validation checklist
|
|
1770
|
+
|
|
1771
|
+
### 3. Reference Existing Agents
|
|
1772
|
+
|
|
1773
|
+
Before creating custom agent, check existing agents:
|
|
1774
|
+
```bash
|
|
1775
|
+
ls .claude/agents/health/workers/
|
|
1776
|
+
ls .claude/agents/health/orchestrators/
|
|
1777
|
+
```
|
|
1778
|
+
|
|
1779
|
+
Use similar agent as template:
|
|
1780
|
+
- Copy structure
|
|
1781
|
+
- Modify domain logic
|
|
1782
|
+
- Update YAML frontmatter
|
|
1783
|
+
|
|
1784
|
+
### 4. Validate with Skills
|
|
1785
|
+
|
|
1786
|
+
Use validation skills:
|
|
1787
|
+
- `validate-plan-file` - Check plan JSON schema
|
|
1788
|
+
- `validate-report-file` - Check report completeness
|
|
1789
|
+
|
|
1790
|
+
### 5. Test Incrementally
|
|
1791
|
+
|
|
1792
|
+
Don't test full workflow at once:
|
|
1793
|
+
|
|
1794
|
+
1. Test plan file generation
|
|
1795
|
+
2. Test worker in isolation
|
|
1796
|
+
3. Test quality gates
|
|
1797
|
+
4. Test full orchestrator workflow
|
|
1798
|
+
|
|
1799
|
+
### 6. Use Descriptive Names
|
|
1800
|
+
|
|
1801
|
+
**Good names:**
|
|
1802
|
+
- `test-coverage-analyzer`
|
|
1803
|
+
- `security-scanner`
|
|
1804
|
+
- `dependency-auditor`
|
|
1805
|
+
|
|
1806
|
+
**Bad names:**
|
|
1807
|
+
- `analyzer`
|
|
1808
|
+
- `checker`
|
|
1809
|
+
- `helper`
|
|
1810
|
+
|
|
1811
|
+
### 7. Document MCP Requirements
|
|
1812
|
+
|
|
1813
|
+
Specify which MCP servers agent needs:
|
|
1814
|
+
```yaml
|
|
1815
|
+
mcpGuidance:
|
|
1816
|
+
recommended: ["mcp__context7__*"]
|
|
1817
|
+
library: "jest"
|
|
1818
|
+
reason: "Check current Jest best practices"
|
|
1819
|
+
```
|
|
1820
|
+
|
|
1821
|
+
### 8. Handle Errors Gracefully
|
|
1822
|
+
|
|
1823
|
+
Every phase should have error handling:
|
|
1824
|
+
- Plan file missing → Use defaults + log warning
|
|
1825
|
+
- Validation fails → Rollback + report error
|
|
1826
|
+
- MCP unavailable → Use fallback + reduce confidence
|
|
1827
|
+
|
|
1828
|
+
### 9. Keep Skills Small
|
|
1829
|
+
|
|
1830
|
+
Skills should be < 100 lines:
|
|
1831
|
+
- If logic exceeds 100 lines → Create worker agent instead
|
|
1832
|
+
- Focus on single utility function
|
|
1833
|
+
- No multi-step workflows in skills
|
|
1834
|
+
|
|
1835
|
+
### 10. Use TodoWrite for Progress
|
|
1836
|
+
|
|
1837
|
+
Orchestrators should track progress:
|
|
1838
|
+
```json
|
|
1839
|
+
[
|
|
1840
|
+
{"content": "Phase 1", "status": "completed", "activeForm": "..."},
|
|
1841
|
+
{"content": "Phase 2", "status": "in_progress", "activeForm": "..."},
|
|
1842
|
+
{"content": "Phase 3", "status": "pending", "activeForm": "..."}
|
|
1843
|
+
]
|
|
1844
|
+
```
|
|
1845
|
+
|
|
1846
|
+
---
|
|
1847
|
+
|
|
1848
|
+
## Testing Your Agent
|
|
1849
|
+
|
|
1850
|
+
### Unit Testing (Skills)
|
|
1851
|
+
|
|
1852
|
+
**Test skills directly:**
|
|
1853
|
+
```
|
|
1854
|
+
# Test parse-coverage-report skill
|
|
1855
|
+
Create test file: coverage/test-coverage-summary.json
|
|
1856
|
+
Ask Claude Code: "Use parse-coverage-report skill on coverage/test-coverage-summary.json"
|
|
1857
|
+
Verify output structure matches expected format
|
|
1858
|
+
```
|
|
1859
|
+
|
|
1860
|
+
### Integration Testing (Workers)
|
|
1861
|
+
|
|
1862
|
+
**Test workers with plan files:**
|
|
1863
|
+
```
|
|
1864
|
+
# Create plan file
|
|
1865
|
+
Save plan to .tmp/current/plans/.workflow-plan.json
|
|
1866
|
+
|
|
1867
|
+
# Invoke worker
|
|
1868
|
+
Ask Claude Code: "Invoke {worker-name} worker"
|
|
1869
|
+
|
|
1870
|
+
# Verify outputs
|
|
1871
|
+
- Report generated?
|
|
1872
|
+
- Report has all required sections?
|
|
1873
|
+
- Changes logged?
|
|
1874
|
+
- Validation passed?
|
|
1875
|
+
```
|
|
1876
|
+
|
|
1877
|
+
### End-to-End Testing (Orchestrators)
|
|
1878
|
+
|
|
1879
|
+
**Test full workflow:**
|
|
1880
|
+
```
|
|
1881
|
+
# Start orchestrator
|
|
1882
|
+
Ask Claude Code: "Run {orchestrator-name} for {task}"
|
|
1883
|
+
|
|
1884
|
+
# Follow signals
|
|
1885
|
+
When orchestrator signals "Ready for {worker}", invoke worker
|
|
1886
|
+
Repeat for each phase
|
|
1887
|
+
|
|
1888
|
+
# Verify workflow
|
|
1889
|
+
- All phases completed?
|
|
1890
|
+
- Quality gates passed?
|
|
1891
|
+
- Final summary generated?
|
|
1892
|
+
- Artifacts archived?
|
|
1893
|
+
```
|
|
1894
|
+
|
|
1895
|
+
### Validation Checklist
|
|
1896
|
+
|
|
1897
|
+
Before shipping custom agent, verify:
|
|
1898
|
+
|
|
1899
|
+
**For all agents:**
|
|
1900
|
+
- [ ] YAML frontmatter complete (name, description, model, color)
|
|
1901
|
+
- [ ] Description is clear and action-oriented
|
|
1902
|
+
- [ ] Examples provided
|
|
1903
|
+
- [ ] Error handling included
|
|
1904
|
+
|
|
1905
|
+
**For workers:**
|
|
1906
|
+
- [ ] Has 5 phases (Read Plan → Execute → Validate → Report → Return)
|
|
1907
|
+
- [ ] Reads plan file from `.tmp/current/plans/`
|
|
1908
|
+
- [ ] Generates structured report following REPORT-TEMPLATE-STANDARD.md
|
|
1909
|
+
- [ ] Logs changes to `.tmp/current/changes/`
|
|
1910
|
+
- [ ] Returns control (does NOT invoke other agents)
|
|
1911
|
+
|
|
1912
|
+
**For orchestrators:**
|
|
1913
|
+
- [ ] Uses Return Control pattern (signals readiness, exits)
|
|
1914
|
+
- [ ] Does NOT use Task tool to invoke workers
|
|
1915
|
+
- [ ] Creates valid plan files (validated via `validate-plan-file`)
|
|
1916
|
+
- [ ] Has quality gates between phases
|
|
1917
|
+
- [ ] Tracks progress via TodoWrite
|
|
1918
|
+
- [ ] Handles errors with rollback instructions
|
|
1919
|
+
|
|
1920
|
+
**For skills:**
|
|
1921
|
+
- [ ] Stateless (no side effects)
|
|
1922
|
+
- [ ] < 100 lines logic
|
|
1923
|
+
- [ ] Clear input/output format
|
|
1924
|
+
- [ ] Examples provided
|
|
1925
|
+
- [ ] Tool restrictions specified (if any)
|
|
1926
|
+
|
|
1927
|
+
---
|
|
1928
|
+
|
|
1929
|
+
## Troubleshooting
|
|
1930
|
+
|
|
1931
|
+
### Agent Not Showing Up
|
|
1932
|
+
|
|
1933
|
+
**Problem**: Created agent but Claude Code doesn't recognize it.
|
|
1934
|
+
|
|
1935
|
+
**Solution:**
|
|
1936
|
+
1. Verify file location: `.claude/agents/{category}/{type}/{name}.md`
|
|
1937
|
+
2. Check YAML frontmatter syntax
|
|
1938
|
+
3. Restart Claude Code
|
|
1939
|
+
4. Try invoking explicitly: "Use {agent-name} agent for {task}"
|
|
1940
|
+
|
|
1941
|
+
### YAML Frontmatter Errors
|
|
1942
|
+
|
|
1943
|
+
**Problem**: Agent fails to load due to YAML syntax error.
|
|
1944
|
+
|
|
1945
|
+
**Solution:**
|
|
1946
|
+
```yaml
|
|
1947
|
+
# ✅ Correct
|
|
1948
|
+
---
|
|
1949
|
+
name: my-agent
|
|
1950
|
+
description: Use for...
|
|
1951
|
+
model: sonnet
|
|
1952
|
+
color: cyan
|
|
1953
|
+
---
|
|
1954
|
+
|
|
1955
|
+
# ❌ Wrong (missing closing ---)
|
|
1956
|
+
---
|
|
1957
|
+
name: my-agent
|
|
1958
|
+
description: Use for...
|
|
1959
|
+
```
|
|
1960
|
+
|
|
1961
|
+
### Worker Not Reading Plan File
|
|
1962
|
+
|
|
1963
|
+
**Problem**: Worker starts but doesn't find plan file.
|
|
1964
|
+
|
|
1965
|
+
**Solution:**
|
|
1966
|
+
1. Check plan file location: `.tmp/current/plans/.{workflow}-plan.json`
|
|
1967
|
+
2. Verify plan file is valid JSON
|
|
1968
|
+
3. Ensure orchestrator created plan BEFORE invoking worker
|
|
1969
|
+
4. Check worker phase 1 instructions read correct path
|
|
1970
|
+
|
|
1971
|
+
### Quality Gate Always Failing
|
|
1972
|
+
|
|
1973
|
+
**Problem**: Quality gate fails even after fixes.
|
|
1974
|
+
|
|
1975
|
+
**Solution:**
|
|
1976
|
+
```bash
|
|
1977
|
+
# Run validation manually to see full errors
|
|
1978
|
+
npm run type-check
|
|
1979
|
+
npm run build
|
|
1980
|
+
npm run test
|
|
1981
|
+
|
|
1982
|
+
# Check quality gate script
|
|
1983
|
+
cat .claude/scripts/gates/check-*.sh
|
|
1984
|
+
|
|
1985
|
+
# Verify validation criteria in plan file
|
|
1986
|
+
cat .tmp/current/plans/*.json | jq .validation
|
|
1987
|
+
```
|
|
1988
|
+
|
|
1989
|
+
### Orchestrator Invoking Workers (PD-1 Violation)
|
|
1990
|
+
|
|
1991
|
+
**Problem**: Orchestrator tries to use Task tool to invoke workers.
|
|
1992
|
+
|
|
1993
|
+
**Solution:**
|
|
1994
|
+
- Remove Task tool invocation
|
|
1995
|
+
- Add "Signal readiness" step instead
|
|
1996
|
+
- Add "EXIT" after signaling
|
|
1997
|
+
- Wait for user to invoke worker manually
|
|
1998
|
+
|
|
1999
|
+
Example fix:
|
|
2000
|
+
```markdown
|
|
2001
|
+
# ❌ Wrong
|
|
2002
|
+
Use Task tool to invoke bug-hunter worker
|
|
2003
|
+
|
|
2004
|
+
# ✅ Correct
|
|
2005
|
+
Signal readiness:
|
|
2006
|
+
"✅ Ready for bug-hunter. Next: Invoke bug-hunter worker"
|
|
2007
|
+
|
|
2008
|
+
EXIT (Return Control)
|
|
2009
|
+
```
|
|
2010
|
+
|
|
2011
|
+
### Report Missing Required Sections
|
|
2012
|
+
|
|
2013
|
+
**Problem**: Worker report fails `validate-report-file` skill.
|
|
2014
|
+
|
|
2015
|
+
**Solution:**
|
|
2016
|
+
- Reference REPORT-TEMPLATE-STANDARD.md
|
|
2017
|
+
- Use `generate-report-header` skill for header
|
|
2018
|
+
- Ensure all required sections present:
|
|
2019
|
+
- Executive Summary
|
|
2020
|
+
- Work Performed
|
|
2021
|
+
- Changes Made
|
|
2022
|
+
- Validation Results
|
|
2023
|
+
- Next Steps
|
|
2024
|
+
- Artifacts
|
|
2025
|
+
|
|
2026
|
+
---
|
|
2027
|
+
|
|
2028
|
+
## Additional Resources
|
|
2029
|
+
|
|
2030
|
+
- **Architecture**: [ARCHITECTURE.md](./ARCHITECTURE.md) — System design and patterns
|
|
2031
|
+
- **FAQ**: [FAQ.md](./FAQ.md) — Common questions
|
|
2032
|
+
- **Use Cases**: [USE-CASES.md](./USE-CASES.md) — Real-world examples
|
|
2033
|
+
- **Performance**: [PERFORMANCE-OPTIMIZATION.md](./PERFORMANCE-OPTIMIZATION.md) — Token optimization
|
|
2034
|
+
- **Behavioral OS**: [../CLAUDE.md](../CLAUDE.md) — Prime Directives and contracts
|
|
2035
|
+
- **Agent Ecosystem**: [Agents Ecosystem/ARCHITECTURE.md](./Agents%20Ecosystem/ARCHITECTURE.md) — Detailed specifications
|
|
2036
|
+
|
|
2037
|
+
---
|
|
2038
|
+
|
|
2039
|
+
**Tutorial Version**: 1.0
|
|
2040
|
+
**Last Updated**: 2025-01-11
|
|
2041
|
+
**Maintained by**: [Igor Maslennikov](https://github.com/maslennikov-ig)
|