@champpaba/claude-agent-kit 1.7.1 → 1.8.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 CHANGED
@@ -1,8 +1,8 @@
1
1
  # CLAUDE.md
2
2
 
3
3
  > **Navigation Hub for AI Agents**
4
- > **Template Version:** 1.7.1 - Universal Multi-Agent Template (Opus 4.5)
5
- > **Latest:** Incremental Testing - Milestone-based validation for high-risk tasks with round-based retry
4
+ > **Template Version:** 1.8.0 - Universal Multi-Agent Template (Opus 4.5)
5
+ > **Latest:** Token Optimization - Removed documentation/report phases, verbose terminal output instead
6
6
 
7
7
  ---
8
8
 
@@ -57,8 +57,8 @@ Universal, framework-agnostic template for AI-assisted development.
57
57
  - ✅ Domain-Specific Support (add your business logic)
58
58
 
59
59
  **What's NOT Included:**
60
- - ❌ Framework patterns → Generated dynamically via `/agentsetup`
61
- - ❌ Package managers → Detected by `/agentsetup`
60
+ - ❌ Framework patterns → Generated dynamically via `/csetup`
61
+ - ❌ Package managers → Auto-detected by `/csetup`
62
62
  - ❌ Spec frameworks → Optional (OpenSpec, BMAD, SpecKit)
63
63
 
64
64
  ---
@@ -84,9 +84,8 @@ Universal, framework-agnostic template for AI-assisted development.
84
84
  - `@/.claude/contexts/patterns/frontend-component-strategy.md`
85
85
 
86
86
  **Project Setup:**
87
- - `/designsetup` - **NEW!** Auto-generate style guide (reference → codebase → AI)
88
- - `/psetup` - One-time project setup (detect tech stack, generate best practices)
89
- - `/agentsetup` - Auto-detect tech stack and generate best practices
87
+ - `/designsetup` - Auto-generate style guide (reference → codebase → AI)
88
+ - `/csetup` - **v1.8.0:** Now auto-detects tech stack + generates best practices (replaces /psetup, /agentsetup)
90
89
 
91
90
  **Page Planning (UI Tasks):**
92
91
  - `/pageplan @prd.md @brief.md` - **ENHANCED v1.4.0!** Generate page structure & conversion-optimized content
@@ -102,7 +101,7 @@ Universal, framework-agnostic template for AI-assisted development.
102
101
  - `/cstatus {change-id}` - Quick progress status for a change
103
102
 
104
103
  **Best Practices (Dynamic):**
105
- - `.claude/contexts/domain/{project}/best-practices/` (generated by `/agentsetup`)
104
+ - `.claude/contexts/domain/project/best-practices/` (auto-generated by `/csetup`)
106
105
  - Framework-specific guidelines from Context7 MCP
107
106
 
108
107
  **Indexing (3 Levels):**
@@ -121,15 +120,20 @@ Universal, framework-agnostic template for AI-assisted development.
121
120
 
122
121
  ---
123
122
 
124
- ## 📚 Best Practices System
125
-
126
- **→ See:** `@/.claude/lib/detailed-guides/best-practices-system.md` for complete guide
123
+ ## 📚 Best Practices System (v1.8.0)
127
124
 
128
125
  **Quick Summary:**
129
- - Run `/agentsetup` → Auto-detects tech stack → Queries Context7 Generates framework-specific best practices
130
- - Files created in `.claude/contexts/domain/{project}/best-practices/` (React, Next.js, Prisma, etc.)
131
- - Agents auto-discover via 3-level indexing (domainprojectbest-practices)
132
- - Enforces code quality with framework-specific patterns
126
+ - `/csetup` **auto-detects tech stack** from: package.json design.mdproposal/tasks (3 sources)
127
+ - **Auto-generates best practices** from Context7 MCP (React, Next.js, Prisma, etc.)
128
+ - Files created in `.claude/contexts/domain/project/best-practices/`
129
+ - **Agents MUST read** best practices before coding (validated by agent-executor)
130
+ - `/cdev` **injects** relevant best-practices paths into agent prompts
131
+
132
+ **Flow:**
133
+ ```
134
+ /csetup → detect stack → query Context7 → generate best-practices
135
+ /cdev → inject paths into prompt → agent reads → validation checks
136
+ ```
133
137
 
134
138
  ---
135
139
 
@@ -526,7 +526,7 @@ Frontend expects `email` but backend doesn't return it.
526
526
  - ✅ ALWAYS read `tech-stack.md` before ANY install/run commands
527
527
  - ✅ Use exact package manager from tech-stack.md (pnpm, npm, bun, uv, poetry, pip)
528
528
  - ❌ NEVER assume or hardcode package manager
529
- - ❌ If tech-stack.md missing → warn user to run `/agentsetup`
529
+ - ❌ If tech-stack.md missing → warn user to run `/csetup`
530
530
 
531
531
  ### Validation Standards
532
532
  - ✅ Read ACTUAL code files (don't guess or assume)
@@ -638,14 +638,18 @@ Found: 3 endpoints
638
638
 
639
639
  ---
640
640
 
641
- ## Documentation Policy
641
+ ## Documentation Policy (v1.8.0)
642
642
 
643
- **→ See:** `.claude/contexts/patterns/code-standards.md` for complete policy
643
+ **→ See:** `.claude/contexts/patterns/code-standards.md` "Forbidden Files" section
644
+
645
+ **Simple Rule:** Only create **actual code/config files**. No reports, summaries, or temp files.
644
646
 
645
647
  **Quick Reference:**
646
- - ❌ NEVER create documentation files unless explicitly requested
647
- - ❌ NO INTEGRATION_REPORT.md, CONTRACT_ANALYSIS.md, API_CONTRACTS.md, etc.
648
- - ✅ Return comprehensive text reports in your final message instead
649
- - ✅ Exception: Only when user explicitly says "create documentation"
648
+ - ❌ NEVER create files for: reports, summaries, logs, guides, analysis results
649
+ - ❌ NEVER create ALL_CAPS filenames or files with PHASE_/STEP_ prefixes
650
+ - ✅ Return all results in your **final response text**
651
+ - ✅ Update `flags.json` with validation results
652
+
653
+ **Rule of thumb:** If it wouldn't be committed to git as part of the feature, don't create it.
650
654
 
651
655
  ---
@@ -922,14 +922,19 @@ Return to Orchestrator:
922
922
 
923
923
  ---
924
924
 
925
- ## Documentation Policy
925
+ ## Documentation Policy (v1.8.0)
926
926
 
927
- **→ See:** `.claude/contexts/patterns/code-standards.md` for complete policy
927
+ **→ See:** `.claude/contexts/patterns/code-standards.md` "Forbidden Files" section
928
928
 
929
- **Quick Rule:**
930
- - ❌ **NEVER** create .md documentation files (README, DOCS, GUIDE, etc.)
931
- - ✅ **ALWAYS** report results as verbose text output in final message
932
- - Exception: ONLY when user explicitly requests documentation
929
+ **Simple Rule:** Only create **actual component/style files**. No reports, summaries, or temp files.
930
+
931
+ **Quick Reference:**
932
+ - ❌ NEVER create files for: reports, summaries, logs, guides, analysis results
933
+ - ❌ NEVER create ALL_CAPS filenames or files with PHASE_/STEP_ prefixes
934
+ - ✅ Return all results in your **final response text**
935
+ - ✅ Update `flags.json` with component list and files created
936
+
937
+ **Rule of thumb:** If it wouldn't be committed to git as part of the feature, don't create it.
933
938
 
934
939
  ## Rules
935
940
 
@@ -431,15 +431,19 @@ Recommendation:
431
431
 
432
432
  ---
433
433
 
434
- ## Documentation Policy
434
+ ## Documentation Policy (v1.8.0)
435
435
 
436
- **→ See:** `.claude/contexts/patterns/code-standards.md` for complete policy
436
+ **→ See:** `.claude/contexts/patterns/code-standards.md` "Forbidden Files" section
437
+
438
+ **Simple Rule:** Only create **actual code/test files**. No reports, summaries, or temp files.
437
439
 
438
440
  **Quick Reference:**
439
- - ❌ NEVER create documentation files unless explicitly requested
440
- - ❌ NO TEST_REPORT.md, DEBUG_LOG.md, TEST_RESULTS.md, etc.
441
- - ✅ Return comprehensive text reports in your final message instead
442
- - ✅ Exception: Only when user explicitly says "create documentation"
441
+ - ❌ NEVER create files for: reports, summaries, logs, guides, analysis results
442
+ - ❌ NEVER create ALL_CAPS filenames or files with PHASE_/STEP_ prefixes
443
+ - ✅ Return all results in your **final response text**
444
+ - ✅ Update `flags.json` with test results (passed/failed/coverage)
445
+
446
+ **Rule of thumb:** If it wouldn't be committed to git as part of the feature, don't create it.
443
447
 
444
448
  ## Rules
445
449
 
@@ -451,7 +455,7 @@ Recommendation:
451
455
  - ✅ ALWAYS read `tech-stack.md` before ANY install/run commands
452
456
  - ✅ Use exact package manager from tech-stack.md (pnpm, npm, bun, uv, poetry, pip)
453
457
  - ❌ NEVER assume or hardcode package manager
454
- - ❌ If tech-stack.md missing → warn user to run `/agentsetup`
458
+ - ❌ If tech-stack.md missing → warn user to run `/csetup`
455
459
 
456
460
  ### Testing Standards
457
461
  - ✅ Run tests automatically (no manual testing)
@@ -561,15 +561,19 @@ test('failed login shows error message', async () => {
561
561
 
562
562
  ---
563
563
 
564
- ## Documentation Policy
564
+ ## Documentation Policy (v1.8.0)
565
565
 
566
- **→ See:** `.claude/contexts/patterns/code-standards.md` for complete policy
566
+ **→ See:** `.claude/contexts/patterns/code-standards.md` "Forbidden Files" section
567
+
568
+ **Simple Rule:** Only create **actual code files**. No reports, summaries, or temp files.
567
569
 
568
570
  **Quick Reference:**
569
- - ❌ NEVER create documentation files unless explicitly requested
570
- - ❌ NO README.md, IMPLEMENTATION_GUIDE.md, API_DOCS.md, etc.
571
- - ✅ Return comprehensive text reports in your final message instead
572
- - ✅ Exception: Only when user explicitly says "create documentation"
571
+ - ❌ NEVER create files for: reports, summaries, logs, guides, analysis results
572
+ - ❌ NEVER create ALL_CAPS filenames or files with PHASE_/STEP_ prefixes
573
+ - ✅ Return all results in your **final response text**
574
+ - ✅ Update `flags.json` with integration results
575
+
576
+ **Rule of thumb:** If it wouldn't be committed to git as part of the feature, don't create it.
573
577
 
574
578
  ## Rules
575
579
 
@@ -581,7 +585,7 @@ test('failed login shows error message', async () => {
581
585
  - ✅ ALWAYS read `tech-stack.md` before ANY install/run commands
582
586
  - ✅ Use exact package manager from tech-stack.md (pnpm, npm, bun, uv, poetry, pip)
583
587
  - ❌ NEVER assume or hardcode package manager
584
- - ❌ If tech-stack.md missing → warn user to run `/agentsetup`
588
+ - ❌ If tech-stack.md missing → warn user to run `/csetup`
585
589
 
586
590
  ### TDD Compliance
587
591
  - ✅ Check `tdd_required` flag from Orchestrator
@@ -579,14 +579,19 @@ Response: { token: string, user: { id, email, name } }
579
579
 
580
580
  ---
581
581
 
582
- ## Documentation Policy
582
+ ## Documentation Policy (v1.8.0)
583
583
 
584
- **→ See:** `.claude/contexts/patterns/code-standards.md` for complete policy
584
+ **→ See:** `.claude/contexts/patterns/code-standards.md` "Forbidden Files" section
585
585
 
586
- **Quick Rule:**
587
- - ❌ **NEVER** create .md documentation files (README, API_DOCS, etc.)
588
- - ✅ **ALWAYS** report results as verbose text output in final message
589
- - Exception: ONLY when user explicitly requests documentation
586
+ **Simple Rule:** Only create **actual code files**. No reports, summaries, or temp files.
587
+
588
+ **Quick Reference:**
589
+ - ❌ NEVER create files for: reports, summaries, logs, guides, analysis results
590
+ - ❌ NEVER create ALL_CAPS filenames or files with PHASE_/STEP_ prefixes
591
+ - ✅ Return all results in your **final response text**
592
+ - ✅ Update `flags.json` with endpoints created
593
+
594
+ **Rule of thumb:** If it wouldn't be committed to git as part of the feature, don't create it.
590
595
 
591
596
  ## Rules
592
597
 
@@ -620,15 +620,19 @@ users = await db.execute(
620
620
 
621
621
  ---
622
622
 
623
- ## Documentation Policy
623
+ ## Documentation Policy (v1.8.0)
624
624
 
625
- **→ See:** `.claude/contexts/patterns/code-standards.md` for complete policy
625
+ **→ See:** `.claude/contexts/patterns/code-standards.md` "Forbidden Files" section
626
+
627
+ **Simple Rule:** Only create **actual schema/migration files**. No reports, summaries, or temp files.
626
628
 
627
629
  **Quick Reference:**
628
- - ❌ NEVER create documentation files unless explicitly requested
629
- - ❌ NO SCHEMA_DOCUMENTATION.md, DATABASE_GUIDE.md, MIGRATION_GUIDE.md, etc.
630
- - ✅ Return comprehensive text reports in your final message instead
631
- - ✅ Exception: Only when user explicitly says "create documentation"
630
+ - ❌ NEVER create files for: reports, summaries, logs, guides, analysis results
631
+ - ❌ NEVER create ALL_CAPS filenames or files with PHASE_/STEP_ prefixes
632
+ - ✅ Return all results in your **final response text**
633
+ - ✅ Update `flags.json` with schema changes and migrations
634
+
635
+ **Rule of thumb:** If it wouldn't be committed to git as part of the feature, don't create it.
632
636
 
633
637
  ## Rules
634
638
 
@@ -640,7 +644,7 @@ users = await db.execute(
640
644
  - ✅ ALWAYS read `tech-stack.md` before ANY install/run commands
641
645
  - ✅ Use exact package manager from tech-stack.md (pnpm, npm, bun, uv, poetry, pip)
642
646
  - ❌ NEVER assume or hardcode package manager
643
- - ❌ If tech-stack.md missing → warn user to run `/agentsetup`
647
+ - ❌ If tech-stack.md missing → warn user to run `/csetup`
644
648
 
645
649
  ### TDD Compliance
646
650
  - ✅ Check `tdd_required` flag from Orchestrator
@@ -94,7 +94,7 @@ See: `.claude/lib/agent-executor.md` for full implementation
94
94
  ```typescript
95
95
  // Step 4: Invoke Agent with Retry & Validation
96
96
 
97
- // 4.1: Build agent prompt (with design reference - Context Optimization v1.2.0)
97
+ // 4.1: Build agent prompt (with design reference + best practices - v1.8.0)
98
98
  function buildAgentPrompt(phase, changeContext) {
99
99
  let prompt = `
100
100
  # Phase ${phase.phase_number}: ${phase.name}
@@ -108,7 +108,56 @@ ${changeContext.tasks}
108
108
  ${phase.instructions}
109
109
  `
110
110
 
111
- // 🆕 Add design reference for uxui-frontend agent (not full content!)
111
+ // 🆕 v1.8.0: Add best-practices reference for ALL agents
112
+ const bpDir = '.claude/contexts/domain/project/best-practices/'
113
+ if (fileExists(bpDir)) {
114
+ const bpFiles = listFiles(bpDir).filter(f => f.endsWith('.md') && f !== 'index.md')
115
+
116
+ // Map agent type to relevant best-practices
117
+ const agentBpMapping = {
118
+ 'uxui-frontend': ['react', 'nextjs', 'vue', 'tailwind'],
119
+ 'frontend': ['react', 'nextjs', 'vue', 'typescript'],
120
+ 'backend': ['express', 'fastapi', 'django', 'prisma', 'drizzle'],
121
+ 'database': ['prisma', 'drizzle', 'postgres', 'mongodb'],
122
+ 'test-debug': ['vitest', 'jest', 'playwright'],
123
+ 'integration': ['typescript'] // minimal
124
+ }
125
+
126
+ const relevantTechs = agentBpMapping[phase.agent] || []
127
+ const relevantFiles = bpFiles.filter(f =>
128
+ relevantTechs.some(tech => f.toLowerCase().includes(tech))
129
+ )
130
+
131
+ if (relevantFiles.length > 0) {
132
+ prompt += `
133
+
134
+ ---
135
+
136
+ ## 📚 Best Practices (MANDATORY - STEP 0)
137
+
138
+ **YOU MUST READ these files before writing ANY code:**
139
+
140
+ ${relevantFiles.map(f => `
141
+ ### ${f.replace('.md', '')}
142
+ \`\`\`
143
+ Read: ${bpDir}${f}
144
+ \`\`\`
145
+ `).join('')}
146
+
147
+ **After reading, REPORT:**
148
+ \`\`\`
149
+ ✅ Best Practices Loaded
150
+ ${relevantFiles.map(f => `- ${f.replace('.md', '')} ✓`).join('\n ')}
151
+ \`\`\`
152
+
153
+ **If you skip this, your work will be REJECTED!**
154
+
155
+ ---
156
+ `
157
+ }
158
+ }
159
+
160
+ // Add design reference for uxui-frontend agent (not full content!)
112
161
  if (phase.agent === 'uxui-frontend') {
113
162
  const tokensPath = 'design-system/STYLE_TOKENS.json'
114
163
  const styleGuidePath = 'design-system/STYLE_GUIDE.md'
@@ -392,11 +441,65 @@ output(` ⏱️ ${formatDuration(flags.meta.time_remaining_estimate)} remaini
392
441
 
393
442
  // 4. Check next phase
394
443
  if (flags.ready_to_archive) {
395
- output('\n✅ All phases complete! Ready to archive.')
396
- output(`\nNext steps:`)
397
- output(`1. Review: /cview ${changeId}`)
398
- output(`2. Update tasks.md (mark all [x])`)
399
- output(`3. Archive: openspec archive ${changeId}`)
444
+ // 🆕 v1.2.0: Verbose Summary Output (replaces documentation/report phases)
445
+ output(`\n`)
446
+ output(`╔════════════════════════════════════════════════════════════╗`)
447
+ output(`║ ✅ CHANGE COMPLETED SUCCESSFULLY ║`)
448
+ output(`╚════════════════════════════════════════════════════════════╝`)
449
+ output(``)
450
+ output(`📦 Change: ${changeId}`)
451
+ output(`📋 Template: ${flags.template} (${flags.meta.total_phases} phases)`)
452
+ output(``)
453
+ output(`═══════════════════════════════════════════════════════════════`)
454
+ output(`📊 EXECUTION SUMMARY`)
455
+ output(`═══════════════════════════════════════════════════════════════`)
456
+ output(``)
457
+ output(`⏱️ Time:`)
458
+ output(` • Estimated: ${formatDuration(flags.meta.total_estimated_minutes)}`)
459
+ output(` • Actual: ${formatDuration(flags.meta.total_actual_minutes)}`)
460
+ output(` • Variance: ${calculateVariance(flags.meta)}`)
461
+ output(``)
462
+ output(`📈 Phases Completed: ${flags.meta.completed_phases}/${flags.meta.total_phases}`)
463
+
464
+ // List all phases with status
465
+ Object.entries(flags.phases).forEach(([phaseId, phase]) => {
466
+ const status = phase.status === 'completed' ? '✅' :
467
+ phase.status === 'skipped' ? '⏭️' : '❌'
468
+ const time = phase.actual_minutes ? `(${phase.actual_minutes}m)` : ''
469
+ output(` ${status} ${phase.phase_number}. ${phaseId} ${time}`)
470
+ })
471
+
472
+ output(``)
473
+ output(`═══════════════════════════════════════════════════════════════`)
474
+ output(`📁 FILES CREATED/MODIFIED`)
475
+ output(`═══════════════════════════════════════════════════════════════`)
476
+
477
+ // Collect all files from phase outputs
478
+ const allFiles = collectFilesFromPhases(flags.phases)
479
+ if (allFiles.created.length > 0) {
480
+ output(``)
481
+ output(`✨ Created (${allFiles.created.length}):`)
482
+ allFiles.created.forEach(f => output(` • ${f}`))
483
+ }
484
+ if (allFiles.modified.length > 0) {
485
+ output(``)
486
+ output(`📝 Modified (${allFiles.modified.length}):`)
487
+ allFiles.modified.forEach(f => output(` • ${f}`))
488
+ }
489
+
490
+ output(``)
491
+ output(`═══════════════════════════════════════════════════════════════`)
492
+ output(`🚀 NEXT STEPS`)
493
+ output(`═══════════════════════════════════════════════════════════════`)
494
+ output(``)
495
+ output(`1. Review changes: /cview ${changeId}`)
496
+ output(`2. Test manually: Verify the implementation works`)
497
+ output(`3. Mark complete: Update tasks.md (mark all [x])`)
498
+ output(`4. Archive: openspec archive ${changeId}`)
499
+ output(``)
500
+ output(`💡 Note: flags.json contains full execution history`)
501
+ output(` Path: openspec/changes/${changeId}/.claude/flags.json`)
502
+ output(``)
400
503
  } else {
401
504
  const nextPhase = flags.phases[flags.current_phase]
402
505
 
@@ -96,6 +96,212 @@ Continue anyway? (yes/no)
96
96
 
97
97
  ---
98
98
 
99
+ ### Step 2.7: Auto-Setup Best Practices (v1.8.0)
100
+
101
+ > **NEW:** Auto-detect tech stack and generate best-practices (replaces /psetup and /agentsetup)
102
+
103
+ ```typescript
104
+ // 1. Detect tech stack from multiple sources
105
+ output(`\n🔍 Detecting Tech Stack...`)
106
+
107
+ // Source 1: package.json / requirements.txt (if exists)
108
+ let packageStack = []
109
+ if (fileExists('package.json')) {
110
+ const pkg = JSON.parse(Read('package.json'))
111
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies }
112
+ packageStack = Object.keys(deps).filter(d =>
113
+ ['next', 'react', 'vue', 'express', 'fastapi', 'prisma', 'drizzle', 'vitest', 'jest'].some(k => d.includes(k))
114
+ )
115
+ output(` 📦 From package.json: ${packageStack.join(', ') || 'none'}`)
116
+ }
117
+
118
+ // Source 2: design.md (architecture section)
119
+ let designStack = []
120
+ const designPath = `openspec/changes/${changeId}/design.md`
121
+ if (fileExists(designPath)) {
122
+ const designContent = Read(designPath)
123
+ // Look for tech stack section
124
+ const techMatch = designContent.match(/tech.*stack|architecture|framework/gi)
125
+ if (techMatch) {
126
+ designStack = extractTechFromText(designContent)
127
+ output(` 📐 From design.md: ${designStack.join(', ') || 'none'}`)
128
+ }
129
+ }
130
+
131
+ // Source 3: proposal.md + tasks.md (keywords)
132
+ const proposalContent = Read(`openspec/changes/${changeId}/proposal.md`)
133
+ const tasksContent = Read(`openspec/changes/${changeId}/tasks.md`)
134
+ const combined = (proposalContent + ' ' + tasksContent).toLowerCase()
135
+
136
+ const techDetection = {
137
+ react: /\b(react|jsx|tsx|use[A-Z]\w+|usestate|useeffect)\b/i,
138
+ nextjs: /\b(next\.?js|next js|app router|pages router)\b/i,
139
+ vue: /\b(vue|vuex|pinia|nuxt)\b/i,
140
+ express: /\b(express\.js|express js|expressjs)\b/i,
141
+ fastapi: /\b(fastapi|fast api)\b/i,
142
+ django: /\b(django)\b/i,
143
+ prisma: /\b(prisma)\b/i,
144
+ drizzle: /\b(drizzle)\b/i,
145
+ postgres: /\b(postgres|postgresql)\b/i,
146
+ mongodb: /\b(mongodb|mongoose)\b/i,
147
+ tailwind: /\b(tailwind)\b/i,
148
+ typescript: /\b(typescript)\b/i,
149
+ vitest: /\b(vitest)\b/i,
150
+ jest: /\b(jest)\b/i,
151
+ playwright: /\b(playwright)\b/i
152
+ }
153
+
154
+ const proposalStack = []
155
+ for (const [tech, pattern] of Object.entries(techDetection)) {
156
+ if (pattern.test(combined)) {
157
+ proposalStack.push(tech)
158
+ }
159
+ }
160
+ output(` 📝 From proposal/tasks: ${proposalStack.join(', ') || 'none'}`)
161
+
162
+ // Merge all sources (remove duplicates)
163
+ const detectedStack = [...new Set([...packageStack, ...designStack, ...proposalStack])]
164
+
165
+ // 2. If no stack detected, ask user
166
+ if (detectedStack.length === 0) {
167
+ output(`\n⚠️ Could not auto-detect tech stack`)
168
+
169
+ const answer = await askUserQuestion({
170
+ questions: [{
171
+ question: 'What tech stack will you use?',
172
+ header: 'Stack',
173
+ options: [
174
+ { label: 'Next.js + React', description: 'Full-stack React framework' },
175
+ { label: 'FastAPI + Python', description: 'Python async API' },
176
+ { label: 'Express + Node', description: 'Node.js backend' },
177
+ { label: 'Vue + Nuxt', description: 'Vue.js framework' }
178
+ ],
179
+ multiSelect: true
180
+ }]
181
+ })
182
+
183
+ // Parse user selection into detectedStack
184
+ detectedStack.push(...parseUserStackSelection(answer))
185
+ }
186
+
187
+ output(`\n✅ Final Tech Stack: ${detectedStack.join(', ')}`)
188
+
189
+ // 3. Check if best-practices already exist
190
+ const bpDir = '.claude/contexts/domain/project/best-practices/'
191
+ const existingBp = fileExists(bpDir) ? listFiles(bpDir) : []
192
+
193
+ const missingBp = detectedStack.filter(tech => {
194
+ return !existingBp.some(f => f.toLowerCase().includes(tech.toLowerCase()))
195
+ })
196
+
197
+ // 4. Generate missing best-practices from Context7
198
+ if (missingBp.length > 0) {
199
+ output(`\n📚 Generating Best Practices from Context7...`)
200
+
201
+ // Create directory structure if needed
202
+ if (!fileExists('.claude/contexts/domain/')) {
203
+ mkdir('.claude/contexts/domain/project/best-practices/')
204
+ }
205
+
206
+ // Context7 library ID mapping
207
+ const context7Ids = {
208
+ react: '/facebook/react',
209
+ nextjs: '/vercel/next.js',
210
+ vue: '/vuejs/vue',
211
+ express: '/expressjs/express',
212
+ fastapi: '/fastapi/fastapi',
213
+ prisma: '/prisma/prisma',
214
+ drizzle: '/drizzle-team/drizzle-orm',
215
+ vitest: '/vitest-dev/vitest',
216
+ jest: '/jestjs/jest',
217
+ playwright: '/microsoft/playwright',
218
+ tailwind: '/tailwindlabs/tailwindcss'
219
+ }
220
+
221
+ for (const tech of missingBp) {
222
+ const libraryId = context7Ids[tech.toLowerCase()]
223
+
224
+ if (libraryId) {
225
+ output(` 📖 Fetching ${tech} best practices...`)
226
+
227
+ // Query Context7 for best practices
228
+ const docs = await mcp__context7__get-library-docs({
229
+ context7CompatibleLibraryID: libraryId,
230
+ topic: 'best practices, common mistakes, anti-patterns, patterns',
231
+ mode: 'code'
232
+ })
233
+
234
+ // Generate best-practices file
235
+ const bpContent = generateBestPracticesFile(tech, docs)
236
+ Write(`.claude/contexts/domain/project/best-practices/${tech}.md`, bpContent)
237
+
238
+ output(` ✅ ${tech}.md generated`)
239
+ } else {
240
+ output(` ⚠️ ${tech} - no Context7 mapping, using universal patterns`)
241
+ }
242
+ }
243
+
244
+ // Generate index.md
245
+ generateBestPracticesIndex(detectedStack, changeId)
246
+ output(` ✅ index.md generated`)
247
+
248
+ // Generate domain/index.md if not exists
249
+ if (!fileExists('.claude/contexts/domain/index.md')) {
250
+ generateDomainIndex('project', detectedStack)
251
+ output(` ✅ domain/index.md generated`)
252
+ }
253
+
254
+ output(`\n✅ Best Practices Setup Complete!`)
255
+ output(` Files: ${missingBp.length + 1} generated`)
256
+ output(` Location: .claude/contexts/domain/project/best-practices/`)
257
+ } else {
258
+ output(`\n✅ Best Practices: Already configured (${existingBp.length} files)`)
259
+ }
260
+
261
+ // 5. Store detected stack in context.md (for agents to reference)
262
+ const stackForContext = {
263
+ detected: detectedStack,
264
+ bestPracticesPath: '.claude/contexts/domain/project/best-practices/',
265
+ files: [...existingBp, ...missingBp.map(t => `${t}.md`)]
266
+ }
267
+ ```
268
+
269
+ **Helper: generateBestPracticesFile()**
270
+ ```typescript
271
+ function generateBestPracticesFile(tech: string, context7Docs: string): string {
272
+ return `# ${tech} Best Practices
273
+
274
+ > **Source:** Context7 MCP
275
+ > **Generated:** ${new Date().toISOString().split('T')[0]}
276
+
277
+ ---
278
+
279
+ ## ✅ DO (Best Practices)
280
+
281
+ ${extractDos(context7Docs)}
282
+
283
+ ---
284
+
285
+ ## ❌ DON'T (Anti-Patterns)
286
+
287
+ ${extractDonts(context7Docs)}
288
+
289
+ ---
290
+
291
+ ## 🎯 Quick Checklist
292
+
293
+ Before committing ${tech} code:
294
+ ${extractChecklist(context7Docs)}
295
+
296
+ ---
297
+
298
+ **⚠️ Agents MUST read this file before writing ${tech} code!**
299
+ `
300
+ }
301
+ ```
302
+
303
+ ---
304
+
99
305
  ### Step 3: Analyze Tasks
100
306
 
101
307
  **Parse tasks.md content and detect keywords:**
@@ -711,8 +917,6 @@ function getAgentForPhase(phaseId: string): string {
711
917
  'refactor': 'test-debug',
712
918
  'regression-tests': 'test-debug',
713
919
  'test-coverage': 'test-debug',
714
- 'documentation': 'integration',
715
- 'report': 'integration',
716
920
  'script-implementation': 'backend',
717
921
  'automated-tests': 'test-debug',
718
922
  'manual-testing': 'user',
@@ -786,19 +990,19 @@ Detected:
786
990
  Change type: feature
787
991
 
788
992
  📋 Template selected: frontend-only
789
- - Total phases: 11
790
- - Estimated time: 3.25 hours
993
+ - Total phases: 9
994
+ - Estimated time: 2h 50m
791
995
  - Reason: Frontend work detected, no backend/API needed
792
996
 
793
997
  Generating workflow...
794
- ✓ Generated phases.md (127 lines, 11 phases)
998
+ ✓ Generated phases.md (115 lines, 9 phases)
795
999
  ✓ Generated flags.json (initialized all phases as pending)
796
1000
  ✓ Generated context.md (change context with core tech references)
797
1001
 
798
1002
  ✅ Change setup complete!
799
1003
 
800
1004
  📦 Change: CHANGE-003
801
- 📋 Template: frontend-only (11 phases)
1005
+ 📋 Template: frontend-only (9 phases)
802
1006
  🛠️ Detected: Frontend
803
1007
 
804
1008
  📁 Files created:
@@ -816,10 +1020,12 @@ Generating workflow...
816
1020
  Phase 7: Responsive Test (user, 15 min)
817
1021
  Phase 8: Refactor (test-debug, 20 min)
818
1022
  Phase 9: Test Coverage (test-debug, 5 min)
819
- Phase 10: Documentation (integration, 15 min)
820
- Phase 11: Final Report (integration, 10 min)
821
1023
 
822
- ⏱️ Total estimated time: ~3h 15m
1024
+ ⏱️ Total estimated time: ~2h 50m
1025
+
1026
+ 💡 Note: Documentation/Report phases removed in v1.2.0
1027
+ → Verbose summary output in terminal when change completes
1028
+ → flags.json contains full execution history
823
1029
 
824
1030
  🚀 Ready to start development!
825
1031