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,746 @@
|
|
|
1
|
+
# 🏗️ Architecture Overview
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [System Architecture](#system-architecture)
|
|
6
|
+
- [Component Relationships](#component-relationships)
|
|
7
|
+
- [Workflow Patterns](#workflow-patterns)
|
|
8
|
+
- [File Structure](#file-structure)
|
|
9
|
+
- [Data Flow](#data-flow)
|
|
10
|
+
- [Design Principles](#design-principles)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## System Architecture
|
|
15
|
+
|
|
16
|
+
### High-Level Overview
|
|
17
|
+
|
|
18
|
+
```mermaid
|
|
19
|
+
graph TB
|
|
20
|
+
User[👤 User] -->|Slash Commands| Claude[Claude Code]
|
|
21
|
+
Claude -->|Invokes| Orchestrator[🎼 Orchestrator]
|
|
22
|
+
Claude -->|Invokes| SimpleAgent[🤖 Simple Agent]
|
|
23
|
+
|
|
24
|
+
Orchestrator -->|Creates| Plan[📋 Plan File]
|
|
25
|
+
Plan -->|Guides| Worker[⚙️ Worker Agent]
|
|
26
|
+
Worker -->|Uses| Skills[🎯 Skills]
|
|
27
|
+
Worker -->|Generates| Report[📄 Report]
|
|
28
|
+
|
|
29
|
+
Report -->|Validates| QualityGate[✅ Quality Gate]
|
|
30
|
+
QualityGate -->|Pass| NextPhase[Next Phase]
|
|
31
|
+
QualityGate -->|Fail| Rollback[🔄 Rollback]
|
|
32
|
+
|
|
33
|
+
Skills -->|Validates| MCP[🔌 MCP Servers]
|
|
34
|
+
MCP -->|Context7| LibDocs[📚 Library Docs]
|
|
35
|
+
MCP -->|Supabase| Database[🗄️ Database]
|
|
36
|
+
MCP -->|Others| ExternalAPI[🌐 External APIs]
|
|
37
|
+
|
|
38
|
+
style Orchestrator fill:#4A90E2
|
|
39
|
+
style Worker fill:#50C878
|
|
40
|
+
style Skills fill:#FFB347
|
|
41
|
+
style MCP fill:#9B59B6
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Component Relationships
|
|
47
|
+
|
|
48
|
+
### Agent Ecosystem
|
|
49
|
+
|
|
50
|
+
```mermaid
|
|
51
|
+
graph LR
|
|
52
|
+
subgraph "Agent Types"
|
|
53
|
+
O[Orchestrator<br/>Coordinates workflow]
|
|
54
|
+
W[Worker<br/>Executes tasks]
|
|
55
|
+
S[Simple Agent<br/>Standalone tool]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
subgraph "Utilities"
|
|
59
|
+
SK[Skills<br/>Reusable functions]
|
|
60
|
+
QG[Quality Gates<br/>Validation]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
subgraph "Infrastructure"
|
|
64
|
+
MCP[MCP Servers<br/>External services]
|
|
65
|
+
FS[File System<br/>Plans, reports, logs]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
O -->|Creates plan| FS
|
|
69
|
+
FS -->|Reads plan| W
|
|
70
|
+
W -->|Generates report| FS
|
|
71
|
+
FS -->|Validates| QG
|
|
72
|
+
|
|
73
|
+
W -->|Invokes| SK
|
|
74
|
+
O -->|Invokes| SK
|
|
75
|
+
S -->|Invokes| SK
|
|
76
|
+
|
|
77
|
+
W -->|Uses| MCP
|
|
78
|
+
S -->|Uses| MCP
|
|
79
|
+
|
|
80
|
+
style O fill:#4A90E2,color:#fff
|
|
81
|
+
style W fill:#50C878,color:#fff
|
|
82
|
+
style S fill:#9370DB,color:#fff
|
|
83
|
+
style SK fill:#FFB347
|
|
84
|
+
style QG fill:#E74C3C,color:#fff
|
|
85
|
+
style MCP fill:#9B59B6,color:#fff
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Category Hierarchy
|
|
89
|
+
|
|
90
|
+
```mermaid
|
|
91
|
+
graph TD
|
|
92
|
+
Root[.claude/agents/] --> Health[health/]
|
|
93
|
+
Root --> Development[development/]
|
|
94
|
+
Root --> Testing[testing/]
|
|
95
|
+
Root --> Database[database/]
|
|
96
|
+
Root --> Infrastructure[infrastructure/]
|
|
97
|
+
Root --> Frontend[frontend/]
|
|
98
|
+
Root --> Documentation[documentation/]
|
|
99
|
+
Root --> Research[research/]
|
|
100
|
+
Root --> Meta[meta/]
|
|
101
|
+
|
|
102
|
+
Health --> HO[orchestrators/]
|
|
103
|
+
Health --> HW[workers/]
|
|
104
|
+
|
|
105
|
+
HO --> BO[bug-orchestrator]
|
|
106
|
+
HO --> SO[security-orchestrator]
|
|
107
|
+
HO --> DO[dependency-orchestrator]
|
|
108
|
+
HO --> DCO[dead-code-orchestrator]
|
|
109
|
+
|
|
110
|
+
HW --> BH[bug-hunter]
|
|
111
|
+
HW --> BF[bug-fixer]
|
|
112
|
+
HW --> SS[security-scanner]
|
|
113
|
+
HW --> DA[dependency-auditor]
|
|
114
|
+
|
|
115
|
+
style Health fill:#E74C3C,color:#fff
|
|
116
|
+
style Development fill:#3498DB,color:#fff
|
|
117
|
+
style Meta fill:#9B59B6,color:#fff
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Workflow Patterns
|
|
123
|
+
|
|
124
|
+
### 1. Return Control Pattern (PD-1)
|
|
125
|
+
|
|
126
|
+
**The Core Pattern** preventing context nesting:
|
|
127
|
+
|
|
128
|
+
```mermaid
|
|
129
|
+
sequenceDiagram
|
|
130
|
+
participant User
|
|
131
|
+
participant Main as Main Session
|
|
132
|
+
participant Orch as Orchestrator
|
|
133
|
+
participant FS as File System
|
|
134
|
+
participant Worker
|
|
135
|
+
|
|
136
|
+
User->>Main: /health-bugs
|
|
137
|
+
Main->>Orch: Invoke orchestrator
|
|
138
|
+
|
|
139
|
+
Note over Orch: Phase 0: Pre-Flight
|
|
140
|
+
Orch->>FS: Setup .tmp/current/
|
|
141
|
+
|
|
142
|
+
Note over Orch: Phase 1: Create Plan
|
|
143
|
+
Orch->>FS: Write .bug-plan.json
|
|
144
|
+
Orch->>Main: "Ready for bug-hunter" + EXIT
|
|
145
|
+
|
|
146
|
+
Note over Main: User sees signal
|
|
147
|
+
Main->>Worker: Invoke bug-hunter
|
|
148
|
+
|
|
149
|
+
Note over Worker: Read plan, execute, validate
|
|
150
|
+
Worker->>FS: Write bug-hunting-report.md
|
|
151
|
+
Worker->>Main: Report summary + EXIT
|
|
152
|
+
|
|
153
|
+
Note over Main: User sees completion
|
|
154
|
+
Main->>Orch: Resume orchestrator
|
|
155
|
+
|
|
156
|
+
Note over Orch: Quality Gate 1
|
|
157
|
+
Orch->>FS: Read bug-hunting-report.md
|
|
158
|
+
Orch->>Orch: Validate (type-check, build)
|
|
159
|
+
|
|
160
|
+
alt Quality Gate PASS
|
|
161
|
+
Note over Orch: Phase 2: Create Fix Plan
|
|
162
|
+
Orch->>FS: Write .bug-fix-plan.json
|
|
163
|
+
Orch->>Main: "Ready for bug-fixer" + EXIT
|
|
164
|
+
else Quality Gate FAIL
|
|
165
|
+
Orch->>Main: HALT + Error Report
|
|
166
|
+
end
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Why Return Control?**
|
|
170
|
+
- ✅ Prevents context nesting (worker context stays isolated)
|
|
171
|
+
- ✅ Enables rollback (clear separation of phases)
|
|
172
|
+
- ✅ Prevents infinite loops (main session controls invocations)
|
|
173
|
+
- ✅ User visibility (sees each phase completion)
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
### 2. Quality Gate Pattern
|
|
178
|
+
|
|
179
|
+
```mermaid
|
|
180
|
+
graph LR
|
|
181
|
+
Start[Worker<br/>Completes Work] --> Report[Generate<br/>Report]
|
|
182
|
+
Report --> QG{Quality Gate}
|
|
183
|
+
|
|
184
|
+
QG -->|Type-Check| TC[npm run type-check]
|
|
185
|
+
QG -->|Build| B[npm run build]
|
|
186
|
+
QG -->|Tests| T[npm run test]
|
|
187
|
+
|
|
188
|
+
TC --> TCR{Pass?}
|
|
189
|
+
B --> BR{Pass?}
|
|
190
|
+
T --> TR{Pass?}
|
|
191
|
+
|
|
192
|
+
TCR -->|Yes| Check2[Next Check]
|
|
193
|
+
TCR -->|No<br/>Blocking| Fail[HALT Workflow]
|
|
194
|
+
|
|
195
|
+
BR -->|Yes| Check3[Next Check]
|
|
196
|
+
BR -->|No<br/>Blocking| Fail
|
|
197
|
+
|
|
198
|
+
TR -->|Yes| Success[✅ Proceed]
|
|
199
|
+
TR -->|No<br/>Optional| Warning[⚠️ Log Warning<br/>Continue]
|
|
200
|
+
|
|
201
|
+
Fail --> Rollback[Rollback Changes]
|
|
202
|
+
Rollback --> UserPrompt[Ask User:<br/>Fix or Skip?]
|
|
203
|
+
|
|
204
|
+
style QG fill:#E74C3C,color:#fff
|
|
205
|
+
style Success fill:#50C878,color:#fff
|
|
206
|
+
style Fail fill:#C0392B,color:#fff
|
|
207
|
+
style Warning fill:#F39C12
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Quality Gate Configuration** in plan files:
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"validation": {
|
|
215
|
+
"required": ["type-check", "build"],
|
|
216
|
+
"optional": ["tests", "lint"]
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
### 3. Iterative Workflow Pattern
|
|
224
|
+
|
|
225
|
+
```mermaid
|
|
226
|
+
stateDiagram-v2
|
|
227
|
+
[*] --> PreFlight: Start Orchestrator
|
|
228
|
+
|
|
229
|
+
PreFlight --> IterationCheck: Setup complete
|
|
230
|
+
|
|
231
|
+
IterationCheck --> Discovery: iteration < max
|
|
232
|
+
IterationCheck --> FinalSummary: iteration >= max
|
|
233
|
+
|
|
234
|
+
Discovery --> QualityGate1: Worker completes
|
|
235
|
+
QualityGate1 --> Implementation: PASS
|
|
236
|
+
QualityGate1 --> Rollback: FAIL
|
|
237
|
+
|
|
238
|
+
Implementation --> QualityGate2: Worker completes
|
|
239
|
+
QualityGate2 --> PostIteration: PASS
|
|
240
|
+
QualityGate2 --> Rollback: FAIL
|
|
241
|
+
|
|
242
|
+
PostIteration --> Archive: All work complete
|
|
243
|
+
PostIteration --> IterationCheck: Work remaining
|
|
244
|
+
|
|
245
|
+
Rollback --> UserDecision: Changes reverted
|
|
246
|
+
UserDecision --> IterationCheck: Fix applied
|
|
247
|
+
UserDecision --> FinalSummary: Abort requested
|
|
248
|
+
|
|
249
|
+
Archive --> FinalSummary
|
|
250
|
+
FinalSummary --> [*]: Workflow complete
|
|
251
|
+
|
|
252
|
+
note right of IterationCheck
|
|
253
|
+
Max iterations: 3-10
|
|
254
|
+
Prevents infinite loops
|
|
255
|
+
end note
|
|
256
|
+
|
|
257
|
+
note right of QualityGate1
|
|
258
|
+
Blocking: type-check, build
|
|
259
|
+
Optional: tests
|
|
260
|
+
end note
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
**Example**: bug-orchestrator runs up to 3 iterations:
|
|
264
|
+
1. Iteration 1: Find bugs → Fix critical/high
|
|
265
|
+
2. Iteration 2: Verification scan → Fix remaining
|
|
266
|
+
3. Iteration 3: Final check → Report
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## File Structure
|
|
271
|
+
|
|
272
|
+
### Directory Layout
|
|
273
|
+
|
|
274
|
+
```mermaid
|
|
275
|
+
graph TB
|
|
276
|
+
subgraph "Source of Truth (Git)"
|
|
277
|
+
Claude[.claude/]
|
|
278
|
+
Agents[agents/]
|
|
279
|
+
Commands[commands/]
|
|
280
|
+
Skills[skills/]
|
|
281
|
+
Scripts[scripts/]
|
|
282
|
+
Schemas[schemas/]
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
subgraph "Runtime (Git-Ignored)"
|
|
286
|
+
Tmp[.tmp/]
|
|
287
|
+
Current[current/]
|
|
288
|
+
Plans[plans/]
|
|
289
|
+
Reports[reports/]
|
|
290
|
+
Changes[changes/]
|
|
291
|
+
Backups[backups/]
|
|
292
|
+
Archive[archive/]
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
subgraph "Configuration"
|
|
296
|
+
MCP[.mcp.json]
|
|
297
|
+
Env[.env.local]
|
|
298
|
+
BehavioralOS[CLAUDE.md]
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
Claude --> Agents
|
|
302
|
+
Claude --> Commands
|
|
303
|
+
Claude --> Skills
|
|
304
|
+
Claude --> Scripts
|
|
305
|
+
Claude --> Schemas
|
|
306
|
+
|
|
307
|
+
Tmp --> Current
|
|
308
|
+
Tmp --> Archive
|
|
309
|
+
Current --> Plans
|
|
310
|
+
Current --> Reports
|
|
311
|
+
Current --> Changes
|
|
312
|
+
Current --> Backups
|
|
313
|
+
|
|
314
|
+
style Claude fill:#4A90E2,color:#fff
|
|
315
|
+
style Tmp fill:#E74C3C,color:#fff
|
|
316
|
+
style MCP fill:#9B59B6,color:#fff
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### File Flow During Workflow
|
|
320
|
+
|
|
321
|
+
```mermaid
|
|
322
|
+
sequenceDiagram
|
|
323
|
+
participant O as Orchestrator
|
|
324
|
+
participant P as .tmp/current/plans/
|
|
325
|
+
participant W as Worker
|
|
326
|
+
participant C as .tmp/current/changes/
|
|
327
|
+
participant B as .tmp/current/backups/
|
|
328
|
+
participant R as .tmp/current/reports/
|
|
329
|
+
participant A as .tmp/archive/
|
|
330
|
+
|
|
331
|
+
Note over O: Phase 1: Create Plan
|
|
332
|
+
O->>P: Write .workflow-plan.json
|
|
333
|
+
|
|
334
|
+
Note over W: Phase 2: Execute
|
|
335
|
+
W->>P: Read .workflow-plan.json
|
|
336
|
+
W->>B: Backup files before edit
|
|
337
|
+
W->>W: Modify files
|
|
338
|
+
W->>C: Log changes
|
|
339
|
+
W->>R: Write report.md
|
|
340
|
+
|
|
341
|
+
Note over O: Phase 3: Validate
|
|
342
|
+
O->>R: Read report.md
|
|
343
|
+
O->>O: Run quality gates
|
|
344
|
+
|
|
345
|
+
alt Success
|
|
346
|
+
O->>A: Archive run (timestamp)
|
|
347
|
+
A->>A: Copy plans, reports, changes
|
|
348
|
+
else Failure
|
|
349
|
+
O->>C: Read changes log
|
|
350
|
+
O->>B: Restore backups
|
|
351
|
+
O->>C: Clear changes log
|
|
352
|
+
end
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## Data Flow
|
|
358
|
+
|
|
359
|
+
### Plan File → Worker → Report
|
|
360
|
+
|
|
361
|
+
```mermaid
|
|
362
|
+
graph LR
|
|
363
|
+
subgraph "Input: Plan File"
|
|
364
|
+
P1[phase: 2]
|
|
365
|
+
P2[config:<br/>priority, scope]
|
|
366
|
+
P3[validation:<br/>required, optional]
|
|
367
|
+
P4[mcpGuidance:<br/>recommended servers]
|
|
368
|
+
P5[nextAgent:<br/>worker-name]
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
subgraph "Processing: Worker"
|
|
372
|
+
W1[Read Plan]
|
|
373
|
+
W2[Execute Tasks]
|
|
374
|
+
W3[Log Changes]
|
|
375
|
+
W4[Validate Work]
|
|
376
|
+
W5[Generate Report]
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
subgraph "Output: Report"
|
|
380
|
+
R1[Header:<br/>timestamp, status]
|
|
381
|
+
R2[Executive Summary]
|
|
382
|
+
R3[Work Performed]
|
|
383
|
+
R4[Changes Made]
|
|
384
|
+
R5[Validation Results]
|
|
385
|
+
R6[Next Steps]
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
P1 & P2 & P3 & P4 & P5 --> W1
|
|
389
|
+
W1 --> W2
|
|
390
|
+
W2 --> W3
|
|
391
|
+
W3 --> W4
|
|
392
|
+
W4 --> W5
|
|
393
|
+
W5 --> R1 & R2 & R3 & R4 & R5 & R6
|
|
394
|
+
|
|
395
|
+
style P1 fill:#3498DB
|
|
396
|
+
style W1 fill:#50C878
|
|
397
|
+
style R1 fill:#9B59B6
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### MCP Server Integration
|
|
401
|
+
|
|
402
|
+
```mermaid
|
|
403
|
+
graph TB
|
|
404
|
+
Worker[Worker Agent] -->|Need library docs?| Context7Decision{Use Context7?}
|
|
405
|
+
Worker -->|Need database?| SupabaseDecision{Use Supabase?}
|
|
406
|
+
Worker -->|Need UI components?| ShadcnDecision{Use shadcn?}
|
|
407
|
+
|
|
408
|
+
Context7Decision -->|Yes| Context7[mcp__context7__*]
|
|
409
|
+
Context7Decision -->|No| DirectCode[Use general knowledge]
|
|
410
|
+
|
|
411
|
+
SupabaseDecision -->|Yes| Supabase[mcp__supabase__*]
|
|
412
|
+
SupabaseDecision -->|No| DirectCode
|
|
413
|
+
|
|
414
|
+
ShadcnDecision -->|Yes| Shadcn[mcp__shadcn__*]
|
|
415
|
+
ShadcnDecision -->|No| DirectCode
|
|
416
|
+
|
|
417
|
+
Context7 -->|Query| Upstash[Upstash API]
|
|
418
|
+
Supabase -->|Query| SupabaseAPI[Supabase Management API]
|
|
419
|
+
Shadcn -->|Query| Registry[Component Registry]
|
|
420
|
+
|
|
421
|
+
Upstash -->|Return docs| Context7
|
|
422
|
+
SupabaseAPI -->|Return schema| Supabase
|
|
423
|
+
Registry -->|Return components| Shadcn
|
|
424
|
+
|
|
425
|
+
Context7 & Supabase & Shadcn & DirectCode --> Implementation[Implement Solution]
|
|
426
|
+
|
|
427
|
+
style Context7 fill:#3498DB,color:#fff
|
|
428
|
+
style Supabase fill:#50C878,color:#fff
|
|
429
|
+
style Shadcn fill:#9B59B6,color:#fff
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## Design Principles
|
|
435
|
+
|
|
436
|
+
### 1. Single Responsibility
|
|
437
|
+
|
|
438
|
+
**Each component has one clear purpose:**
|
|
439
|
+
|
|
440
|
+
```mermaid
|
|
441
|
+
graph LR
|
|
442
|
+
O[Orchestrator:<br/>Coordinate workflow]
|
|
443
|
+
W[Worker:<br/>Execute tasks]
|
|
444
|
+
S[Skill:<br/>Utility function]
|
|
445
|
+
Q[Quality Gate:<br/>Validate code]
|
|
446
|
+
|
|
447
|
+
O -.->|Creates| Plan[Plan File]
|
|
448
|
+
Plan -.->|Guides| W
|
|
449
|
+
W -.->|Uses| S
|
|
450
|
+
W -.->|Generates| Report[Report]
|
|
451
|
+
Report -.->|Checked by| Q
|
|
452
|
+
|
|
453
|
+
style O fill:#4A90E2,color:#fff
|
|
454
|
+
style W fill:#50C878,color:#fff
|
|
455
|
+
style S fill:#FFB347
|
|
456
|
+
style Q fill:#E74C3C,color:#fff
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
**Anti-pattern**: Orchestrator doing implementation work (violates SRP)
|
|
460
|
+
|
|
461
|
+
---
|
|
462
|
+
|
|
463
|
+
### 2. Separation of Concerns
|
|
464
|
+
|
|
465
|
+
```mermaid
|
|
466
|
+
graph TB
|
|
467
|
+
subgraph "Coordination Layer"
|
|
468
|
+
Orchestrator[Orchestrators<br/>Plan & Coordinate]
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
subgraph "Execution Layer"
|
|
472
|
+
Workers[Workers<br/>Execute & Report]
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
subgraph "Utility Layer"
|
|
476
|
+
Skills[Skills<br/>Reusable Logic]
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
subgraph "Validation Layer"
|
|
480
|
+
Gates[Quality Gates<br/>Verify Quality]
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
subgraph "Infrastructure Layer"
|
|
484
|
+
MCP[MCP Servers<br/>External Services]
|
|
485
|
+
FS[File System<br/>State Management]
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
Orchestrator --> Workers
|
|
489
|
+
Workers --> Skills
|
|
490
|
+
Workers --> Gates
|
|
491
|
+
Workers --> MCP
|
|
492
|
+
Workers --> FS
|
|
493
|
+
Skills --> FS
|
|
494
|
+
|
|
495
|
+
style Orchestrator fill:#4A90E2,color:#fff
|
|
496
|
+
style Workers fill:#50C878,color:#fff
|
|
497
|
+
style Skills fill:#FFB347
|
|
498
|
+
style Gates fill:#E74C3C,color:#fff
|
|
499
|
+
style MCP fill:#9B59B6,color:#fff
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
---
|
|
503
|
+
|
|
504
|
+
### 3. Fail-Fast with Rollback
|
|
505
|
+
|
|
506
|
+
```mermaid
|
|
507
|
+
graph TD
|
|
508
|
+
Start[Start Work] --> Backup[Backup Files]
|
|
509
|
+
Backup --> Changes[Track Changes]
|
|
510
|
+
Changes --> Work[Modify Files]
|
|
511
|
+
Work --> Validate{Validate}
|
|
512
|
+
|
|
513
|
+
Validate -->|Pass| Commit[Commit Changes]
|
|
514
|
+
Validate -->|Fail| Rollback[Rollback]
|
|
515
|
+
|
|
516
|
+
Rollback --> RestoreBackups[Restore Backups]
|
|
517
|
+
RestoreBackups --> ClearLogs[Clear Change Logs]
|
|
518
|
+
ClearLogs --> Report[Report Failure]
|
|
519
|
+
|
|
520
|
+
Commit --> CleanupBackups[Cleanup Backups]
|
|
521
|
+
CleanupBackups --> Success[Success]
|
|
522
|
+
|
|
523
|
+
style Validate fill:#E74C3C,color:#fff
|
|
524
|
+
style Rollback fill:#C0392B,color:#fff
|
|
525
|
+
style Success fill:#50C878,color:#fff
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
**Implementation**:
|
|
529
|
+
- All changes logged to `.tmp/current/changes/*.json`
|
|
530
|
+
- Original files backed up to `.tmp/current/backups/`
|
|
531
|
+
- `rollback-changes` skill reverses all modifications
|
|
532
|
+
|
|
533
|
+
---
|
|
534
|
+
|
|
535
|
+
### 4. Observable Workflows
|
|
536
|
+
|
|
537
|
+
```mermaid
|
|
538
|
+
sequenceDiagram
|
|
539
|
+
participant User
|
|
540
|
+
participant Orch as Orchestrator
|
|
541
|
+
participant TODO as TodoWrite
|
|
542
|
+
participant Worker
|
|
543
|
+
participant Report as Reports
|
|
544
|
+
|
|
545
|
+
User->>Orch: Start workflow
|
|
546
|
+
|
|
547
|
+
Orch->>TODO: Phase 1: Discovery (in_progress)
|
|
548
|
+
Note over Orch: User sees: "Discovering bugs in codebase"
|
|
549
|
+
|
|
550
|
+
Orch->>Worker: Invoke bug-hunter
|
|
551
|
+
Worker->>Report: Generate report
|
|
552
|
+
Worker-->>User: "Found 45 bugs (12 critical, 18 high...)"
|
|
553
|
+
|
|
554
|
+
Orch->>TODO: Phase 1: Discovery (completed)
|
|
555
|
+
Orch->>TODO: Phase 2: Fix Critical (in_progress)
|
|
556
|
+
Note over Orch: User sees: "Fixing critical priority bugs"
|
|
557
|
+
|
|
558
|
+
Orch->>Worker: Invoke bug-fixer
|
|
559
|
+
Worker->>Report: Generate fix report
|
|
560
|
+
Worker-->>User: "Fixed 12 critical bugs, 0 failed"
|
|
561
|
+
|
|
562
|
+
Orch->>TODO: Phase 2: Fix Critical (completed)
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
**Observability features**:
|
|
566
|
+
- TodoWrite updates (real-time progress)
|
|
567
|
+
- Phase-by-phase execution (clear stages)
|
|
568
|
+
- Detailed reports (audit trail)
|
|
569
|
+
- User prompts at critical decisions
|
|
570
|
+
|
|
571
|
+
---
|
|
572
|
+
|
|
573
|
+
### 5. Graceful Degradation
|
|
574
|
+
|
|
575
|
+
```mermaid
|
|
576
|
+
graph TD
|
|
577
|
+
Start[Worker Starts] --> CheckMCP{MCP Available?}
|
|
578
|
+
|
|
579
|
+
CheckMCP -->|Context7 Available| UseContext7[Use Context7 for validation]
|
|
580
|
+
CheckMCP -->|Context7 Unavailable| Fallback[Use general knowledge]
|
|
581
|
+
|
|
582
|
+
UseContext7 --> HighConfidence[High Confidence Results]
|
|
583
|
+
Fallback --> LowerConfidence[Lower Confidence + Warning]
|
|
584
|
+
|
|
585
|
+
HighConfidence --> Report[Generate Report]
|
|
586
|
+
LowerConfidence --> Report
|
|
587
|
+
|
|
588
|
+
Report --> Status{Overall Status}
|
|
589
|
+
Status -->|All MCP Available| FullSuccess[✅ PASSED]
|
|
590
|
+
Status -->|Some MCP Unavailable| PartialSuccess[⚠️ PASSED WITH WARNINGS]
|
|
591
|
+
Status -->|Critical MCP Unavailable| Failure[❌ FAILED]
|
|
592
|
+
|
|
593
|
+
style UseContext7 fill:#50C878,color:#fff
|
|
594
|
+
style Fallback fill:#F39C12
|
|
595
|
+
style FullSuccess fill:#27AE60,color:#fff
|
|
596
|
+
style PartialSuccess fill:#F39C12
|
|
597
|
+
style Failure fill:#E74C3C,color:#fff
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
**Fallback strategy**:
|
|
601
|
+
- Context7 unavailable → Use general knowledge + reduce confidence
|
|
602
|
+
- Quality gate fails → Prompt user (fix/skip/abort)
|
|
603
|
+
- Max iterations → Generate summary with partial results
|
|
604
|
+
- Token budget exhausted → Simplified mode → Emergency exit
|
|
605
|
+
|
|
606
|
+
---
|
|
607
|
+
|
|
608
|
+
## MCP Configuration Architecture
|
|
609
|
+
|
|
610
|
+
### Configuration Tiers
|
|
611
|
+
|
|
612
|
+
```mermaid
|
|
613
|
+
graph TB
|
|
614
|
+
subgraph "BASE (~600 tokens)"
|
|
615
|
+
B1[Context7<br/>Library Docs]
|
|
616
|
+
B2[Sequential Thinking<br/>Enhanced Reasoning]
|
|
617
|
+
end
|
|
618
|
+
|
|
619
|
+
subgraph "SUPABASE (~2500 tokens)"
|
|
620
|
+
S1[Context7]
|
|
621
|
+
S2[Sequential Thinking]
|
|
622
|
+
S3[Supabase<br/>Database Access]
|
|
623
|
+
end
|
|
624
|
+
|
|
625
|
+
subgraph "FULL (~5000 tokens)"
|
|
626
|
+
F1[Context7]
|
|
627
|
+
F2[Sequential Thinking]
|
|
628
|
+
F3[Supabase Main]
|
|
629
|
+
F4[Supabase Legacy]
|
|
630
|
+
F5[n8n Workflows]
|
|
631
|
+
F6[n8n MCP]
|
|
632
|
+
F7[Playwright<br/>Browser Automation]
|
|
633
|
+
F8[shadcn<br/>UI Components]
|
|
634
|
+
end
|
|
635
|
+
|
|
636
|
+
BASE --> SUPABASE
|
|
637
|
+
SUPABASE --> FULL
|
|
638
|
+
|
|
639
|
+
style BASE fill:#27AE60,color:#fff
|
|
640
|
+
style SUPABASE fill:#3498DB,color:#fff
|
|
641
|
+
style FULL fill:#9B59B6,color:#fff
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
### Configuration Selection Decision Tree
|
|
645
|
+
|
|
646
|
+
```mermaid
|
|
647
|
+
graph TD
|
|
648
|
+
Start{What are you building?}
|
|
649
|
+
|
|
650
|
+
Start -->|General Development| CheckDB{Database work?}
|
|
651
|
+
Start -->|UI/UX| Frontend[FRONTEND Config]
|
|
652
|
+
Start -->|Automation| N8N[N8N Config]
|
|
653
|
+
Start -->|Everything| Full[FULL Config]
|
|
654
|
+
|
|
655
|
+
CheckDB -->|Yes| CheckMulti{Multiple projects?}
|
|
656
|
+
CheckDB -->|No| Base[BASE Config]
|
|
657
|
+
|
|
658
|
+
CheckMulti -->|Yes| SupabaseFull[SUPABASE-FULL Config]
|
|
659
|
+
CheckMulti -->|No| Supabase[SUPABASE Config]
|
|
660
|
+
|
|
661
|
+
style Base fill:#27AE60,color:#fff
|
|
662
|
+
style Supabase fill:#3498DB,color:#fff
|
|
663
|
+
style SupabaseFull fill:#E67E22,color:#fff
|
|
664
|
+
style Frontend fill:#E74C3C,color:#fff
|
|
665
|
+
style N8N fill:#9B59B6,color:#fff
|
|
666
|
+
style Full fill:#34495E,color:#fff
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
---
|
|
670
|
+
|
|
671
|
+
## Behavioral OS (CLAUDE.md) Architecture
|
|
672
|
+
|
|
673
|
+
### Prime Directives Enforcement
|
|
674
|
+
|
|
675
|
+
```mermaid
|
|
676
|
+
graph TB
|
|
677
|
+
AgentStart[Agent Invoked] --> SelfDiag{Self-Diagnostics}
|
|
678
|
+
|
|
679
|
+
SelfDiag --> CheckPD1{PD-1:<br/>Return Control?}
|
|
680
|
+
SelfDiag --> CheckPD2{PD-2:<br/>Quality Gates?}
|
|
681
|
+
SelfDiag --> CheckPD3{PD-3:<br/>Change Logging?}
|
|
682
|
+
SelfDiag --> CheckPD4{PD-4:<br/>Context7 Validation?}
|
|
683
|
+
|
|
684
|
+
CheckPD1 -->|Compliant| CheckPD2
|
|
685
|
+
CheckPD1 -->|Violates| Halt1[HALT: Cannot invoke workers via Task]
|
|
686
|
+
|
|
687
|
+
CheckPD2 -->|Compliant| CheckPD3
|
|
688
|
+
CheckPD2 -->|Violates| Halt2[HALT: Cannot skip blocking gates]
|
|
689
|
+
|
|
690
|
+
CheckPD3 -->|Compliant| CheckPD4
|
|
691
|
+
CheckPD3 -->|Violates| Halt3[HALT: Must log all changes]
|
|
692
|
+
|
|
693
|
+
CheckPD4 -->|Compliant| Execute[✅ Execute Work]
|
|
694
|
+
CheckPD4 -->|Violates| Halt4[HALT: Must validate with Context7]
|
|
695
|
+
|
|
696
|
+
Halt1 & Halt2 & Halt3 & Halt4 --> Report[Report Violation to User]
|
|
697
|
+
|
|
698
|
+
style Execute fill:#50C878,color:#fff
|
|
699
|
+
style Halt1 fill:#E74C3C,color:#fff
|
|
700
|
+
style Halt2 fill:#E74C3C,color:#fff
|
|
701
|
+
style Halt3 fill:#E74C3C,color:#fff
|
|
702
|
+
style Halt4 fill:#E74C3C,color:#fff
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
---
|
|
706
|
+
|
|
707
|
+
## Summary
|
|
708
|
+
|
|
709
|
+
### Key Architectural Patterns
|
|
710
|
+
|
|
711
|
+
1. **Return Control Pattern** — Prevents context nesting, enables rollback
|
|
712
|
+
2. **Quality Gates** — Automated validation checkpoints
|
|
713
|
+
3. **Iterative Workflows** — Bounded loops with max iterations
|
|
714
|
+
4. **Plan → Execute → Report** — Standardized communication protocol
|
|
715
|
+
5. **Graceful Degradation** — Fallback strategies for failures
|
|
716
|
+
6. **Observability** — TodoWrite, reports, logs for transparency
|
|
717
|
+
7. **Fail-Fast with Rollback** — Detect errors early, restore state
|
|
718
|
+
8. **Behavioral OS (CLAUDE.md)** — Constitutional rules for all agents
|
|
719
|
+
|
|
720
|
+
### Component Summary
|
|
721
|
+
|
|
722
|
+
| Component | Purpose | Count | Examples |
|
|
723
|
+
|-----------|---------|-------|----------|
|
|
724
|
+
| **Orchestrators** | Coordinate multi-phase workflows | 4 | bug-orchestrator, security-orchestrator |
|
|
725
|
+
| **Workers** | Execute specific tasks from plans | 25+ | bug-hunter, bug-fixer, security-scanner |
|
|
726
|
+
| **Simple Agents** | Standalone utilities | 4+ | code-reviewer, technical-writer |
|
|
727
|
+
| **Skills** | Reusable utility functions | 15+ | run-quality-gate, validate-plan-file |
|
|
728
|
+
| **MCP Configs** | External service integrations | 6 | BASE, SUPABASE, FULL |
|
|
729
|
+
| **Quality Gates** | Validation scripts | 3+ | check-bundle-size, check-security |
|
|
730
|
+
|
|
731
|
+
---
|
|
732
|
+
|
|
733
|
+
## Related Documentation
|
|
734
|
+
|
|
735
|
+
- **Tutorial**: [TUTORIAL-CUSTOM-AGENTS.md](./TUTORIAL-CUSTOM-AGENTS.md) — Create custom agents
|
|
736
|
+
- **Use Cases**: [USE-CASES.md](./USE-CASES.md) — Real-world examples
|
|
737
|
+
- **Performance**: [PERFORMANCE-OPTIMIZATION.md](./PERFORMANCE-OPTIMIZATION.md) — Token optimization
|
|
738
|
+
- **FAQ**: [FAQ.md](./FAQ.md) — Common questions
|
|
739
|
+
- **Behavioral OS**: [../CLAUDE.md](../CLAUDE.md) — Prime Directives and contracts
|
|
740
|
+
- **Detailed Specs**: [Agents Ecosystem/](./Agents%20Ecosystem/) — Full specifications
|
|
741
|
+
|
|
742
|
+
---
|
|
743
|
+
|
|
744
|
+
**Architecture Version**: 3.0
|
|
745
|
+
**Last Updated**: 2025-01-11
|
|
746
|
+
**Maintained by**: [Igor Maslennikov](https://github.com/maslennikov-ig)
|