@dzhechkov/p-replicator 1.0.1 → 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.
- package/README.md +25 -3
- package/package.json +6 -3
- package/src/commands/doctor.js +2 -2
- package/src/commands/list.js +1 -1
- package/templates/.claude/rules/replicate-pipeline.md +13 -1
- package/templates/.claude/rules/skill-interface-protocol.md +148 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/SKILL.md +116 -63
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/01-detect-parse.md +329 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/02-analyze-map.md +449 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/03-generate-p0.md +630 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/04-generate-p1.md +537 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/05-generate-p2p3.md +512 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/06-package-deliver.md +710 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/07-harvest-feedback.md +286 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/08-skill-composition.md +378 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/09-cross-project-learning.md +461 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/modules/README.md +83 -0
- package/templates/.claude/skills/cc-toolkit-generator-enhanced/references/maturity-integration.md +198 -0
- package/templates/.claude/skills/pipeline-forge/references/self-extracted-patterns.md +260 -0
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
# Module: Generate P2-P3 (Optional)
|
|
2
|
+
|
|
3
|
+
Phase 5 of the CC-Toolkit-Generator-Enhanced pipeline. Generates optional advanced instruments
|
|
4
|
+
across two tiers: P2 (enhanced development workflow) and P3 (external integrations).
|
|
5
|
+
Items are feature-flagged by project characteristics — DDD-specific items only generate
|
|
6
|
+
when DDD documentation is detected.
|
|
7
|
+
|
|
8
|
+
## Input
|
|
9
|
+
|
|
10
|
+
- **Internal Project Model (IPM)** — from Phase 1 (Detect & Parse)
|
|
11
|
+
- `project_name`, `tech_stack`, `docker_services`, `monorepo_packages`
|
|
12
|
+
- `has_ddd`, `has_gherkin`, `has_fitness`, `has_adr`, `has_c4`
|
|
13
|
+
- `has_external_apis`, `has_database`
|
|
14
|
+
- `detected_integrations[]` — list of external services found in Architecture.md
|
|
15
|
+
- `pipeline_type` — SPARC | IDEA2PRD_FULL | IDEA2PRD_PARTIAL | MINIMAL
|
|
16
|
+
- **Instrument Map** — from Phase 2 (Analyze & Map)
|
|
17
|
+
- Scored instrument list; P2 items have score 8-11, P3 items are external/MCP
|
|
18
|
+
- **P0/P1 Outputs** — from Phase 3-4
|
|
19
|
+
- Existing `.claude/settings.json` with hooks (insights, roadmap, plans, SessionStart)
|
|
20
|
+
- Generated agents, skills, commands, and rules to extend
|
|
21
|
+
- Confirmed file paths and naming conventions
|
|
22
|
+
|
|
23
|
+
## Process
|
|
24
|
+
|
|
25
|
+
### Tier Overview
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
P2 — Enhanced Development Workflow (score 8-11):
|
|
29
|
+
Universal: tdd-guide.md agent, settings.json hooks, /review command
|
|
30
|
+
DDD-only: ddd-validator.md agent, aggregate-patterns/ skill, event-handlers/ skill, /validate-ddd command
|
|
31
|
+
|
|
32
|
+
P3 — External Integrations:
|
|
33
|
+
Universal: .mcp.json
|
|
34
|
+
Specific: Coolify MCP, Docker MCP (based on detection)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Step 1: Generate P2 Universal Items
|
|
38
|
+
|
|
39
|
+
#### 1a. tdd-guide.md Agent
|
|
40
|
+
|
|
41
|
+
Source: Pseudocode (SPARC/idea2prd) + Gherkin tests (idea2prd) + Fitness Functions (idea2prd)
|
|
42
|
+
|
|
43
|
+
Read template: `view("references/templates/ddd-agents.md")` section "tdd-guide.md Agent (Enhanced)"
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
Generate .claude/agents/tdd-guide.md:
|
|
47
|
+
- Set frontmatter:
|
|
48
|
+
name: tdd-guide
|
|
49
|
+
description: TDD guide with Gherkin and pseudocode awareness (include trigger keywords)
|
|
50
|
+
tools: Read, Write, Edit, Bash
|
|
51
|
+
model: sonnet
|
|
52
|
+
skills: testing-patterns
|
|
53
|
+
- Include TDD workflow: Red → Green → Refactor
|
|
54
|
+
- IF has_pseudocode: index all .pseudo files with descriptions
|
|
55
|
+
Fill {{PSEUDOCODE_INDEX}} from docs/pseudocode/*.pseudo file listing
|
|
56
|
+
- IF has_gherkin: index all .feature files with scenario counts
|
|
57
|
+
Fill {{GHERKIN_FEATURES_LIST}} from docs/tests/*.feature file listing
|
|
58
|
+
Include Gherkin-to-test mapping example for the project's tech stack
|
|
59
|
+
Fill {{EXAMPLE_SCENARIO}} from first feature file
|
|
60
|
+
Fill {{TEST_TEMPLATE}} with language-appropriate test boilerplate
|
|
61
|
+
- IF has_fitness: extract coverage requirements
|
|
62
|
+
Fill {{TARGET_LINE}} from fitness function line coverage target
|
|
63
|
+
Fill {{TARGET_BRANCH}} from fitness function branch coverage target
|
|
64
|
+
- ELSE (no Gherkin/Pseudocode): derive from Refinement.md test strategy
|
|
65
|
+
Include standard TDD patterns for the tech stack
|
|
66
|
+
Fill coverage targets with sensible defaults (80% line, 70% branch)
|
|
67
|
+
- Fill {{LANGUAGE}} from IPM tech_stack primary language
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### 1b. settings.json Hooks (Merge)
|
|
71
|
+
|
|
72
|
+
Source: Fitness Functions + DDD Tactical
|
|
73
|
+
|
|
74
|
+
Read template: `view("references/templates/ddd-hooks-commands.md")` section "Fitness Function Hooks"
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
Merge additional hooks into existing .claude/settings.json:
|
|
78
|
+
|
|
79
|
+
EXISTING hooks from P0/P1:
|
|
80
|
+
- Stop: insights auto-commit, roadmap auto-commit, plans auto-commit
|
|
81
|
+
- SessionStart: feature-context.py
|
|
82
|
+
|
|
83
|
+
NEW hooks to ADD (do NOT overwrite existing):
|
|
84
|
+
|
|
85
|
+
IF has_fitness:
|
|
86
|
+
- PreToolUse (matcher: "Write|Edit"):
|
|
87
|
+
command: "$CLAUDE_PROJECT_DIR"/.claude/hooks/validate-aggregate-size.sh "$CLAUDE_FILE_PATH"
|
|
88
|
+
timeout: 10
|
|
89
|
+
|
|
90
|
+
- PostToolUse (matcher: "Write|Edit"):
|
|
91
|
+
command: check-ddd-patterns.sh on aggregate/entity files
|
|
92
|
+
timeout: 30
|
|
93
|
+
|
|
94
|
+
- PostToolUse (matcher: "Write|Edit"):
|
|
95
|
+
command: run tests on .test./.spec. files with coverage
|
|
96
|
+
timeout: 120
|
|
97
|
+
|
|
98
|
+
IF has_ddd:
|
|
99
|
+
- Stop (additional prompt):
|
|
100
|
+
"Before stopping, verify: 1) All aggregate invariants enforced,
|
|
101
|
+
2) Domain events emitted for state changes, 3) Tests cover Gherkin scenarios,
|
|
102
|
+
4) Fitness functions pass."
|
|
103
|
+
timeout: 30
|
|
104
|
+
|
|
105
|
+
Generate hook scripts:
|
|
106
|
+
IF has_fitness OR has_ddd:
|
|
107
|
+
- .claude/hooks/validate-aggregate-size.sh
|
|
108
|
+
Fill {{MAX_ENTITIES_FROM_FITNESS}} from fitness functions (default: 7)
|
|
109
|
+
Fill {{MAX_METHODS_FROM_FITNESS}} from fitness functions (default: 15)
|
|
110
|
+
Make executable: chmod +x
|
|
111
|
+
|
|
112
|
+
- .claude/hooks/check-ddd-patterns.sh
|
|
113
|
+
Validates: no direct entity modification outside aggregate,
|
|
114
|
+
state changes emit domain events
|
|
115
|
+
Make executable: chmod +x
|
|
116
|
+
|
|
117
|
+
Merge strategy:
|
|
118
|
+
1. Read existing settings.json
|
|
119
|
+
2. Parse JSON
|
|
120
|
+
3. For each hook event type (PreToolUse, PostToolUse, Stop, SessionStart):
|
|
121
|
+
- Append new hook entries to existing array
|
|
122
|
+
- Never remove or modify existing entries
|
|
123
|
+
4. Write back valid JSON
|
|
124
|
+
5. Verify JSON validity with json.parse or equivalent
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### 1c. /review Command
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
Generate .claude/commands/review.md:
|
|
131
|
+
- Purpose: On-demand code review using code-reviewer agent
|
|
132
|
+
- $ARGUMENTS: file path, directory, "all", or "staged" (git staged files)
|
|
133
|
+
- Process:
|
|
134
|
+
1. Parse scope from $ARGUMENTS
|
|
135
|
+
2. Gather files to review
|
|
136
|
+
3. Invoke code-reviewer agent analysis
|
|
137
|
+
4. IF has_ddd: include DDD compliance check
|
|
138
|
+
5. IF has_fitness: include fitness function verification
|
|
139
|
+
6. IF has_adr: include ADR compliance check
|
|
140
|
+
7. Generate review report
|
|
141
|
+
- Output format:
|
|
142
|
+
Summary → DDD Compliance → Fitness Functions → ADR Compliance →
|
|
143
|
+
Code Quality → Verdict (APPROVE/REQUEST_CHANGES/COMMENT)
|
|
144
|
+
- Reference code-reviewer.md agent for the actual review logic
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Step 2: Generate P2 DDD-Only Items
|
|
148
|
+
|
|
149
|
+
**Trigger:** `IPM.has_ddd == true`
|
|
150
|
+
|
|
151
|
+
All items in this step are gated by the DDD feature flag. If `has_ddd == false`,
|
|
152
|
+
skip this entire step.
|
|
153
|
+
|
|
154
|
+
#### 2a. ddd-validator.md Agent
|
|
155
|
+
|
|
156
|
+
Source: DDD Tactical (aggregates) + Fitness Functions
|
|
157
|
+
|
|
158
|
+
Read template: `view("references/templates/ddd-agents.md")` section "ddd-validator.md Agent"
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
IF has_ddd:
|
|
162
|
+
Generate .claude/agents/ddd-validator.md:
|
|
163
|
+
- Set frontmatter:
|
|
164
|
+
name: ddd-validator
|
|
165
|
+
description: DDD tactical design validator (include trigger keywords)
|
|
166
|
+
tools: Read, Glob, Grep, Bash
|
|
167
|
+
model: sonnet
|
|
168
|
+
skills: aggregate-patterns, coding-standards
|
|
169
|
+
- Extract aggregate invariants from docs/ddd/tactical/aggregates/
|
|
170
|
+
Fill {{AGGREGATE_INVARIANTS}} with invariant rules per aggregate
|
|
171
|
+
- Extract size limits from fitness functions:
|
|
172
|
+
Fill {{MAX_ENTITIES}} (default: 7)
|
|
173
|
+
Fill {{MAX_METHODS}} (default: 15)
|
|
174
|
+
Fill {{MAX_DEPTH}} (default: 3)
|
|
175
|
+
- Include validation rules:
|
|
176
|
+
- Aggregate rules (root controls modifications, events emitted)
|
|
177
|
+
- Entity rules (identity-based equals, immutable ID)
|
|
178
|
+
- Value Object rules (immutable, property-based equals, no ID)
|
|
179
|
+
- Domain Event rules (past tense naming, immutable payload, aggregate ID, timestamp)
|
|
180
|
+
- Include validation checklist:
|
|
181
|
+
- Aggregate root controls all modifications
|
|
182
|
+
- No direct entity/VO modification from outside
|
|
183
|
+
- Events emitted for state changes
|
|
184
|
+
- Invariants checked before state change
|
|
185
|
+
- Repository per aggregate only
|
|
186
|
+
- Output format: Valid/Warning/Violation per aspect + Fitness Score
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
#### 2b. aggregate-patterns/ Skill
|
|
190
|
+
|
|
191
|
+
Source: DDD Tactical (aggregates, entities, value-objects)
|
|
192
|
+
|
|
193
|
+
Read template: `view("references/templates/ddd-skills.md")` section "aggregate-patterns/ Skill"
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
IF has_ddd:
|
|
197
|
+
Generate .claude/skills/aggregate-patterns/SKILL.md:
|
|
198
|
+
- Extract all aggregates from docs/ddd/tactical/aggregates/
|
|
199
|
+
Fill {{AGGREGATE_LIST_WITH_DESCRIPTIONS}} with name + description
|
|
200
|
+
- Generate language-specific templates based on tech_stack:
|
|
201
|
+
Fill {{LANGUAGE}} from primary language
|
|
202
|
+
Fill {{AGGREGATE_TEMPLATE_FOR_STACK}} — aggregate root class/struct
|
|
203
|
+
Fill {{VALIDATION_PATTERN}} — invariant validation pattern
|
|
204
|
+
Fill {{FACTORY_PATTERN}} — aggregate factory method
|
|
205
|
+
Fill {{ENTITY_ID_PATTERN}} — entity identity pattern
|
|
206
|
+
Fill {{VALUE_OBJECT_PATTERN}} — immutable value object pattern
|
|
207
|
+
- Extract invariants table:
|
|
208
|
+
Fill {{INVARIANTS_TABLE}} with aggregate | invariant | validation mapping
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### 2c. event-handlers/ Skill
|
|
212
|
+
|
|
213
|
+
Source: DDD Tactical (events)
|
|
214
|
+
|
|
215
|
+
Read template: `view("references/templates/ddd-skills.md")` section "event-handlers/ Skill"
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
IF has_ddd:
|
|
219
|
+
Generate .claude/skills/event-handlers/SKILL.md:
|
|
220
|
+
- Extract all domain events from docs/ddd/tactical/events/
|
|
221
|
+
Fill {{EVENTS_TABLE}} with event | aggregate | payload | handlers mapping
|
|
222
|
+
- Generate language-specific patterns:
|
|
223
|
+
Fill {{LANGUAGE}} from primary language
|
|
224
|
+
Fill {{EVENT_EMISSION_PATTERN}} — how aggregates emit events
|
|
225
|
+
Fill {{EVENT_HANDLER_PATTERN}} — handler implementation template
|
|
226
|
+
Fill {{SUBSCRIPTION_PATTERN}} — event subscription/registration
|
|
227
|
+
- Include event flow diagrams:
|
|
228
|
+
Fill {{AGGREGATE}}, {{EVENT}}, {{HANDLER}}, {{TARGET}} per event chain
|
|
229
|
+
- Include anti-patterns section (hardcoded, universal):
|
|
230
|
+
- DON'T modify aggregate state in handler
|
|
231
|
+
- DON'T throw exceptions in handlers (use dead letter)
|
|
232
|
+
- DON'T create circular event chains
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### 2d. /validate-ddd Command
|
|
236
|
+
|
|
237
|
+
Source: Fitness Functions + DDD Tactical
|
|
238
|
+
|
|
239
|
+
Read template: `view("references/templates/ddd-hooks-commands.md")` section "/validate-ddd Command"
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
IF has_ddd:
|
|
243
|
+
Generate .claude/commands/validate-ddd.md:
|
|
244
|
+
- $ARGUMENTS: scope — "all" | "aggregate [name]" | "context [name]"
|
|
245
|
+
- Validation checks:
|
|
246
|
+
Aggregate Validation:
|
|
247
|
+
- Single aggregate root per file
|
|
248
|
+
- All modifications through aggregate root
|
|
249
|
+
- Invariants checked before state changes
|
|
250
|
+
- Events emitted for state changes
|
|
251
|
+
Fitness Functions:
|
|
252
|
+
Fill {{FITNESS_FUNCTIONS_LIST}} from docs/fitness/fitness-functions.md
|
|
253
|
+
Bounded Context Validation:
|
|
254
|
+
- No cross-context direct dependencies
|
|
255
|
+
- Anti-corruption layers in place
|
|
256
|
+
- Shared kernel properly isolated
|
|
257
|
+
- Process: parse scope → scan files → run checks → calculate scores → report
|
|
258
|
+
- Output format: DDD Validation Report with:
|
|
259
|
+
- Per-aggregate status (Valid/Warning/Violation)
|
|
260
|
+
- Fitness function results (Target vs Actual vs Status)
|
|
261
|
+
- Violation details with fix suggestions
|
|
262
|
+
- Overall score out of 100
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
#### 2e. fitness-functions.md Rule
|
|
266
|
+
|
|
267
|
+
Source: Fitness Functions document
|
|
268
|
+
|
|
269
|
+
Read template: `view("references/templates/ddd-hooks-commands.md")` section "Fitness Functions Rule"
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
IF has_ddd AND has_fitness:
|
|
273
|
+
Generate .claude/rules/fitness-functions.md:
|
|
274
|
+
- Extract fitness functions from docs/fitness/fitness-functions.md
|
|
275
|
+
- Map each function to a measurable quality gate:
|
|
276
|
+
Fill {{FITNESS_FUNCTIONS_TABLE}} with name | metric | target | frequency
|
|
277
|
+
- Include enforcement guidance:
|
|
278
|
+
- Which functions run on every commit (fast)
|
|
279
|
+
- Which functions run on PR review (medium)
|
|
280
|
+
- Which functions run on release (slow)
|
|
281
|
+
- Reference /validate-ddd command for DDD-specific fitness checks
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Step 3: Generate P3 Items — MCP Configuration
|
|
285
|
+
|
|
286
|
+
Read complete template: `view("references/templates/mcp.md")`
|
|
287
|
+
|
|
288
|
+
```
|
|
289
|
+
Generate .mcp.json in project root:
|
|
290
|
+
|
|
291
|
+
Step 1: Extract integrations from Architecture.md:
|
|
292
|
+
- Scan for "External Integrations", "Third-Party Services", "API" sections
|
|
293
|
+
- Match each integration against known MCP server list
|
|
294
|
+
|
|
295
|
+
Step 2: Match integrations to MCP servers:
|
|
296
|
+
Priority order:
|
|
297
|
+
1. Exact match → use official server config
|
|
298
|
+
2. Category match → use generic server (e.g., any SQL → postgres server)
|
|
299
|
+
3. No match → add comment for custom consideration
|
|
300
|
+
|
|
301
|
+
Step 3: Build .mcp.json:
|
|
302
|
+
Base structure:
|
|
303
|
+
{ "mcpServers": { ... }, "disabledMcpServers": [] }
|
|
304
|
+
|
|
305
|
+
For each matched integration:
|
|
306
|
+
- Add server config with command, args, env
|
|
307
|
+
- Always use ${VAR_NAME} syntax for secrets (never hardcode)
|
|
308
|
+
- Use descriptive env var names
|
|
309
|
+
|
|
310
|
+
Common server configs (from template):
|
|
311
|
+
| Integration | Package | Env Vars |
|
|
312
|
+
|-------------|---------|----------|
|
|
313
|
+
| GitHub | @modelcontextprotocol/server-github | GITHUB_TOKEN |
|
|
314
|
+
| PostgreSQL | @modelcontextprotocol/server-postgres | DATABASE_URL |
|
|
315
|
+
| Supabase | @supabase/mcp-server | SUPABASE_URL, SUPABASE_KEY |
|
|
316
|
+
| Slack | @modelcontextprotocol/server-slack | SLACK_BOT_TOKEN |
|
|
317
|
+
| Notion | @modelcontextprotocol/server-notion | NOTION_TOKEN |
|
|
318
|
+
| Brave Search | @anthropic/mcp-server-brave-search | BRAVE_API_KEY |
|
|
319
|
+
| Puppeteer | @anthropic/mcp-server-puppeteer | (none) |
|
|
320
|
+
| Sequential Thinking | @anthropic/mcp-server-sequential-thinking | (none) |
|
|
321
|
+
| Memory | @anthropic/mcp-server-memory | (none) |
|
|
322
|
+
| Filesystem | @anthropic/mcp-server-filesystem | (path arg) |
|
|
323
|
+
|
|
324
|
+
Step 4: Conditionally add infrastructure MCP servers:
|
|
325
|
+
|
|
326
|
+
IF "Coolify" detected in Architecture.md or docker-compose.yml:
|
|
327
|
+
Add Coolify MCP server configuration
|
|
328
|
+
Score boost: +8 from recommendations engine
|
|
329
|
+
|
|
330
|
+
IF "Docker" detected in docker_services or Architecture.md:
|
|
331
|
+
Add Docker MCP server configuration
|
|
332
|
+
Score boost: +5 from recommendations engine
|
|
333
|
+
|
|
334
|
+
Step 5: Apply best practices:
|
|
335
|
+
- Keep total enabled servers < 10 (context window impact)
|
|
336
|
+
- Move rarely-used servers to disabledMcpServers[]
|
|
337
|
+
- Document required env vars in INSTALL.md
|
|
338
|
+
|
|
339
|
+
Step 6: Verify output:
|
|
340
|
+
- Parse .mcp.json as JSON — must be valid
|
|
341
|
+
- Verify no hardcoded secrets
|
|
342
|
+
- Verify all env vars use ${} syntax
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Step 4: Update INSTALL.md
|
|
346
|
+
|
|
347
|
+
```
|
|
348
|
+
IF .mcp.json was generated:
|
|
349
|
+
Add MCP Configuration section to INSTALL.md:
|
|
350
|
+
- List all required environment variables from .mcp.json
|
|
351
|
+
- Include setup instructions for each MCP server
|
|
352
|
+
- Note which servers are optional (in disabledMcpServers)
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## Output
|
|
356
|
+
|
|
357
|
+
### Generated Files (P2 Universal)
|
|
358
|
+
|
|
359
|
+
| File | Type | Path |
|
|
360
|
+
|------|------|------|
|
|
361
|
+
| tdd-guide.md | Agent | `.claude/agents/tdd-guide.md` |
|
|
362
|
+
| settings.json | Config (merge) | `.claude/settings.json` |
|
|
363
|
+
| review.md | Command | `.claude/commands/review.md` |
|
|
364
|
+
|
|
365
|
+
### Generated Files (P2 DDD-Only — IF has_ddd)
|
|
366
|
+
|
|
367
|
+
| File | Type | Path |
|
|
368
|
+
|------|------|------|
|
|
369
|
+
| ddd-validator.md | Agent | `.claude/agents/ddd-validator.md` |
|
|
370
|
+
| aggregate-patterns/ | Skill | `.claude/skills/aggregate-patterns/SKILL.md` |
|
|
371
|
+
| event-handlers/ | Skill | `.claude/skills/event-handlers/SKILL.md` |
|
|
372
|
+
| validate-ddd.md | Command | `.claude/commands/validate-ddd.md` |
|
|
373
|
+
|
|
374
|
+
### Generated Files (P2 DDD-Only — Hook Scripts, IF has_fitness OR has_ddd)
|
|
375
|
+
|
|
376
|
+
| File | Type | Path |
|
|
377
|
+
|------|------|------|
|
|
378
|
+
| validate-aggregate-size.sh | Hook Script | `.claude/hooks/validate-aggregate-size.sh` |
|
|
379
|
+
| check-ddd-patterns.sh | Hook Script | `.claude/hooks/check-ddd-patterns.sh` |
|
|
380
|
+
|
|
381
|
+
### Generated Files (P3)
|
|
382
|
+
|
|
383
|
+
| File | Type | Path |
|
|
384
|
+
|------|------|------|
|
|
385
|
+
| .mcp.json | Config | `.mcp.json` (project root) |
|
|
386
|
+
|
|
387
|
+
### Modified Files
|
|
388
|
+
|
|
389
|
+
| File | Modification |
|
|
390
|
+
|------|-------------|
|
|
391
|
+
| `.claude/settings.json` | Merged PreToolUse, PostToolUse, Stop hooks (if DDD/fitness) |
|
|
392
|
+
| `INSTALL.md` | Added MCP environment variable documentation (if .mcp.json generated) |
|
|
393
|
+
|
|
394
|
+
## Quality Gate
|
|
395
|
+
|
|
396
|
+
All of the following must pass before proceeding to Phase 6:
|
|
397
|
+
|
|
398
|
+
### P2 Universal Validation
|
|
399
|
+
|
|
400
|
+
- [ ] `tdd-guide.md` agent generated with correct frontmatter (model, tools, skills)
|
|
401
|
+
- [ ] `tdd-guide.md` includes TDD workflow (Red/Green/Refactor)
|
|
402
|
+
- [ ] `tdd-guide.md` has Gherkin mapping IF has_gherkin, pseudocode index IF has_pseudocode
|
|
403
|
+
- [ ] `settings.json` is valid JSON after merge
|
|
404
|
+
- [ ] Existing hooks preserved — no P0/P1 hooks removed or modified
|
|
405
|
+
- [ ] New hooks correctly appended to existing hook event arrays
|
|
406
|
+
- [ ] `/review` command generated with scope handling ($ARGUMENTS parsing)
|
|
407
|
+
|
|
408
|
+
### P2 DDD-Only Validation (IF has_ddd)
|
|
409
|
+
|
|
410
|
+
- [ ] `ddd-validator.md` agent generated ONLY if `has_ddd == true`
|
|
411
|
+
- [ ] `ddd-validator.md` includes aggregate invariants extracted from source docs
|
|
412
|
+
- [ ] `ddd-validator.md` includes fitness function size limits (or sensible defaults)
|
|
413
|
+
- [ ] `aggregate-patterns/SKILL.md` generated ONLY if `has_ddd == true`
|
|
414
|
+
- [ ] `aggregate-patterns/SKILL.md` includes language-specific templates matching tech stack
|
|
415
|
+
- [ ] `aggregate-patterns/SKILL.md` includes all aggregates from DDD tactical docs
|
|
416
|
+
- [ ] `event-handlers/SKILL.md` generated ONLY if `has_ddd == true`
|
|
417
|
+
- [ ] `event-handlers/SKILL.md` includes event table with aggregate mapping
|
|
418
|
+
- [ ] `event-handlers/SKILL.md` includes anti-patterns section
|
|
419
|
+
- [ ] `/validate-ddd` command generated ONLY if `has_ddd == true`
|
|
420
|
+
- [ ] `/validate-ddd` supports all three scopes: all, aggregate, context
|
|
421
|
+
- [ ] Hook scripts are executable (`chmod +x` applied)
|
|
422
|
+
- [ ] Hook scripts have correct shebang (`#!/bin/bash`)
|
|
423
|
+
- [ ] DDD items have NO presence in output when `has_ddd == false`
|
|
424
|
+
|
|
425
|
+
### P3 Validation
|
|
426
|
+
|
|
427
|
+
- [ ] `.mcp.json` is valid JSON (parseable without errors)
|
|
428
|
+
- [ ] `.mcp.json` contains no hardcoded secrets (all use `${VAR_NAME}` syntax)
|
|
429
|
+
- [ ] Only actually-needed MCP servers are enabled (matched to detected integrations)
|
|
430
|
+
- [ ] Total enabled servers < 10 (context window budget)
|
|
431
|
+
- [ ] `disabledMcpServers` array present (even if empty)
|
|
432
|
+
- [ ] `INSTALL.md` documents all required env vars from `.mcp.json`
|
|
433
|
+
|
|
434
|
+
### Cross-Phase Consistency
|
|
435
|
+
|
|
436
|
+
- [ ] All `{{PLACEHOLDER}}` values substituted with actual project data
|
|
437
|
+
- [ ] No `{{IF_DDD}}` markers in output when `has_ddd == false`
|
|
438
|
+
- [ ] Agent `skills:` references only point to skills that actually exist (generated in P0/P1/P2)
|
|
439
|
+
- [ ] Command cross-references only point to commands that exist
|
|
440
|
+
- [ ] settings.json hook `command` paths reference scripts that exist in `.claude/hooks/`
|
|
441
|
+
|
|
442
|
+
## Dependencies
|
|
443
|
+
|
|
444
|
+
### Template Files (read via view())
|
|
445
|
+
|
|
446
|
+
| Template | Used For |
|
|
447
|
+
|----------|----------|
|
|
448
|
+
| `references/templates/ddd-hooks-commands.md` | DDD hooks, /validate-ddd command, /test enhanced, /deploy enhanced |
|
|
449
|
+
| `references/templates/mcp.md` | .mcp.json generation — server configs, matching rules, best practices |
|
|
450
|
+
| `references/templates/ddd-agents.md` | tdd-guide.md, ddd-validator.md, code-reviewer.md (enhanced) agent templates |
|
|
451
|
+
| `references/templates/ddd-skills.md` | aggregate-patterns/, event-handlers/ skill templates |
|
|
452
|
+
|
|
453
|
+
### Upstream Modules
|
|
454
|
+
|
|
455
|
+
| Module | Provides |
|
|
456
|
+
|--------|----------|
|
|
457
|
+
| `01-detect-parse.md` | IPM with detection flags and integration list |
|
|
458
|
+
| `02-analyze-map.md` | Instrument Map with P2/P3 scored items |
|
|
459
|
+
| `03-generate-p0.md` | Base settings.json, CLAUDE.md, rules to extend |
|
|
460
|
+
| `04-generate-p1.md` | P1 agents/skills/commands that P2 items reference |
|
|
461
|
+
|
|
462
|
+
### Source Documents (from uploads)
|
|
463
|
+
|
|
464
|
+
| Document | Used By |
|
|
465
|
+
|----------|---------|
|
|
466
|
+
| Pseudocode.md / docs/pseudocode/*.pseudo | tdd-guide.md agent |
|
|
467
|
+
| docs/tests/*.feature (Gherkin) | tdd-guide.md, testing hooks |
|
|
468
|
+
| docs/fitness/fitness-functions.md | hooks, ddd-validator, /validate-ddd |
|
|
469
|
+
| docs/ddd/tactical/aggregates/ | ddd-validator, aggregate-patterns |
|
|
470
|
+
| docs/ddd/tactical/events/ | event-handlers skill |
|
|
471
|
+
| docs/ddd/strategic/ | /validate-ddd bounded context validation |
|
|
472
|
+
| Architecture.md | .mcp.json integration detection |
|
|
473
|
+
|
|
474
|
+
## Reusability
|
|
475
|
+
|
|
476
|
+
### Optional Tier Generation with Feature Flags Pattern
|
|
477
|
+
|
|
478
|
+
The P2-P3 generation approach demonstrates a reusable pattern for optional-tier output
|
|
479
|
+
in any multi-file generation system:
|
|
480
|
+
|
|
481
|
+
1. **Feature flag detection** — boolean flags from input analysis control which items generate
|
|
482
|
+
2. **Strict gating** — items only appear in output when their flag is true; no partial generation
|
|
483
|
+
3. **Merge-not-overwrite** — new configuration is merged into existing files, preserving prior content
|
|
484
|
+
4. **Tier isolation** — P2 and P3 items are independent; either can be generated without the other
|
|
485
|
+
5. **Graceful absence** — when flags are false, no trace of gated items appears in output
|
|
486
|
+
|
|
487
|
+
This pattern is applicable to:
|
|
488
|
+
- Plugin systems with optional feature modules
|
|
489
|
+
- Configuration generators with tiered complexity
|
|
490
|
+
- Scaffold tools that adapt to detected capabilities
|
|
491
|
+
- Any system where output should contain zero artifacts for disabled features
|
|
492
|
+
|
|
493
|
+
### MCP Configuration Generation Pattern
|
|
494
|
+
|
|
495
|
+
The .mcp.json generation logic is a reusable pattern for matching detected integrations
|
|
496
|
+
to known service configurations:
|
|
497
|
+
|
|
498
|
+
1. Scan source documents for integration signals
|
|
499
|
+
2. Match against a known server registry with priority (exact > category > none)
|
|
500
|
+
3. Generate configurations with templated environment variables
|
|
501
|
+
4. Apply budget constraints (max servers for context window)
|
|
502
|
+
5. Document requirements in installation guide
|
|
503
|
+
|
|
504
|
+
This pattern works for any system that needs to auto-configure integrations based on
|
|
505
|
+
project analysis — CI/CD configs, docker-compose services, package dependencies, etc.
|
|
506
|
+
|
|
507
|
+
### Hook Merge Strategy
|
|
508
|
+
|
|
509
|
+
The settings.json merge approach (append new hooks to existing event arrays without
|
|
510
|
+
modifying prior entries) is a reusable pattern for incremental configuration building
|
|
511
|
+
across pipeline phases. Each phase can independently add hooks without coordination,
|
|
512
|
+
as long as the merge is additive-only.
|