@champpaba/claude-agent-kit 2.0.0 → 2.1.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/CLAUDE.md +253 -31
- package/.claude/agents/01-integration.md +106 -552
- package/.claude/agents/02-uxui-frontend.md +188 -850
- package/.claude/agents/03-test-debug.md +152 -521
- package/.claude/agents/04-frontend.md +169 -549
- package/.claude/agents/05-backend.md +132 -661
- package/.claude/agents/06-database.md +149 -698
- package/.claude/agents/_shared/README.md +57 -0
- package/.claude/agents/_shared/agent-boundaries.md +64 -0
- package/.claude/agents/_shared/documentation-policy.md +47 -0
- package/.claude/agents/_shared/package-manager.md +59 -0
- package/.claude/agents/_shared/pre-work-checklist.md +57 -0
- package/.claude/commands/cdev.md +36 -61
- package/.claude/commands/csetup.md +90 -14
- package/.claude/commands/cstatus.md +153 -60
- package/.claude/commands/cview.md +364 -364
- package/.claude/commands/designsetup.md +1 -1
- package/.claude/commands/pageplan.md +53 -177
- package/.claude/commands/pstatus.md +431 -0
- package/.claude/contexts/design/accessibility.md +611 -611
- package/.claude/contexts/design/box-thinking.md +1 -1
- package/.claude/contexts/design/index.md +1 -1
- package/.claude/contexts/design/layout.md +400 -400
- package/.claude/contexts/design/responsive.md +551 -551
- package/.claude/contexts/design/shadows.md +522 -522
- package/.claude/contexts/design/typography.md +465 -465
- package/.claude/contexts/domain/README.md +164 -164
- package/.claude/contexts/patterns/agent-coordination.md +388 -388
- package/.claude/contexts/patterns/agent-discovery.md +2 -2
- package/.claude/contexts/patterns/animation-patterns.md +1 -1
- package/.claude/contexts/patterns/change-workflow.md +541 -538
- package/.claude/contexts/patterns/code-standards.md +10 -8
- package/.claude/contexts/patterns/development-principles.md +513 -513
- package/.claude/contexts/patterns/error-handling.md +478 -478
- package/.claude/contexts/patterns/error-recovery.md +365 -365
- package/.claude/contexts/patterns/frontend-component-strategy.md +1 -1
- package/.claude/contexts/patterns/logging.md +424 -424
- package/.claude/contexts/patterns/performance-optimization.md +1 -1
- package/.claude/contexts/patterns/task-breakdown.md +452 -452
- package/.claude/contexts/patterns/task-classification.md +523 -523
- package/.claude/contexts/patterns/tdd-classification.md +516 -516
- package/.claude/contexts/patterns/testing.md +413 -413
- package/.claude/contexts/patterns/ui-component-consistency.md +3 -3
- package/.claude/contexts/patterns/validation-framework.md +779 -776
- package/.claude/lib/README.md +4 -4
- package/.claude/lib/agent-executor.md +31 -40
- package/.claude/lib/agent-router.md +450 -572
- package/.claude/lib/context-loading-protocol.md +19 -36
- package/.claude/lib/detailed-guides/agent-system.md +43 -121
- package/.claude/lib/detailed-guides/taskmaster-analysis.md +1 -1
- package/.claude/lib/document-loader.md +22 -25
- package/.claude/lib/flags-updater.md +461 -469
- package/.claude/lib/tdd-classifier.md +345 -345
- package/.claude/lib/validation-gates.md +484 -484
- package/.claude/settings.local.json +42 -42
- package/.claude/templates/STYLE_GUIDE.template.md +1 -1
- package/.claude/templates/context-template.md +45 -45
- package/.claude/templates/design-context-template.md +1 -1
- package/.claude/templates/flags-template.json +42 -42
- package/.claude/templates/phases-sections/accessibility-test.md +17 -17
- package/.claude/templates/phases-sections/api-design.md +37 -37
- package/.claude/templates/phases-sections/backend-tests.md +16 -16
- package/.claude/templates/phases-sections/backend.md +37 -37
- package/.claude/templates/phases-sections/business-logic-validation.md +16 -16
- package/.claude/templates/phases-sections/component-tests.md +17 -17
- package/.claude/templates/phases-sections/contract-backend.md +16 -16
- package/.claude/templates/phases-sections/contract-frontend.md +16 -16
- package/.claude/templates/phases-sections/database.md +35 -35
- package/.claude/templates/phases-sections/e2e-tests.md +16 -16
- package/.claude/templates/phases-sections/fix-implementation.md +17 -17
- package/.claude/templates/phases-sections/frontend-integration.md +18 -18
- package/.claude/templates/phases-sections/frontend-mockup.md +126 -123
- package/.claude/templates/phases-sections/manual-flow-test.md +15 -15
- package/.claude/templates/phases-sections/manual-ux-test.md +16 -16
- package/.claude/templates/phases-sections/refactor-implementation.md +17 -17
- package/.claude/templates/phases-sections/refactor.md +16 -16
- package/.claude/templates/phases-sections/regression-tests.md +15 -15
- package/.claude/templates/phases-sections/responsive-test.md +16 -16
- package/.claude/templates/phases-sections/script-implementation.md +43 -43
- package/.claude/templates/phases-sections/test-coverage.md +16 -16
- package/.claude/templates/phases-sections/user-approval.md +14 -14
- package/LICENSE +21 -21
- package/PROJECT_STATUS.template.yml +105 -0
- package/README.md +103 -1115
- package/lib/init.js +30 -2
- package/package.json +3 -2
- package/.claude/CHANGELOG-v1.1.1.md +0 -259
|
@@ -1,572 +1,450 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
> **
|
|
4
|
-
> **
|
|
5
|
-
> **
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 🎯 Core Principle
|
|
10
|
-
|
|
11
|
-
**Main Claude
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
✅
|
|
18
|
-
✅
|
|
19
|
-
✅
|
|
20
|
-
✅
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
'
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
'
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
'
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
'
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
### Q1: What is the user requesting?
|
|
236
|
-
- [ ]
|
|
237
|
-
- [ ]
|
|
238
|
-
|
|
239
|
-
### Q2: Is this implementation work?
|
|
240
|
-
- [ ] YES →
|
|
241
|
-
- [ ] NO → Can proceed directly (planning/reading)
|
|
242
|
-
|
|
243
|
-
### Q3: Which
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
-
|
|
256
|
-
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
-
|
|
304
|
-
-
|
|
305
|
-
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
###
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
###
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
// Step 4: Delegate
|
|
452
|
-
Task(
|
|
453
|
-
agent: 'uxui-frontend',
|
|
454
|
-
prompt: buildLoginFormPrompt(),
|
|
455
|
-
description: 'Create login form component'
|
|
456
|
-
)
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
### Scenario 2: "Explain how authentication works"
|
|
460
|
-
|
|
461
|
-
```typescript
|
|
462
|
-
// Step 1: Detect
|
|
463
|
-
workType = 'planning'
|
|
464
|
-
keywords matched: ['explain', 'how']
|
|
465
|
-
|
|
466
|
-
// Step 2: Match
|
|
467
|
-
agent = 'main-claude'
|
|
468
|
-
canMainDo = true
|
|
469
|
-
|
|
470
|
-
// Step 3: Decision
|
|
471
|
-
output('🔍 Task Analysis:')
|
|
472
|
-
output('- Work type: Explanation/planning')
|
|
473
|
-
output('- Can handle directly')
|
|
474
|
-
output('')
|
|
475
|
-
|
|
476
|
-
// Step 4: Execute directly
|
|
477
|
-
// Read auth files
|
|
478
|
-
const authFiles = Glob('**/auth*.{ts,tsx,py}')
|
|
479
|
-
// Analyze and explain
|
|
480
|
-
output('Here is how authentication works in this codebase:')
|
|
481
|
-
output('[detailed explanation]')
|
|
482
|
-
```
|
|
483
|
-
|
|
484
|
-
### Scenario 3: "Fix the failing login test"
|
|
485
|
-
|
|
486
|
-
```typescript
|
|
487
|
-
// Step 1: Detect
|
|
488
|
-
workType = 'testing-debugging'
|
|
489
|
-
keywords matched: ['fix', 'failing', 'test']
|
|
490
|
-
|
|
491
|
-
// Step 2: Match
|
|
492
|
-
agent = 'test-debug'
|
|
493
|
-
canMainDo = false
|
|
494
|
-
|
|
495
|
-
// Step 3: Decision
|
|
496
|
-
output('🔍 Task Analysis:')
|
|
497
|
-
output('- Work type: Testing/debugging')
|
|
498
|
-
output('- Requires: test-debug agent')
|
|
499
|
-
output('- Reason: Bug fixing requires iterative debugging')
|
|
500
|
-
output('')
|
|
501
|
-
output('🚀 Invoking test-debug agent...')
|
|
502
|
-
|
|
503
|
-
// Step 4: Delegate
|
|
504
|
-
Task(
|
|
505
|
-
agent: 'test-debug',
|
|
506
|
-
prompt: buildTestFixPrompt(),
|
|
507
|
-
description: 'Fix failing login test'
|
|
508
|
-
)
|
|
509
|
-
```
|
|
510
|
-
|
|
511
|
-
---
|
|
512
|
-
|
|
513
|
-
## ⚠️ Override Protection
|
|
514
|
-
|
|
515
|
-
**Even if user explicitly requests Main Claude to "do it yourself":**
|
|
516
|
-
|
|
517
|
-
```markdown
|
|
518
|
-
User: "Just create the button component yourself, don't use agents"
|
|
519
|
-
|
|
520
|
-
Main Claude Response:
|
|
521
|
-
"I understand you'd like me to create the button component directly, but I must delegate this to the uxui-frontend agent for the following reasons:
|
|
522
|
-
|
|
523
|
-
1. **Design Consistency:** The uxui-frontend agent enforces design system patterns (spacing, colors, shadows) that ensure visual consistency.
|
|
524
|
-
|
|
525
|
-
2. **Component Reuse:** The agent checks for existing components first to avoid duplicates.
|
|
526
|
-
|
|
527
|
-
3. **Quality Assurance:** The agent follows mandatory pre-work checklists (Box Thinking, Design Tokens) that I cannot replicate.
|
|
528
|
-
|
|
529
|
-
This ensures your codebase maintains high quality standards. I'll invoke the agent now."
|
|
530
|
-
|
|
531
|
-
[Proceeds to invoke uxui-frontend agent]
|
|
532
|
-
```
|
|
533
|
-
|
|
534
|
-
**Exception:** Only if user says "I know you should delegate, but this is a special test/demo case" → Can proceed with warning
|
|
535
|
-
|
|
536
|
-
---
|
|
537
|
-
|
|
538
|
-
## 🔧 Integration with Other Systems
|
|
539
|
-
|
|
540
|
-
**This protocol is enforced by:**
|
|
541
|
-
- CLAUDE.md (top-level instructions)
|
|
542
|
-
- /cdev command (when executing phases)
|
|
543
|
-
- validation-gates.md (pre-work checks)
|
|
544
|
-
|
|
545
|
-
**This protocol depends on:**
|
|
546
|
-
- task-classification.md (agent selection guide)
|
|
547
|
-
- agent-executor.md (retry and validation)
|
|
548
|
-
- flags-updater.md (progress tracking)
|
|
549
|
-
|
|
550
|
-
---
|
|
551
|
-
|
|
552
|
-
## 🎯 Success Metrics
|
|
553
|
-
|
|
554
|
-
After implementing this protocol, you should see:
|
|
555
|
-
|
|
556
|
-
1. **95%+ Delegation Rate**
|
|
557
|
-
- Implementation work always delegated
|
|
558
|
-
- Only planning/reading done by Main Claude
|
|
559
|
-
|
|
560
|
-
2. **Zero Boundary Violations**
|
|
561
|
-
- Main Claude never writes components
|
|
562
|
-
- Main Claude never creates endpoints
|
|
563
|
-
- Main Claude never designs schemas
|
|
564
|
-
|
|
565
|
-
3. **Clear Task Classification**
|
|
566
|
-
- Every task analyzed before execution
|
|
567
|
-
- Decision reasoning visible to user
|
|
568
|
-
- No ambiguity in routing
|
|
569
|
-
|
|
570
|
-
---
|
|
571
|
-
|
|
572
|
-
**💡 Remember:** Main Claude orchestrates, agents implement. No exceptions.
|
|
1
|
+
# Agent Routing Protocol
|
|
2
|
+
|
|
3
|
+
> **Purpose:** Route tasks to specialized agents for best results
|
|
4
|
+
> **Scope:** All tasks received from users
|
|
5
|
+
> **Version:** 2.0.0 (Claude 4.5 Optimized)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🎯 Core Principle
|
|
10
|
+
|
|
11
|
+
**Main Claude orchestrates, specialist agents implement.**
|
|
12
|
+
|
|
13
|
+
WHY: Specialist agents have domain-specific validation (design tokens, TDD patterns, error handling) that ensures higher quality output than general implementation.
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
Main Claude's Role:
|
|
17
|
+
✅ Read files and analyze codebase
|
|
18
|
+
✅ Plan workflows and break down tasks
|
|
19
|
+
✅ Invoke specialized agents
|
|
20
|
+
✅ Update flags.json
|
|
21
|
+
✅ Report progress
|
|
22
|
+
✅ Coordinate between agents
|
|
23
|
+
|
|
24
|
+
Delegate to specialists:
|
|
25
|
+
→ UI work → uxui-frontend agent
|
|
26
|
+
→ API endpoints → backend agent
|
|
27
|
+
→ Database schemas → database agent
|
|
28
|
+
→ Tests/bugs → test-debug agent
|
|
29
|
+
→ API integration → frontend agent
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 📋 Routing Rules
|
|
35
|
+
|
|
36
|
+
### Rule 1: Detect Work Type First
|
|
37
|
+
|
|
38
|
+
**Before starting work, determine the task type:**
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
function routeTask(userRequest: string): AgentPlan {
|
|
42
|
+
// 1. Read task classification guide
|
|
43
|
+
const classification = Read('.claude/contexts/patterns/task-classification.md')
|
|
44
|
+
|
|
45
|
+
// 2. Detect work type
|
|
46
|
+
const workType = detectWorkType(userRequest)
|
|
47
|
+
|
|
48
|
+
// 3. Match to agent
|
|
49
|
+
const agent = matchAgent(workType)
|
|
50
|
+
|
|
51
|
+
// 4. Validate match
|
|
52
|
+
if (agent === 'main-claude' && isImplementationWork(workType)) {
|
|
53
|
+
return { mustDelegate: true, reason: 'Implementation work routes to specialist' }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
agent,
|
|
58
|
+
workType,
|
|
59
|
+
reason: `Detected ${workType} → ${agent} agent`,
|
|
60
|
+
mustDelegate: agent !== 'main-claude'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
### Rule 2: Work Type Detection Patterns
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const WORK_PATTERNS = {
|
|
71
|
+
// IMPLEMENTATION WORK (MUST DELEGATE)
|
|
72
|
+
'ui-component': {
|
|
73
|
+
keywords: [
|
|
74
|
+
'component', 'ui', 'page', 'layout', 'design', 'mockup',
|
|
75
|
+
'form', 'button', 'card', 'modal', 'menu', 'navbar',
|
|
76
|
+
'responsive', 'css', 'tailwind', 'styling', 'theme'
|
|
77
|
+
],
|
|
78
|
+
agent: 'uxui-frontend',
|
|
79
|
+
canMainDo: false,
|
|
80
|
+
reason: 'UI design requires specialized design system knowledge'
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
'api-endpoint': {
|
|
84
|
+
keywords: [
|
|
85
|
+
'api', 'endpoint', 'route', 'POST', 'GET', 'PUT', 'DELETE',
|
|
86
|
+
'backend', 'server', 'controller', 'handler', 'middleware',
|
|
87
|
+
'validation', 'authentication', 'authorization'
|
|
88
|
+
],
|
|
89
|
+
agent: 'backend',
|
|
90
|
+
canMainDo: false,
|
|
91
|
+
reason: 'Backend logic requires specialized error handling patterns'
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
'database-work': {
|
|
95
|
+
keywords: [
|
|
96
|
+
'database', 'schema', 'migration', 'model', 'table', 'query',
|
|
97
|
+
'prisma', 'sql', 'orm', 'relationship', 'index', 'foreign key'
|
|
98
|
+
],
|
|
99
|
+
agent: 'database',
|
|
100
|
+
canMainDo: false,
|
|
101
|
+
reason: 'Database design requires specialized schema knowledge'
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
'api-integration': {
|
|
105
|
+
keywords: [
|
|
106
|
+
'connect', 'integrate', 'api call', 'fetch', 'axios',
|
|
107
|
+
'state', 'zustand', 'redux', 'context', 'hook',
|
|
108
|
+
'replace mock', 'real data', 'loading state'
|
|
109
|
+
],
|
|
110
|
+
agent: 'frontend',
|
|
111
|
+
canMainDo: false,
|
|
112
|
+
reason: 'API integration requires specialized state management'
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
'testing-debugging': {
|
|
116
|
+
keywords: [
|
|
117
|
+
'test', 'debug', 'fix', 'error', 'bug', 'issue',
|
|
118
|
+
'vitest', 'jest', 'playwright', 'unit test', 'e2e',
|
|
119
|
+
'coverage', 'failing test', 'crash'
|
|
120
|
+
],
|
|
121
|
+
agent: 'test-debug',
|
|
122
|
+
canMainDo: false,
|
|
123
|
+
reason: 'Testing requires specialized debugging skills'
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
'contract-validation': {
|
|
127
|
+
keywords: [
|
|
128
|
+
'validate contract', 'api contract', 'integration report',
|
|
129
|
+
'verify endpoint', 'check compatibility', 'openapi'
|
|
130
|
+
],
|
|
131
|
+
agent: 'integration',
|
|
132
|
+
canMainDo: false,
|
|
133
|
+
reason: 'Contract validation requires specialized analysis'
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
// NON-IMPLEMENTATION WORK (MAIN CAN DO)
|
|
137
|
+
'planning': {
|
|
138
|
+
keywords: [
|
|
139
|
+
'plan', 'analyze', 'review', 'explain', 'break down',
|
|
140
|
+
'how does', 'what is', 'show me', 'find', 'search'
|
|
141
|
+
],
|
|
142
|
+
agent: 'main-claude',
|
|
143
|
+
canMainDo: true,
|
|
144
|
+
reason: 'Planning and analysis is orchestrator work'
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
'reading': {
|
|
148
|
+
keywords: [
|
|
149
|
+
'read', 'show', 'display', 'view', 'list', 'find',
|
|
150
|
+
'what files', 'where is', 'search for'
|
|
151
|
+
],
|
|
152
|
+
agent: 'main-claude',
|
|
153
|
+
canMainDo: true,
|
|
154
|
+
reason: 'File reading is orchestrator work'
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
'orchestration': {
|
|
158
|
+
keywords: [
|
|
159
|
+
'/cdev', '/csetup', '/cview', '/cstatus', '/psetup',
|
|
160
|
+
'continue workflow', 'next phase', 'progress'
|
|
161
|
+
],
|
|
162
|
+
agent: 'main-claude',
|
|
163
|
+
canMainDo: true,
|
|
164
|
+
reason: 'Workflow orchestration is orchestrator work'
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### Rule 3: Detection Function
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
function detectWorkType(request: string): string {
|
|
175
|
+
const lower = request.toLowerCase()
|
|
176
|
+
|
|
177
|
+
// Score each work type
|
|
178
|
+
const scores: Record<string, number> = {}
|
|
179
|
+
|
|
180
|
+
for (const [type, config] of Object.entries(WORK_PATTERNS)) {
|
|
181
|
+
scores[type] = 0
|
|
182
|
+
for (const keyword of config.keywords) {
|
|
183
|
+
if (lower.includes(keyword)) {
|
|
184
|
+
scores[type]++
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Find highest scoring type
|
|
190
|
+
let maxScore = 0
|
|
191
|
+
let detectedType = 'planning' // Safe default
|
|
192
|
+
|
|
193
|
+
for (const [type, score] of Object.entries(scores)) {
|
|
194
|
+
if (score > maxScore) {
|
|
195
|
+
maxScore = score
|
|
196
|
+
detectedType = type
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// If no keywords match, assume planning
|
|
201
|
+
if (maxScore === 0) {
|
|
202
|
+
detectedType = 'planning'
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return detectedType
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### Rule 4: Agent Matching
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
function matchAgent(workType: string): string {
|
|
215
|
+
const pattern = WORK_PATTERNS[workType]
|
|
216
|
+
|
|
217
|
+
if (!pattern) {
|
|
218
|
+
// Unknown type → ask user
|
|
219
|
+
return 'ask-user'
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return pattern.agent
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## 🚦 Pre-Work Checklist
|
|
229
|
+
|
|
230
|
+
**Before starting work, complete this quick check:**
|
|
231
|
+
|
|
232
|
+
```markdown
|
|
233
|
+
## ✅ Task Routing Checklist
|
|
234
|
+
|
|
235
|
+
### Q1: What is the user requesting?
|
|
236
|
+
- [ ] Read request carefully
|
|
237
|
+
- [ ] Identify the end goal
|
|
238
|
+
|
|
239
|
+
### Q2: Is this implementation work?
|
|
240
|
+
- [ ] YES → Route to specialist (see Q3)
|
|
241
|
+
- [ ] NO → Can proceed directly (planning/reading)
|
|
242
|
+
|
|
243
|
+
### Q3: Which specialist handles this?
|
|
244
|
+
| Task Type | Agent |
|
|
245
|
+
|-----------|-------|
|
|
246
|
+
| UI components, layouts, design | uxui-frontend |
|
|
247
|
+
| API endpoints, business logic | backend |
|
|
248
|
+
| Schema, migrations, queries | database |
|
|
249
|
+
| API integration, state management | frontend |
|
|
250
|
+
| Testing, bug fixes | test-debug |
|
|
251
|
+
| Contract validation | integration |
|
|
252
|
+
| Planning, reading, orchestration | main-claude |
|
|
253
|
+
|
|
254
|
+
### Q4: Execute
|
|
255
|
+
- If specialist needed → Use Task tool with selected agent
|
|
256
|
+
- If main-claude work → Proceed directly
|
|
257
|
+
|
|
258
|
+
WHY this routing: Specialists have domain-specific validation
|
|
259
|
+
(design tokens, TDD patterns, error handling) that ensures quality.
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## 📋 Task Routing Table
|
|
265
|
+
|
|
266
|
+
### Route to Specialists
|
|
267
|
+
|
|
268
|
+
| Task Type | Route To | WHY |
|
|
269
|
+
|-----------|----------|-----|
|
|
270
|
+
| UI/Frontend | uxui-frontend | Design system validation, component reuse checks |
|
|
271
|
+
| API endpoints | backend | TDD patterns, error handling, validation |
|
|
272
|
+
| Database | database | Schema validation, migration safety |
|
|
273
|
+
| API integration | frontend | State management patterns |
|
|
274
|
+
| Testing | test-debug | Iterative debugging, coverage |
|
|
275
|
+
|
|
276
|
+
### Main Claude Handles Directly
|
|
277
|
+
|
|
278
|
+
| Task Type | Examples |
|
|
279
|
+
|-----------|----------|
|
|
280
|
+
| Analysis | Read files, explain code, analyze structure |
|
|
281
|
+
| Planning | Break down tasks, create workflows |
|
|
282
|
+
| Orchestration | /cdev, /csetup, coordinate agents |
|
|
283
|
+
| Progress | Update flags.json, report status |
|
|
284
|
+
| User interaction | Ask questions, provide options |
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## 🔄 Quick Routing Flow
|
|
291
|
+
|
|
292
|
+
```
|
|
293
|
+
1. Parse → What is the user asking?
|
|
294
|
+
2. Classify → Is this implementation work?
|
|
295
|
+
3. Route → Which specialist handles this?
|
|
296
|
+
4. Execute → Task tool or proceed directly
|
|
297
|
+
5. Report → Show decision to user
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**Output format:**
|
|
301
|
+
```
|
|
302
|
+
🔍 Task Analysis:
|
|
303
|
+
- Work type: [type]
|
|
304
|
+
- Routing to: [agent] agent
|
|
305
|
+
- Reason: [explanation]
|
|
306
|
+
|
|
307
|
+
🚀 Invoking [agent] agent...
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## 📊 Decision Tree
|
|
313
|
+
|
|
314
|
+
```
|
|
315
|
+
User Request Received
|
|
316
|
+
↓
|
|
317
|
+
Parse Request
|
|
318
|
+
↓
|
|
319
|
+
Detect Work Type ────────────────┐
|
|
320
|
+
↓ │
|
|
321
|
+
Is Implementation? ──NO───→ Can Proceed Directly
|
|
322
|
+
↓ YES (Planning/Reading)
|
|
323
|
+
Match Agent
|
|
324
|
+
↓
|
|
325
|
+
Invoke Agent ←─────────────────┘
|
|
326
|
+
↓
|
|
327
|
+
Wait for Response
|
|
328
|
+
↓
|
|
329
|
+
Update flags.json
|
|
330
|
+
↓
|
|
331
|
+
Report to User
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## 🎯 Example Scenarios
|
|
337
|
+
|
|
338
|
+
### Scenario 1: "Create a login form"
|
|
339
|
+
|
|
340
|
+
```typescript
|
|
341
|
+
// Step 1: Detect
|
|
342
|
+
workType = 'ui-component'
|
|
343
|
+
keywords matched: ['create', 'form']
|
|
344
|
+
|
|
345
|
+
// Step 2: Match
|
|
346
|
+
agent = 'uxui-frontend'
|
|
347
|
+
canMainDo = false
|
|
348
|
+
|
|
349
|
+
// Step 3: Decision
|
|
350
|
+
output('🔍 Task Analysis:')
|
|
351
|
+
output('- Work type: UI component')
|
|
352
|
+
output('- Requires: uxui-frontend agent')
|
|
353
|
+
output('- Reason: Form design requires design system knowledge')
|
|
354
|
+
output('')
|
|
355
|
+
output('🚀 Invoking uxui-frontend agent...')
|
|
356
|
+
|
|
357
|
+
// Step 4: Delegate
|
|
358
|
+
Task(
|
|
359
|
+
agent: 'uxui-frontend',
|
|
360
|
+
prompt: buildLoginFormPrompt(),
|
|
361
|
+
description: 'Create login form component'
|
|
362
|
+
)
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Scenario 2: "Explain how authentication works"
|
|
366
|
+
|
|
367
|
+
```typescript
|
|
368
|
+
// Step 1: Detect
|
|
369
|
+
workType = 'planning'
|
|
370
|
+
keywords matched: ['explain', 'how']
|
|
371
|
+
|
|
372
|
+
// Step 2: Match
|
|
373
|
+
agent = 'main-claude'
|
|
374
|
+
canMainDo = true
|
|
375
|
+
|
|
376
|
+
// Step 3: Decision
|
|
377
|
+
output('🔍 Task Analysis:')
|
|
378
|
+
output('- Work type: Explanation/planning')
|
|
379
|
+
output('- Can handle directly')
|
|
380
|
+
output('')
|
|
381
|
+
|
|
382
|
+
// Step 4: Execute directly
|
|
383
|
+
// Read auth files
|
|
384
|
+
const authFiles = Glob('**/auth*.{ts,tsx,py}')
|
|
385
|
+
// Analyze and explain
|
|
386
|
+
output('Here is how authentication works in this codebase:')
|
|
387
|
+
output('[detailed explanation]')
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Scenario 3: "Fix the failing login test"
|
|
391
|
+
|
|
392
|
+
```typescript
|
|
393
|
+
// Step 1: Detect
|
|
394
|
+
workType = 'testing-debugging'
|
|
395
|
+
keywords matched: ['fix', 'failing', 'test']
|
|
396
|
+
|
|
397
|
+
// Step 2: Match
|
|
398
|
+
agent = 'test-debug'
|
|
399
|
+
canMainDo = false
|
|
400
|
+
|
|
401
|
+
// Step 3: Decision
|
|
402
|
+
output('🔍 Task Analysis:')
|
|
403
|
+
output('- Work type: Testing/debugging')
|
|
404
|
+
output('- Requires: test-debug agent')
|
|
405
|
+
output('- Reason: Bug fixing requires iterative debugging')
|
|
406
|
+
output('')
|
|
407
|
+
output('🚀 Invoking test-debug agent...')
|
|
408
|
+
|
|
409
|
+
// Step 4: Delegate
|
|
410
|
+
Task(
|
|
411
|
+
agent: 'test-debug',
|
|
412
|
+
prompt: buildTestFixPrompt(),
|
|
413
|
+
description: 'Fix failing login test'
|
|
414
|
+
)
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## 💡 When User Asks to Skip Routing
|
|
420
|
+
|
|
421
|
+
If user requests direct implementation:
|
|
422
|
+
|
|
423
|
+
```markdown
|
|
424
|
+
User: "Just create the button yourself, skip the agent"
|
|
425
|
+
|
|
426
|
+
Response:
|
|
427
|
+
"I'll route this to the uxui-frontend agent. Here's why this produces better results:
|
|
428
|
+
|
|
429
|
+
1. **Design Consistency** - Agent validates against design tokens
|
|
430
|
+
2. **Component Reuse** - Agent searches for existing components first
|
|
431
|
+
3. **Quality Checks** - Agent follows Box Thinking, spacing rules
|
|
432
|
+
|
|
433
|
+
Invoking uxui-frontend agent now..."
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
**Exception:** User explicitly confirms "this is a test/demo" → proceed with note
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
## 🔗 Related Files
|
|
441
|
+
|
|
442
|
+
| File | Purpose |
|
|
443
|
+
|------|---------|
|
|
444
|
+
| `task-classification.md` | Agent selection guide |
|
|
445
|
+
| `agent-executor.md` | Retry and validation |
|
|
446
|
+
| `flags-updater.md` | Progress tracking |
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
**💡 Summary:** Main Claude orchestrates, specialists implement. This routing ensures quality through domain-specific validation.
|