@champpaba/claude-agent-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/LICENSE +21 -0
- package/README.md +561 -0
- package/bin/cli.js +61 -0
- package/lib/init.js +52 -0
- package/lib/update.js +73 -0
- package/package.json +47 -0
- package/template/.claude/CHANGELOG-v1.1.1.md +259 -0
- package/template/.claude/CLAUDE.md +329 -0
- package/template/.claude/agents/01-integration.md +797 -0
- package/template/.claude/agents/02-uxui-frontend.md +899 -0
- package/template/.claude/agents/03-test-debug.md +759 -0
- package/template/.claude/agents/04-frontend.md +1099 -0
- package/template/.claude/agents/05-backend.md +1217 -0
- package/template/.claude/agents/06-database.md +969 -0
- package/template/.claude/commands/agentsetup.md +1464 -0
- package/template/.claude/commands/cdev.md +327 -0
- package/template/.claude/commands/csetup.md +447 -0
- package/template/.claude/commands/cstatus.md +60 -0
- package/template/.claude/commands/cview.md +364 -0
- package/template/.claude/commands/psetup.md +101 -0
- package/template/.claude/contexts/design/accessibility.md +611 -0
- package/template/.claude/contexts/design/box-thinking.md +553 -0
- package/template/.claude/contexts/design/color-theory.md +498 -0
- package/template/.claude/contexts/design/index.md +247 -0
- package/template/.claude/contexts/design/layout.md +400 -0
- package/template/.claude/contexts/design/responsive.md +551 -0
- package/template/.claude/contexts/design/shadows.md +522 -0
- package/template/.claude/contexts/design/spacing.md +428 -0
- package/template/.claude/contexts/design/typography.md +465 -0
- package/template/.claude/contexts/domain/README.md +164 -0
- package/template/.claude/contexts/patterns/agent-coordination.md +388 -0
- package/template/.claude/contexts/patterns/agent-discovery.md +182 -0
- package/template/.claude/contexts/patterns/change-workflow.md +538 -0
- package/template/.claude/contexts/patterns/code-standards.md +515 -0
- package/template/.claude/contexts/patterns/development-principles.md +513 -0
- package/template/.claude/contexts/patterns/error-handling.md +478 -0
- package/template/.claude/contexts/patterns/error-recovery.md +365 -0
- package/template/.claude/contexts/patterns/frontend-component-strategy.md +365 -0
- package/template/.claude/contexts/patterns/git-workflow.md +207 -0
- package/template/.claude/contexts/patterns/logging.md +424 -0
- package/template/.claude/contexts/patterns/task-breakdown.md +452 -0
- package/template/.claude/contexts/patterns/task-classification.md +523 -0
- package/template/.claude/contexts/patterns/tdd-classification.md +516 -0
- package/template/.claude/contexts/patterns/testing.md +413 -0
- package/template/.claude/contexts/patterns/ui-component-consistency.md +304 -0
- package/template/.claude/contexts/patterns/validation-framework.md +776 -0
- package/template/.claude/lib/README.md +39 -0
- package/template/.claude/lib/agent-executor.md +258 -0
- package/template/.claude/lib/agent-router.md +572 -0
- package/template/.claude/lib/flags-updater.md +469 -0
- package/template/.claude/lib/tdd-classifier.md +345 -0
- package/template/.claude/lib/validation-gates.md +484 -0
- package/template/.claude/settings.local.json +42 -0
- package/template/.claude/templates/context-template.md +45 -0
- package/template/.claude/templates/flags-template.json +42 -0
- package/template/.claude/templates/phase-templates.json +124 -0
- package/template/.claude/templates/phases-sections/accessibility-test.md +17 -0
- package/template/.claude/templates/phases-sections/api-design.md +37 -0
- package/template/.claude/templates/phases-sections/backend-tests.md +16 -0
- package/template/.claude/templates/phases-sections/backend.md +37 -0
- package/template/.claude/templates/phases-sections/business-logic-validation.md +16 -0
- package/template/.claude/templates/phases-sections/component-tests.md +17 -0
- package/template/.claude/templates/phases-sections/contract-backend.md +16 -0
- package/template/.claude/templates/phases-sections/contract-frontend.md +16 -0
- package/template/.claude/templates/phases-sections/database.md +35 -0
- package/template/.claude/templates/phases-sections/documentation.md +17 -0
- package/template/.claude/templates/phases-sections/e2e-tests.md +16 -0
- package/template/.claude/templates/phases-sections/fix-implementation.md +17 -0
- package/template/.claude/templates/phases-sections/frontend-integration.md +18 -0
- package/template/.claude/templates/phases-sections/frontend-mockup.md +123 -0
- package/template/.claude/templates/phases-sections/manual-flow-test.md +15 -0
- package/template/.claude/templates/phases-sections/manual-ux-test.md +16 -0
- package/template/.claude/templates/phases-sections/refactor-implementation.md +17 -0
- package/template/.claude/templates/phases-sections/refactor.md +16 -0
- package/template/.claude/templates/phases-sections/regression-tests.md +15 -0
- package/template/.claude/templates/phases-sections/report.md +16 -0
- package/template/.claude/templates/phases-sections/responsive-test.md +16 -0
- package/template/.claude/templates/phases-sections/script-implementation.md +43 -0
- package/template/.claude/templates/phases-sections/test-coverage.md +16 -0
- package/template/.claude/templates/phases-sections/user-approval.md +14 -0
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
# Mandatory Agent Routing Protocol
|
|
2
|
+
|
|
3
|
+
> **CRITICAL:** Main Claude CANNOT do implementation work directly
|
|
4
|
+
> **PURPOSE:** Enforce strict agent boundaries and specialization
|
|
5
|
+
> **APPLIES TO:** ALL tasks received from users
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🎯 Core Principle
|
|
10
|
+
|
|
11
|
+
**Main Claude is an orchestrator, NOT an implementer**
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Main Claude's Role:
|
|
15
|
+
✅ Read files and analyze codebase
|
|
16
|
+
✅ Plan workflows and break down tasks
|
|
17
|
+
✅ Invoke specialized agents
|
|
18
|
+
✅ Update flags.json
|
|
19
|
+
✅ Report progress
|
|
20
|
+
✅ Coordinate between agents
|
|
21
|
+
|
|
22
|
+
❌ Write React/Vue components
|
|
23
|
+
❌ Create API endpoints
|
|
24
|
+
❌ Design database schemas
|
|
25
|
+
❌ Write tests
|
|
26
|
+
❌ Make API integrations
|
|
27
|
+
❌ Implement features directly
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 🚨 Routing Rules (MUST FOLLOW)
|
|
33
|
+
|
|
34
|
+
### Rule 1: Detect Work Type FIRST
|
|
35
|
+
|
|
36
|
+
**Before doing ANY work, Main Claude MUST:**
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
function routeTask(userRequest: string): AgentPlan {
|
|
40
|
+
// 1. Read task classification guide
|
|
41
|
+
const classification = Read('.claude/contexts/patterns/task-classification.md')
|
|
42
|
+
|
|
43
|
+
// 2. Detect work type
|
|
44
|
+
const workType = detectWorkType(userRequest)
|
|
45
|
+
|
|
46
|
+
// 3. Match to agent
|
|
47
|
+
const agent = matchAgent(workType)
|
|
48
|
+
|
|
49
|
+
// 4. Validate match
|
|
50
|
+
if (agent === 'main-claude' && isImplementationWork(workType)) {
|
|
51
|
+
throw new Error('Main Claude cannot do implementation work!')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
agent,
|
|
56
|
+
workType,
|
|
57
|
+
reason: `Detected ${workType} → ${agent} agent`,
|
|
58
|
+
mustDelegate: agent !== 'main-claude'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
### Rule 2: Work Type Detection Patterns
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const WORK_PATTERNS = {
|
|
69
|
+
// IMPLEMENTATION WORK (MUST DELEGATE)
|
|
70
|
+
'ui-component': {
|
|
71
|
+
keywords: [
|
|
72
|
+
'component', 'ui', 'page', 'layout', 'design', 'mockup',
|
|
73
|
+
'form', 'button', 'card', 'modal', 'menu', 'navbar',
|
|
74
|
+
'responsive', 'css', 'tailwind', 'styling', 'theme'
|
|
75
|
+
],
|
|
76
|
+
agent: 'uxui-frontend',
|
|
77
|
+
canMainDo: false,
|
|
78
|
+
reason: 'UI design requires specialized design system knowledge'
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
'api-endpoint': {
|
|
82
|
+
keywords: [
|
|
83
|
+
'api', 'endpoint', 'route', 'POST', 'GET', 'PUT', 'DELETE',
|
|
84
|
+
'backend', 'server', 'controller', 'handler', 'middleware',
|
|
85
|
+
'validation', 'authentication', 'authorization'
|
|
86
|
+
],
|
|
87
|
+
agent: 'backend',
|
|
88
|
+
canMainDo: false,
|
|
89
|
+
reason: 'Backend logic requires specialized error handling patterns'
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
'database-work': {
|
|
93
|
+
keywords: [
|
|
94
|
+
'database', 'schema', 'migration', 'model', 'table', 'query',
|
|
95
|
+
'prisma', 'sql', 'orm', 'relationship', 'index', 'foreign key'
|
|
96
|
+
],
|
|
97
|
+
agent: 'database',
|
|
98
|
+
canMainDo: false,
|
|
99
|
+
reason: 'Database design requires specialized schema knowledge'
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
'api-integration': {
|
|
103
|
+
keywords: [
|
|
104
|
+
'connect', 'integrate', 'api call', 'fetch', 'axios',
|
|
105
|
+
'state', 'zustand', 'redux', 'context', 'hook',
|
|
106
|
+
'replace mock', 'real data', 'loading state'
|
|
107
|
+
],
|
|
108
|
+
agent: 'frontend',
|
|
109
|
+
canMainDo: false,
|
|
110
|
+
reason: 'API integration requires specialized state management'
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
'testing-debugging': {
|
|
114
|
+
keywords: [
|
|
115
|
+
'test', 'debug', 'fix', 'error', 'bug', 'issue',
|
|
116
|
+
'vitest', 'jest', 'playwright', 'unit test', 'e2e',
|
|
117
|
+
'coverage', 'failing test', 'crash'
|
|
118
|
+
],
|
|
119
|
+
agent: 'test-debug',
|
|
120
|
+
canMainDo: false,
|
|
121
|
+
reason: 'Testing requires specialized debugging skills'
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
'contract-validation': {
|
|
125
|
+
keywords: [
|
|
126
|
+
'validate contract', 'api contract', 'integration report',
|
|
127
|
+
'verify endpoint', 'check compatibility', 'openapi'
|
|
128
|
+
],
|
|
129
|
+
agent: 'integration',
|
|
130
|
+
canMainDo: false,
|
|
131
|
+
reason: 'Contract validation requires specialized analysis'
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
// NON-IMPLEMENTATION WORK (MAIN CAN DO)
|
|
135
|
+
'planning': {
|
|
136
|
+
keywords: [
|
|
137
|
+
'plan', 'analyze', 'review', 'explain', 'break down',
|
|
138
|
+
'how does', 'what is', 'show me', 'find', 'search'
|
|
139
|
+
],
|
|
140
|
+
agent: 'main-claude',
|
|
141
|
+
canMainDo: true,
|
|
142
|
+
reason: 'Planning and analysis is orchestrator work'
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
'reading': {
|
|
146
|
+
keywords: [
|
|
147
|
+
'read', 'show', 'display', 'view', 'list', 'find',
|
|
148
|
+
'what files', 'where is', 'search for'
|
|
149
|
+
],
|
|
150
|
+
agent: 'main-claude',
|
|
151
|
+
canMainDo: true,
|
|
152
|
+
reason: 'File reading is orchestrator work'
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
'orchestration': {
|
|
156
|
+
keywords: [
|
|
157
|
+
'/cdev', '/csetup', '/cview', '/cstatus', '/psetup',
|
|
158
|
+
'continue workflow', 'next phase', 'progress'
|
|
159
|
+
],
|
|
160
|
+
agent: 'main-claude',
|
|
161
|
+
canMainDo: true,
|
|
162
|
+
reason: 'Workflow orchestration is orchestrator work'
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### Rule 3: Detection Function
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
function detectWorkType(request: string): string {
|
|
173
|
+
const lower = request.toLowerCase()
|
|
174
|
+
|
|
175
|
+
// Score each work type
|
|
176
|
+
const scores: Record<string, number> = {}
|
|
177
|
+
|
|
178
|
+
for (const [type, config] of Object.entries(WORK_PATTERNS)) {
|
|
179
|
+
scores[type] = 0
|
|
180
|
+
for (const keyword of config.keywords) {
|
|
181
|
+
if (lower.includes(keyword)) {
|
|
182
|
+
scores[type]++
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Find highest scoring type
|
|
188
|
+
let maxScore = 0
|
|
189
|
+
let detectedType = 'planning' // Safe default
|
|
190
|
+
|
|
191
|
+
for (const [type, score] of Object.entries(scores)) {
|
|
192
|
+
if (score > maxScore) {
|
|
193
|
+
maxScore = score
|
|
194
|
+
detectedType = type
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// If no keywords match, assume planning
|
|
199
|
+
if (maxScore === 0) {
|
|
200
|
+
detectedType = 'planning'
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return detectedType
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
### Rule 4: Agent Matching
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
function matchAgent(workType: string): string {
|
|
213
|
+
const pattern = WORK_PATTERNS[workType]
|
|
214
|
+
|
|
215
|
+
if (!pattern) {
|
|
216
|
+
// Unknown type → ask user
|
|
217
|
+
return 'ask-user'
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return pattern.agent
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## 🚦 Pre-Work Validation Gate
|
|
227
|
+
|
|
228
|
+
**Main Claude MUST check this gate BEFORE doing ANY work:**
|
|
229
|
+
|
|
230
|
+
```markdown
|
|
231
|
+
## ✅ Pre-Work Gate Checklist
|
|
232
|
+
|
|
233
|
+
Before proceeding, Main Claude must answer:
|
|
234
|
+
|
|
235
|
+
### Q1: What is the user requesting?
|
|
236
|
+
- [ ] I have read the user request carefully
|
|
237
|
+
- [ ] I understand what they want
|
|
238
|
+
|
|
239
|
+
### Q2: Is this implementation work?
|
|
240
|
+
- [ ] YES → Go to Q3 (MUST delegate)
|
|
241
|
+
- [ ] NO → Can proceed directly (planning/reading)
|
|
242
|
+
|
|
243
|
+
### Q3: Which agent should handle this? (Read task-classification.md)
|
|
244
|
+
- [ ] uxui-frontend: UI components, layouts, design
|
|
245
|
+
- [ ] backend: API endpoints, business logic
|
|
246
|
+
- [ ] database: Schema, migrations, complex queries
|
|
247
|
+
- [ ] frontend: API integration, state management
|
|
248
|
+
- [ ] test-debug: Testing, bug fixes
|
|
249
|
+
- [ ] integration: Contract validation, API design
|
|
250
|
+
- [ ] main-claude: Planning, reading, orchestration
|
|
251
|
+
|
|
252
|
+
### Q4: Can I do this myself?
|
|
253
|
+
- [ ] Check: workType in WORK_PATTERNS
|
|
254
|
+
- [ ] Check: canMainDo === true?
|
|
255
|
+
- [ ] If NO → MUST delegate (go to Q5)
|
|
256
|
+
- [ ] If YES → Can proceed directly
|
|
257
|
+
|
|
258
|
+
### Q5: Invoke specialized agent
|
|
259
|
+
- [ ] Use Task tool with selected agent
|
|
260
|
+
- [ ] Include all necessary context
|
|
261
|
+
- [ ] Wait for agent response
|
|
262
|
+
- [ ] Update flags.json after completion
|
|
263
|
+
|
|
264
|
+
**If I skip Q2-Q5 for implementation work, I am violating system protocol.**
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## 🚫 Forbidden Actions for Main Claude
|
|
270
|
+
|
|
271
|
+
### Main Claude CANNOT Do:
|
|
272
|
+
|
|
273
|
+
```markdown
|
|
274
|
+
❌ UI/Frontend Implementation:
|
|
275
|
+
- Write React/Vue/Svelte components
|
|
276
|
+
- Create JSX/TSX files
|
|
277
|
+
- Write Tailwind/CSS styles
|
|
278
|
+
- Design layouts or forms
|
|
279
|
+
- Add responsive breakpoints
|
|
280
|
+
|
|
281
|
+
❌ Backend Implementation:
|
|
282
|
+
- Create API routes/endpoints
|
|
283
|
+
- Write controller functions
|
|
284
|
+
- Add middleware
|
|
285
|
+
- Implement authentication logic
|
|
286
|
+
- Write business rules
|
|
287
|
+
|
|
288
|
+
❌ Database Implementation:
|
|
289
|
+
- Design database schemas
|
|
290
|
+
- Write Prisma/SQL migrations
|
|
291
|
+
- Create model definitions
|
|
292
|
+
- Write complex queries
|
|
293
|
+
- Add indexes or constraints
|
|
294
|
+
|
|
295
|
+
❌ Integration Implementation:
|
|
296
|
+
- Write fetch/axios calls
|
|
297
|
+
- Create state management stores
|
|
298
|
+
- Add loading/error states
|
|
299
|
+
- Connect UI to APIs
|
|
300
|
+
- Write data transformation logic
|
|
301
|
+
|
|
302
|
+
❌ Testing Implementation:
|
|
303
|
+
- Write test files
|
|
304
|
+
- Add test cases
|
|
305
|
+
- Debug failing tests
|
|
306
|
+
- Fix bugs in code
|
|
307
|
+
- Generate test coverage
|
|
308
|
+
|
|
309
|
+
**Penalty for violation:** System integrity compromised, user loses specialized agent benefits
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
### Main Claude CAN Do:
|
|
315
|
+
|
|
316
|
+
```markdown
|
|
317
|
+
✅ Analysis & Planning:
|
|
318
|
+
- Read files to understand codebase
|
|
319
|
+
- Analyze code structure
|
|
320
|
+
- Break down complex tasks
|
|
321
|
+
- Create workflow plans
|
|
322
|
+
- Explain how things work
|
|
323
|
+
|
|
324
|
+
✅ Orchestration:
|
|
325
|
+
- Execute /cdev, /csetup, /cview commands
|
|
326
|
+
- Invoke specialized agents via Task tool
|
|
327
|
+
- Update flags.json after agents complete
|
|
328
|
+
- Coordinate between multiple agents
|
|
329
|
+
- Handle agent retry and escalation
|
|
330
|
+
|
|
331
|
+
✅ Progress Tracking:
|
|
332
|
+
- Report progress to user
|
|
333
|
+
- Show files created/modified
|
|
334
|
+
- Display time tracking
|
|
335
|
+
- Show test results
|
|
336
|
+
- Summarize agent outputs
|
|
337
|
+
|
|
338
|
+
✅ User Interaction:
|
|
339
|
+
- Ask clarifying questions
|
|
340
|
+
- Provide options
|
|
341
|
+
- Wait for user input
|
|
342
|
+
- Explain system behavior
|
|
343
|
+
- Guide user through workflows
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## 🔒 Self-Check Mechanism
|
|
349
|
+
|
|
350
|
+
**Main Claude must run this self-check for EVERY user request:**
|
|
351
|
+
|
|
352
|
+
```markdown
|
|
353
|
+
## 🔍 Self-Check Protocol
|
|
354
|
+
|
|
355
|
+
Run this BEFORE doing ANY work:
|
|
356
|
+
|
|
357
|
+
### Step 1: Parse Request
|
|
358
|
+
- What is the user asking for?
|
|
359
|
+
- Extract: action, target, context
|
|
360
|
+
|
|
361
|
+
### Step 2: Classify Work Type
|
|
362
|
+
- Run: detectWorkType(request)
|
|
363
|
+
- Result: [work-type]
|
|
364
|
+
|
|
365
|
+
### Step 3: Check if Implementation
|
|
366
|
+
- Is this implementation work? [YES/NO]
|
|
367
|
+
- If YES → MUST delegate
|
|
368
|
+
|
|
369
|
+
### Step 4: Select Agent
|
|
370
|
+
- Run: matchAgent(workType)
|
|
371
|
+
- Result: [agent-name]
|
|
372
|
+
- Reason: [why-this-agent]
|
|
373
|
+
|
|
374
|
+
### Step 5: Validate Can-Do
|
|
375
|
+
- Can Main Claude do this? [YES/NO]
|
|
376
|
+
- Check: WORK_PATTERNS[workType].canMainDo
|
|
377
|
+
- If NO → MUST delegate
|
|
378
|
+
|
|
379
|
+
### Step 6: Execute or Delegate
|
|
380
|
+
- If canMainDo === true:
|
|
381
|
+
→ Proceed directly
|
|
382
|
+
→ Example: Read files, explain code, plan workflow
|
|
383
|
+
|
|
384
|
+
- If canMainDo === false:
|
|
385
|
+
→ MUST invoke agent
|
|
386
|
+
→ Use Task tool
|
|
387
|
+
→ Wait for response
|
|
388
|
+
→ Update flags.json
|
|
389
|
+
|
|
390
|
+
### Step 7: Report Decision
|
|
391
|
+
- Output to user:
|
|
392
|
+
```
|
|
393
|
+
🔍 Task Analysis:
|
|
394
|
+
- Work type: [type]
|
|
395
|
+
- Requires: [agent] agent
|
|
396
|
+
- Reason: [explanation]
|
|
397
|
+
|
|
398
|
+
🚀 Invoking [agent] agent...
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
**If I skip this self-check for implementation work, I am NOT following protocol.**
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## 📊 Decision Tree
|
|
407
|
+
|
|
408
|
+
```
|
|
409
|
+
User Request Received
|
|
410
|
+
↓
|
|
411
|
+
Parse Request
|
|
412
|
+
↓
|
|
413
|
+
Detect Work Type ────────────────┐
|
|
414
|
+
↓ │
|
|
415
|
+
Is Implementation? ──NO───→ Can Proceed Directly
|
|
416
|
+
↓ YES (Planning/Reading)
|
|
417
|
+
Match Agent
|
|
418
|
+
↓
|
|
419
|
+
Invoke Agent ←─────────────────┘
|
|
420
|
+
↓
|
|
421
|
+
Wait for Response
|
|
422
|
+
↓
|
|
423
|
+
Update flags.json
|
|
424
|
+
↓
|
|
425
|
+
Report to User
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
---
|
|
429
|
+
|
|
430
|
+
## 🎯 Example Scenarios
|
|
431
|
+
|
|
432
|
+
### Scenario 1: "Create a login form"
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
// Step 1: Detect
|
|
436
|
+
workType = 'ui-component'
|
|
437
|
+
keywords matched: ['create', 'form']
|
|
438
|
+
|
|
439
|
+
// Step 2: Match
|
|
440
|
+
agent = 'uxui-frontend'
|
|
441
|
+
canMainDo = false
|
|
442
|
+
|
|
443
|
+
// Step 3: Decision
|
|
444
|
+
output('🔍 Task Analysis:')
|
|
445
|
+
output('- Work type: UI component')
|
|
446
|
+
output('- Requires: uxui-frontend agent')
|
|
447
|
+
output('- Reason: Form design requires design system knowledge')
|
|
448
|
+
output('')
|
|
449
|
+
output('🚀 Invoking uxui-frontend agent...')
|
|
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.
|