@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,388 @@
|
|
|
1
|
+
# Agent Coordination Pattern
|
|
2
|
+
|
|
3
|
+
> **Purpose:** Guide Main Claude on when to run agents sequentially, in parallel, or conditionally.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🎯 Core Principle
|
|
8
|
+
|
|
9
|
+
**Maximize parallelism, minimize waiting.**
|
|
10
|
+
|
|
11
|
+
- ✅ Run agents in **parallel** when they don't depend on each other
|
|
12
|
+
- ✅ Run agents **sequentially** when one depends on another's output
|
|
13
|
+
- ✅ Run agents **conditionally** when only needed in specific scenarios
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 📊 Execution Strategies
|
|
18
|
+
|
|
19
|
+
### 🔵 Sequential Execution
|
|
20
|
+
**Run agents one after another**
|
|
21
|
+
|
|
22
|
+
**When to use:**
|
|
23
|
+
- Agent B needs output from Agent A
|
|
24
|
+
- Agent B modifies what Agent A created
|
|
25
|
+
- Order matters for correctness
|
|
26
|
+
|
|
27
|
+
**Example:**
|
|
28
|
+
```
|
|
29
|
+
uxui-frontend → frontend
|
|
30
|
+
(frontend needs the UI components that uxui-frontend creates)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**How to execute:**
|
|
34
|
+
```markdown
|
|
35
|
+
1. Run uxui-frontend first
|
|
36
|
+
2. Wait for completion
|
|
37
|
+
3. Then run frontend
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
### 🟢 Parallel Execution
|
|
43
|
+
**Run agents at the same time**
|
|
44
|
+
|
|
45
|
+
**When to use:**
|
|
46
|
+
- Agents are completely independent
|
|
47
|
+
- No shared dependencies
|
|
48
|
+
- Can work simultaneously without conflicts
|
|
49
|
+
|
|
50
|
+
**Example:**
|
|
51
|
+
```
|
|
52
|
+
backend + database (parallel)
|
|
53
|
+
(backend creates API logic, database creates schema - independent)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**How to execute:**
|
|
57
|
+
```markdown
|
|
58
|
+
1. Run backend AND database simultaneously
|
|
59
|
+
2. Wait for BOTH to complete
|
|
60
|
+
3. Then proceed to next phase
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Benefits:**
|
|
64
|
+
- ⚡ 2x faster (if 2 agents run parallel)
|
|
65
|
+
- 🔄 Better resource utilization
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
### 🟡 Conditional Execution
|
|
70
|
+
**Run agent only if condition is met**
|
|
71
|
+
|
|
72
|
+
**When to use:**
|
|
73
|
+
- Agent only needed in specific scenarios
|
|
74
|
+
- Optional validation/enhancement
|
|
75
|
+
- Feature flags or environment-specific
|
|
76
|
+
|
|
77
|
+
**Example:**
|
|
78
|
+
```
|
|
79
|
+
integration (conditional)
|
|
80
|
+
Run ONLY IF both frontend AND backend exist
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**How to execute:**
|
|
84
|
+
```markdown
|
|
85
|
+
IF (frontend code exists AND backend code exists):
|
|
86
|
+
Run integration agent
|
|
87
|
+
ELSE:
|
|
88
|
+
Skip (nothing to validate)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 🔄 Common Workflows
|
|
94
|
+
|
|
95
|
+
### 1. Full-Stack Feature (Login System)
|
|
96
|
+
|
|
97
|
+
**Task:** "Build a login system with email/password"
|
|
98
|
+
|
|
99
|
+
**Execution Plan:**
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
Phase 1: UI with Mock Data (Sequential)
|
|
103
|
+
├─ uxui-frontend → Create login form UI with mock data
|
|
104
|
+
└─ ⏸️ PAUSE for manual approval (optional)
|
|
105
|
+
|
|
106
|
+
Phase 2: Backend + Database (Parallel)
|
|
107
|
+
├─ backend → Create POST /api/login endpoint
|
|
108
|
+
└─ database → Create User table + migration
|
|
109
|
+
(Run simultaneously - no dependency)
|
|
110
|
+
|
|
111
|
+
Phase 2.5: Contract Validation (Conditional)
|
|
112
|
+
└─ integration → Verify frontend expects what backend returns
|
|
113
|
+
(Run ONLY IF both exist)
|
|
114
|
+
|
|
115
|
+
Phase 3: Connect UI to API (Sequential)
|
|
116
|
+
└─ frontend → Replace mock data with real API calls
|
|
117
|
+
(Depends on Phase 2 completion)
|
|
118
|
+
|
|
119
|
+
Phase 4: Testing (Sequential)
|
|
120
|
+
└─ test-debug → Run all tests, fix bugs
|
|
121
|
+
(Depends on Phase 3 completion)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Timeline:**
|
|
125
|
+
```
|
|
126
|
+
Without parallel: ~30 minutes
|
|
127
|
+
uxui (5m) → backend (10m) → database (5m) → integration (2m) → frontend (5m) → test (3m)
|
|
128
|
+
|
|
129
|
+
With parallel: ~20 minutes
|
|
130
|
+
uxui (5m) → [backend + database parallel] (10m) → integration (2m) → frontend (5m) → test (3m)
|
|
131
|
+
|
|
132
|
+
Savings: 10 minutes (33% faster)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
### 2. UI-Only Feature (Landing Page)
|
|
138
|
+
|
|
139
|
+
**Task:** "Create a landing page with hero, features, and CTA sections"
|
|
140
|
+
|
|
141
|
+
**Execution Plan:**
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
Phase 1: UI Components (Sequential)
|
|
145
|
+
└─ uxui-frontend → Create all sections (hero, features, CTA)
|
|
146
|
+
|
|
147
|
+
Phase 2: Testing (Sequential)
|
|
148
|
+
└─ test-debug → Test responsive design, accessibility
|
|
149
|
+
(Depends on Phase 1)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**No backend/database needed → Simple workflow**
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### 3. API-Only Feature (Analytics Endpoint)
|
|
157
|
+
|
|
158
|
+
**Task:** "Create GET /api/analytics endpoint with aggregations"
|
|
159
|
+
|
|
160
|
+
**Execution Plan:**
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
Phase 1: Database Query (Sequential)
|
|
164
|
+
└─ database → Create complex aggregation query
|
|
165
|
+
(Needs to be tested first)
|
|
166
|
+
|
|
167
|
+
Phase 2: API Endpoint (Sequential)
|
|
168
|
+
└─ backend → Create GET /api/analytics using query
|
|
169
|
+
(Depends on database query)
|
|
170
|
+
|
|
171
|
+
Phase 3: Testing (Sequential)
|
|
172
|
+
└─ test-debug → Test endpoint with various inputs
|
|
173
|
+
(Depends on Phase 2)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**No frontend needed → Backend-only workflow**
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### 4. Refactoring Task (Extract Shared Component)
|
|
181
|
+
|
|
182
|
+
**Task:** "Extract repeated button styles into shared component"
|
|
183
|
+
|
|
184
|
+
**Execution Plan:**
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
Phase 1: Refactor (Sequential)
|
|
188
|
+
└─ uxui-frontend → Extract ButtonComponent, update all usages
|
|
189
|
+
|
|
190
|
+
Phase 2: Testing (Sequential)
|
|
191
|
+
└─ test-debug → Ensure all buttons still work correctly
|
|
192
|
+
(Depends on Phase 1)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Simple refactor → No multiple agents needed**
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## 🎯 Decision Matrix
|
|
200
|
+
|
|
201
|
+
| Scenario | Agents Needed | Execution | Rationale |
|
|
202
|
+
|----------|---------------|-----------|-----------|
|
|
203
|
+
| **Full-stack CRUD** | uxui → backend + database (parallel) → integration → frontend → test | Mixed | Backend + database independent |
|
|
204
|
+
| **UI component only** | uxui → test | Sequential | Simple workflow |
|
|
205
|
+
| **API endpoint only** | backend → test (or database → backend → test) | Sequential | Backend may need database |
|
|
206
|
+
| **Database schema** | database → test | Sequential | Simple workflow |
|
|
207
|
+
| **Complex query** | database → backend → test | Sequential | Backend uses database query |
|
|
208
|
+
| **Connect existing UI to API** | integration → frontend → test | Sequential | Validate then connect |
|
|
209
|
+
| **Bug fix** | test-debug | Single agent | Focused debugging |
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## 🚀 Optimization Tips
|
|
214
|
+
|
|
215
|
+
### 1. **Identify Independent Work**
|
|
216
|
+
Before starting, ask:
|
|
217
|
+
- "Can backend work without waiting for database?"
|
|
218
|
+
- "Can database schema be designed independently?"
|
|
219
|
+
|
|
220
|
+
If YES → Run in parallel
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
### 2. **Batch Similar Tasks**
|
|
225
|
+
Instead of:
|
|
226
|
+
```
|
|
227
|
+
Create User endpoint → Test → Create Post endpoint → Test
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Do:
|
|
231
|
+
```
|
|
232
|
+
Create User + Post endpoints (batch) → Test both together
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Benefit:** Fewer context switches
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
### 3. **Use Integration Agent Wisely**
|
|
240
|
+
Only run integration agent when:
|
|
241
|
+
- ✅ Both frontend AND backend exist
|
|
242
|
+
- ✅ API contracts might mismatch
|
|
243
|
+
- ❌ Don't run if only UI or only API exists (nothing to validate)
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
### 4. **Defer Testing When Safe**
|
|
248
|
+
Instead of:
|
|
249
|
+
```
|
|
250
|
+
uxui → test → backend → test → frontend → test
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Do:
|
|
254
|
+
```
|
|
255
|
+
uxui → backend + database (parallel) → frontend → test (once at end)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Benefit:** Faster iteration (test once instead of 3 times)
|
|
259
|
+
|
|
260
|
+
**⚠️ Trade-off:** If test fails, harder to debug (but usually worth it)
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## 📋 Coordination Checklist
|
|
265
|
+
|
|
266
|
+
**Before starting multi-agent task, ask:**
|
|
267
|
+
|
|
268
|
+
### 🔍 Analysis Questions
|
|
269
|
+
- [ ] What agents are needed? (List all)
|
|
270
|
+
- [ ] Which agents depend on others? (Map dependencies)
|
|
271
|
+
- [ ] Which agents can run in parallel? (Identify independent work)
|
|
272
|
+
- [ ] Are there any conditional agents? (integration, optional features)
|
|
273
|
+
|
|
274
|
+
### ⚡ Optimization Questions
|
|
275
|
+
- [ ] Can I reduce sequential steps by parallelizing?
|
|
276
|
+
- [ ] Can I batch similar work to avoid context switching?
|
|
277
|
+
- [ ] Can I defer testing to end instead of after each agent?
|
|
278
|
+
- [ ] Is there a faster path to MVP?
|
|
279
|
+
|
|
280
|
+
### 🎯 Execution Plan
|
|
281
|
+
- [ ] Write down the phase breakdown
|
|
282
|
+
- [ ] Mark parallel agents clearly
|
|
283
|
+
- [ ] Identify manual approval points (if any)
|
|
284
|
+
- [ ] Estimate time savings from parallelism
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## 📖 Example: Main Claude Analysis
|
|
289
|
+
|
|
290
|
+
**User Request:** "Build a blog system with posts and comments"
|
|
291
|
+
|
|
292
|
+
**Main Claude's Internal Thought Process:**
|
|
293
|
+
|
|
294
|
+
```markdown
|
|
295
|
+
Step 1: What agents are needed?
|
|
296
|
+
- uxui-frontend (blog list, post detail, comment form)
|
|
297
|
+
- backend (GET /posts, POST /comments, etc.)
|
|
298
|
+
- database (Post + Comment models)
|
|
299
|
+
- frontend (connect UI to API)
|
|
300
|
+
- test-debug (test everything)
|
|
301
|
+
|
|
302
|
+
Step 2: Dependencies?
|
|
303
|
+
- uxui-frontend → independent (uses mock data)
|
|
304
|
+
- backend → independent (can create endpoints)
|
|
305
|
+
- database → independent (can design schema)
|
|
306
|
+
- frontend → depends on uxui + backend + database
|
|
307
|
+
- test-debug → depends on everything
|
|
308
|
+
|
|
309
|
+
Step 3: Can we parallelize?
|
|
310
|
+
YES! backend + database can run together (independent)
|
|
311
|
+
|
|
312
|
+
Step 4: Execution Plan:
|
|
313
|
+
Phase 1: uxui-frontend (create UI with mock)
|
|
314
|
+
Phase 2: backend + database (parallel - create API + schema)
|
|
315
|
+
Phase 2.5: integration (verify contracts)
|
|
316
|
+
Phase 3: frontend (connect UI to real API)
|
|
317
|
+
Phase 4: test-debug (test all features)
|
|
318
|
+
|
|
319
|
+
Step 5: Execute:
|
|
320
|
+
Run uxui-frontend...
|
|
321
|
+
✅ Done
|
|
322
|
+
|
|
323
|
+
Run backend AND database in parallel...
|
|
324
|
+
✅ Both done
|
|
325
|
+
|
|
326
|
+
Run integration...
|
|
327
|
+
✅ Contracts match
|
|
328
|
+
|
|
329
|
+
Run frontend...
|
|
330
|
+
✅ Done
|
|
331
|
+
|
|
332
|
+
Run test-debug...
|
|
333
|
+
✅ All tests pass
|
|
334
|
+
|
|
335
|
+
Task complete!
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## 🎨 Visual Workflow Examples
|
|
341
|
+
|
|
342
|
+
### Sequential (Waterfall)
|
|
343
|
+
```
|
|
344
|
+
[uxui] ──► [backend] ──► [database] ──► [frontend] ──► [test]
|
|
345
|
+
5m 10m 5m 5m 3m
|
|
346
|
+
Total: 28 minutes
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Parallel (Optimized)
|
|
350
|
+
```
|
|
351
|
+
[uxui] ──► [backend ] ──► [frontend] ──► [test]
|
|
352
|
+
5m [database ] 5m 3m
|
|
353
|
+
10m (parallel)
|
|
354
|
+
Total: 23 minutes (18% faster)
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### Hybrid (Best)
|
|
358
|
+
```
|
|
359
|
+
[uxui] ──► [backend + database] ──► [integration] ──► [frontend] ──► [test]
|
|
360
|
+
5m 10m (parallel) 2m 5m 3m
|
|
361
|
+
Total: 25 minutes (but safer with validation)
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
## ✅ Summary
|
|
367
|
+
|
|
368
|
+
### Key Principles:
|
|
369
|
+
1. **Parallel > Sequential** (when safe)
|
|
370
|
+
2. **Validate contracts** (use integration agent)
|
|
371
|
+
3. **Defer testing** (batch at end when possible)
|
|
372
|
+
4. **Map dependencies** (before starting)
|
|
373
|
+
|
|
374
|
+
### Common Patterns:
|
|
375
|
+
- **Full-stack:** uxui → [backend + database] → integration → frontend → test
|
|
376
|
+
- **UI-only:** uxui → test
|
|
377
|
+
- **API-only:** backend → test (or database → backend → test)
|
|
378
|
+
- **Refactor:** specialist agent → test
|
|
379
|
+
|
|
380
|
+
### When in Doubt:
|
|
381
|
+
- **Ask:** "Does Agent B need Agent A's output?"
|
|
382
|
+
- **If YES:** Sequential
|
|
383
|
+
- **If NO:** Parallel
|
|
384
|
+
- **If MAYBE:** Run integration agent to verify
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
**Remember:** The goal is speed AND quality. Parallelize when safe, validate when needed, test thoroughly.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Agent Discovery Pattern
|
|
2
|
+
|
|
3
|
+
> **Standard 5-level project context discovery for ALL agents**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🎯 Purpose
|
|
8
|
+
|
|
9
|
+
Every agent MUST discover project context before ANY work. This ensures agents have all necessary context loaded.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 📋 Discovery Sequence
|
|
14
|
+
|
|
15
|
+
### Level 1: Find Current Project
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
Read: .claude/contexts/domain/index.md
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Extract:**
|
|
22
|
+
- Current project name
|
|
23
|
+
- Project location path
|
|
24
|
+
|
|
25
|
+
**If not found:** → Go to [Fallback Strategy](#fallback-strategy)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### Level 2: Load Project Overview
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
Read: .claude/contexts/domain/{project}/README.md
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Extract:**
|
|
36
|
+
- Tech stack summary (frameworks, versions)
|
|
37
|
+
- Package manager
|
|
38
|
+
- Available best practices files
|
|
39
|
+
|
|
40
|
+
**If not found:** → Go to [Fallback Strategy](#fallback-strategy)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### Level 3: Check Best Practices Index
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
Read: .claude/contexts/domain/{project}/best-practices/index.md
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Find section:** "For `{your-agent-type}` agent"
|
|
51
|
+
|
|
52
|
+
**Extract:** List of must-read files for your role
|
|
53
|
+
|
|
54
|
+
**If not found:** → Go to [Fallback Strategy](#fallback-strategy)
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### Level 4: Load Relevant Best Practices
|
|
59
|
+
|
|
60
|
+
**Based on Level 3 index, read agent-specific best practices:**
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Example for backend agent:
|
|
64
|
+
Read: .claude/contexts/domain/{project}/best-practices/fastapi-*.md
|
|
65
|
+
Read: .claude/contexts/domain/{project}/best-practices/express-*.md
|
|
66
|
+
|
|
67
|
+
# Example for frontend agent:
|
|
68
|
+
Read: .claude/contexts/domain/{project}/best-practices/react-*.md
|
|
69
|
+
Read: .claude/contexts/domain/{project}/best-practices/nextjs-*.md
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Use glob to find files:**
|
|
73
|
+
```bash
|
|
74
|
+
Glob: ".claude/contexts/domain/{project}/best-practices/*.md"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### Level 5: Change Context (If Working on OpenSpec Change)
|
|
80
|
+
|
|
81
|
+
**Check if change-specific context exists:**
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
ls openspec/changes/{change-id}/.claude/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**If exists, read change context:**
|
|
88
|
+
|
|
89
|
+
1. **Change-specific tech & patterns:**
|
|
90
|
+
```bash
|
|
91
|
+
Read: openspec/changes/{change-id}/.claude/context.md
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
2. **Current progress:**
|
|
95
|
+
```bash
|
|
96
|
+
Read: openspec/changes/{change-id}/.claude/flags.json
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
3. **Current phase instructions:**
|
|
100
|
+
```bash
|
|
101
|
+
Read: openspec/changes/{change-id}/.claude/phases.md
|
|
102
|
+
```
|
|
103
|
+
Find current phase section only (based on flags.json)
|
|
104
|
+
|
|
105
|
+
4. **OpenSpec files:**
|
|
106
|
+
```bash
|
|
107
|
+
Read: openspec/changes/{change-id}/proposal.md
|
|
108
|
+
Read: openspec/changes/{change-id}/tasks.md
|
|
109
|
+
Read: openspec/changes/{change-id}/design.md # if exists
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**If change context doesn't exist:**
|
|
113
|
+
- Skip Level 5 (working on general task, not OpenSpec change)
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## ✅ Discovery Complete - Report
|
|
118
|
+
|
|
119
|
+
**After completing Levels 1-4, output:**
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
✅ Project Context Loaded
|
|
123
|
+
|
|
124
|
+
📁 Project: {project-name}
|
|
125
|
+
🛠️ Stack: {tech-stack-summary}
|
|
126
|
+
📚 Best Practices Loaded:
|
|
127
|
+
- {framework-1} ✓
|
|
128
|
+
- {framework-2} ✓
|
|
129
|
+
|
|
130
|
+
🎯 Ready to proceed!
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 🚨 Fallback Strategy
|
|
136
|
+
|
|
137
|
+
**If any level fails:**
|
|
138
|
+
|
|
139
|
+
1. **Try Glob Search:**
|
|
140
|
+
```bash
|
|
141
|
+
Glob: ".claude/contexts/domain/*/README.md"
|
|
142
|
+
```
|
|
143
|
+
- **Found 1:** Use it
|
|
144
|
+
- **Found multiple:** Ask user which project
|
|
145
|
+
- **Found 0:** Go to step 2
|
|
146
|
+
|
|
147
|
+
2. **Warn User:**
|
|
148
|
+
```
|
|
149
|
+
⚠️ No project context found!
|
|
150
|
+
|
|
151
|
+
It looks like you haven't run `/agentsetup` yet.
|
|
152
|
+
|
|
153
|
+
Options:
|
|
154
|
+
1. Run `/agentsetup` now (recommended)
|
|
155
|
+
2. Continue without best practices (universal patterns only)
|
|
156
|
+
|
|
157
|
+
Which would you like?
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
3. **If user chooses option 2:**
|
|
161
|
+
- Continue with universal patterns from `.claude/contexts/patterns/`
|
|
162
|
+
- Warn that code may not follow project-specific conventions
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 📖 Usage in Agent Files
|
|
167
|
+
|
|
168
|
+
**In each agent .md file, replace entire STEP 0 with:**
|
|
169
|
+
|
|
170
|
+
```markdown
|
|
171
|
+
## STEP 0: Discover Project Context (MANDATORY - DO THIS FIRST!)
|
|
172
|
+
|
|
173
|
+
**Follow standard agent discovery:**
|
|
174
|
+
→ See `.claude/contexts/patterns/agent-discovery.md`
|
|
175
|
+
|
|
176
|
+
**Report when complete:**
|
|
177
|
+
✅ Project Context Loaded
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
This pattern ensures ALL agents follow the same discovery flow consistently.
|