claude-cli-advanced-starter-pack 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 (67) hide show
  1. package/LICENSE +21 -0
  2. package/OVERVIEW.md +597 -0
  3. package/README.md +439 -0
  4. package/bin/gtask.js +282 -0
  5. package/bin/postinstall.js +53 -0
  6. package/package.json +69 -0
  7. package/src/agents/phase-dev-templates.js +1011 -0
  8. package/src/agents/templates.js +668 -0
  9. package/src/analysis/checklist-parser.js +414 -0
  10. package/src/analysis/codebase.js +481 -0
  11. package/src/cli/menu.js +958 -0
  12. package/src/commands/claude-audit.js +1482 -0
  13. package/src/commands/claude-settings.js +2243 -0
  14. package/src/commands/create-agent.js +681 -0
  15. package/src/commands/create-command.js +337 -0
  16. package/src/commands/create-hook.js +262 -0
  17. package/src/commands/create-phase-dev/codebase-analyzer.js +813 -0
  18. package/src/commands/create-phase-dev/documentation-generator.js +352 -0
  19. package/src/commands/create-phase-dev/post-completion.js +404 -0
  20. package/src/commands/create-phase-dev/scale-calculator.js +344 -0
  21. package/src/commands/create-phase-dev/wizard.js +492 -0
  22. package/src/commands/create-phase-dev.js +481 -0
  23. package/src/commands/create-skill.js +313 -0
  24. package/src/commands/create.js +446 -0
  25. package/src/commands/decompose.js +392 -0
  26. package/src/commands/detect-tech-stack.js +768 -0
  27. package/src/commands/explore-mcp/claude-md-updater.js +252 -0
  28. package/src/commands/explore-mcp/mcp-installer.js +346 -0
  29. package/src/commands/explore-mcp/mcp-registry.js +438 -0
  30. package/src/commands/explore-mcp.js +638 -0
  31. package/src/commands/gtask-init.js +641 -0
  32. package/src/commands/help.js +128 -0
  33. package/src/commands/init.js +1890 -0
  34. package/src/commands/install.js +250 -0
  35. package/src/commands/list.js +116 -0
  36. package/src/commands/roadmap.js +750 -0
  37. package/src/commands/setup-wizard.js +482 -0
  38. package/src/commands/setup.js +351 -0
  39. package/src/commands/sync.js +534 -0
  40. package/src/commands/test-run.js +456 -0
  41. package/src/commands/test-setup.js +456 -0
  42. package/src/commands/validate.js +67 -0
  43. package/src/config/tech-stack.defaults.json +182 -0
  44. package/src/config/tech-stack.schema.json +502 -0
  45. package/src/github/client.js +359 -0
  46. package/src/index.js +84 -0
  47. package/src/templates/claude-command.js +244 -0
  48. package/src/templates/issue-body.js +284 -0
  49. package/src/testing/config.js +411 -0
  50. package/src/utils/template-engine.js +398 -0
  51. package/src/utils/validate-templates.js +223 -0
  52. package/src/utils.js +396 -0
  53. package/templates/commands/ccasp-setup.template.md +113 -0
  54. package/templates/commands/context-audit.template.md +97 -0
  55. package/templates/commands/create-task-list.template.md +382 -0
  56. package/templates/commands/deploy-full.template.md +261 -0
  57. package/templates/commands/github-task-start.template.md +99 -0
  58. package/templates/commands/github-update.template.md +69 -0
  59. package/templates/commands/happy-start.template.md +117 -0
  60. package/templates/commands/phase-track.template.md +142 -0
  61. package/templates/commands/tunnel-start.template.md +127 -0
  62. package/templates/commands/tunnel-stop.template.md +106 -0
  63. package/templates/hooks/context-guardian.template.js +173 -0
  64. package/templates/hooks/deployment-orchestrator.template.js +219 -0
  65. package/templates/hooks/github-progress-hook.template.js +197 -0
  66. package/templates/hooks/happy-checkpoint-manager.template.js +222 -0
  67. package/templates/hooks/phase-dev-enforcer.template.js +183 -0
@@ -0,0 +1,1011 @@
1
+ /**
2
+ * Phased Development Templates
3
+ *
4
+ * Generic template generators for phased development plans.
5
+ * Works with ANY tech stack - no hardcoded assumptions.
6
+ */
7
+
8
+ /**
9
+ * Scale definitions
10
+ */
11
+ export const SCALE_DEFINITIONS = {
12
+ S: {
13
+ name: 'Small',
14
+ phases: 2,
15
+ taskRange: [10, 30],
16
+ description: 'Focused feature or bug fix',
17
+ },
18
+ M: {
19
+ name: 'Medium',
20
+ phases: [3, 4],
21
+ taskRange: [30, 80],
22
+ description: 'Multi-component feature or refactor',
23
+ },
24
+ L: {
25
+ name: 'Large',
26
+ phases: [5, 8],
27
+ taskRange: [80, 200],
28
+ description: 'Major system overhaul or new module',
29
+ },
30
+ };
31
+
32
+ /**
33
+ * Generate PROGRESS.json structure
34
+ */
35
+ export function generateProgressJson(config) {
36
+ const {
37
+ projectName,
38
+ projectSlug,
39
+ description,
40
+ scale,
41
+ phases,
42
+ architecture = {},
43
+ enhancements = [],
44
+ } = config;
45
+
46
+ const timestamp = new Date().toISOString();
47
+
48
+ return JSON.stringify(
49
+ {
50
+ project: {
51
+ name: projectName,
52
+ slug: projectSlug,
53
+ description,
54
+ scale,
55
+ created: timestamp,
56
+ lastUpdated: timestamp,
57
+ },
58
+ metadata: {
59
+ version: '2.0',
60
+ generator: 'gtask create-phase-dev',
61
+ successProbability: 0.95,
62
+ enhancements,
63
+ },
64
+ tech_stack: {
65
+ frontend: architecture.frontend || null,
66
+ backend: architecture.backend || null,
67
+ database: architecture.database || null,
68
+ deployment: architecture.deployment || null,
69
+ auto_detected: architecture.autoDetected || false,
70
+ },
71
+ phases: phases.map((phase, idx) => ({
72
+ id: idx + 1,
73
+ name: phase.name,
74
+ description: phase.description,
75
+ status: idx === 0 ? 'not_started' : 'blocked',
76
+ prerequisites: phase.prerequisites || [],
77
+ tasks: phase.tasks.map((task, taskIdx) => ({
78
+ id: `${idx + 1}.${taskIdx + 1}`,
79
+ title: task.title,
80
+ description: task.description,
81
+ status: 'pending',
82
+ files: task.files || [],
83
+ acceptance_criteria: task.acceptanceCriteria || [],
84
+ })),
85
+ validation: {
86
+ criteria: phase.validationCriteria || [],
87
+ tests: phase.tests || [],
88
+ },
89
+ })),
90
+ execution_log: [],
91
+ checkpoints: [],
92
+ },
93
+ null,
94
+ 2
95
+ );
96
+ }
97
+
98
+ /**
99
+ * Generate EXECUTIVE_SUMMARY.md
100
+ */
101
+ export function generateExecutiveSummary(config) {
102
+ const {
103
+ projectName,
104
+ projectSlug,
105
+ description,
106
+ scale,
107
+ phases,
108
+ scope,
109
+ architecture,
110
+ } = config;
111
+
112
+ const scaleInfo = SCALE_DEFINITIONS[scale];
113
+ const totalTasks = phases.reduce((sum, p) => sum + p.tasks.length, 0);
114
+
115
+ const phaseList = phases
116
+ .map(
117
+ (p, i) => `
118
+ ### Phase ${i + 1}: ${p.name}
119
+
120
+ **Description:** ${p.description}
121
+
122
+ **Tasks:** ${p.tasks.length}
123
+
124
+ **Key Deliverables:**
125
+ ${p.tasks.slice(0, 5).map((t) => `- ${t.title}`).join('\n')}${p.tasks.length > 5 ? `\n- ... and ${p.tasks.length - 5} more` : ''}
126
+
127
+ **Validation Criteria:**
128
+ ${(p.validationCriteria || ['All tasks complete', 'Tests pass']).map((c) => `- ${c}`).join('\n')}
129
+ `
130
+ )
131
+ .join('\n');
132
+
133
+ return `# ${projectName} - Executive Summary
134
+
135
+ ## Project Overview
136
+
137
+ **Slug:** \`${projectSlug}\`
138
+ **Scale:** ${scaleInfo.name} (${scale})
139
+ **Phases:** ${phases.length}
140
+ **Total Tasks:** ${totalTasks}
141
+ **Success Probability:** 95%+
142
+
143
+ ## Description
144
+
145
+ ${description}
146
+
147
+ ## Scope Assessment
148
+
149
+ | Metric | Value |
150
+ |--------|-------|
151
+ | Lines of Code | ${scope?.linesOfCode || 'TBD'} |
152
+ | Components | ${scope?.components || 'TBD'} |
153
+ | Integrations | ${scope?.integrations || 'TBD'} |
154
+ | Familiarity | ${scope?.familiarity || 'TBD'} |
155
+
156
+ ## Architecture
157
+
158
+ ${architecture?.summary || 'See detected stack below.'}
159
+
160
+ ### Technology Stack
161
+
162
+ ${generateStackTable(architecture)}
163
+
164
+ ## Phase Breakdown
165
+
166
+ ${phaseList}
167
+
168
+ ## Execution
169
+
170
+ ### Start Development
171
+
172
+ \`\`\`bash
173
+ # Run the interactive command
174
+ /phase-dev-${projectSlug}
175
+
176
+ # Or execute Phase 1
177
+ /phase-dev-${projectSlug} 1
178
+ \`\`\`
179
+
180
+ ### Monitor Progress
181
+
182
+ \`\`\`bash
183
+ # Check current status
184
+ cat .claude/docs/${projectSlug}/PROGRESS.json | jq '.phases[] | {name, status}'
185
+ \`\`\`
186
+
187
+ ## Success Criteria
188
+
189
+ - [ ] All phases completed
190
+ - [ ] Tests pass
191
+ - [ ] No build errors
192
+ - [ ] Documentation updated
193
+
194
+ ---
195
+
196
+ *Generated by gtask create-phase-dev - ${new Date().toISOString()}*
197
+ `;
198
+ }
199
+
200
+ /**
201
+ * Generate stack table from architecture config
202
+ */
203
+ function generateStackTable(architecture) {
204
+ if (!architecture) return '- Not specified';
205
+
206
+ const rows = [];
207
+
208
+ if (architecture.frontend) {
209
+ const fe = architecture.frontend;
210
+ rows.push(`- **Frontend:** ${fe.framework}${fe.language === 'typescript' ? ' + TypeScript' : ''}${fe.bundler ? ` + ${fe.bundler}` : ''}`);
211
+ }
212
+
213
+ if (architecture.backend) {
214
+ const be = architecture.backend;
215
+ rows.push(`- **Backend:** ${be.framework} (${be.language})`);
216
+ }
217
+
218
+ if (architecture.database) {
219
+ const db = architecture.database;
220
+ rows.push(`- **Database:** ${db.type}${db.orm ? ` + ${db.orm}` : ''}`);
221
+ }
222
+
223
+ if (architecture.deployment) {
224
+ rows.push(`- **Deployment:** ${architecture.deployment.platform}`);
225
+ }
226
+
227
+ return rows.length > 0 ? rows.join('\n') : '- Not specified';
228
+ }
229
+
230
+ /**
231
+ * Generate MIDDLEWARE_SPEC.md (generic)
232
+ */
233
+ export function generateMiddlewareSpec(config) {
234
+ const { projectName, projectSlug, architecture = {} } = config;
235
+
236
+ const backend = architecture.backend;
237
+ const backendInfo = backend
238
+ ? `${backend.framework} (${backend.language})`
239
+ : 'Not specified';
240
+
241
+ return `# ${projectName} - Middleware Specification
242
+
243
+ ## Overview
244
+
245
+ **Backend Framework:** ${backendInfo}
246
+
247
+ ## Middleware Stack
248
+
249
+ Configure your middleware based on your framework:
250
+
251
+ ### 1. Request Logging
252
+
253
+ Track all incoming requests for debugging and analytics.
254
+
255
+ \`\`\`
256
+ # Add your logging middleware here
257
+ \`\`\`
258
+
259
+ ### 2. Authentication
260
+
261
+ Verify user identity and permissions.
262
+
263
+ \`\`\`
264
+ # JWT validation, session handling, etc.
265
+ \`\`\`
266
+
267
+ ### 3. Rate Limiting
268
+
269
+ Protect against abuse and ensure fair usage.
270
+
271
+ \`\`\`
272
+ # Configure rate limits based on your needs
273
+ \`\`\`
274
+
275
+ ### 4. CORS Configuration
276
+
277
+ Control cross-origin access.
278
+
279
+ \`\`\`
280
+ # Configure allowed origins
281
+ \`\`\`
282
+
283
+ ### 5. Error Handling
284
+
285
+ Consistent error response formatting.
286
+
287
+ \`\`\`
288
+ # Global error handler
289
+ \`\`\`
290
+
291
+ ### 6. Validation
292
+
293
+ Request body and parameter validation.
294
+
295
+ \`\`\`
296
+ # Schema validation middleware
297
+ \`\`\`
298
+
299
+ ## Middleware Order
300
+
301
+ Execute middleware in this order for best results:
302
+
303
+ 1. Request logging (first - captures all requests)
304
+ 2. CORS (early - reject invalid origins fast)
305
+ 3. Rate limiting (early - prevent abuse)
306
+ 4. Authentication (verify identity)
307
+ 5. Validation (validate request data)
308
+ 6. Route handlers (business logic)
309
+ 7. Error handling (last - catch all errors)
310
+
311
+ ## Framework-Specific Notes
312
+
313
+ *Add notes specific to your backend framework here*
314
+
315
+ ---
316
+
317
+ *Reference: .claude/docs/${projectSlug}/MIDDLEWARE_SPEC.md*
318
+ `;
319
+ }
320
+
321
+ /**
322
+ * Generate API_ENDPOINTS.md (generic)
323
+ */
324
+ export function generateApiEndpoints(config) {
325
+ const { projectName, projectSlug, architecture = {} } = config;
326
+
327
+ const backend = architecture.backend;
328
+ const backendInfo = backend
329
+ ? `${backend.framework} (${backend.language})`
330
+ : 'Not specified';
331
+
332
+ return `# ${projectName} - API Endpoints
333
+
334
+ ## Overview
335
+
336
+ **Backend Framework:** ${backendInfo}
337
+
338
+ ## Base URL
339
+
340
+ Configure your base URL in environment variables:
341
+
342
+ \`\`\`
343
+ # Development
344
+ API_URL=http://localhost:3000/api
345
+
346
+ # Production
347
+ API_URL=https://your-domain.com/api
348
+ \`\`\`
349
+
350
+ ## Authentication
351
+
352
+ Define your authentication strategy here:
353
+
354
+ - JWT Bearer tokens
355
+ - API keys
356
+ - Session-based auth
357
+ - OAuth 2.0
358
+
359
+ ## Endpoints
360
+
361
+ *Define your endpoints here as you build them:*
362
+
363
+ ### Example Endpoint
364
+
365
+ \`\`\`
366
+ GET /api/health
367
+ \`\`\`
368
+
369
+ **Response:**
370
+ \`\`\`json
371
+ {
372
+ "status": "ok",
373
+ "timestamp": "2024-01-01T00:00:00Z"
374
+ }
375
+ \`\`\`
376
+
377
+ ## Error Responses
378
+
379
+ All errors should follow a consistent structure:
380
+
381
+ \`\`\`json
382
+ {
383
+ "error": true,
384
+ "code": "ERROR_CODE",
385
+ "message": "Human-readable message",
386
+ "details": {}
387
+ }
388
+ \`\`\`
389
+
390
+ ---
391
+
392
+ *Reference: .claude/docs/${projectSlug}/API_ENDPOINTS.md*
393
+ `;
394
+ }
395
+
396
+ /**
397
+ * Generate DATABASE_SCHEMA.md (generic)
398
+ */
399
+ export function generateDatabaseSchema(config) {
400
+ const { projectName, projectSlug, architecture = {} } = config;
401
+
402
+ const database = architecture.database;
403
+ const dbType = database?.type || 'Not specified';
404
+ const orm = database?.orm || 'Not specified';
405
+
406
+ return `# ${projectName} - Database Schema
407
+
408
+ ## Overview
409
+
410
+ **Database:** ${dbType}
411
+ **ORM/Driver:** ${orm}
412
+
413
+ ## Configuration
414
+
415
+ Set your database connection in environment variables:
416
+
417
+ \`\`\`
418
+ DATABASE_URL=your-connection-string-here
419
+ \`\`\`
420
+
421
+ ## Tables / Collections
422
+
423
+ *Define your schema here as you build it:*
424
+
425
+ ### Example Table
426
+
427
+ | Column | Type | Constraints |
428
+ |--------|------|-------------|
429
+ | id | UUID/ObjectId | PRIMARY KEY |
430
+ | created_at | TIMESTAMP | DEFAULT NOW() |
431
+ | updated_at | TIMESTAMP | DEFAULT NOW() |
432
+
433
+ ## Migrations
434
+
435
+ Document your migration strategy:
436
+
437
+ - Migration tool: (Prisma/TypeORM/Alembic/etc.)
438
+ - Migration location: \`/migrations\` or \`/prisma\`
439
+
440
+ ## Indexes
441
+
442
+ *List important indexes for query optimization*
443
+
444
+ ## Relationships
445
+
446
+ *Document entity relationships*
447
+
448
+ ---
449
+
450
+ *Reference: .claude/docs/${projectSlug}/DATABASE_SCHEMA.md*
451
+ `;
452
+ }
453
+
454
+ /**
455
+ * Generate DEPLOYMENT_CONFIG.md (generic)
456
+ */
457
+ export function generateDeploymentConfig(config) {
458
+ const { projectName, projectSlug, architecture = {} } = config;
459
+
460
+ const deployment = architecture.deployment;
461
+ const platform = deployment?.platform || 'Not specified';
462
+
463
+ return `# ${projectName} - Deployment Configuration
464
+
465
+ ## Platform
466
+
467
+ **Target Platform:** ${platform}
468
+
469
+ ## Environment Variables
470
+
471
+ ### Required Variables
472
+
473
+ \`\`\`
474
+ # Add your required environment variables here
475
+ NODE_ENV=production
476
+ DATABASE_URL=
477
+ API_URL=
478
+ \`\`\`
479
+
480
+ ### Optional Variables
481
+
482
+ \`\`\`
483
+ # Add optional configuration here
484
+ LOG_LEVEL=info
485
+ ENABLE_ANALYTICS=true
486
+ \`\`\`
487
+
488
+ ## Deployment Steps
489
+
490
+ 1. Build the application
491
+ 2. Run database migrations
492
+ 3. Deploy to ${platform}
493
+ 4. Verify health checks
494
+ 5. Update DNS if needed
495
+
496
+ ## Deployment Commands
497
+
498
+ *Add your deployment commands here:*
499
+
500
+ \`\`\`bash
501
+ # Example build command
502
+ npm run build
503
+
504
+ # Example deploy command
505
+ # Your platform-specific deploy command here
506
+ \`\`\`
507
+
508
+ ## Rollback Procedure
509
+
510
+ 1. Identify the issue
511
+ 2. Revert to previous deployment
512
+ 3. Investigate root cause
513
+ 4. Deploy fix
514
+
515
+ ## Monitoring
516
+
517
+ - Health check endpoint: \`/api/health\`
518
+ - Logs: Configure your logging service
519
+ - Alerts: Set up monitoring for critical metrics
520
+
521
+ ---
522
+
523
+ *Reference: .claude/docs/${projectSlug}/DEPLOYMENT_CONFIG.md*
524
+ `;
525
+ }
526
+
527
+ /**
528
+ * Generate RAG Phase Executor Agent
529
+ */
530
+ export function generatePhaseExecutorAgent(config) {
531
+ const { projectName, projectSlug, phases, architecture } = config;
532
+
533
+ const phaseChecks = phases
534
+ .map(
535
+ (p, i) => `
536
+ ### Phase ${i + 1}: ${p.name}
537
+
538
+ **Status Check:**
539
+ \`\`\`bash
540
+ cat .claude/docs/${projectSlug}/PROGRESS.json | jq '.phases[${i}]'
541
+ \`\`\`
542
+
543
+ **Tasks:**
544
+ ${p.tasks.map((t, j) => `${i + 1}.${j + 1}. ${t.title}`).join('\n')}
545
+
546
+ **Validation:**
547
+ ${(p.validationCriteria || ['All tasks complete']).map((c) => `- ${c}`).join('\n')}
548
+ `
549
+ )
550
+ .join('\n');
551
+
552
+ return `---
553
+ name: ${projectSlug}-phase-executor
554
+ description: Autonomous phase executor for ${projectName}
555
+ level: L1
556
+ tools: Task, Read, Write, Edit, Grep, Glob, Bash
557
+ model: sonnet
558
+ capabilities:
559
+ - token_monitoring
560
+ - context_compaction
561
+ - state_persistence
562
+ - auto_respawn
563
+ ---
564
+
565
+ # ${projectName} - Phase Executor Agent
566
+
567
+ Autonomous agent for executing phased development of ${projectName}.
568
+
569
+ ## Tech Stack
570
+
571
+ ${architecture?.summary || 'See PROGRESS.json for detected stack'}
572
+
573
+ ## Activation
574
+
575
+ This agent activates when:
576
+ - User runs \`/phase-dev-${projectSlug}\`
577
+ - User requests work on "${projectName}"
578
+ - PROGRESS.json shows incomplete phases
579
+
580
+ ## State Management
581
+
582
+ **Progress File:** \`.claude/docs/${projectSlug}/PROGRESS.json\`
583
+
584
+ ### Read Current State
585
+
586
+ \`\`\`bash
587
+ cat .claude/docs/${projectSlug}/PROGRESS.json | jq '.phases[] | {id, name, status}'
588
+ \`\`\`
589
+
590
+ ### Update Task Status
591
+
592
+ When completing a task, update PROGRESS.json:
593
+ 1. Set task status to "completed"
594
+ 2. Add entry to execution_log
595
+ 3. Update phase status if all tasks done
596
+
597
+ ## Workflow
598
+
599
+ ### Phase Execution Protocol
600
+
601
+ 1. **Read PROGRESS.json** - Identify current phase and pending tasks
602
+ 2. **Check Prerequisites** - Ensure previous phases are complete
603
+ 3. **Execute Tasks** - Work through tasks sequentially
604
+ 4. **Validate** - Run validation criteria after each task
605
+ 5. **Update Progress** - Mark tasks/phases complete
606
+ 6. **Report** - Summarize what was done
607
+
608
+ ### Token Management
609
+
610
+ | Threshold | Action |
611
+ |-----------|--------|
612
+ | 75% | Compact context, save state |
613
+ | 90% | Create checkpoint, prepare handoff |
614
+ | 95% | Force save, spawn continuation |
615
+
616
+ ## Phase Details
617
+
618
+ ${phaseChecks}
619
+
620
+ ## Completion Protocol
621
+
622
+ When all phases complete:
623
+ 1. Update PROGRESS.json with completion timestamp
624
+ 2. Run final validation suite
625
+ 3. Generate completion report
626
+ 4. Suggest next steps
627
+
628
+ ---
629
+
630
+ *Generated by gtask create-phase-dev - ${new Date().toISOString()}*
631
+ `;
632
+ }
633
+
634
+ /**
635
+ * Generate interactive slash command
636
+ */
637
+ export function generatePhaseDevCommand(config) {
638
+ const { projectName, projectSlug, phases } = config;
639
+
640
+ const phaseOptions = phases
641
+ .map((p, i) => ` - **${i + 1}** - Execute Phase ${i + 1}: ${p.name}`)
642
+ .join('\n');
643
+
644
+ return `---
645
+ description: Interactive phased development menu for ${projectName}
646
+ type: project
647
+ complexity: high
648
+ ---
649
+
650
+ # /phase-dev-${projectSlug}
651
+
652
+ Interactive phased development execution for ${projectName}.
653
+
654
+ ## Usage
655
+
656
+ \`\`\`bash
657
+ /phase-dev-${projectSlug} # Show menu
658
+ /phase-dev-${projectSlug} 1 # Execute Phase 1
659
+ /phase-dev-${projectSlug} status # Check progress
660
+ \`\`\`
661
+
662
+ ## Quick Actions
663
+
664
+ | Key | Action |
665
+ |-----|--------|
666
+ | 1-${phases.length} | Execute specific phase |
667
+ | S | Show status |
668
+ | V | Validate current phase |
669
+ | C | Create checkpoint |
670
+ | X | Exit |
671
+
672
+ ## Phases
673
+
674
+ ${phaseOptions}
675
+
676
+ ## Instructions
677
+
678
+ When this command is invoked:
679
+
680
+ ### Step 1: Load Progress
681
+
682
+ Read \`.claude/docs/${projectSlug}/PROGRESS.json\` to understand current state.
683
+
684
+ ### Step 2: Display Menu
685
+
686
+ Show phase status and available actions.
687
+
688
+ ### Step 3: Execute Selection
689
+
690
+ Based on user selection:
691
+ - **Phase execution**: Load phase executor agent
692
+ - **Status**: Display current progress
693
+ - **Validate**: Run validation criteria
694
+
695
+ ### Step 4: Update Progress
696
+
697
+ After any action, update PROGRESS.json with:
698
+ - Task completions
699
+ - Execution log entries
700
+ - Timestamps
701
+
702
+ ## Related
703
+
704
+ - \`.claude/docs/${projectSlug}/EXECUTIVE_SUMMARY.md\` - Overview
705
+ - \`.claude/docs/${projectSlug}/PROGRESS.json\` - State tracking
706
+
707
+ ---
708
+
709
+ *Created by gtask create-phase-dev - ${new Date().toISOString()}*
710
+ `;
711
+ }
712
+
713
+ /**
714
+ * Generate TEST_DEFINITIONS.json
715
+ */
716
+ export function generateTestDefinitions(config) {
717
+ const { projectSlug, phases, architecture = {} } = config;
718
+
719
+ const testing = architecture.testing || {};
720
+ const testFramework = testing.framework || 'jest';
721
+ const e2eFramework = testing.e2e || 'playwright';
722
+ const extension = testing.framework === 'vitest' || architecture.frontend?.language === 'typescript' ? '.ts' : '.js';
723
+
724
+ const testSuites = phases.map((phase, phaseIdx) => ({
725
+ phase: phaseIdx + 1,
726
+ name: phase.name,
727
+ tests: phase.tasks.map((task, taskIdx) => ({
728
+ id: `test-${phaseIdx + 1}-${taskIdx + 1}`,
729
+ task: `${phaseIdx + 1}.${taskIdx + 1}`,
730
+ title: `Test: ${task.title}`,
731
+ type: task.testType || 'unit',
732
+ file: `tests/phase${phaseIdx + 1}/${projectSlug}.spec${extension}`,
733
+ criteria: task.acceptanceCriteria || [],
734
+ })),
735
+ }));
736
+
737
+ return JSON.stringify(
738
+ {
739
+ project: projectSlug,
740
+ generated: new Date().toISOString(),
741
+ frameworks: {
742
+ unit: testFramework,
743
+ e2e: e2eFramework,
744
+ },
745
+ suites: testSuites,
746
+ coverage: {
747
+ target: 80,
748
+ unit: true,
749
+ integration: true,
750
+ e2e: true,
751
+ },
752
+ },
753
+ null,
754
+ 2
755
+ );
756
+ }
757
+
758
+ /**
759
+ * Generate enforcement hook (optional, generic)
760
+ */
761
+ export function generatePhaseDevEnforcerHook(config) {
762
+ const { projectSlug, projectName } = config;
763
+
764
+ return `#!/usr/bin/env node
765
+ /**
766
+ * ${projectName} - Phase Development Enforcer
767
+ *
768
+ * Event: PreToolUse (Edit|Write)
769
+ * Purpose: Track file changes during phased development
770
+ *
771
+ * Created by: gtask create-phase-dev
772
+ * Date: ${new Date().toISOString()}
773
+ */
774
+
775
+ const fs = require('fs');
776
+ const path = require('path');
777
+
778
+ const hookInput = JSON.parse(process.env.CLAUDE_HOOK_INPUT || '{}');
779
+
780
+ // Configuration - customize these patterns for your project
781
+ const CONFIG = {
782
+ projectSlug: '${projectSlug}',
783
+ progressFile: '.claude/docs/${projectSlug}/PROGRESS.json',
784
+
785
+ // Add patterns to warn about (optional)
786
+ warningPatterns: [
787
+ // Example: 'TODO', 'FIXME', 'HACK'
788
+ ],
789
+
790
+ // Add patterns to block (optional)
791
+ blockedPatterns: [
792
+ // Example: 'console.log' in production code
793
+ ],
794
+ };
795
+
796
+ async function main() {
797
+ try {
798
+ const tool = hookInput.tool_name || '';
799
+ const input = hookInput.tool_input || {};
800
+
801
+ // Only check Edit and Write
802
+ if (!['Edit', 'Write'].includes(tool)) {
803
+ console.log(JSON.stringify({ decision: 'approve' }));
804
+ return;
805
+ }
806
+
807
+ const content = input.content || input.new_string || '';
808
+ const filePath = input.file_path || '';
809
+
810
+ // Log file changes to progress (optional)
811
+ // You can customize this to track which files were modified
812
+
813
+ // Check for blocked patterns (if any defined)
814
+ if (CONFIG.blockedPatterns.length > 0) {
815
+ const blocked = CONFIG.blockedPatterns.filter(p => content.includes(p));
816
+ if (blocked.length > 0) {
817
+ console.log(JSON.stringify({
818
+ decision: 'block',
819
+ reason: 'Pattern violation',
820
+ systemMessage: \`Blocked patterns found: \${blocked.join(', ')}\`
821
+ }));
822
+ process.exit(1);
823
+ return;
824
+ }
825
+ }
826
+
827
+ // Check for warning patterns (if any defined)
828
+ if (CONFIG.warningPatterns.length > 0) {
829
+ const warnings = CONFIG.warningPatterns.filter(p => content.includes(p));
830
+ if (warnings.length > 0) {
831
+ console.log(JSON.stringify({
832
+ decision: 'approve',
833
+ systemMessage: \`Warning - patterns found: \${warnings.join(', ')}\`
834
+ }));
835
+ return;
836
+ }
837
+ }
838
+
839
+ // All checks passed
840
+ console.log(JSON.stringify({ decision: 'approve' }));
841
+
842
+ } catch (error) {
843
+ // Fail-safe: approve on error
844
+ console.log(JSON.stringify({
845
+ decision: 'approve',
846
+ reason: \`Hook error (non-blocking): \${error.message}\`
847
+ }));
848
+ }
849
+ }
850
+
851
+ main();
852
+ `;
853
+ }
854
+
855
+ /**
856
+ * Small project phase templates (generic)
857
+ */
858
+ export const SMALL_PHASE_TEMPLATES = [
859
+ {
860
+ name: 'Foundation',
861
+ description: 'Core implementation and setup',
862
+ taskTemplates: [
863
+ 'Set up project structure',
864
+ 'Implement core functionality',
865
+ 'Add basic validation',
866
+ 'Create unit tests',
867
+ ],
868
+ },
869
+ {
870
+ name: 'Polish & Deploy',
871
+ description: 'Refinement and deployment',
872
+ taskTemplates: [
873
+ 'Add error handling',
874
+ 'Implement UI polish',
875
+ 'Run tests',
876
+ 'Deploy to environment',
877
+ ],
878
+ },
879
+ ];
880
+
881
+ /**
882
+ * Medium project phase templates (generic)
883
+ */
884
+ export const MEDIUM_PHASE_TEMPLATES = [
885
+ {
886
+ name: 'Foundation',
887
+ description: 'Setup and core architecture',
888
+ taskTemplates: [
889
+ 'Set up project structure',
890
+ 'Configure development environment',
891
+ 'Implement data layer',
892
+ 'Set up API structure',
893
+ ],
894
+ },
895
+ {
896
+ name: 'Core Features',
897
+ description: 'Main functionality implementation',
898
+ taskTemplates: [
899
+ 'Build primary UI components',
900
+ 'Implement business logic',
901
+ 'Add state management',
902
+ 'Create integration tests',
903
+ ],
904
+ },
905
+ {
906
+ name: 'Integration',
907
+ description: 'Connect components and test',
908
+ taskTemplates: [
909
+ 'Wire frontend to backend',
910
+ 'Add real-time features (if needed)',
911
+ 'Implement caching',
912
+ 'Run E2E tests',
913
+ ],
914
+ },
915
+ {
916
+ name: 'Polish & Deploy',
917
+ description: 'Final touches and deployment',
918
+ taskTemplates: [
919
+ 'UI/UX refinements',
920
+ 'Performance optimization',
921
+ 'Documentation',
922
+ 'Production deployment',
923
+ ],
924
+ },
925
+ ];
926
+
927
+ /**
928
+ * Large project phase templates (generic)
929
+ */
930
+ export const LARGE_PHASE_TEMPLATES = [
931
+ {
932
+ name: 'Architecture',
933
+ description: 'System design and infrastructure',
934
+ taskTemplates: [
935
+ 'Define system architecture',
936
+ 'Design data model',
937
+ 'Plan API structure',
938
+ 'Set up CI/CD pipeline',
939
+ ],
940
+ },
941
+ {
942
+ name: 'Data Layer',
943
+ description: 'Database and data access',
944
+ taskTemplates: [
945
+ 'Create database schema',
946
+ 'Implement data access layer',
947
+ 'Add data validation',
948
+ 'Set up caching layer',
949
+ ],
950
+ },
951
+ {
952
+ name: 'API Layer',
953
+ description: 'Backend endpoints and services',
954
+ taskTemplates: [
955
+ 'Build REST/GraphQL endpoints',
956
+ 'Add real-time support (if needed)',
957
+ 'Implement middleware',
958
+ 'Create API documentation',
959
+ ],
960
+ },
961
+ {
962
+ name: 'Core UI',
963
+ description: 'Primary user interface',
964
+ taskTemplates: [
965
+ 'Build core components',
966
+ 'Implement navigation',
967
+ 'Add form handling',
968
+ 'Create state management',
969
+ ],
970
+ },
971
+ {
972
+ name: 'Features',
973
+ description: 'Feature-specific implementation',
974
+ taskTemplates: [
975
+ 'Implement feature modules',
976
+ 'Add business logic',
977
+ 'Create feature tests',
978
+ 'Wire to backend',
979
+ ],
980
+ },
981
+ {
982
+ name: 'Integration',
983
+ description: 'System integration and testing',
984
+ taskTemplates: [
985
+ 'End-to-end integration',
986
+ 'Performance testing',
987
+ 'Security review',
988
+ 'Load testing',
989
+ ],
990
+ },
991
+ {
992
+ name: 'Polish',
993
+ description: 'Refinement and optimization',
994
+ taskTemplates: [
995
+ 'UI/UX improvements',
996
+ 'Accessibility audit',
997
+ 'Mobile optimization',
998
+ 'Documentation',
999
+ ],
1000
+ },
1001
+ {
1002
+ name: 'Launch',
1003
+ description: 'Deployment and monitoring',
1004
+ taskTemplates: [
1005
+ 'Staging deployment',
1006
+ 'Production deployment',
1007
+ 'Monitoring setup',
1008
+ 'Post-launch support',
1009
+ ],
1010
+ },
1011
+ ];