@dzhechkov/p-replicator 1.0.0 → 1.1.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 (19) hide show
  1. package/README.md +25 -3
  2. package/package.json +7 -4
  3. package/src/commands/doctor.js +2 -2
  4. package/src/commands/list.js +1 -1
  5. package/templates/.claude/rules/replicate-pipeline.md +13 -1
  6. package/templates/.claude/rules/skill-interface-protocol.md +148 -0
  7. package/templates/.claude/skills/cc-toolkit-generator-enhanced/SKILL.md +116 -63
  8. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/01-detect-parse.md +329 -0
  9. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/02-analyze-map.md +449 -0
  10. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/03-generate-p0.md +630 -0
  11. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/04-generate-p1.md +537 -0
  12. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/05-generate-p2p3.md +512 -0
  13. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/06-package-deliver.md +710 -0
  14. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/07-harvest-feedback.md +286 -0
  15. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/08-skill-composition.md +378 -0
  16. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/09-cross-project-learning.md +461 -0
  17. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/README.md +83 -0
  18. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/maturity-integration.md +198 -0
  19. package/templates/.claude/skills/pipeline-forge/references/self-extracted-patterns.md +260 -0
@@ -0,0 +1,710 @@
1
+ # Module: Package & Deliver
2
+
3
+ Phase 6 of the CC-Toolkit-Generator-Enhanced pipeline. Final validation, integrity checking,
4
+ and delivery of the complete toolkit package. Runs the Master Validation Checklist to ensure
5
+ 100% pass rate on P0 mandatory items and verifies all placeholders are substituted before
6
+ declaring the toolkit ready for use.
7
+
8
+ ## Input
9
+
10
+ - **All generated files from Phases 3-5:**
11
+ - Phase 3 (P0): CLAUDE.md, DEVELOPMENT_GUIDE.md, settings.json, 6 lifecycle skills,
12
+ /start, /myinsights, /feature commands, git-workflow, insights-capture, feature-lifecycle rules,
13
+ security.md, coding-style.md rules, docs/features/ directory
14
+ - Phase 4 (P1): planner/code-reviewer/architect agents, project-context/coding-standards/testing-patterns skills,
15
+ /plan, /test, /deploy commands, testing.md rule.
16
+ Conditional: /feature-ent, feature-lifecycle-ent rule, idea2prd-manual + goap-research-ed25519 skills,
17
+ /next + feature-navigator + roadmap.json + feature-context.py,
18
+ /go, /run, /docs commands
19
+ - Phase 5 (P2-P3): tdd-guide agent, merged settings.json, /review command.
20
+ Conditional: ddd-validator agent, aggregate-patterns + event-handlers skills, /validate-ddd,
21
+ hook scripts, .mcp.json
22
+ - **Internal Project Model (IPM)** — for placeholder substitution verification and conditional validation
23
+ - **Instrument Map** — for verifying all scored items above threshold were generated
24
+
25
+ ## Process
26
+
27
+ ### Step 1: Run Master Validation Checklist
28
+
29
+ Execute every item from the SKILL.md Master Validation Checklist. Each item must be
30
+ verified by checking the actual generated file exists and contains the required content.
31
+
32
+ #### 1a. P0 Mandatory Checks
33
+
34
+ ```
35
+ CHECK 1: CLAUDE.md
36
+ - File exists at project root
37
+ - Generated per references/claude-md-strategy.md
38
+ - Contains ALL required sections:
39
+ [ ] Parallel Execution Strategy
40
+ [ ] Swarm Agents
41
+ [ ] Development Insights reference
42
+ [ ] Feature Lifecycle (/feature summary)
43
+ [ ] Feature Roadmap (link to roadmap.json)
44
+ [ ] Plans (/plan summary)
45
+ [ ] Automation Commands (/go, /run, /docs)
46
+ [ ] Available Agents table
47
+ [ ] Available Skills table
48
+ [ ] Available Commands table
49
+ [ ] Git Workflow conventions
50
+ - Total size within budget: target 4k, max 6k tokens
51
+
52
+ CHECK 2: DEVELOPMENT_GUIDE.md
53
+ - File exists at project root
54
+ - Contains full lifecycle instructions
55
+ - References all generated commands
56
+ - Includes development workflow section
57
+ - Includes feature workflow section (if feature suggestions generated)
58
+ - Includes autonomous development section (if automation commands generated)
59
+
60
+ CHECK 3: /start command
61
+ - File exists at .claude/commands/start.md
62
+ - Contains complete project generation instructions
63
+ - Includes all packages from IPM
64
+ - Uses Task tool for parallelism where appropriate
65
+ - Includes Docker health check verification
66
+ - References actual SPARC/idea2prd docs (not hallucinated paths)
67
+ - IF has_database: includes DB migration + seed steps
68
+
69
+ CHECK 4: /myinsights command
70
+ - File exists at .claude/commands/myinsights.md
71
+ - Supports duplicate detection
72
+ - Supports subcommands (list, search, add)
73
+ - Uses index + detail architecture (myinsights/1nsights.md + myinsights/details/)
74
+
75
+ CHECK 5: insights-capture.md rule
76
+ - File exists at .claude/rules/insights-capture.md
77
+ - Includes auto-grep pattern for insight detection
78
+ - References myinsights/ directory structure
79
+
80
+ CHECK 6: /feature command
81
+ - File exists at .claude/commands/feature.md
82
+ - Contains 4-phase lifecycle: plan -> validate -> implement -> review
83
+ - References sparc-prd-mini, requirements-validator, brutal-honesty-review skills
84
+
85
+ CHECK 7: feature-lifecycle.md rule
86
+ - File exists at .claude/rules/feature-lifecycle.md
87
+ - Documents the 4-phase lifecycle protocol
88
+ - Includes phase skip guidance
89
+
90
+ CHECK 8: 6 lifecycle skills
91
+ - All 6 skills copied to .claude/skills/:
92
+ [ ] sparc-prd-mini/SKILL.md
93
+ [ ] explore/SKILL.md
94
+ [ ] goap-research-ed25519/SKILL.md (maps to goap-research in skill name)
95
+ [ ] problem-solver-enhanced/SKILL.md
96
+ [ ] requirements-validator/SKILL.md
97
+ [ ] brutal-honesty-review/SKILL.md
98
+ - Path rewrite applied: /mnt/skills/user/ -> .claude/skills/
99
+ - Each skill directory contains SKILL.md + references/ (if applicable)
100
+
101
+ CHECK 9: git-workflow.md rule
102
+ - File exists at .claude/rules/git-workflow.md
103
+ - Contains semantic commit conventions
104
+ - Includes commit format specification
105
+
106
+ CHECK 10: settings.json
107
+ - File exists at .claude/settings.json
108
+ - Valid JSON (parseable)
109
+ - Contains Stop hooks:
110
+ [ ] Insights auto-commit hook
111
+ [ ] Roadmap auto-commit hook (if feature suggestions generated)
112
+ [ ] Plans auto-commit hook
113
+ - Contains SessionStart hook:
114
+ [ ] feature-context.py hook (if feature suggestions generated)
115
+
116
+ CHECK 11: docs/features/ directory
117
+ - Directory exists at docs/features/
118
+ - Ready for feature documentation output
119
+ ```
120
+
121
+ #### 1b. P0 Conditional Checks
122
+
123
+ ```
124
+ CHECK 12: secrets-management.md + security-patterns/ (IF has_external_apis)
125
+ - IF has_external_apis == true:
126
+ [ ] .claude/rules/secrets-management.md exists
127
+ [ ] .claude/skills/security-patterns/SKILL.md exists
128
+ - IF has_external_apis == false:
129
+ [ ] Neither file exists (no false positives)
130
+
131
+ CHECK 13: domain-model.md rule (IF DDD Strategic docs)
132
+ - IF has_ddd == true:
133
+ [ ] .claude/rules/domain-model.md exists
134
+ [ ] Contains bounded context rules, aggregate rules, entity/VO/event rules
135
+ - IF has_ddd == false:
136
+ [ ] File does not exist
137
+
138
+ CHECK 14: /start DB migration (IF has_database)
139
+ - IF has_database == true:
140
+ [ ] /start command includes database migration step
141
+ [ ] /start command includes seed data step
142
+ - IF has_database == false:
143
+ [ ] No DB migration references in /start
144
+ ```
145
+
146
+ #### 1c. P1 Enterprise Checks (IF DDD)
147
+
148
+ ```
149
+ CHECK 15: Enterprise lifecycle (IF has_ddd)
150
+ - IF has_ddd == true:
151
+ [ ] .claude/commands/feature-ent.md exists with 4 phases
152
+ [ ] .claude/rules/feature-lifecycle-ent.md exists with decision matrix
153
+ [ ] .claude/skills/idea2prd-manual/ copied with path rewrites
154
+ [ ] .claude/skills/goap-research-ed25519/ copied (enterprise copy)
155
+ [ ] CLAUDE.md includes Enterprise Feature Lifecycle section
156
+ [ ] Path rewrites verified in idea2prd-manual/SKILL.md:
157
+ - /mnt/skills/user/explore/ -> .claude/skills/explore/
158
+ - /mnt/skills/user/goap-research-ed25519/ -> .claude/skills/goap-research-ed25519/
159
+ - /mnt/skills/user/problem-solver-enhanced/ -> .claude/skills/problem-solver-enhanced/
160
+ - IF has_ddd == false:
161
+ [ ] None of these files exist
162
+ ```
163
+
164
+ #### 1d. P1 Feature Suggestions Checks
165
+
166
+ ```
167
+ CHECK 16: Feature suggestions system
168
+ [ ] .claude/feature-roadmap.json exists and is valid JSON
169
+ [ ] feature-roadmap.json contains >= 5 features
170
+ [ ] Feature statuses are valid: done|in_progress|next|planned|blocked
171
+ [ ] .claude/hooks/feature-context.py exists and is valid Python syntax
172
+ [ ] .claude/commands/next.md exists with 3 subcommands (default, update, feature-id)
173
+ [ ] .claude/skills/feature-navigator/SKILL.md exists with priority rules
174
+ [ ] settings.json SessionStart hook references feature-context.py
175
+ [ ] settings.json Stop hook includes roadmap auto-commit
176
+ ```
177
+
178
+ #### 1e. P1 Automation Checks
179
+
180
+ ```
181
+ CHECK 17: Automation commands
182
+ [ ] .claude/commands/go.md exists with complexity scoring matrix
183
+ [ ] .claude/commands/run.md exists with MVP/all scope handling
184
+ [ ] .claude/commands/docs.md exists with bilingual generation
185
+ [ ] CLAUDE.md includes Automation Commands section
186
+ [ ] DEVELOPMENT_GUIDE.md includes command hierarchy diagram
187
+ [ ] /go references /plan, /feature correctly
188
+ [ ] /go references /feature-ent ONLY if has_ddd (conditional reference)
189
+ [ ] /run references /start, /next, /go correctly
190
+ [ ] /docs references docs/, myinsights/, source code as inputs
191
+ ```
192
+
193
+ #### 1f. Pipeline-Specific Checks (IF applicable)
194
+
195
+ ```
196
+ CHECK 18: DDD pipeline artifacts (IF has_ddd)
197
+ [ ] Bounded Contexts mapped to agent scopes (domain-expert, architect)
198
+ [ ] Aggregates mapped to validation patterns (ddd-validator, aggregate-patterns)
199
+ [ ] ADR decisions mapped to rules (coding-style, architect agent)
200
+ [ ] Fitness Functions mapped to hooks (validate-aggregate-size, check-ddd-patterns)
201
+ [ ] Gherkin features mapped to test commands (/test, testing-patterns)
202
+ [ ] .ai-context/ integrated into CLAUDE.md (if present)
203
+
204
+ CHECK 19: P2 DDD items (IF has_ddd AND P2 generated)
205
+ [ ] .claude/agents/ddd-validator.md exists
206
+ [ ] .claude/skills/aggregate-patterns/SKILL.md exists
207
+ [ ] .claude/skills/event-handlers/SKILL.md exists
208
+ [ ] .claude/commands/validate-ddd.md exists
209
+ [ ] .claude/hooks/validate-aggregate-size.sh exists and is executable
210
+ [ ] .claude/hooks/check-ddd-patterns.sh exists and is executable
211
+
212
+ CHECK 20: P3 MCP (IF external integrations detected)
213
+ [ ] .mcp.json exists in project root and is valid JSON
214
+ [ ] No hardcoded secrets (all env vars use ${VAR_NAME} syntax)
215
+ [ ] Enabled servers count < 10
216
+ [ ] INSTALL.md documents all required env vars from .mcp.json
217
+ ```
218
+
219
+ ### Step 2: Verify Placeholder Substitution
220
+
221
+ Scan ALL generated files for unsubstituted placeholders:
222
+
223
+ ```
224
+ Scan targets:
225
+ - All files in .claude/ recursively (agents/, skills/, commands/, rules/, hooks/)
226
+ - CLAUDE.md, DEVELOPMENT_GUIDE.md, INSTALL.md at project root
227
+ - .mcp.json at project root (if exists)
228
+ - .claude/feature-roadmap.json (if exists)
229
+
230
+ Scan patterns (all are CRITICAL if found):
231
+
232
+ Pattern: {{[A-Z_]+}}
233
+ Examples: {{PROJECT_NAME}}, {{LANGUAGE}}, {{MAX_ENTITIES}}, {{TECH_KEYWORDS}}
234
+ Action: Look up value in IPM and substitute
235
+
236
+ Pattern: {{IF_DDD}}, {{IF_EXTERNAL_APIS}}, {{IF_EXTERNAL_INTEGRATIONS}}
237
+ Action: Remove conditional marker and enclosed block if condition is false,
238
+ keep enclosed content (remove markers only) if condition is true
239
+
240
+ Pattern: /mnt/skills/user/
241
+ Action: Replace with .claude/skills/ (path rewrite was missed)
242
+
243
+ Pattern: /mnt/user-data/uploads/
244
+ Action: Replace with docs/ (path rewrite was missed)
245
+
246
+ Pattern: /output/
247
+ Action: Replace with docs/ or project root (path rewrite was missed)
248
+
249
+ Process:
250
+ 1. Glob all target files
251
+ 2. For each file, search for ALL scan patterns
252
+ 3. Collect all findings with file path, line number, and pattern
253
+ 4. Report findings as CRITICAL FAILURE if any found
254
+ 5. Attempt auto-fix for each finding:
255
+ - {{PLACEHOLDER}} -> look up in IPM, substitute
256
+ - {{IF_*}} -> evaluate condition, resolve block
257
+ - /mnt/* -> apply path rewrite
258
+ 6. Re-scan after auto-fix to verify zero remaining
259
+
260
+ Expected result: ZERO unsubstituted placeholders across all generated files.
261
+ ```
262
+
263
+ ### Step 3: Run Integrity Checks
264
+
265
+ ```
266
+ INTEGRITY CHECK 1: JSON Validity
267
+ Parse each JSON file and verify:
268
+ - .claude/settings.json -> must parse without errors
269
+ - .claude/feature-roadmap.json -> must parse without errors (if exists)
270
+ - .mcp.json -> must parse without errors (if exists)
271
+ Common issues to auto-fix: trailing commas, missing quotes, unescaped characters
272
+
273
+ INTEGRITY CHECK 2: File Cross-References
274
+ For every generated file, verify that all references resolve:
275
+ - Agent frontmatter skills: field -> each skill name maps to .claude/skills/{name}/SKILL.md
276
+ - Command text references to other commands -> .claude/commands/{name}.md exists
277
+ - Rule text references to commands -> .claude/commands/{name}.md exists
278
+ - settings.json hook commands -> referenced scripts exist at specified paths
279
+ - CLAUDE.md Available Agents table -> each agent file exists
280
+ - CLAUDE.md Available Skills table -> each skill directory exists
281
+ - CLAUDE.md Available Commands table -> each command file exists
282
+ Failure here means a file references something that was not generated.
283
+
284
+ INTEGRITY CHECK 3: Directory Structure
285
+ Verify the complete directory tree exists:
286
+ - .claude/agents/ -> contains expected agent files
287
+ - .claude/skills/ -> contains expected skill directories, each with SKILL.md
288
+ - .claude/commands/ -> contains expected command files
289
+ - .claude/rules/ -> contains expected rule files
290
+ - .claude/hooks/ -> exists if any hooks were generated
291
+ - docs/features/ -> exists
292
+ - docs/plans/ -> exists (if /plan command was generated)
293
+
294
+ INTEGRITY CHECK 4: Skill Completeness
295
+ For each skill directory in .claude/skills/:
296
+ - SKILL.md exists and is non-empty (minimum 100 bytes)
297
+ - If the source skill had a references/ subdirectory, it was copied
298
+ - If the source skill had scripts/, they were copied
299
+ - SKILL.md frontmatter contains name and description fields
300
+
301
+ INTEGRITY CHECK 5: Context Budget
302
+ Measure approximate token count for each component:
303
+
304
+ | Component | Target | Max | Actual | Status |
305
+ |-----------|--------|-----|--------|--------|
306
+ | CLAUDE.md | 4k | 6k | [measure] | [OK/WARN/FAIL] |
307
+ | /start command | 2k | 4k | [measure] | [OK/WARN/FAIL] |
308
+ | /myinsights + /feature + /plan | 3k combined | 5.5k | [measure] | [OK/WARN/FAIL] |
309
+ | Domain rules (all .claude/rules/) | 1.5k | 2.5k | [measure] | [OK/WARN/FAIL] |
310
+ | Generated skills + agents | 3.5k | 5k | [measure] | [OK/WARN/FAIL] |
311
+ | Copied lifecycle skills | 0 (on-demand) | 0 | [verify] | [OK/WARN/FAIL] |
312
+ | Commands + hooks | 1k | 2k | [measure] | [OK/WARN/FAIL] |
313
+ | DEVELOPMENT_GUIDE | 1k | 2k | [measure] | [OK/WARN/FAIL] |
314
+ | TOTAL | ~18k | 30k | [sum] | [OK/WARN/FAIL] |
315
+
316
+ Measurement method: character count / 4 (approximate tokens)
317
+ WARN if any component exceeds Target but within Max
318
+ FAIL if any component exceeds Max
319
+ FAIL if Total exceeds 30k (15% of 200k context window)
320
+
321
+ Note: Copied lifecycle skills count as 0 because they are loaded on-demand
322
+ (only when /feature or /feature-ent is invoked), not at session start.
323
+
324
+ INTEGRITY CHECK 6: Executable Permissions
325
+ For all scripts in .claude/hooks/:
326
+ - .sh files have executable permission (chmod +x)
327
+ - .py files have executable permission (chmod +x)
328
+ - .sh files have correct shebang: #!/bin/bash
329
+ - .py files have correct shebang: #!/usr/bin/env python3
330
+ ```
331
+
332
+ ### Step 4: Create Output Structure Summary
333
+
334
+ Compile the complete file tree of everything produced, annotated with phase and status:
335
+
336
+ ```
337
+ [project-name]-cc-toolkit/
338
+ |-- CLAUDE.md <- P0 [size] [PASS/FAIL]
339
+ |-- DEVELOPMENT_GUIDE.md <- P0 [size] [PASS/FAIL]
340
+ |-- INSTALL.md <- P0 (updated P3) [size] [PASS/FAIL]
341
+ |-- .mcp.json <- P3 (IF integrations) [size] [PASS/FAIL]
342
+ |-- .claude/
343
+ | |-- settings.json <- P0+P1+P2 merged [size] [PASS/FAIL]
344
+ | |-- feature-roadmap.json <- P1 [size] [PASS/FAIL]
345
+ | |-- hooks/
346
+ | | |-- feature-context.py <- P1 [size] [PASS/FAIL]
347
+ | | |-- validate-aggregate-size.sh <- P2 IF DDD [size] [PASS/FAIL]
348
+ | | |-- check-ddd-patterns.sh <- P2 IF DDD [size] [PASS/FAIL]
349
+ | |-- agents/
350
+ | | |-- planner.md <- P1 [size] [PASS/FAIL]
351
+ | | |-- code-reviewer.md <- P1 [size] [PASS/FAIL]
352
+ | | |-- architect.md <- P1 [size] [PASS/FAIL]
353
+ | | |-- tdd-guide.md <- P2 [size] [PASS/FAIL]
354
+ | | |-- ddd-validator.md <- P2 IF DDD [size] [PASS/FAIL]
355
+ | |-- skills/
356
+ | | |-- sparc-prd-mini/ <- P0 lifecycle [PASS/FAIL]
357
+ | | |-- explore/ <- P0 lifecycle [PASS/FAIL]
358
+ | | |-- goap-research-ed25519/ <- P0 lifecycle [PASS/FAIL]
359
+ | | |-- problem-solver-enhanced/ <- P0 lifecycle [PASS/FAIL]
360
+ | | |-- requirements-validator/ <- P0 lifecycle [PASS/FAIL]
361
+ | | |-- brutal-honesty-review/ <- P0 lifecycle [PASS/FAIL]
362
+ | | |-- idea2prd-manual/ <- P1 IF DDD (path-rewritten) [PASS/FAIL]
363
+ | | |-- feature-navigator/ <- P1 [PASS/FAIL]
364
+ | | |-- project-context/ <- P1 [PASS/FAIL]
365
+ | | |-- coding-standards/ <- P1 [PASS/FAIL]
366
+ | | |-- testing-patterns/ <- P1 [PASS/FAIL]
367
+ | | |-- security-patterns/ <- P0 IF external APIs [PASS/FAIL]
368
+ | | |-- aggregate-patterns/ <- P2 IF DDD [PASS/FAIL]
369
+ | | |-- event-handlers/ <- P2 IF DDD [PASS/FAIL]
370
+ | |-- commands/
371
+ | | |-- start.md <- P0 [size] [PASS/FAIL]
372
+ | | |-- myinsights.md <- P0 [size] [PASS/FAIL]
373
+ | | |-- feature.md <- P0 [size] [PASS/FAIL]
374
+ | | |-- feature-ent.md <- P1 IF DDD [size] [PASS/FAIL]
375
+ | | |-- next.md <- P1 [size] [PASS/FAIL]
376
+ | | |-- plan.md <- P1 [size] [PASS/FAIL]
377
+ | | |-- test.md <- P1 [size] [PASS/FAIL]
378
+ | | |-- deploy.md <- P1 [size] [PASS/FAIL]
379
+ | | |-- go.md <- P1 [size] [PASS/FAIL]
380
+ | | |-- run.md <- P1 [size] [PASS/FAIL]
381
+ | | |-- docs.md <- P1 [size] [PASS/FAIL]
382
+ | | |-- review.md <- P2 [size] [PASS/FAIL]
383
+ | | |-- validate-ddd.md <- P2 IF DDD [size] [PASS/FAIL]
384
+ | |-- rules/
385
+ | |-- security.md <- P0 [size] [PASS/FAIL]
386
+ | |-- coding-style.md <- P0 [size] [PASS/FAIL]
387
+ | |-- git-workflow.md <- P0 [size] [PASS/FAIL]
388
+ | |-- insights-capture.md <- P0 [size] [PASS/FAIL]
389
+ | |-- feature-lifecycle.md <- P0 [size] [PASS/FAIL]
390
+ | |-- feature-lifecycle-ent.md <- P1 IF DDD [size] [PASS/FAIL]
391
+ | |-- secrets-management.md <- P0 IF external APIs [size] [PASS/FAIL]
392
+ | |-- domain-model.md <- P0 IF DDD [size] [PASS/FAIL]
393
+ | |-- fitness-functions.md <- P2 IF DDD [size] [PASS/FAIL]
394
+ | |-- testing.md <- P1 [size] [PASS/FAIL]
395
+ |-- docs/
396
+ | |-- features/ <- P0 (empty, ready for use)
397
+ | |-- plans/ <- P1 (empty, ready for use)
398
+ |-- myinsights/ <- created on first /myinsights use
399
+ ```
400
+
401
+ Annotate each item with:
402
+ - Phase that generated it (P0/P1/P2/P3)
403
+ - Conditional flag (IF DDD, IF external APIs, etc.)
404
+ - File size in bytes
405
+ - Validation status (PASS/FAIL) from Step 1 checks
406
+
407
+ ### Step 5: Generate Validation Report
408
+
409
+ Present the validation report to the user (not saved as a file):
410
+
411
+ ```
412
+ =====================================================================
413
+ TOOLKIT VALIDATION REPORT
414
+ =====================================================================
415
+
416
+ Pipeline: [SPARC | IDEA2PRD_FULL | IDEA2PRD_PARTIAL | MINIMAL]
417
+ Project: [project name from IPM]
418
+ Mode: [AUTO | HYBRID | MANUAL]
419
+
420
+ ---------------------------------------------------------------------
421
+ CHECKLIST RESULTS
422
+ ---------------------------------------------------------------------
423
+
424
+ P0 MANDATORY: [X/11 passed]
425
+ P0 CONDITIONAL: [X/Y passed] (Y = applicable checks)
426
+ P1 CORE: [X/10 passed]
427
+ P1 ENTERPRISE (IF DDD): [X/5 passed | N/A]
428
+ P1 FEATURE SUGGESTIONS: [X/8 passed]
429
+ P1 AUTOMATION: [X/9 passed]
430
+ P2 UNIVERSAL: [X/3 passed]
431
+ P2 DDD-ONLY (IF DDD): [X/5 passed | N/A]
432
+ P3 MCP: [X/4 passed | N/A]
433
+
434
+ PLACEHOLDER SCAN: [0 found | N found -- CRITICAL]
435
+ INTEGRITY CHECKS: [6/6 passed | X/6 passed]
436
+ CONTEXT BUDGET: [Xk / 30k tokens -- OK | OVER]
437
+
438
+ ---------------------------------------------------------------------
439
+ FILE SUMMARY
440
+ ---------------------------------------------------------------------
441
+
442
+ Agents: X files
443
+ Skills: X directories (Y copied with path rewrite, Z generated new)
444
+ Commands: X files
445
+ Rules: X files
446
+ Hooks: X files (scripts)
447
+ Configs: X files (settings.json, roadmap.json, .mcp.json)
448
+ Docs: CLAUDE.md, DEVELOPMENT_GUIDE.md, INSTALL.md
449
+
450
+ TOTAL: X files across Y directories
451
+
452
+ ---------------------------------------------------------------------
453
+ RESULT
454
+ ---------------------------------------------------------------------
455
+
456
+ IF all P0 mandatory checks pass AND placeholder scan is clean:
457
+
458
+ TOOLKIT READY
459
+
460
+ The toolkit is complete and validated. Next steps:
461
+ 1. Run /start to bootstrap the project
462
+ 2. Run /next to see the feature roadmap
463
+ 3. Run /feature [name] to start your first feature
464
+ 4. Run /go [name] for autonomous implementation
465
+
466
+ IF any P0 mandatory check fails:
467
+
468
+ TOOLKIT INCOMPLETE -- P0 failures must be fixed
469
+
470
+ FAILED CHECKS:
471
+ - [Check N]: [description of what failed and where]
472
+ - [Check N]: [description of what failed and where]
473
+
474
+ Auto-fix attempted: [Y/N]
475
+ Remaining failures after auto-fix: [count]
476
+
477
+ Action required: Fix the listed failures and re-run Phase 6 validation.
478
+
479
+ IF placeholder scan found unresolved tokens:
480
+
481
+ UNRESOLVED PLACEHOLDERS FOUND -- must be fixed
482
+
483
+ FILES WITH PLACEHOLDERS:
484
+ - [file path]: {{PLACEHOLDER_NAME}} (line N)
485
+ - [file path]: /mnt/skills/user/ (line N)
486
+
487
+ Auto-fix attempted: [Y/N]
488
+ Remaining after auto-fix: [count]
489
+
490
+ =====================================================================
491
+ ```
492
+
493
+ ### Step 6: MANUAL Mode Final Checkpoint
494
+
495
+ ```
496
+ IF mode == MANUAL:
497
+
498
+ =====================================================================
499
+ MANUAL CHECKPOINT 6: Final Review
500
+ =====================================================================
501
+
502
+ [Full validation report from Step 5]
503
+
504
+ Available actions:
505
+ "ok" -- accept and finalize toolkit
506
+ "preview [file]" -- preview contents of a specific generated file
507
+ "add [tool]" -- add a missing instrument to the toolkit
508
+ "regenerate [N]" -- regenerate a specific failed check item
509
+ "download" -- package toolkit for download
510
+
511
+ =====================================================================
512
+
513
+ Wait for user confirmation before finalizing.
514
+
515
+ IF mode == HYBRID:
516
+
517
+ =====================================================================
518
+ HYBRID CHECKPOINT 2: Final Validation
519
+ =====================================================================
520
+
521
+ [Abbreviated validation report: tier counts + any failures]
522
+
523
+ "ok" to finalize | "fix" to address failures
524
+
525
+ =====================================================================
526
+
527
+ IF mode == AUTO:
528
+
529
+ [No checkpoint -- proceed directly to finalization]
530
+ [Only stop if P0 mandatory checks fail]
531
+ ```
532
+
533
+ ### Step 7: Failure Protocol
534
+
535
+ ```
536
+ IF any hard requirement fails after all checks:
537
+
538
+ 1. LOG the specific failure:
539
+ - File path
540
+ - Check number and description
541
+ - Expected vs actual state
542
+ - Root cause (if determinable)
543
+
544
+ 2. ATTEMPT auto-fix (one attempt per failure):
545
+
546
+ Missing file:
547
+ -> Identify which phase module (03/04/05) should have generated it
548
+ -> Re-execute that specific generation step
549
+ -> Verify file now exists
550
+
551
+ Unsubstituted placeholder:
552
+ -> Look up placeholder name in IPM
553
+ -> IF value found: substitute in file
554
+ -> IF value not found: use sensible default and WARN user
555
+
556
+ Invalid JSON:
557
+ -> Attempt common fixes: remove trailing commas, add missing brackets
558
+ -> Re-parse to verify
559
+ -> IF still invalid: regenerate the file
560
+
561
+ Unrewritten path (/mnt/*):
562
+ -> Apply the standard path rewrite rules:
563
+ /mnt/skills/user/ -> .claude/skills/
564
+ /mnt/user-data/uploads/ -> docs/
565
+ /output/ -> docs/ or project root
566
+ -> Verify no /mnt/ paths remain
567
+
568
+ Missing cross-reference:
569
+ -> Identify which file is referenced but missing
570
+ -> Check if it should have been generated (consult Instrument Map)
571
+ -> IF yes: regenerate it
572
+ -> IF no: remove the reference from the referring file
573
+
574
+ 3. RE-RUN the failed check after auto-fix
575
+
576
+ 4. IF still failing after auto-fix:
577
+ -> Report to user with full details
578
+ -> Suggest manual intervention
579
+ -> Do NOT declare toolkit ready
580
+
581
+ 5. NEVER declare TOOLKIT READY if any P0 mandatory check fails
582
+ ```
583
+
584
+ ## Output
585
+
586
+ ### Primary Output
587
+
588
+ - **Validation Report** -- displayed to user, not persisted as a file
589
+ - Per-tier pass/fail counts
590
+ - Placeholder scan results
591
+ - Integrity check results (6 checks)
592
+ - Context budget measurements per component
593
+ - Complete file count summary
594
+ - Clear READY or INCOMPLETE verdict
595
+
596
+ ### Verification State (internal)
597
+
598
+ - Output structure manifest (complete file tree with per-file annotations)
599
+ - Cross-reference verification map
600
+ - Context budget measurements table
601
+ - Placeholder scan results log
602
+
603
+ ### Delivery State
604
+
605
+ Upon successful validation (all hard requirements pass):
606
+ - All generated files are in their final locations within the project directory
607
+ - No temporary or intermediate files remain
608
+ - All JSON files parse without errors
609
+ - All hook scripts have executable permissions
610
+ - All placeholders are resolved
611
+ - All cross-references resolve to existing files
612
+ - Context budget is within limits
613
+ - The project is ready for `/start` to bootstrap
614
+
615
+ ## Quality Gate
616
+
617
+ The Phase 6 quality gate IS the Master Validation Checklist. The gate passes when:
618
+
619
+ ### Hard Requirements (must ALL pass -- blocking)
620
+
621
+ - [ ] P0 Mandatory: 100% pass rate (all 11 checks green)
622
+ - [ ] P0 Conditional: 100% pass rate for all applicable checks
623
+ - [ ] Placeholder scan: ZERO unsubstituted `{{PLACEHOLDER}}` patterns found
624
+ - [ ] Placeholder scan: ZERO unrewritten `/mnt/` paths found
625
+ - [ ] JSON validity: ALL JSON files parse without errors
626
+ - [ ] File cross-references: ALL referenced files exist
627
+ - [ ] Context budget: Total < 30k tokens
628
+
629
+ ### Soft Requirements (warning if failed, not blocking)
630
+
631
+ - [ ] P1/P2/P3 checks pass for all generated tiers
632
+ - [ ] Context budget within target (not just max) per component
633
+ - [ ] All skill directories contain references/ subdirectory (when source had one)
634
+ - [ ] Feature roadmap contains >= 5 features with correct statuses
635
+ - [ ] All agents have trigger keywords in their description frontmatter
636
+ - [ ] Hook scripts have correct shebang lines
637
+
638
+ ### Failure Protocol Summary
639
+
640
+ ```
641
+ Hard requirement fails -> auto-fix attempt -> re-check -> report if still failing
642
+ Soft requirement fails -> WARN in report -> proceed with delivery
643
+ P0 failure after auto-fix -> BLOCK delivery, require user intervention
644
+ ```
645
+
646
+ ## Dependencies
647
+
648
+ ### Upstream Modules (all prior phases)
649
+
650
+ | Module | Provides |
651
+ |--------|----------|
652
+ | `01-detect-parse.md` | IPM with detection flags and project characteristics for conditional checks |
653
+ | `02-analyze-map.md` | Instrument Map for verifying scored items were generated |
654
+ | `03-generate-p0.md` | P0 mandatory files to validate |
655
+ | `04-generate-p1.md` | P1 recommended files to validate |
656
+ | `05-generate-p2p3.md` | P2/P3 optional files to validate |
657
+
658
+ ### Reference Files
659
+
660
+ | Reference | Used For |
661
+ |-----------|----------|
662
+ | `references/claude-md-strategy.md` | Verifying CLAUDE.md structure follows the generation strategy |
663
+ | SKILL.md "Master Validation Checklist" section | Authoritative checklist source |
664
+ | SKILL.md "Output Structure" section | Expected directory tree reference |
665
+ | SKILL.md "Context Budget" section | Token budget limits |
666
+
667
+ ### No External Dependencies
668
+
669
+ This module operates entirely on generated files from prior phases. It does not read
670
+ source documentation, invoke external skills, or generate new content (except auto-fixes).
671
+ Its sole purpose is validation, integrity verification, and delivery reporting.
672
+
673
+ ## Reusability
674
+
675
+ ### Package Validation Pattern for Multi-File Generation Systems
676
+
677
+ The validation approach in this module is a universal pattern for any system that generates
678
+ multiple interdependent files across several phases:
679
+
680
+ 1. **Tiered checklist validation** -- organize checks by priority (mandatory vs optional)
681
+ so that critical failures are caught first and block delivery while non-critical issues
682
+ produce warnings but allow proceeding
683
+
684
+ 2. **Placeholder sweep** -- scan all generated files for template markers that should have
685
+ been substituted, catching generation errors that single-file validation would miss.
686
+ This is especially important in multi-phase pipelines where later phases may assume
687
+ earlier phases resolved all placeholders
688
+
689
+ 3. **Cross-reference verification** -- verify that every reference between generated files
690
+ (agent -> skill, command -> command, config -> script, documentation -> file) resolves
691
+ to an actual existing file. This catches orphaned references from conditional generation
692
+ where a file was gated out but references to it were not
693
+
694
+ 4. **Context budget enforcement** -- measure aggregate resource consumption across all
695
+ generated files against defined limits. In AI-assisted development, context window
696
+ budget is a hard constraint that determines whether the toolkit is usable
697
+
698
+ 5. **Auto-fix protocol** -- attempt mechanical fixes for common failure modes before
699
+ escalating to the user. This reduces friction in the generation pipeline while
700
+ maintaining strict quality gates
701
+
702
+ 6. **Structured reporting** -- present validation results in a clear, actionable format
703
+ with per-tier counts, specific failure descriptions, and explicit next-step guidance
704
+
705
+ This pattern is directly applicable to:
706
+ - Project scaffolding tools (cookiecutter, yeoman, create-* CLIs)
707
+ - Infrastructure-as-code generators (Terraform modules, Kubernetes manifests)
708
+ - API SDK generators (OpenAPI codegen, gRPC generators)
709
+ - Documentation site generators (Docusaurus, Sphinx)
710
+ - Any multi-phase pipeline producing interdependent output artifacts