@dzhechkov/p-replicator 1.2.0 → 1.5.2

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 (46) hide show
  1. package/README.md +55 -0
  2. package/bin/cli.js +0 -0
  3. package/package.json +10 -3
  4. package/src/cli.js +23 -6
  5. package/src/commands/doctor.js +46 -29
  6. package/src/commands/init.js +61 -8
  7. package/src/commands/list.js +5 -26
  8. package/src/commands/update.js +73 -7
  9. package/src/commands/verify.js +111 -0
  10. package/src/utils.js +275 -4
  11. package/templates/.claude/commands/deploy.md +100 -0
  12. package/templates/.claude/commands/docs.md +79 -0
  13. package/templates/.claude/commands/feature.md +134 -0
  14. package/templates/.claude/commands/go.md +115 -0
  15. package/templates/.claude/commands/myinsights.md +72 -0
  16. package/templates/.claude/commands/next.md +110 -0
  17. package/templates/.claude/commands/plan.md +88 -0
  18. package/templates/.claude/commands/replicate.md +103 -17
  19. package/templates/.claude/commands/run.md +151 -0
  20. package/templates/.claude/commands/start.md +88 -0
  21. package/templates/.claude/hooks/autocommit-insights.cjs +39 -0
  22. package/templates/.claude/hooks/autocommit-plans.cjs +39 -0
  23. package/templates/.claude/hooks/autocommit-roadmap.cjs +44 -0
  24. package/templates/.claude/hooks/session-insights.cjs +28 -0
  25. package/templates/.claude/hooks/state-update.cjs +79 -0
  26. package/templates/.claude/hooks/statusline.cjs +399 -0
  27. package/templates/.claude/rules/feature-lifecycle.md +145 -0
  28. package/templates/.claude/rules/git-workflow.md +74 -0
  29. package/templates/.claude/rules/insights-capture.md +77 -0
  30. package/templates/.claude/rules/replicate-pipeline.md +97 -20
  31. package/templates/.claude/settings.json +44 -0
  32. package/templates/.claude/skills/brutal-honesty-review/SKILL.md +43 -0
  33. package/templates/.claude/skills/brutal-honesty-review/scripts/assess-code.sh +0 -0
  34. package/templates/.claude/skills/brutal-honesty-review/scripts/assess-tests.sh +0 -0
  35. package/templates/.claude/skills/cc-toolkit-generator-enhanced/SKILL.md +8 -0
  36. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/03-generate-p0.md +46 -0
  37. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/04-generate-p1.md +9 -0
  38. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/05-generate-p2p3.md +11 -0
  39. package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/06-package-deliver.md +46 -0
  40. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/security-patterns-library.md +196 -0
  41. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/automation-commands.md +15 -0
  42. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/ddd-agents.md +39 -0
  43. package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/templates/feature-lifecycle.md +8 -0
  44. package/templates/.claude/skills/goap-research-ed25519/scripts/ed25519_verifier.py +0 -0
  45. package/templates/.claude/skills/goap-research-ed25519/scripts/goap_planner.py +0 -0
  46. package/templates/.claude/skills/requirements-validator/SKILL.md +25 -1
@@ -20,7 +20,7 @@ When executing skills during the pipeline:
20
20
  3. When a skill references `/mnt/user-data/uploads/` — read from `docs/` instead
21
21
  4. When a skill outputs to `/output/` — write to `docs/` or project root instead
22
22
  5. `goap-research` skill name maps to `goap-research-ed25519` in this repo
23
- 6. When a skill has `modules/` directory — read the module file referenced by the phase
23
+ 6. **CRITICAL:** When a skill has `modules/` directory — you MUST read the FULL module file for EVERY phase before executing it. SKILL.md is the orchestrator only — it contains summaries, NOT the actual generation logic. NEVER generate artifacts from SKILL.md summaries. In a real project, skipping `modules/04-generate-p1.md` caused 10+ artifacts to be silently omitted.
24
24
  7. See `.claude/rules/skill-interface-protocol.md` for full interface specification
25
25
 
26
26
  ## Modular Skills
@@ -28,6 +28,10 @@ When executing skills during the pipeline:
28
28
  Skills with `modules/` directories delegate phases to self-contained module files.
29
29
  Each module follows: INPUT → PROCESS → OUTPUT → QUALITY GATE interface.
30
30
 
31
+ **MANDATORY:** Before executing any modular skill phase, read the corresponding module file in full.
32
+ Module files contain the actual generation instructions, templates, and quality gates.
33
+ SKILL.md contains only summaries and orchestration logic — it is NOT sufficient for generation.
34
+
31
35
  Currently modularized skills:
32
36
  - `cc-toolkit-generator-enhanced` — 9 modules (6 core pipeline + 3 extensions)
33
37
  - `knowledge-extractor` — 4 modules (agent review → classify → decontextualize → integrate)
@@ -51,6 +55,47 @@ All generated files go directly into the project. Never create a separate output
51
55
  | Dev guide | `DEVELOPMENT_GUIDE.md` |
52
56
  | Scaffolds | `docker-compose.yml`, `Dockerfile`, `.gitignore` |
53
57
 
58
+ ## Alternative entry: starting from existing technical documentation
59
+
60
+ The pipeline officially supports starting from user-provided technical
61
+ documentation as an alternative to the full Phase 0 (Product Discovery) flow.
62
+
63
+ ### Trigger detection
64
+
65
+ The orchestrator switches to this entry mode when user input contains any of:
66
+ - A path reference (e.g., "use my docs in `docs/existing/`")
67
+ - An explicit skip request ("skip discovery", "skip Phase 0")
68
+ - A statement of available docs ("I already have technical documentation")
69
+ - The semantic flag `--from-docs <path>` or `--skip-discovery`
70
+
71
+ ### Behavior
72
+
73
+ When triggered:
74
+ 1. Phase 0 is SKIPPED (no reverse-engineering-unicorn invocation)
75
+ 2. Phase 1 runs sparc-prd-mini in AUTO mode with pre-filled context from user docs
76
+ 3. Phase 1 skips internal Explore/Research/Solve sub-phases (those exist to
77
+ generate answers that the user already has)
78
+ 4. Phase 2 (validation) runs UNCHANGED
79
+ 5. Phase 3 (toolkit generation) and Phase 4 (finalize) run UNCHANGED
80
+
81
+ ### Three supported sub-paths
82
+
83
+ | Path | Use case | Skills invoked |
84
+ |---|---|---|
85
+ | **A** | Full pipeline with existing docs as input | sparc-prd-mini (AUTO) → requirements-validator → cc-toolkit-generator-enhanced |
86
+ | **B** | SPARC docs only, no toolkit/scaffold | sparc-prd-mini (AUTO) only |
87
+ | **C** | Validation-only (docs already SPARC-shaped) | requirements-validator only |
88
+
89
+ ### Test contract preserved
90
+
91
+ The alternative entry mode preserves:
92
+ - All pre-shipped artifacts (init contract intact)
93
+ - Manifest schema (.p-replicator.json including shippedDefaults)
94
+ - `verify` and `doctor` exit codes
95
+ - All meta-tests (replicate.md ↔ replicate-pipeline.md consistency)
96
+
97
+ No new flags or state-file fields are required.
98
+
54
99
  ## Architecture Constraints
55
100
 
56
101
  Always pass these constraints to sparc-prd-mini (Phase 1):
@@ -69,27 +114,59 @@ Commit after each major phase completion:
69
114
  - After Phase 3: `feat: Claude Code toolkit for [project-name]`
70
115
  - After Phase 4: `chore: initial project setup from SPARC documentation`
71
116
 
72
- ## What Gets Generated vs Pre-existing
73
-
74
- ### Pre-existing (template files do NOT overwrite)
75
- - `.claude/skills/*` — all 10 skills (with modules/ subdirectories)
76
- - `.claude/commands/replicate.md` this pipeline
77
- - `.claude/commands/harvest.md` knowledge extraction pipeline
78
- - `.claude/agents/replicate-coordinator.md`
79
- - `.claude/agents/product-discoverer.md`
80
- - `.claude/agents/doc-validator.md`
81
- - `.claude/agents/harvest-coordinator.md`
82
- - `.claude/rules/replicate-pipeline.md` — this file
83
- - `.claude/rules/skill-interface-protocol.md` — skill composition rules
84
-
85
- ### Generated by /replicate (create new)
86
- - `.claude/commands/start.md`, `feature.md`, `plan.md`, `myinsights.md`, `deploy.md`
87
- - `.claude/agents/planner.md`, `code-reviewer.md`, `architect.md`
88
- - `.claude/rules/git-workflow.md`, `insights-capture.md`, `feature-lifecycle.md`, `security.md`, `coding-style.md`
89
- - `.claude/settings.json` — hooks
90
- - `docs/*` — all documentation
117
+ ## What Gets Generated vs Pre-shipped (post v1.4)
118
+
119
+ ### Pre-shipped by `npx @dzhechkov/p-replicator init` (do NOT overwrite)
120
+
121
+ These files arrive with the package and form the stable workflow toolkit. They
122
+ are project-agnostic and can be enhanced (read by Phase 3) but never recreated.
123
+
124
+ **Skills (10):** all skills in `.claude/skills/` (`explore`, `sparc-prd-mini`,
125
+ `goap-research-ed25519`, `problem-solver-enhanced`, `requirements-validator`,
126
+ `brutal-honesty-review`, `cc-toolkit-generator-enhanced`,
127
+ `reverse-engineering-unicorn`, `pipeline-forge`, `knowledge-extractor`)
128
+
129
+ **Commands (11):** `replicate`, `harvest`, `start`, `plan`, `feature`, `go`,
130
+ `run`, `next`, `myinsights`, `docs`, `deploy`
131
+
132
+ **Agents (4):** `replicate-coordinator`, `product-discoverer`, `doc-validator`,
133
+ `harvest-coordinator`
134
+
135
+ **Rules (5):** `replicate-pipeline`, `skill-interface-protocol`, `git-workflow`,
136
+ `insights-capture`, `feature-lifecycle`
137
+
138
+ **Hooks:** `.claude/settings.json` (SessionStart + Stop) + cross-platform Node
139
+ scripts in `.claude/hooks/` (`session-insights.cjs`, `autocommit-roadmap.cjs`,
140
+ `autocommit-insights.cjs`, `autocommit-plans.cjs`)
141
+
142
+ ### Generated by /replicate Phase 3 (project-specific — create new)
143
+
144
+ These exist only AFTER `/replicate` runs because they encode project-specific
145
+ data extracted from SPARC docs.
146
+
147
+ - `.claude/agents/planner.md` — algorithm templates from Pseudocode.md
148
+ - `.claude/agents/code-reviewer.md` — edge cases from Refinement.md
149
+ - `.claude/agents/architect.md` — system design from Architecture.md
150
+ - `.claude/rules/security.md` — NFRs from Specification.md
151
+ - `.claude/rules/coding-style.md` — tech-stack conventions
152
+ - `.claude/rules/secrets-management.md` — IF external APIs detected
153
+ - `.claude/rules/testing.md` — test strategy from Refinement.md
154
+ - `.claude/skills/project-context/` — domain knowledge
155
+ - `.claude/skills/coding-standards/` — tech-specific patterns
156
+ - `.claude/skills/security-patterns/` — IF external APIs
157
+ - `.claude/feature-roadmap.json` — feature list from PRD MVP scope
158
+ - `.claude/commands/feature-ent.md` — IF DDD docs (idea2prd-manual)
159
+ - `.mcp.json` — IF external integrations
91
160
  - `CLAUDE.md`, `README.md`, `DEVELOPMENT_GUIDE.md`
92
161
  - `docker-compose.yml`, `Dockerfile`, `.gitignore`
162
+ - `docs/*` — all SPARC documentation
163
+
164
+ ### Post-pipeline verification
165
+
166
+ After `/replicate` completes, run `npx @dzhechkov/p-replicator verify` to
167
+ confirm both contracts (pre-shipped + post-/replicate). The `verify` command
168
+ detects whether `/replicate` was run (via CLAUDE.md or feature-roadmap.json)
169
+ and reports per-artifact status.
93
170
 
94
171
  ## Checkpoint Format
95
172
 
@@ -0,0 +1,44 @@
1
+ {
2
+ "$schema": "https://www.schemastore.org/claude-code-settings.json",
3
+ "_comment": "Default hooks + statusline shipped by @dzhechkov/p-replicator init. Cross-platform Node scripts (no bash dependencies). Auto-commits roadmap/insights/plans on Stop, injects relevant insights on SessionStart. Statusline displays pipeline+roadmap+toolkit dashboard above the prompt. Project-specific hooks (DDD, fitness functions, etc.) are merged in by /replicate Phase 3.",
4
+ "statusLine": {
5
+ "type": "command",
6
+ "command": "node .claude/hooks/statusline.cjs"
7
+ },
8
+ "hooks": {
9
+ "SessionStart": [
10
+ {
11
+ "matcher": "*",
12
+ "hooks": [
13
+ {
14
+ "type": "command",
15
+ "command": "node .claude/hooks/session-insights.cjs",
16
+ "timeout": 5
17
+ }
18
+ ]
19
+ }
20
+ ],
21
+ "Stop": [
22
+ {
23
+ "matcher": "*",
24
+ "hooks": [
25
+ {
26
+ "type": "command",
27
+ "command": "node .claude/hooks/autocommit-roadmap.cjs",
28
+ "timeout": 10
29
+ },
30
+ {
31
+ "type": "command",
32
+ "command": "node .claude/hooks/autocommit-insights.cjs",
33
+ "timeout": 10
34
+ },
35
+ {
36
+ "type": "command",
37
+ "command": "node .claude/hooks/autocommit-plans.cjs",
38
+ "timeout": 10
39
+ }
40
+ ]
41
+ }
42
+ ]
43
+ }
44
+ }
@@ -136,6 +136,49 @@ higher quality. They don't."
136
136
 
137
137
  ---
138
138
 
139
+ ## Security Review Checklist (Linus Mode — CRITICAL)
140
+
141
+ When reviewing code that handles authentication, authorization, data storage,
142
+ or external integrations, apply this checklist in addition to standard code quality:
143
+
144
+ ### OWASP Top 10 Quick Checks
145
+
146
+ | # | Vulnerability | What to Look For | Severity |
147
+ |---|--------------|-------------------|----------|
148
+ | A01 | Broken Access Control | Missing auth middleware, RLS bypass (pool.query vs dbClient), cross-tenant entity access without ownership check | CRITICAL |
149
+ | A02 | Cryptographic Failures | Weak JWT secrets with fallback defaults, hardcoded secrets, missing HMAC on webhooks | CRITICAL |
150
+ | A03 | Injection | SQL via string interpolation (SET LOCAL), template literals in queries, unsanitized user input in commands | CRITICAL |
151
+ | A04 | Insecure Design | Per-request stateful services (circuit breakers never trigger), missing rate limiting | HIGH |
152
+ | A05 | Security Misconfiguration | Same CORS policy across environments, verbose errors in production, missing security headers | HIGH |
153
+ | A07 | Auth Failures | No account lockout, weak password policy, session fixation | HIGH |
154
+ | A08 | Data Integrity | Unsigned webhook payloads, missing CSRF tokens, unvalidated redirects | HIGH |
155
+ | A09 | Logging Failures | No audit trail for auth events, PII in logs, missing failed-attempt logging | MEDIUM |
156
+
157
+ ### Multi-Tenant Security (if applicable)
158
+
159
+ - [ ] All DB queries use tenant-scoped connection, NOT shared pool
160
+ - [ ] SET LOCAL uses parameterized set_config(), NOT string interpolation
161
+ - [ ] Cross-entity references verify tenant ownership before operation
162
+ - [ ] Tenant isolation tested with cross-tenant attack scenarios
163
+
164
+ ### Secret Management
165
+
166
+ - [ ] All secrets validated at startup — missing = process.exit(1)
167
+ - [ ] No fallback defaults for security-critical secrets
168
+ - [ ] Secrets never appear in logs, error messages, or stack traces
169
+ - [ ] Environment-specific security posture (dev/staging/prod)
170
+
171
+ ### Webhook Security
172
+
173
+ - [ ] Every webhook endpoint verifies request signature/HMAC
174
+ - [ ] Unsigned payloads are rejected and logged
175
+ - [ ] Webhook secrets stored in environment variables
176
+
177
+ **Calibration:** Security violations ALWAYS trigger Level 3 (Brutal).
178
+ Security bugs are not "style issues" — they are negligence.
179
+
180
+ ---
181
+
139
182
  ## Assessment Rubrics
140
183
 
141
184
  ### Code Quality (Linus Mode)
@@ -18,6 +18,14 @@ description: >
18
18
  Three modes: AUTO, HYBRID (default), MANUAL.
19
19
  ---
20
20
 
21
+ > **CRITICAL MODULE LOADING REQUIREMENT:**
22
+ > This skill has 9 modules in `modules/`. SKILL.md is the orchestrator ONLY.
23
+ > You MUST read EVERY module file referenced in the Module Execution Protocol below
24
+ > before executing its phase. Skipping module files causes entire artifact categories
25
+ > to be silently omitted. In one real project, skipping `modules/04-generate-p1.md`
26
+ > caused 10+ P1 artifacts (agents, skills, commands) to be completely missing.
27
+ > NEVER generate artifacts from SKILL.md summaries alone — always read the full module.
28
+
21
29
  # CC-Toolkit-Generator Enhanced
22
30
 
23
31
  Generate production-ready Claude Code instruments from **SPARC or idea2prd-manual documentation**.
@@ -27,6 +27,12 @@ From the Instrument Map this module uses:
27
27
 
28
28
  ## Process
29
29
 
30
+ > **ANTI-COMPRESSION DIRECTIVE:** When generating files from templates in this module,
31
+ > COPY the FULL text of each template. Do NOT summarize, compress, or "interpret" templates.
32
+ > Every section, every placeholder, every comment must be preserved verbatim.
33
+ > AI systems routinely compress 211-line templates to 60 lines — this is a CRITICAL defect.
34
+ > Validate: generated file line count must be >= 80% of template line count.
35
+
30
36
  ### P0 Mandatory Items (always generated)
31
37
 
32
38
  The following 16 items are generated for every project, regardless of pipeline
@@ -37,6 +43,7 @@ type or user mode.
37
43
  #### Item 1: CLAUDE.md
38
44
 
39
45
  **Template:** `view() references/claude-md-strategy.md`
46
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
40
47
 
41
48
  The project's root context file. Generation strategy differs by pipeline:
42
49
 
@@ -154,6 +161,39 @@ Generate `.claude/rules/coding-style.md` containing:
154
161
  - Code organization patterns
155
162
  - IF idea2prd: DDD tactical patterns (aggregate rules, entity identity, VO immutability)
156
163
 
164
+ **Known Gotchas section (always include):**
165
+
166
+ Add a `## Known Gotchas` section to coding-style.md with language/framework-specific
167
+ pitfalls extracted from harvest insights. Include at minimum:
168
+
169
+ ```markdown
170
+ ## Known Gotchas
171
+
172
+ ### TypeScript / JavaScript
173
+ - `\w` in regex does NOT match Cyrillic or other non-Latin characters.
174
+ Use `\p{L}` with `/u` flag or explicit character classes for Unicode text.
175
+ - Direct type casting `req as CustomType` fails with TS2352. Use double-cast
176
+ via `unknown`: `(req as unknown as CustomType)`. Better: use generic route handlers.
177
+ - Jest `coverageThreshold` (singular) silently fails if spelled `coverageThresholds` (plural).
178
+ Per-directory thresholds require a `global` key. ts-jest needs `ts-node` as peer dependency.
179
+ - `jest.fn(async () => value)` doesn't satisfy `jest.Mocked<T>` in strict mode.
180
+ Use `jest.fn().mockResolvedValue(value)` or `jest.fn().mockImplementation(...)`.
181
+ - Opossum `CircuitBreaker.fire()` returns `Promise<unknown>`, requires explicit cast.
182
+ Both `@types/opossum` and `opossum` packages are needed.
183
+ - Socket.io `Server` has no `.toRoom()` method. Wrap it:
184
+ `{ toRoom: (room) => io.to(room) }` for hexagonal architecture ports.
185
+
186
+ ### Infrastructure
187
+ - Services with circuit breakers/rate limiters MUST be singletons.
188
+ Per-request instances bypass protection (breaker never accumulates failures).
189
+ - `SET LOCAL` in PostgreSQL only affects the current transaction on the current connection.
190
+ Use parameterized `set_config()` instead of string interpolation.
191
+ ```
192
+
193
+ Adapt gotchas to the specific tech stack detected in IPM. Remove irrelevant entries
194
+ (e.g., no TypeScript gotchas for Python projects). Add stack-specific gotchas from
195
+ `view() references/security-patterns-library.md` if applicable.
196
+
157
197
  **Output path:** `.claude/rules/coding-style.md`
158
198
 
159
199
  ---
@@ -161,6 +201,7 @@ Generate `.claude/rules/coding-style.md` containing:
161
201
  #### Item 4: /start command
162
202
 
163
203
  **Template:** `view() references/templates/start-command.md`
204
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
164
205
 
165
206
  Generate `.claude/commands/start.md` -- the full project bootstrap command.
166
207
 
@@ -189,6 +230,7 @@ code from memory. Every Phase 2 Task includes explicit doc references.
189
230
  #### Item 5: /myinsights command
190
231
 
191
232
  **Template:** `view() references/templates/insights-system.md` (Section 1)
233
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
192
234
 
193
235
  Generate `.claude/commands/myinsights.md` -- the insight capture and management
194
236
  command with:
@@ -207,6 +249,7 @@ command with:
207
249
  #### Item 6: /feature command
208
250
 
209
251
  **Template:** `view() references/templates/feature-lifecycle.md` (Section 2)
252
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
210
253
 
211
254
  Generate `.claude/commands/feature.md` -- the 4-phase feature lifecycle command:
212
255
 
@@ -278,6 +321,7 @@ type(scope): description
278
321
  #### Item 8: insights-capture.md rule
279
322
 
280
323
  **Template:** `view() references/templates/insights-system.md` (Section 2)
324
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
281
325
 
282
326
  Generate `.claude/rules/insights-capture.md` with:
283
327
  - Error-First Lookup protocol (grep index BEFORE debugging)
@@ -293,6 +337,7 @@ Generate `.claude/rules/insights-capture.md` with:
293
337
  #### Item 9: feature-lifecycle.md rule
294
338
 
295
339
  **Template:** `view() references/templates/feature-lifecycle.md` (Section 3)
340
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
296
341
 
297
342
  Generate `.claude/rules/feature-lifecycle.md` with:
298
343
  - Protocol definition (4-phase lifecycle)
@@ -310,6 +355,7 @@ Generate `.claude/rules/feature-lifecycle.md` with:
310
355
  #### Item 10: settings.json hooks
311
356
 
312
357
  **Template:** `view() references/templates/insights-system.md` (Section 3 -- Stop hook)
358
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
313
359
 
314
360
  Generate `.claude/settings.json` with hook configuration:
315
361
 
@@ -19,6 +19,12 @@ engine and conditionally included based on project characteristics and document
19
19
 
20
20
  ## Process
21
21
 
22
+ > **ANTI-COMPRESSION DIRECTIVE:** When generating files from templates in this module,
23
+ > COPY the FULL text of each template. Do NOT summarize, compress, or "interpret" templates.
24
+ > Every section, every placeholder, every comment must be preserved verbatim.
25
+ > AI systems routinely compress 211-line templates to 60 lines — this is a CRITICAL defect.
26
+ > Validate: generated file line count must be >= 80% of template line count.
27
+
22
28
  ### Step 1: Filter P1 Candidates
23
29
 
24
30
  Select all instruments assigned tier P1 from the Instrument Map (score >= 12 after tier boosts).
@@ -208,6 +214,7 @@ Generate .claude/rules/testing.md:
208
214
  **Trigger:** `IPM.has_ddd == true`
209
215
 
210
216
  Read complete template: `view("references/templates/feature-lifecycle-ent.md")`
217
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
211
218
 
212
219
  ```
213
220
  IF has_ddd:
@@ -254,6 +261,7 @@ IF has_ddd:
254
261
  **Trigger:** Always generated for P1 (enhances developer workflow regardless of pipeline).
255
262
 
256
263
  Read complete template: `view("references/templates/feature-suggestions.md")`
264
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
257
265
 
258
266
  ```
259
267
  7a. Generate .claude/feature-roadmap.json
@@ -305,6 +313,7 @@ Read complete template: `view("references/templates/feature-suggestions.md")`
305
313
  **Trigger:** Always generated for P1 (provides autonomous execution capabilities).
306
314
 
307
315
  Read complete template: `view("references/templates/automation-commands.md")`
316
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
308
317
 
309
318
  ```
310
319
  8a. Generate .claude/commands/go.md
@@ -22,6 +22,12 @@ when DDD documentation is detected.
22
22
 
23
23
  ## Process
24
24
 
25
+ > **ANTI-COMPRESSION DIRECTIVE:** When generating files from templates in this module,
26
+ > COPY the FULL text of each template. Do NOT summarize, compress, or "interpret" templates.
27
+ > Every section, every placeholder, every comment must be preserved verbatim.
28
+ > AI systems routinely compress 211-line templates to 60 lines — this is a CRITICAL defect.
29
+ > Validate: generated file line count must be >= 80% of template line count.
30
+
25
31
  ### Tier Overview
26
32
 
27
33
  ```
@@ -41,6 +47,7 @@ P3 — External Integrations:
41
47
  Source: Pseudocode (SPARC/idea2prd) + Gherkin tests (idea2prd) + Fitness Functions (idea2prd)
42
48
 
43
49
  Read template: `view("references/templates/ddd-agents.md")` section "tdd-guide.md Agent (Enhanced)"
50
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
44
51
 
45
52
  ```
46
53
  Generate .claude/agents/tdd-guide.md:
@@ -156,6 +163,7 @@ skip this entire step.
156
163
  Source: DDD Tactical (aggregates) + Fitness Functions
157
164
 
158
165
  Read template: `view("references/templates/ddd-agents.md")` section "ddd-validator.md Agent"
166
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
159
167
 
160
168
  ```
161
169
  IF has_ddd:
@@ -191,6 +199,7 @@ IF has_ddd:
191
199
  Source: DDD Tactical (aggregates, entities, value-objects)
192
200
 
193
201
  Read template: `view("references/templates/ddd-skills.md")` section "aggregate-patterns/ Skill"
202
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
194
203
 
195
204
  ```
196
205
  IF has_ddd:
@@ -213,6 +222,7 @@ IF has_ddd:
213
222
  Source: DDD Tactical (events)
214
223
 
215
224
  Read template: `view("references/templates/ddd-skills.md")` section "event-handlers/ Skill"
225
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
216
226
 
217
227
  ```
218
228
  IF has_ddd:
@@ -284,6 +294,7 @@ IF has_ddd AND has_fitness:
284
294
  ### Step 3: Generate P3 Items — MCP Configuration
285
295
 
286
296
  Read complete template: `view("references/templates/mcp.md")`
297
+ > CRITICAL: COPY the full template. Do NOT compress or summarize.
287
298
 
288
299
  ```
289
300
  Generate .mcp.json in project root:
@@ -216,6 +216,52 @@ CHECK 20: P3 MCP (IF external integrations detected)
216
216
  [ ] INSTALL.md documents all required env vars from .mcp.json
217
217
  ```
218
218
 
219
+ ### Step 1.5: Automated File-Existence Validation
220
+
221
+ Before proceeding to placeholder scanning, run an automated file-existence check
222
+ against the expected output manifest. This catches the most common generation failure:
223
+ files that should exist but were silently omitted (often due to skipping module files).
224
+
225
+ ```
226
+ AUTOMATED FILE CHECK PROTOCOL:
227
+
228
+ Step 1: Build expected file list from Instrument Map tiers:
229
+ - P0 mandatory: 16 items (always expected)
230
+ - P0 conditional: check IPM flags before expecting
231
+ - P1 core: 10 items (if P1 was executed)
232
+ - P1 conditional: check IPM flags
233
+ - P2/P3: check flags and execution status
234
+
235
+ Step 2: For each expected file, run existence check:
236
+ for file in expected_files:
237
+ if not exists(file.path):
238
+ log CRITICAL: "Missing file: {file.path} (expected from {file.phase})"
239
+ missing_count++
240
+
241
+ Step 3: For each expected directory, verify SKILL.md exists inside:
242
+ for skill_dir in expected_skill_directories:
243
+ if not exists(skill_dir + "/SKILL.md"):
244
+ log CRITICAL: "Missing SKILL.md in {skill_dir}"
245
+ missing_count++
246
+
247
+ Step 4: Verify file sizes (anti-compression check):
248
+ for file in generated_files:
249
+ if file.size_bytes < 100:
250
+ log WARNING: "Suspiciously small file: {file.path} ({file.size_bytes} bytes)"
251
+ log WARNING: "Possible template compression — verify content completeness"
252
+
253
+ Step 5: Report
254
+ if missing_count > 0:
255
+ CRITICAL FAILURE: {missing_count} expected files are missing.
256
+ List each missing file with its expected source phase/module.
257
+ Attempt auto-fix by re-reading the relevant module and regenerating.
258
+ else:
259
+ PASS: All {total_count} expected files exist.
260
+ ```
261
+
262
+ This step was added based on a real-project insight where skipping `modules/04-generate-p1.md`
263
+ caused 10+ P1 artifacts to be silently omitted without any error in the final report.
264
+
219
265
  ### Step 2: Verify Placeholder Substitution
220
266
 
221
267
  Scan ALL generated files for unsubstituted placeholders: