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,568 @@
|
|
|
1
|
+
# Agent-Based Orchestration Pattern
|
|
2
|
+
|
|
3
|
+
> **CONTEXT**: This pattern is used in ~5% of cases for automated health workflows.
|
|
4
|
+
> For manual development (95% of cases), see CLAUDE.md.
|
|
5
|
+
|
|
6
|
+
## When to Use
|
|
7
|
+
|
|
8
|
+
This pattern applies ONLY to automated health workflows:
|
|
9
|
+
- `/health-bugs` - Bug detection and fixing
|
|
10
|
+
- `/health-security` - Security vulnerability scanning
|
|
11
|
+
- `/health-cleanup` - Dead code removal
|
|
12
|
+
- `/health-deps` - Dependency management
|
|
13
|
+
|
|
14
|
+
## Why Different from Main Pattern?
|
|
15
|
+
|
|
16
|
+
| Aspect | Main Session (95%) | Agent-Based (5%) |
|
|
17
|
+
|--------|-------------------|------------------|
|
|
18
|
+
| Orchestrator | Main session itself | Slash command + suborchestrator agents |
|
|
19
|
+
| Communication | Direct Task tool delegation | Plan files |
|
|
20
|
+
| Context | Full conversation history | Isolated agent context |
|
|
21
|
+
| Tool access | Main session uses Task tool freely | Orchestrator agents cannot use Task tool |
|
|
22
|
+
| Pattern | You delegate and verify | Command coordinates multi-phase workflow |
|
|
23
|
+
|
|
24
|
+
## Architecture
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
User runs /health-bugs
|
|
28
|
+
↓
|
|
29
|
+
Slash Command (main orchestrator)
|
|
30
|
+
↓
|
|
31
|
+
Task tool → bug-orchestrator (suborchestrator)
|
|
32
|
+
↓
|
|
33
|
+
Creates plan file: .tmp/current/plans/bug-detection.json
|
|
34
|
+
Returns control
|
|
35
|
+
↓
|
|
36
|
+
Command reads plan file
|
|
37
|
+
↓
|
|
38
|
+
Task tool → bug-hunter (worker)
|
|
39
|
+
↓
|
|
40
|
+
Worker executes, generates report, returns control
|
|
41
|
+
↓
|
|
42
|
+
Command → Task tool → bug-orchestrator (validation)
|
|
43
|
+
↓
|
|
44
|
+
Orchestrator validates at quality gate
|
|
45
|
+
Creates next plan file
|
|
46
|
+
Returns control
|
|
47
|
+
↓
|
|
48
|
+
...cycle continues
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Key Components
|
|
52
|
+
|
|
53
|
+
### 1. Slash Commands (Main Orchestrators)
|
|
54
|
+
|
|
55
|
+
**Location**: `.claude/commands/health-*.md`
|
|
56
|
+
|
|
57
|
+
**Role**:
|
|
58
|
+
- Coordinate full workflow cycle
|
|
59
|
+
- Invoke suborchestrators via Task tool
|
|
60
|
+
- Read plan files between phases
|
|
61
|
+
- Invoke workers via Task tool
|
|
62
|
+
- Display results to user
|
|
63
|
+
|
|
64
|
+
**Responsibilities**:
|
|
65
|
+
- Phase coordination
|
|
66
|
+
- Read plan files to determine next steps
|
|
67
|
+
- Invoke agents explicitly with Task tool
|
|
68
|
+
- Handle user interaction
|
|
69
|
+
|
|
70
|
+
### 2. Agent Orchestrators (Suborchestrators)
|
|
71
|
+
|
|
72
|
+
**Location**: `.claude/agents/health/orchestrators/`
|
|
73
|
+
|
|
74
|
+
**Examples**: bug-orchestrator, security-orchestrator, dead-code-orchestrator
|
|
75
|
+
|
|
76
|
+
**Role**:
|
|
77
|
+
- Create plan files for each phase
|
|
78
|
+
- Validate worker outputs at quality gates
|
|
79
|
+
- Return control to main session after each phase
|
|
80
|
+
|
|
81
|
+
**Critical Rules**:
|
|
82
|
+
- NO Task tool usage (use plan files instead)
|
|
83
|
+
- NO implementation work (only coordination)
|
|
84
|
+
- NO skip quality gate validations
|
|
85
|
+
- MUST create plan files before returning control
|
|
86
|
+
- MUST validate worker outputs
|
|
87
|
+
- MUST return control after each phase
|
|
88
|
+
|
|
89
|
+
**Why no Task tool?**
|
|
90
|
+
Orchestrator agents run in isolated context without access to Task tool. They coordinate through file-based communication (plan files).
|
|
91
|
+
|
|
92
|
+
### 3. Workers
|
|
93
|
+
|
|
94
|
+
**Location**: `.claude/agents/health/workers/`
|
|
95
|
+
|
|
96
|
+
**Examples**: bug-hunter, bug-fixer, security-scanner, vulnerability-fixer
|
|
97
|
+
|
|
98
|
+
**Role**:
|
|
99
|
+
- Read plan file first
|
|
100
|
+
- Execute domain-specific work (detection, fixing, scanning)
|
|
101
|
+
- Validate work internally
|
|
102
|
+
- Generate structured report
|
|
103
|
+
- Return to main session
|
|
104
|
+
|
|
105
|
+
**Critical Rules**:
|
|
106
|
+
- MUST read plan file first
|
|
107
|
+
- NO invoke other agents
|
|
108
|
+
- NO skip report generation
|
|
109
|
+
- MUST log changes for rollback capability
|
|
110
|
+
- MUST self-validate before reporting success
|
|
111
|
+
|
|
112
|
+
## Plan Files
|
|
113
|
+
|
|
114
|
+
**Location**: `.tmp/current/plans/{workflow}-{phase}.json`
|
|
115
|
+
|
|
116
|
+
**Purpose**: File-based communication between orchestrators and workers
|
|
117
|
+
|
|
118
|
+
**Format**:
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"workflow": "bug-management",
|
|
122
|
+
"phase": "detection",
|
|
123
|
+
"config": {
|
|
124
|
+
"priority": "all",
|
|
125
|
+
"severity": "critical"
|
|
126
|
+
},
|
|
127
|
+
"validation": {
|
|
128
|
+
"required": ["report-exists", "type-check", "build"],
|
|
129
|
+
"optional": ["tests-pass"]
|
|
130
|
+
},
|
|
131
|
+
"nextAgent": "bug-hunter"
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Examples**:
|
|
136
|
+
- `.bug-detection-plan.json`
|
|
137
|
+
- `.bug-fixing-critical-plan.json`
|
|
138
|
+
- `.security-scan-plan.json`
|
|
139
|
+
- `.dependency-audit-plan.json`
|
|
140
|
+
|
|
141
|
+
**Lifecycle**:
|
|
142
|
+
1. Orchestrator creates plan file
|
|
143
|
+
2. Orchestrator returns control to main session
|
|
144
|
+
3. Main session (command) reads plan file
|
|
145
|
+
4. Main session invokes worker specified in `nextAgent`
|
|
146
|
+
5. Worker reads plan file, executes work
|
|
147
|
+
6. Worker returns control
|
|
148
|
+
7. Main session invokes orchestrator for validation
|
|
149
|
+
|
|
150
|
+
## Report Files
|
|
151
|
+
|
|
152
|
+
**Location**:
|
|
153
|
+
- Temporary: `.tmp/current/reports/{report-name}.md`
|
|
154
|
+
- Permanent: `docs/reports/{domain}/{YYYY-MM}/{date}-{report-name}.md`
|
|
155
|
+
|
|
156
|
+
**Required Sections**:
|
|
157
|
+
1. Header: Report type, timestamp, status
|
|
158
|
+
2. Executive Summary: Key metrics, validation status
|
|
159
|
+
3. Detailed Findings: Changes, issues, actions
|
|
160
|
+
4. Validation Results: PASS/FAIL for each gate
|
|
161
|
+
5. Next Steps: Recommendations
|
|
162
|
+
|
|
163
|
+
**Format**: Follow `docs/Agents Ecosystem/REPORT-TEMPLATE-STANDARD.md`
|
|
164
|
+
|
|
165
|
+
## Quality Gates
|
|
166
|
+
|
|
167
|
+
**Blocking Gates** (must pass):
|
|
168
|
+
- Report file exists and well-formed
|
|
169
|
+
- Validation status is PASSED
|
|
170
|
+
- Type-check passes
|
|
171
|
+
- Build passes
|
|
172
|
+
- No critical errors
|
|
173
|
+
|
|
174
|
+
**Non-Blocking Gates** (warnings only):
|
|
175
|
+
- Tests pass (recommended)
|
|
176
|
+
- Lint passes
|
|
177
|
+
- Performance benchmarks
|
|
178
|
+
- Documentation complete
|
|
179
|
+
|
|
180
|
+
**On Blocking Failure**:
|
|
181
|
+
1. STOP workflow
|
|
182
|
+
2. Report failures to user
|
|
183
|
+
3. Provide corrective actions
|
|
184
|
+
4. Ask user: "Fix issues or skip validation? (fix/skip)"
|
|
185
|
+
|
|
186
|
+
**Validation Tools**:
|
|
187
|
+
- Use `run-quality-gate` Skill for standardized validation
|
|
188
|
+
- Use `validate-plan-file` Skill for plan file validation
|
|
189
|
+
- Use `validate-report-file` Skill for report validation
|
|
190
|
+
|
|
191
|
+
## Planning Phase (Speckit Workflow)
|
|
192
|
+
|
|
193
|
+
**Context**: This applies to speckit-based feature development, NOT health workflows.
|
|
194
|
+
|
|
195
|
+
**Position**: Always the first phase before implementation in `/speckit.implement`
|
|
196
|
+
|
|
197
|
+
**Responsibilities**:
|
|
198
|
+
1. **Task Analysis**:
|
|
199
|
+
- Review all tasks from tasks.md
|
|
200
|
+
- Classify each as PARALLEL or SEQUENTIAL execution
|
|
201
|
+
- Identify dependencies between tasks
|
|
202
|
+
|
|
203
|
+
2. **Subagent Assignment**:
|
|
204
|
+
- Map each task to appropriate subagent from existing base
|
|
205
|
+
- Document executor in task annotation: `[EXECUTOR: subagent-name]` or `[EXECUTOR: MAIN]`
|
|
206
|
+
- Main agent handles only trivial tasks (1-2 line fixes, simple imports, single dependency install)
|
|
207
|
+
|
|
208
|
+
3. **Missing Subagents**:
|
|
209
|
+
- If no suitable subagent exists for a task, create meta-agent task
|
|
210
|
+
- Add to planning phase: `Create [subagent-name] using meta-agent-v3`
|
|
211
|
+
- Execute meta-agent tasks in parallel during planning
|
|
212
|
+
|
|
213
|
+
4. **Atomicity Rule** (CRITICAL):
|
|
214
|
+
- **1 Task = 1 Agent Invocation**
|
|
215
|
+
- Never give multiple tasks to one agent in single run
|
|
216
|
+
- Example: 3 parallel tasks for meta-agent → 3 separate meta-agent runs (simultaneously)
|
|
217
|
+
- Example: 5 parallel implementation tasks → 5 separate subagent runs (simultaneously)
|
|
218
|
+
- Sequential tasks: 1 agent run, wait for completion, then next agent run
|
|
219
|
+
|
|
220
|
+
**Output**: Updated tasks.md with:
|
|
221
|
+
- `[EXECUTOR: name]` annotations
|
|
222
|
+
- `[SEQUENTIAL]` or `[PARALLEL-GROUP-X]` markers
|
|
223
|
+
- Meta-agent creation tasks if needed
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Research Task Workflow (Speckit Workflow)
|
|
228
|
+
|
|
229
|
+
**Context**: This applies to speckit planning phase, NOT health workflows.
|
|
230
|
+
|
|
231
|
+
**When**: Planning phase, after subagent assignment
|
|
232
|
+
|
|
233
|
+
**Classification**:
|
|
234
|
+
- **Simple Research**: Questions with clear answer path, solvable with agent + existing tools
|
|
235
|
+
- **Complex Research**: Questions without obvious answers, require deep investigation
|
|
236
|
+
|
|
237
|
+
**Simple Research Workflow**:
|
|
238
|
+
1. Agent identifies question
|
|
239
|
+
2. Agent uses available tools (Grep, Read, WebSearch, Context7, Supabase docs)
|
|
240
|
+
3. Agent formulates answer
|
|
241
|
+
4. Agent documents findings in planning notes
|
|
242
|
+
5. Continue to next task
|
|
243
|
+
|
|
244
|
+
**Complex Research Workflow**:
|
|
245
|
+
1. Agent identifies complex question without clear answer
|
|
246
|
+
2. Agent creates detailed English prompt for deepresearch:
|
|
247
|
+
- **File**: `{FEATURE_DIR}/research/{topic-slug}.md`
|
|
248
|
+
- **Format**: Research question + context + constraints + expected output format
|
|
249
|
+
- **Language**: English (for deepresearch compatibility)
|
|
250
|
+
3. Agent adds TODO: "Wait for deepresearch results on {topic}"
|
|
251
|
+
4. Agent STOPS and reports to user: "Complex research required: {file-path}"
|
|
252
|
+
5. **User action**: Run deepresearch with prompt, save results
|
|
253
|
+
6. Agent reads deepresearch results
|
|
254
|
+
7. Agent incorporates findings into planning
|
|
255
|
+
8. Continue to next task
|
|
256
|
+
|
|
257
|
+
**Output**:
|
|
258
|
+
- Research findings documented
|
|
259
|
+
- Complex research prompts in `{FEATURE_DIR}/research/` if needed
|
|
260
|
+
- Updated tasks.md with research-informed decisions
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Workflow Patterns
|
|
265
|
+
|
|
266
|
+
### Pattern 1: Iterative Cycle (Bugs, Security, Dead Code)
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
Phase 1: Detection
|
|
270
|
+
- Orchestrator creates detection plan
|
|
271
|
+
- Hunter/Scanner executes, generates categorized report
|
|
272
|
+
- Orchestrator validates report
|
|
273
|
+
|
|
274
|
+
Phase 2: Fixing (Staged by Priority)
|
|
275
|
+
- Orchestrator creates fixing plan (priority=critical)
|
|
276
|
+
- Fixer executes critical fixes
|
|
277
|
+
- Orchestrator validates (quality gate: type-check, build)
|
|
278
|
+
- If validation passes, move to next priority
|
|
279
|
+
- Repeat for high, medium, low priorities
|
|
280
|
+
|
|
281
|
+
Phase 3: Verification
|
|
282
|
+
- Orchestrator creates verification plan
|
|
283
|
+
- Hunter/Scanner re-scans to verify fixes
|
|
284
|
+
- Orchestrator validates verification
|
|
285
|
+
|
|
286
|
+
Phase 4: Iteration Decision
|
|
287
|
+
- If new issues found: back to Phase 2
|
|
288
|
+
- If max iterations reached (typically 3): stop
|
|
289
|
+
- If no issues: final summary
|
|
290
|
+
|
|
291
|
+
Phase 5: Final Summary
|
|
292
|
+
- Orchestrator generates comprehensive report
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Pattern 2: Sequential Update (Dependencies)
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
Phase 1: Audit
|
|
299
|
+
- Orchestrator creates audit plan
|
|
300
|
+
- Auditor scans and categorizes dependencies
|
|
301
|
+
- Orchestrator validates report
|
|
302
|
+
|
|
303
|
+
Phase 2: Update (One-at-a-Time)
|
|
304
|
+
- Orchestrator creates update plan (category=security, severity=critical)
|
|
305
|
+
- Updater updates ONE dependency
|
|
306
|
+
- Orchestrator validates (quality gate: lockfile-valid, build, tests)
|
|
307
|
+
- If validation passes: update next dependency
|
|
308
|
+
- If validation fails: rollback, mark problematic, continue
|
|
309
|
+
|
|
310
|
+
Phase 3: Verification
|
|
311
|
+
- Orchestrator creates verification plan
|
|
312
|
+
- Auditor re-scans
|
|
313
|
+
- Orchestrator generates final report
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## Temporary Files Structure
|
|
317
|
+
|
|
318
|
+
**Location**: `.tmp/current/`
|
|
319
|
+
|
|
320
|
+
```
|
|
321
|
+
.tmp/
|
|
322
|
+
├── current/ # Active orchestration run
|
|
323
|
+
│ ├── plans/ # Plan files for workers
|
|
324
|
+
│ │ ├── .bug-detection-plan.json
|
|
325
|
+
│ │ ├── .bug-fixing-critical-plan.json
|
|
326
|
+
│ │ └── .security-scan-plan.json
|
|
327
|
+
│ ├── reports/ # Temporary reports from workers
|
|
328
|
+
│ │ ├── bug-hunting-report.md
|
|
329
|
+
│ │ └── security-audit.md
|
|
330
|
+
│ ├── changes/ # Changes logs for rollback
|
|
331
|
+
│ │ ├── .bug-changes.json
|
|
332
|
+
│ │ └── .security-changes.json
|
|
333
|
+
│ ├── backups/ # File backups before modification
|
|
334
|
+
│ └── locks/ # Lock files for conflict prevention
|
|
335
|
+
└── archive/ # Historical runs (auto-cleanup > 7 days)
|
|
336
|
+
└── YYYY-MM-DD-HHMMSS/
|
|
337
|
+
├── plans/
|
|
338
|
+
├── changes/
|
|
339
|
+
└── reports/
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**Lifecycle**:
|
|
343
|
+
1. Command creates `.tmp/current/` directories at workflow start
|
|
344
|
+
2. Workers read/write to `.tmp/current/` during execution
|
|
345
|
+
3. After workflow completion, command archives `.tmp/current/` to `.tmp/archive/{timestamp}/`
|
|
346
|
+
4. Auto-cleanup removes archives older than 7 days
|
|
347
|
+
|
|
348
|
+
## Changes Logging and Rollback
|
|
349
|
+
|
|
350
|
+
**Changes Log Location**: `.tmp/current/changes/.{domain}-changes.json`
|
|
351
|
+
|
|
352
|
+
**Format**:
|
|
353
|
+
```json
|
|
354
|
+
{
|
|
355
|
+
"phase": "bug-fixing",
|
|
356
|
+
"timestamp": "2025-01-10T14:30:00Z",
|
|
357
|
+
"files_modified": [
|
|
358
|
+
{
|
|
359
|
+
"path": "src/components/Button.tsx",
|
|
360
|
+
"backup": ".tmp/current/backups/Button.tsx.backup"
|
|
361
|
+
}
|
|
362
|
+
],
|
|
363
|
+
"files_created": ["src/utils/newHelper.ts"],
|
|
364
|
+
"commands_executed": ["npm install lodash"]
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
**Rollback Procedure**:
|
|
369
|
+
Use `rollback-changes` Skill:
|
|
370
|
+
```
|
|
371
|
+
Input: .tmp/current/changes/.bug-changes.json
|
|
372
|
+
|
|
373
|
+
Actions:
|
|
374
|
+
1. Restore modified files from backups
|
|
375
|
+
2. Delete created files
|
|
376
|
+
3. Revert commands (git checkout, npm install)
|
|
377
|
+
4. Remove artifacts (plan files, lock files)
|
|
378
|
+
5. Generate rollback report
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
## Return Control Pattern
|
|
382
|
+
|
|
383
|
+
**Why needed?**
|
|
384
|
+
Claude Code does NOT support automatic agent invocation. Main session must explicitly invoke all agents using Task tool.
|
|
385
|
+
|
|
386
|
+
**Pattern**:
|
|
387
|
+
1. Orchestrator creates plan file with `nextAgent` field
|
|
388
|
+
2. Orchestrator reports readiness and exits
|
|
389
|
+
3. Main session (command) reads plan file
|
|
390
|
+
4. Main session invokes worker using Task tool with `subagent_type` from plan
|
|
391
|
+
5. Worker executes, returns control
|
|
392
|
+
6. Main session invokes orchestrator for validation
|
|
393
|
+
7. Repeat cycle
|
|
394
|
+
|
|
395
|
+
**Signal Readiness Protocol**:
|
|
396
|
+
Orchestrators must output:
|
|
397
|
+
```
|
|
398
|
+
Phase preparation complete.
|
|
399
|
+
|
|
400
|
+
Plan: .tmp/current/plans/.bug-detection-plan.json
|
|
401
|
+
Next Agent: bug-hunter
|
|
402
|
+
|
|
403
|
+
Returning control to main session.
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
## Best Practices
|
|
407
|
+
|
|
408
|
+
**For Main Session Orchestration (Speckit)**:
|
|
409
|
+
- Apply atomicity rule: 1 task = 1 agent invocation
|
|
410
|
+
- Gather full context before delegation (code, docs, patterns, history, research)
|
|
411
|
+
- Delegate to subagents with complete context (code snippets, file paths, validation criteria)
|
|
412
|
+
- Verify results thoroughly (read files, run type-check, check regressions)
|
|
413
|
+
- Accept/reject loop: re-delegate with corrections if validation fails
|
|
414
|
+
- Commit after each task: `/push patch`
|
|
415
|
+
- Track progress with TodoWrite (in_progress → completed immediately)
|
|
416
|
+
|
|
417
|
+
**For Agent Orchestrators (Health Workflows)**:
|
|
418
|
+
- Always validate plan files after creation using `validate-plan-file` Skill
|
|
419
|
+
- Track progress with TodoWrite (mark phases in_progress → completed immediately)
|
|
420
|
+
- Enforce quality gates, never skip validations
|
|
421
|
+
- Limit iterations (max 3 cycles) to prevent infinite loops
|
|
422
|
+
- Generate comprehensive reports with all phases summarized
|
|
423
|
+
- Handle errors gracefully with rollback instructions
|
|
424
|
+
|
|
425
|
+
**For Workers**:
|
|
426
|
+
- Always read plan file first, never assume config
|
|
427
|
+
- Log all changes to changes log for rollback capability
|
|
428
|
+
- Self-validate before reporting success
|
|
429
|
+
- Generate structured reports following standard format
|
|
430
|
+
- Use MCP servers when specified in policy
|
|
431
|
+
- Return control after completing work
|
|
432
|
+
|
|
433
|
+
**For Commands**:
|
|
434
|
+
- Read plan files to determine next steps
|
|
435
|
+
- Explicitly invoke agents using Task tool
|
|
436
|
+
- Handle orchestrator validation results
|
|
437
|
+
- Display progress and results to user
|
|
438
|
+
- Manage workflow lifecycle (start → phases → completion)
|
|
439
|
+
|
|
440
|
+
## Atomicity Examples (Speckit)
|
|
441
|
+
|
|
442
|
+
**Example 1: Meta-Agent Creation**
|
|
443
|
+
|
|
444
|
+
❌ **WRONG** (batching multiple tasks):
|
|
445
|
+
```
|
|
446
|
+
Task tool → meta-agent-v3
|
|
447
|
+
Prompt: "Create 3 subagents: user-service-specialist, payment-specialist, notification-specialist"
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
✅ **CORRECT** (1 task = 1 agent run):
|
|
451
|
+
```
|
|
452
|
+
Task tool → meta-agent-v3
|
|
453
|
+
Prompt: "Create user-service-specialist subagent"
|
|
454
|
+
|
|
455
|
+
Task tool → meta-agent-v3
|
|
456
|
+
Prompt: "Create payment-specialist subagent"
|
|
457
|
+
|
|
458
|
+
Task tool → meta-agent-v3
|
|
459
|
+
Prompt: "Create notification-specialist subagent"
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
**Example 2: Parallel Implementation**
|
|
463
|
+
|
|
464
|
+
❌ **WRONG** (batching parallel tasks):
|
|
465
|
+
```
|
|
466
|
+
Task tool → fullstack-nextjs-specialist
|
|
467
|
+
Prompt: "Implement these 5 parallel tasks: T001, T002, T003, T004, T005"
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
✅ **CORRECT** (1 task = 1 agent run, all in parallel):
|
|
471
|
+
```
|
|
472
|
+
# Launch all 5 simultaneously in single message with 5 Task tool calls
|
|
473
|
+
Task tool → fullstack-nextjs-specialist
|
|
474
|
+
Prompt: "Implement T001: Create User model in src/models/user.ts"
|
|
475
|
+
|
|
476
|
+
Task tool → fullstack-nextjs-specialist
|
|
477
|
+
Prompt: "Implement T002: Create Payment model in src/models/payment.ts"
|
|
478
|
+
|
|
479
|
+
Task tool → fullstack-nextjs-specialist
|
|
480
|
+
Prompt: "Implement T003: Create Notification model in src/models/notification.ts"
|
|
481
|
+
|
|
482
|
+
Task tool → fullstack-nextjs-specialist
|
|
483
|
+
Prompt: "Implement T004: Create Auth service in src/services/auth.ts"
|
|
484
|
+
|
|
485
|
+
Task tool → fullstack-nextjs-specialist
|
|
486
|
+
Prompt: "Implement T005: Create Email service in src/services/email.ts"
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
**Example 3: Sequential Tasks**
|
|
490
|
+
|
|
491
|
+
✅ **CORRECT** (1 task = 1 agent run, wait for completion):
|
|
492
|
+
```
|
|
493
|
+
1. Task tool → database-architect
|
|
494
|
+
Prompt: "Implement T001: Create database schema"
|
|
495
|
+
Wait for completion, verify results
|
|
496
|
+
|
|
497
|
+
2. Task tool → fullstack-nextjs-specialist
|
|
498
|
+
Prompt: "Implement T002: Create User model (depends on T001)"
|
|
499
|
+
Wait for completion, verify results
|
|
500
|
+
|
|
501
|
+
3. Task tool → fullstack-nextjs-specialist
|
|
502
|
+
Prompt: "Implement T003: Create UserService (depends on T002)"
|
|
503
|
+
Wait for completion, verify results
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
## Common Pitfalls
|
|
509
|
+
|
|
510
|
+
**Batching multiple tasks to one agent (Speckit)**:
|
|
511
|
+
- Problem: Main session gives multiple tasks to one agent in single run
|
|
512
|
+
- Solution: Apply atomicity rule - 1 task = 1 agent invocation
|
|
513
|
+
- Parallel tasks: Launch N agents simultaneously (single message, N Task calls)
|
|
514
|
+
- Sequential tasks: Launch 1 agent, wait, verify, then next
|
|
515
|
+
|
|
516
|
+
**Orchestrator using Task tool (Health Workflows)**:
|
|
517
|
+
- Problem: Orchestrator tries to invoke subagents directly
|
|
518
|
+
- Solution: Remove Task tool usage, create plan files, return control
|
|
519
|
+
|
|
520
|
+
**Skipping plan validation**:
|
|
521
|
+
- Problem: Invalid plan causes worker failure
|
|
522
|
+
- Solution: Always use `validate-plan-file` Skill after creating plan
|
|
523
|
+
|
|
524
|
+
**Missing changes logging**:
|
|
525
|
+
- Problem: Cannot rollback on validation failure
|
|
526
|
+
- Solution: Workers must log all file modifications to changes log
|
|
527
|
+
|
|
528
|
+
**Infinite iteration loops**:
|
|
529
|
+
- Problem: Orchestrator keeps retrying without termination
|
|
530
|
+
- Solution: Set max iterations (typically 3) and track progress
|
|
531
|
+
|
|
532
|
+
**Blocking without user prompt**:
|
|
533
|
+
- Problem: Orchestrator blocks on failure without user interaction
|
|
534
|
+
- Solution: Report failure, provide options (fix/skip), wait for user decision
|
|
535
|
+
|
|
536
|
+
## MCP Server Usage
|
|
537
|
+
|
|
538
|
+
**Worker Requirements**:
|
|
539
|
+
|
|
540
|
+
**bug-hunter**:
|
|
541
|
+
- MUST use Context7 to validate patterns before flagging bugs
|
|
542
|
+
- Use `gh` CLI via Bash for GitHub issues
|
|
543
|
+
|
|
544
|
+
**security-scanner**:
|
|
545
|
+
- MUST use Context7 for security best practices
|
|
546
|
+
- Use Supabase MCP for database security checks (when available)
|
|
547
|
+
|
|
548
|
+
**dependency-auditor**:
|
|
549
|
+
- Use npm audit (standard tool)
|
|
550
|
+
- Use `gh` CLI via Bash for package health
|
|
551
|
+
|
|
552
|
+
**database-architect, infrastructure-specialist, integration-tester**:
|
|
553
|
+
- Use Supabase MCP for all database operations
|
|
554
|
+
- Project ref: `diqooqbuchsliypgwksu` (MegaCampusAI)
|
|
555
|
+
- Migrations: `packages/course-gen-platform/supabase/migrations/`
|
|
556
|
+
|
|
557
|
+
**Fallback Strategy**:
|
|
558
|
+
If MCP unavailable:
|
|
559
|
+
1. Log warning in report
|
|
560
|
+
2. Continue with reduced functionality
|
|
561
|
+
3. Mark findings as "requires MCP verification"
|
|
562
|
+
|
|
563
|
+
## Reference
|
|
564
|
+
|
|
565
|
+
- Architecture overview: `docs/Agents Ecosystem/ARCHITECTURE.md`
|
|
566
|
+
- Quality gates specification: `docs/Agents Ecosystem/QUALITY-GATES-SPECIFICATION.md`
|
|
567
|
+
- Report template standard: `docs/Agents Ecosystem/REPORT-TEMPLATE-STANDARD.md`
|
|
568
|
+
- Main orchestration pattern: `CLAUDE.md`
|