@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.
Files changed (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +561 -0
  3. package/bin/cli.js +61 -0
  4. package/lib/init.js +52 -0
  5. package/lib/update.js +73 -0
  6. package/package.json +47 -0
  7. package/template/.claude/CHANGELOG-v1.1.1.md +259 -0
  8. package/template/.claude/CLAUDE.md +329 -0
  9. package/template/.claude/agents/01-integration.md +797 -0
  10. package/template/.claude/agents/02-uxui-frontend.md +899 -0
  11. package/template/.claude/agents/03-test-debug.md +759 -0
  12. package/template/.claude/agents/04-frontend.md +1099 -0
  13. package/template/.claude/agents/05-backend.md +1217 -0
  14. package/template/.claude/agents/06-database.md +969 -0
  15. package/template/.claude/commands/agentsetup.md +1464 -0
  16. package/template/.claude/commands/cdev.md +327 -0
  17. package/template/.claude/commands/csetup.md +447 -0
  18. package/template/.claude/commands/cstatus.md +60 -0
  19. package/template/.claude/commands/cview.md +364 -0
  20. package/template/.claude/commands/psetup.md +101 -0
  21. package/template/.claude/contexts/design/accessibility.md +611 -0
  22. package/template/.claude/contexts/design/box-thinking.md +553 -0
  23. package/template/.claude/contexts/design/color-theory.md +498 -0
  24. package/template/.claude/contexts/design/index.md +247 -0
  25. package/template/.claude/contexts/design/layout.md +400 -0
  26. package/template/.claude/contexts/design/responsive.md +551 -0
  27. package/template/.claude/contexts/design/shadows.md +522 -0
  28. package/template/.claude/contexts/design/spacing.md +428 -0
  29. package/template/.claude/contexts/design/typography.md +465 -0
  30. package/template/.claude/contexts/domain/README.md +164 -0
  31. package/template/.claude/contexts/patterns/agent-coordination.md +388 -0
  32. package/template/.claude/contexts/patterns/agent-discovery.md +182 -0
  33. package/template/.claude/contexts/patterns/change-workflow.md +538 -0
  34. package/template/.claude/contexts/patterns/code-standards.md +515 -0
  35. package/template/.claude/contexts/patterns/development-principles.md +513 -0
  36. package/template/.claude/contexts/patterns/error-handling.md +478 -0
  37. package/template/.claude/contexts/patterns/error-recovery.md +365 -0
  38. package/template/.claude/contexts/patterns/frontend-component-strategy.md +365 -0
  39. package/template/.claude/contexts/patterns/git-workflow.md +207 -0
  40. package/template/.claude/contexts/patterns/logging.md +424 -0
  41. package/template/.claude/contexts/patterns/task-breakdown.md +452 -0
  42. package/template/.claude/contexts/patterns/task-classification.md +523 -0
  43. package/template/.claude/contexts/patterns/tdd-classification.md +516 -0
  44. package/template/.claude/contexts/patterns/testing.md +413 -0
  45. package/template/.claude/contexts/patterns/ui-component-consistency.md +304 -0
  46. package/template/.claude/contexts/patterns/validation-framework.md +776 -0
  47. package/template/.claude/lib/README.md +39 -0
  48. package/template/.claude/lib/agent-executor.md +258 -0
  49. package/template/.claude/lib/agent-router.md +572 -0
  50. package/template/.claude/lib/flags-updater.md +469 -0
  51. package/template/.claude/lib/tdd-classifier.md +345 -0
  52. package/template/.claude/lib/validation-gates.md +484 -0
  53. package/template/.claude/settings.local.json +42 -0
  54. package/template/.claude/templates/context-template.md +45 -0
  55. package/template/.claude/templates/flags-template.json +42 -0
  56. package/template/.claude/templates/phase-templates.json +124 -0
  57. package/template/.claude/templates/phases-sections/accessibility-test.md +17 -0
  58. package/template/.claude/templates/phases-sections/api-design.md +37 -0
  59. package/template/.claude/templates/phases-sections/backend-tests.md +16 -0
  60. package/template/.claude/templates/phases-sections/backend.md +37 -0
  61. package/template/.claude/templates/phases-sections/business-logic-validation.md +16 -0
  62. package/template/.claude/templates/phases-sections/component-tests.md +17 -0
  63. package/template/.claude/templates/phases-sections/contract-backend.md +16 -0
  64. package/template/.claude/templates/phases-sections/contract-frontend.md +16 -0
  65. package/template/.claude/templates/phases-sections/database.md +35 -0
  66. package/template/.claude/templates/phases-sections/documentation.md +17 -0
  67. package/template/.claude/templates/phases-sections/e2e-tests.md +16 -0
  68. package/template/.claude/templates/phases-sections/fix-implementation.md +17 -0
  69. package/template/.claude/templates/phases-sections/frontend-integration.md +18 -0
  70. package/template/.claude/templates/phases-sections/frontend-mockup.md +123 -0
  71. package/template/.claude/templates/phases-sections/manual-flow-test.md +15 -0
  72. package/template/.claude/templates/phases-sections/manual-ux-test.md +16 -0
  73. package/template/.claude/templates/phases-sections/refactor-implementation.md +17 -0
  74. package/template/.claude/templates/phases-sections/refactor.md +16 -0
  75. package/template/.claude/templates/phases-sections/regression-tests.md +15 -0
  76. package/template/.claude/templates/phases-sections/report.md +16 -0
  77. package/template/.claude/templates/phases-sections/responsive-test.md +16 -0
  78. package/template/.claude/templates/phases-sections/script-implementation.md +43 -0
  79. package/template/.claude/templates/phases-sections/test-coverage.md +16 -0
  80. package/template/.claude/templates/phases-sections/user-approval.md +14 -0
@@ -0,0 +1,327 @@
1
+ ---
2
+ name: Change Develop
3
+ description: Start/continue multi-agent development for a change
4
+ category: Multi-Agent
5
+ tags: [dev, orchestration, agents]
6
+ ---
7
+
8
+ ## Usage
9
+
10
+ ```bash
11
+ /cdev {change-id}
12
+ /cdev {change-id} --continue
13
+ /cdev {change-id} --retry
14
+ ```
15
+
16
+ ## What It Does
17
+
18
+ Orchestrates agent execution for change development:
19
+ 1. Read current phase from flags.json
20
+ 2. Get agent assignment from phases.md
21
+ 3. Invoke appropriate agent(s)
22
+ 4. Update progress
23
+ 5. Continue or pause for user action
24
+
25
+ ## Steps
26
+
27
+ ### Step 1: Load Change Context
28
+
29
+ ```bash
30
+ # Check prerequisites
31
+ ls openspec/changes/{change-id}/.claude/flags.json
32
+ ls openspec/changes/{change-id}/.claude/phases.md
33
+ ```
34
+
35
+ If not found:
36
+ ```
37
+ āŒ Change not set up
38
+ Run: /csetup {change-id}
39
+ ```
40
+
41
+ ### Step 2: Read Current Phase
42
+
43
+ ```typescript
44
+ const flags = JSON.parse(Read('openspec/changes/{change-id}/.claude/flags.json'))
45
+ const currentPhase = flags.current_phase
46
+ const phaseData = flags.phases[currentPhase]
47
+
48
+ if (phaseData.status === 'completed') {
49
+ // Move to next phase
50
+ currentPhase = getNextPhase(flags)
51
+ }
52
+ ```
53
+
54
+ ### Step 3: Check Phase Type
55
+
56
+ ```typescript
57
+ const agent = phaseData.agent
58
+
59
+ if (agent === 'user') {
60
+ // Manual action required
61
+ output(`šŸ›‘ Phase ${phaseData.phase_number} requires manual action`)
62
+ output(`Instructions: ${getInstructions(currentPhase)}`)
63
+ output(`When done: /cdev ${changeId} --continue`)
64
+ return
65
+ }
66
+
67
+ if (agent.includes('+')) {
68
+ // Multiple agents (parallel)
69
+ agents = agent.split('+').map(a => a.trim())
70
+ invokeMultipleAgents(agents, changeId, currentPhase)
71
+ } else {
72
+ // Single agent
73
+ invokeAgent(agent, changeId, currentPhase)
74
+ }
75
+ ```
76
+
77
+ ### Step 4: Invoke Agent with Retry & Validation
78
+
79
+ **This step now uses the enhanced agent-executor framework!**
80
+
81
+ See: `.claude/lib/agent-executor.md` for full implementation
82
+
83
+ **High-Level Flow:**
84
+
85
+ 1. **Calculate Context Size** (for model selection)
86
+ 2. **Select Model** (haiku vs sonnet based on complexity)
87
+ 3. **Execute Agent with Retry** (automatic retry on failure)
88
+ 4. **Validate Pre-Work** (enforce mandatory checklist)
89
+ 5. **Validate Output Quality** (check completeness)
90
+ 6. **Handle Errors** (retry or escalate)
91
+
92
+ **Implementation:**
93
+
94
+ ```typescript
95
+ // Step 4: Invoke Agent with Retry & Validation
96
+
97
+ // 4.1: Build agent prompt
98
+ const prompt = buildAgentPrompt(phase, changeContext)
99
+
100
+ // 4.2: Execute agent with retry & validation
101
+ output(`\nšŸš€ Invoking ${phase.agent} agent (model: haiku)...`)
102
+
103
+ const result = await executeAgentWithRetry(
104
+ phase.agent,
105
+ phase,
106
+ changeContext,
107
+ {
108
+ max_retries: 2,
109
+ retry_delay: 5000,
110
+ timeout: 600000, // 10 minutes
111
+ validate_output: true
112
+ }
113
+ )
114
+
115
+ // 4.3: Handle result
116
+ if (result.success) {
117
+ output(`\nāœ… Phase ${phase.phase_number} completed successfully!`)
118
+ output(`ā±ļø Execution time: ${(result.execution_time / 1000).toFixed(1)}s`)
119
+ output(`šŸ”„ Retries used: ${result.retries_used}`)
120
+ output(`āœ… Validation: ${result.validation_passed ? 'PASSED' : 'SKIPPED'}`)
121
+
122
+ // Continue to Step 5: Post-Execution
123
+ } else {
124
+ output(`\nāŒ Phase ${phase.phase_number} failed`)
125
+ output(`Error: ${result.error}`)
126
+ output(`Retries used: ${result.retries_used}`)
127
+
128
+ // Escalate to user
129
+ const action = await escalateToUser(phase.agent, phase, result)
130
+
131
+ switch (action) {
132
+ case 'retry':
133
+ output(`Retrying Phase ${phase.phase_number}...`)
134
+ // Restart Step 4
135
+ return executePhaseAgain(changeId, phase)
136
+
137
+ case 'skip':
138
+ output(`āš ļø Skipping Phase ${phase.phase_number}`)
139
+ await markPhaseAsSkipped(changeId, phase, result.error)
140
+ // Continue to next phase
141
+ break
142
+
143
+ case 'abort':
144
+ output(`šŸ›‘ Workflow aborted`)
145
+ output(`Resume with: /cdev ${changeId}`)
146
+ return
147
+ }
148
+ }
149
+ ```
150
+
151
+ **Helper Functions Used:**
152
+
153
+ 1. **buildAgentPrompt()**: See `.claude/lib/agent-executor.md`
154
+ 2. **executeAgentWithRetry()**: See `.claude/lib/agent-executor.md`
155
+ 3. **escalateToUser()**: See `.claude/lib/agent-executor.md`
156
+
157
+ **Model Strategy:**
158
+ - All agents use `model: haiku` (fixed)
159
+ - Haiku performs excellently with detailed context
160
+ - 12-20x cheaper than sonnet
161
+ - Quality maintained through comprehensive validation framework
162
+
163
+ ---
164
+
165
+ ### Step 4.5: Validation Details
166
+
167
+ **Validation is handled automatically inside executeAgentWithRetry():**
168
+
169
+ See `.claude/lib/agent-executor.md` for complete validation flow including:
170
+ - Pre-work validation (checks required checklist items)
171
+ - Output quality checks (completion markers, code blocks, test results)
172
+ - Retry logic (max 2 retries with feedback)
173
+ - Escalation (user options on failure)
174
+
175
+ **Agent-specific validation requirements:**
176
+
177
+ See `.claude/contexts/patterns/validation-framework.md` for complete checklist per agent:
178
+ - uxui-frontend: Design Foundation, Box Thinking, Component Search, Design Tokens
179
+ - backend: Patterns Loaded, Endpoint Search, TDD Workflow (if required), Error Handling
180
+ - database: Schema Analysis, Migration Strategy, Existing Schemas Search
181
+ - frontend: API Contract Verification, State Management, Error Handling
182
+ - test-debug: Test Infrastructure, Coverage Targets, Test Plan
183
+ - integration: Contract Collection, Schema Validation, Data Flow Analysis
184
+
185
+ ---
186
+
187
+ ### Step 5: Post-Execution (šŸ†• MANDATORY FLAGS UPDATE)
188
+
189
+ **āš ļø CRITICAL: Main Claude MUST update flags.json after EVERY phase completion**
190
+
191
+ See: `.claude/lib/flags-updater.md` for complete protocol
192
+
193
+ **Execution Order (MUST follow this sequence):**
194
+
195
+ ```typescript
196
+ // 1. MANDATORY: Update flags.json
197
+ output(`\nšŸ”„ Updating progress tracking...`)
198
+
199
+ // See flags-updater.md for updateFlagsAfterPhase() implementation
200
+ updateFlagsAfterPhase(changeId, currentPhase, agentResponse)
201
+
202
+ // This function:
203
+ // - Marks phase as completed
204
+ // - Records actual duration
205
+ // - Extracts files created/modified
206
+ // - Updates meta statistics (progress %, time remaining)
207
+ // - Moves current_phase to next phase
208
+ // - Writes back to flags.json
209
+ // - Reports progress to user
210
+
211
+ // 2. Read updated flags
212
+ const flagsPath = `openspec/changes/${changeId}/.claude/flags.json`
213
+ const flags = JSON.parse(Read(flagsPath))
214
+
215
+ // 3. Report progress to user
216
+ output(`\nšŸ“Š Progress Update:`)
217
+ output(` āœ… ${flags.meta.completed_phases}/${flags.meta.total_phases} phases complete`)
218
+ output(` šŸ“ˆ ${flags.meta.progress_percentage}% progress`)
219
+ output(` ā±ļø ${formatDuration(flags.meta.total_actual_minutes)} spent`)
220
+ output(` ā±ļø ${formatDuration(flags.meta.time_remaining_estimate)} remaining`)
221
+
222
+ // 4. Check next phase
223
+ if (flags.ready_to_archive) {
224
+ output('\nāœ… All phases complete! Ready to archive.')
225
+ output(`\nNext steps:`)
226
+ output(`1. Review: /cview ${changeId}`)
227
+ output(`2. Update tasks.md (mark all [x])`)
228
+ output(`3. Archive: openspec archive ${changeId}`)
229
+ } else {
230
+ const nextPhase = flags.phases[flags.current_phase]
231
+
232
+ output(`\nšŸ“ Next: Phase ${nextPhase.phase_number}: ${flags.current_phase}`)
233
+ output(` Agent: ${nextPhase.agent}`)
234
+ output(` Estimated: ${nextPhase.estimated_minutes} min`)
235
+
236
+ if (nextPhase.agent === 'user') {
237
+ output('\nšŸ›‘ Next phase requires your action')
238
+ output(`When done: /cdev ${changeId} --continue`)
239
+ } else {
240
+ output('\nContinue? (yes/no)')
241
+ }
242
+ }
243
+ ```
244
+
245
+ **Rules:**
246
+ - āœ… Main Claude updates flags.json (NOT sub-agent)
247
+ - āœ… Update happens IMMEDIATELY after sub-agent responds successfully
248
+ - āœ… Update happens BEFORE asking user to continue
249
+ - āœ… Progress is reported to user after EVERY update
250
+ - āœ… No exceptions - even if agent "says" it updated flags
251
+
252
+ **Common Mistake:**
253
+ ```typescript
254
+ āŒ WRONG:
255
+ Agent completes → Ask user to continue → (flags.json never updated)
256
+
257
+ āœ… CORRECT:
258
+ Agent completes → Update flags.json → Report progress → Ask user to continue
259
+ ```
260
+
261
+ ---
262
+
263
+ ## Example Session
264
+
265
+ ```bash
266
+ $ /cdev CHANGE-003
267
+
268
+ āœ… Reading change context...
269
+ šŸ“ Change: CHANGE-003 Create Landing Page
270
+ šŸ“Š Template: frontend-only (11 phases)
271
+ šŸ“ Current: Phase 1/11 Frontend Mockup
272
+
273
+ Invoking uxui-frontend agent...
274
+
275
+ [Agent executes Phase 1...]
276
+
277
+ āœ… Phase 1 completed! (95 minutes)
278
+
279
+ šŸ“ Files created:
280
+ - src/app/page.tsx
281
+ - src/components/landing/hero-section.tsx
282
+ - src/components/landing/features-section.tsx
283
+ - src/components/landing/cta-section.tsx
284
+
285
+ šŸ“ Next: Phase 2 Accessibility Test (test-debug)
286
+
287
+ Continue? (yes/no)
288
+ > yes
289
+
290
+ [Continues...]
291
+
292
+ šŸ›‘ Phase 3 requires manual testing.
293
+ Test visual consistency using Chrome DevTools MCP.
294
+ When done: /cdev CHANGE-003 --continue
295
+
296
+ $ [User tests]
297
+
298
+ $ /cdev CHANGE-003 --continue
299
+
300
+ Updating flags → Phase 3 marked completed
301
+ šŸ“ Next: Phase 4 Business Logic Validation
302
+ Continue? (yes/no)
303
+ > yes
304
+
305
+ [Continues until complete...]
306
+
307
+ āœ… All phases completed! (11/11)
308
+ Ready to archive!
309
+ ```
310
+
311
+ ---
312
+
313
+ ## Flags
314
+
315
+ - `--continue`: Skip to next phase (after manual action)
316
+ - `--retry`: Retry current phase if blocked
317
+
318
+ ---
319
+
320
+ ## Error Handling
321
+
322
+ **If phase blocked:**
323
+ ```
324
+ āŒ Phase blocked: {error}
325
+ Suggestions: {suggestions}
326
+ Retry: /cdev {change-id} --retry
327
+ ```