@anhth2/spec-driven-dev-plugin 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/bin/index.js +285 -11
  2. package/commands/debug.md +233 -11
  3. package/commands/debug.tmpl +170 -6
  4. package/commands/define-product.md +68 -6
  5. package/commands/define-product.tmpl +5 -1
  6. package/commands/fix-bug.md +111 -11
  7. package/commands/fix-bug.tmpl +48 -6
  8. package/commands/generate-bdd.md +86 -9
  9. package/commands/generate-bdd.tmpl +23 -4
  10. package/commands/generate-code.md +146 -19
  11. package/commands/generate-code.tmpl +83 -14
  12. package/commands/generate-design-spec.md +754 -0
  13. package/commands/generate-design-spec.tmpl +399 -0
  14. package/commands/generate-prd.md +91 -7
  15. package/commands/generate-prd.tmpl +28 -2
  16. package/commands/generate-spec-manifest.md +519 -0
  17. package/commands/generate-spec-manifest.tmpl +164 -0
  18. package/commands/generate-tech-docs.md +122 -9
  19. package/commands/generate-tech-docs.tmpl +59 -4
  20. package/commands/generate-tests.md +491 -37
  21. package/commands/generate-tests.tmpl +428 -32
  22. package/commands/refine-prd.md +76 -8
  23. package/commands/refine-prd.tmpl +13 -3
  24. package/commands/review-code.md +94 -6
  25. package/commands/review-code.tmpl +31 -1
  26. package/commands/review-context.md +118 -12
  27. package/commands/review-context.tmpl +55 -7
  28. package/commands/review-tech-docs.md +76 -9
  29. package/commands/review-tech-docs.tmpl +13 -4
  30. package/commands/run-tests.md +196 -18
  31. package/commands/run-tests.tmpl +133 -13
  32. package/commands/setup-ai-first.md +192 -6
  33. package/commands/setup-ai-first.tmpl +136 -5
  34. package/commands/smoke-test.md +228 -22
  35. package/commands/smoke-test.tmpl +165 -17
  36. package/commands/validate-traces.md +77 -8
  37. package/commands/validate-traces.tmpl +14 -3
  38. package/core/FRAMEWORK_VERSION +1 -1
  39. package/core/commands/debug.md +233 -11
  40. package/core/commands/define-product.md +68 -6
  41. package/core/commands/fix-bug.md +111 -11
  42. package/core/commands/generate-bdd.md +86 -9
  43. package/core/commands/generate-code.md +146 -19
  44. package/core/commands/generate-design-spec.md +754 -0
  45. package/core/commands/generate-prd.md +91 -7
  46. package/core/commands/generate-spec-manifest.md +519 -0
  47. package/core/commands/generate-tech-docs.md +122 -9
  48. package/core/commands/generate-tests.md +491 -37
  49. package/core/commands/refine-prd.md +76 -8
  50. package/core/commands/review-code.md +94 -6
  51. package/core/commands/review-context.md +118 -12
  52. package/core/commands/review-tech-docs.md +76 -9
  53. package/core/commands/run-tests.md +196 -18
  54. package/core/commands/setup-ai-first.md +192 -6
  55. package/core/commands/smoke-test.md +228 -22
  56. package/core/commands/validate-traces.md +77 -8
  57. package/core/skills/code/SKILL.md +68 -8
  58. package/core/skills/debug/SKILL.md +72 -10
  59. package/core/skills/design-spec/SKILL.md +450 -0
  60. package/core/skills/discovery/SKILL.md +62 -4
  61. package/core/skills/prd/SKILL.md +12 -8
  62. package/core/skills/setup-ai-first/SKILL.md +5 -3
  63. package/core/skills/spec/SKILL.md +11 -7
  64. package/core/skills/test/SKILL.md +130 -12
  65. package/core/steps/context-loader.md +57 -1
  66. package/core/steps/gate.md +1 -1
  67. package/core/steps/report-footer.md +5 -3
  68. package/core/steps/spawn-agent.md +3 -1
  69. package/core/templates/design-spec.template.md +209 -0
  70. package/core/templates/project-context.yaml +29 -0
  71. package/package.json +1 -1
  72. package/skills/code/SKILL.md +68 -8
  73. package/skills/debug/SKILL.md +72 -10
  74. package/skills/design-spec/SKILL.md +450 -0
  75. package/skills/design-spec/SKILL.tmpl +95 -0
  76. package/skills/discovery/SKILL.md +62 -4
  77. package/skills/prd/SKILL.md +12 -8
  78. package/skills/setup-ai-first/SKILL.md +5 -3
  79. package/skills/spec/SKILL.md +11 -7
  80. package/skills/test/SKILL.md +130 -12
  81. package/steps/context-loader.md +57 -1
  82. package/steps/gate.md +1 -1
  83. package/steps/report-footer.md +5 -3
  84. package/steps/spawn-agent.md +3 -1
  85. package/templates/design-spec.template.md +209 -0
  86. package/templates/project-context.yaml +29 -0
@@ -58,7 +58,9 @@ summary:
58
58
  /refine-prd Complete — {PRD name}
59
59
  Findings: {total} | 🔴 Critical: {N} | 🟡 Major: {N} | 🟢 Minor: {N}
60
60
  Review: {paths.refinement_dir}/{prd-slug}-findings.yaml
61
- Next: Open in Review Board (right-click file) → Update PRD → /generate-bdd
61
+ Next: Open in Review Board (right-click file) → Update PRD
62
+ → /review-context {prd-file} ← verify PRD quality before generating BDD
63
+ → /generate-bdd {prd-file}
62
64
  ```
63
65
 
64
66
  ---
@@ -77,9 +79,16 @@ Next: Open in Review Board (right-click file) → Update PRD → /generate-bdd
77
79
 
78
80
  For each accepted finding, in order of severity (critical → major → minor):
79
81
  - Navigate to the PRD section indicated by `finding.section`.
80
- - Apply `finding.suggestion` (or the note from `modified` status if applicable).
82
+ - Apply `finding.suggestion`. For `status: "modified"` findings, the human has already edited `finding.suggestion` in the Review Board — that edited value IS the fix to apply.
81
83
  - Do not alter any sections not referenced by an accepted finding.
82
84
 
85
+ ### Phase 2.5 — Update findings file
86
+
87
+ For each finding that was applied (status was `accepted` or `modified`):
88
+ - Set `status: "applied"` in `{paths.refinement_dir}/{prd-slug}-findings.yaml`.
89
+
90
+ Update `summary.status: "applied"` in the findings file.
91
+
83
92
  ### Phase 3 — Bump version & write changelog entry
84
93
 
85
94
  1. Read current `| **Version** |` value from PRD metadata table.
@@ -107,5 +116,6 @@ Changes :
107
116
  - {change 2}
108
117
 
109
118
  ⚠️ BDD may be outdated. Run:
110
- /generate-bdd {prd-file}
119
+ /review-context {prd-file} ← verify PRD quality first
120
+ → /generate-bdd {prd-file}
111
121
  ```
@@ -33,7 +33,7 @@ Display and wait for response:
33
33
  ```
34
34
  ⚙️ MODEL CHECK
35
35
  ──────────────────────────────────────────────────────────────────
36
- Recommended : claude-opus-4-5 (or claude-opus-4)
36
+ Recommended : claude-opus-4 (or latest Opus model)
37
37
  Why needed : Spec analysis, architecture review, code generation
38
38
  require deep reasoning. Smaller models miss edge cases.
39
39
 
@@ -133,6 +133,7 @@ Read `.agent/project-context.yaml`. Extract and store:
133
133
  - `paths.core_entities` → path to core-entities.md
134
134
  - `paths.tech_docs_dir` → technical documentation root
135
135
  - `paths.trace_dir` → trace state directory
136
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
136
137
 
137
138
  If `paths` section is absent, use these defaults:
138
139
  - `specs_dir` = `specs/bdd`
@@ -142,13 +143,46 @@ If `paths` section is absent, use these defaults:
142
143
  - `domain_knowledge_dir` = `specs/domain-knowledge`
143
144
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
144
145
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
145
- - `tech_docs_dir` = `tech-docs`
146
+ - `tech_docs_dir` = `specs/tech-docs`
146
147
  - `trace_dir` = `.trace`
148
+ - `design_spec_dir` = `specs/design-spec`
147
149
 
148
150
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
149
151
 
150
152
  ---
151
153
 
154
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
155
+
156
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
157
+
158
+ If `services` section is present:
159
+
160
+ **1. Detect active domain** (in priority order):
161
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
162
+ - Extract from target file path: segment immediately after `prd_dir` base path
163
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
164
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
165
+
166
+ **2. Route to service** — if active domain matches a key in `services`:
167
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
168
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
169
+ - Store `active_service` = `services.{domain}.path`
170
+ - Store `active_service_module` = `services.{domain}.module`
171
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
172
+
173
+ **3. Fallback** — if domain not detected or no matching service key:
174
+ - Keep default paths from Step 1
175
+ - Set `active_service = unresolved`
176
+
177
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
178
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
179
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
180
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
181
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
182
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
183
+
184
+ ---
185
+
152
186
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
153
187
 
154
188
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -219,6 +253,26 @@ If the file does not exist → skip silently.
219
253
 
220
254
  ---
221
255
 
256
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
257
+
258
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
259
+
260
+ ```
261
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
262
+ ```
263
+
264
+ | `platform_type` | Modules |
265
+ |---|---|
266
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
267
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
268
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
269
+
270
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
271
+
272
+ These two variables (`active_module`, `platform_type`) are the canonical source for all branching logic in commands that need platform-specific behavior (generate-tests, debug, fix-bug, smoke-test).
273
+
274
+ ---
275
+
222
276
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
223
277
 
224
278
  After loading all context, synthesize and output a compact summary block.
@@ -229,10 +283,12 @@ Output exactly this block:
229
283
  ```
230
284
  [CTX LOADED]
231
285
  Stack : {language} / {framework} / {database}
286
+ Platform : {active_module} ({platform_type})
232
287
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
233
288
  Ticket : {ticket_prefix}-
234
289
  Dict : {loaded — N canonical terms, M banned terms | missing}
235
290
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
291
+ Service : {active_service} ({active_service_module}) | single-service
236
292
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
237
293
  ```
238
294
 
@@ -254,6 +310,26 @@ After completing all steps, you have loaded:
254
310
  Proceed to the next step of the calling command.
255
311
 
256
312
 
313
+ ---
314
+
315
+ ## Pre-Review Scan
316
+
317
+ *(Separate from the Gate CHECKPOINT — this lists the actual files and scenarios in scope.)*
318
+
319
+ Scan for implementation files and scenarios, then display:
320
+
321
+ ```
322
+ Review Scope — {UC-ID}
323
+ ──────────────────────────────────────
324
+ UC : {UC-ID}
325
+ Files : {list of files tagged @trace.implements={UC-ID}}
326
+ Scenarios : {N} scenarios in .feature file
327
+
328
+ Proceed with review? (Y/N)
329
+ ```
330
+
331
+ Wait for explicit "Y" before proceeding.
332
+
257
333
  ---
258
334
 
259
335
  ## Review Dimensions
@@ -262,7 +338,7 @@ Proceed to the next step of the calling command.
262
338
  - [ ] Every controller endpoint has `@trace.implements` tag?
263
339
  - [ ] Every test file has `@trace.verifies` tag?
264
340
  - [ ] No `@trace` tags on wrong layers?
265
- - [ ] `{paths.trace_dir}/{UC-ID}.tsv` up to date?
341
+ - [ ] `{paths.trace_dir}/{UC-ID}.tsv` up to date? (if stale → run `/validate-traces {UC-ID}` first, then re-run this review)
266
342
 
267
343
  ### 2. Layer Architecture (from CLAUDE.md §2)
268
344
  - [ ] Each class in the correct layer?
@@ -310,21 +386,23 @@ Suggest the logical next command based on workflow phase:
310
386
 
311
387
  | Current command | Suggest next |
312
388
  |-------------------------|-----------------------------------------------|
389
+ | /setup-ai-first | `/define-product` to start your first feature |
313
390
  | /define-product | `/generate-prd {product-definition-file}` |
314
391
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
315
392
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
316
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
393
+ | /review-context (PRD) | FE/App: `/generate-design-spec {prd-file}` (then BDD after sign-off); BE: `/generate-bdd {prd-file}` directly; fix PRD if NEEDS_FIX |
394
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
317
395
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
318
396
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
319
397
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
320
398
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
321
- | /generate-code | `/generate-tests {UC-ID}` |
399
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
322
400
  | /generate-tests | `/run-tests {UC-ID}` |
323
401
  | /run-tests (passing) | `/review-code {UC-ID}` |
324
402
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
325
403
  | /review-code | `/smoke-test {UC-ID}` or create PR |
326
404
  | /smoke-test | Create PR and link to ticket |
327
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
405
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
328
406
  | /fix-bug | Create PR and link to ticket |
329
407
  | /debug | `/fix-bug {ticket-id}` if fix needed |
330
408
 
@@ -350,5 +428,15 @@ Critical: {X} | Major: {Y} | Minor: {Z}
350
428
  ### Minor
351
429
  | # | File | Line | Issue | Suggested Fix |
352
430
 
431
+ Output Artifacts: none (read-only)
432
+
353
433
  Verdict: APPROVED ✅ | NEEDS_FIX ❌
434
+
435
+ If APPROVED ✅:
436
+ Next: /generate-tests {UC-ID}
437
+
438
+ If NEEDS_FIX ❌:
439
+ - Small fix (1–3 lines, no logic change) → fix inline → re-run /review-code {UC-ID}
440
+ - Logic / architecture issue → /fix-bug {TICKET_ID}
441
+ - Spec mismatch (code ≠ scenario) → /generate-code {feature-file} (re-gen affected UC)
354
442
  ```
@@ -12,13 +12,33 @@
12
12
 
13
13
  ---
14
14
 
15
+ ## Pre-Review Scan
16
+
17
+ *(Separate from the Gate CHECKPOINT — this lists the actual files and scenarios in scope.)*
18
+
19
+ Scan for implementation files and scenarios, then display:
20
+
21
+ ```
22
+ Review Scope — {UC-ID}
23
+ ──────────────────────────────────────
24
+ UC : {UC-ID}
25
+ Files : {list of files tagged @trace.implements={UC-ID}}
26
+ Scenarios : {N} scenarios in .feature file
27
+
28
+ Proceed with review? (Y/N)
29
+ ```
30
+
31
+ Wait for explicit "Y" before proceeding.
32
+
33
+ ---
34
+
15
35
  ## Review Dimensions
16
36
 
17
37
  ### 1. Traceability
18
38
  - [ ] Every controller endpoint has `@trace.implements` tag?
19
39
  - [ ] Every test file has `@trace.verifies` tag?
20
40
  - [ ] No `@trace` tags on wrong layers?
21
- - [ ] `{paths.trace_dir}/{UC-ID}.tsv` up to date?
41
+ - [ ] `{paths.trace_dir}/{UC-ID}.tsv` up to date? (if stale → run `/validate-traces {UC-ID}` first, then re-run this review)
22
42
 
23
43
  ### 2. Layer Architecture (from CLAUDE.md §2)
24
44
  - [ ] Each class in the correct layer?
@@ -53,5 +73,15 @@ Critical: {X} | Major: {Y} | Minor: {Z}
53
73
  ### Minor
54
74
  | # | File | Line | Issue | Suggested Fix |
55
75
 
76
+ Output Artifacts: none (read-only)
77
+
56
78
  Verdict: APPROVED ✅ | NEEDS_FIX ❌
79
+
80
+ If APPROVED ✅:
81
+ Next: /generate-tests {UC-ID}
82
+
83
+ If NEEDS_FIX ❌:
84
+ - Small fix (1–3 lines, no logic change) → fix inline → re-run /review-code {UC-ID}
85
+ - Logic / architecture issue → /fix-bug {TICKET_ID}
86
+ - Spec mismatch (code ≠ scenario) → /generate-code {feature-file} (re-gen affected UC)
57
87
  ```
@@ -34,7 +34,7 @@ Display and wait for response:
34
34
  ```
35
35
  ⚙️ MODEL CHECK
36
36
  ──────────────────────────────────────────────────────────────────
37
- Recommended : claude-opus-4-5 (or claude-opus-4)
37
+ Recommended : claude-opus-4 (or latest Opus model)
38
38
  Why needed : Spec analysis, architecture review, code generation
39
39
  require deep reasoning. Smaller models miss edge cases.
40
40
 
@@ -138,6 +138,7 @@ Read `.agent/project-context.yaml`. Extract and store:
138
138
  - `paths.core_entities` → path to core-entities.md
139
139
  - `paths.tech_docs_dir` → technical documentation root
140
140
  - `paths.trace_dir` → trace state directory
141
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
141
142
 
142
143
  If `paths` section is absent, use these defaults:
143
144
  - `specs_dir` = `specs/bdd`
@@ -147,13 +148,46 @@ If `paths` section is absent, use these defaults:
147
148
  - `domain_knowledge_dir` = `specs/domain-knowledge`
148
149
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
149
150
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
150
- - `tech_docs_dir` = `tech-docs`
151
+ - `tech_docs_dir` = `specs/tech-docs`
151
152
  - `trace_dir` = `.trace`
153
+ - `design_spec_dir` = `specs/design-spec`
152
154
 
153
155
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
154
156
 
155
157
  ---
156
158
 
159
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
160
+
161
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
162
+
163
+ If `services` section is present:
164
+
165
+ **1. Detect active domain** (in priority order):
166
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
167
+ - Extract from target file path: segment immediately after `prd_dir` base path
168
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
169
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
170
+
171
+ **2. Route to service** — if active domain matches a key in `services`:
172
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
173
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
174
+ - Store `active_service` = `services.{domain}.path`
175
+ - Store `active_service_module` = `services.{domain}.module`
176
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
177
+
178
+ **3. Fallback** — if domain not detected or no matching service key:
179
+ - Keep default paths from Step 1
180
+ - Set `active_service = unresolved`
181
+
182
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
183
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
184
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
185
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
186
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
187
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
188
+
189
+ ---
190
+
157
191
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
158
192
 
159
193
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -224,6 +258,26 @@ If the file does not exist → skip silently.
224
258
 
225
259
  ---
226
260
 
261
+ ## Step 6.5 — [PLATFORM] Derive active_module and platform_type
262
+
263
+ Using `tech_stack.module` loaded in Step 1, derive and store two variables for use by all downstream commands:
264
+
265
+ ```
266
+ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
267
+ ```
268
+
269
+ | `platform_type` | Modules |
270
+ |---|---|
271
+ | `backend` | `java-spring`, `golang`, `dotnet`, `php-laravel`, `context-engineering` |
272
+ | `web-frontend` | `react`, `nextjs`, `vue`, `nuxt`, `angular` |
273
+ | `mobile` | `flutter`, `react-native`, `ios-swiftui`, `android-compose` |
274
+
275
+ If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
276
+
277
+ These two variables (`active_module`, `platform_type`) are the canonical source for all branching logic in commands that need platform-specific behavior (generate-tests, debug, fix-bug, smoke-test).
278
+
279
+ ---
280
+
227
281
  ## Step 7 — [RECAP] Working Memory Recap (anti-lost-in-middle)
228
282
 
229
283
  After loading all context, synthesize and output a compact summary block.
@@ -234,10 +288,12 @@ Output exactly this block:
234
288
  ```
235
289
  [CTX LOADED]
236
290
  Stack : {language} / {framework} / {database}
291
+ Platform : {active_module} ({platform_type})
237
292
  Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
238
293
  Ticket : {ticket_prefix}-
239
294
  Dict : {loaded — N canonical terms, M banned terms | missing}
240
295
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
296
+ Service : {active_service} ({active_service_module}) | single-service
241
297
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
242
298
  ```
243
299
 
@@ -280,6 +336,44 @@ Derive the output findings filename:
280
336
 
281
337
  ## PRD Review Mode
282
338
 
339
+ ### P0 — Umbrella Routing Check (umbrella mode only)
340
+
341
+ *Skip this check entirely if `setup.mode` is not `"umbrella"` (i.e., `services` section absent from project-context.yaml).*
342
+
343
+ When `setup.mode = umbrella`, the PRD must have correct routing metadata so context-loader Step 1.5 can direct generated output to the right service submodule. Run these checks **before P1–P5**:
344
+
345
+ **P0.1 — `@trace.domain` presence**
346
+ - Read the PRD frontmatter block (lines starting with `@trace.` at top of file)
347
+ - If `@trace.domain` is **absent** → **critical** finding:
348
+ - `finding`: "`@trace.domain` is missing. Dev team's umbrella routing depends on this field to route BDD and code output to the correct service submodule."
349
+ - `suggestion`: "Add `@trace.domain: {domain}` to the PRD frontmatter. Use one of the domain keys defined in the umbrella's `project-context.yaml` services section."
350
+ - `auto_fixable: false` — PO must confirm the correct domain name
351
+
352
+ **P0.2 — `@trace.domain` matches a service key**
353
+ - If `@trace.domain` is present, check if its value matches any key in the `services` section of project-context.yaml
354
+ - If **no match found** → **critical** finding:
355
+ - `finding`: "`@trace.domain: {value}` does not match any key in the umbrella's `services` config. Routing will fall back to default paths and BDD may be generated to the wrong location."
356
+ - `suggestion`: "Either update `@trace.domain` to match an existing service key ({list known keys}), or add a new entry to `services` in project-context.yaml for domain `{value}`."
357
+ - `auto_fixable: false`
358
+ - If `services` section is not yet configured (empty/placeholder) → **major** finding:
359
+ - `finding`: "Umbrella `services` section is not yet configured. Cannot verify domain routing."
360
+ - `suggestion`: "Update `.agent/project-context.yaml` services section with domain-to-submodule mapping before generating BDD."
361
+ - `auto_fixable: false`
362
+
363
+ **P0.3 — `@trace.status` check**
364
+ - If `@trace.status` is absent → **minor**, `auto_fixable: true` (add `@trace.status: draft`)
365
+ - If `@trace.status: draft` → **major**, `auto_fixable: false`:
366
+ - `finding`: "PRD status is `draft`. Dev team should not generate BDD from an unapproved PRD."
367
+ - `suggestion`: "PO/SA should review and update status to `approved` before dev team proceeds."
368
+
369
+ > **P0 is a gate check:** If P0.1 or P0.2 yields a critical finding, display a warning before proceeding:
370
+ > ```
371
+ > ⚠️ ROUTING WARNING: @trace.domain issue detected.
372
+ > BDD/code generated from this PRD may land in the wrong service submodule.
373
+ > Resolve P0 findings before running /generate-bdd.
374
+ > ```
375
+ > Then continue with P1–P5 (do not abort — PO may be reviewing early-stage PRDs).
376
+
283
377
  ### P1 — Terminology Check (Business Dictionary)
284
378
 
285
379
  Load `{paths.business_dictionary}`.
@@ -379,14 +473,15 @@ Using `{paths.business_dictionary}` and `{paths.core_entities}`:
379
473
  ### B4 — Compliance Checks (C.1–C.5)
380
474
 
381
475
  - [ ] C.1 Wireframe Coverage: every screen component/action has ≥1 SC → finding per missing item
382
- - [ ] C.2 PRD Traceability: same as B1 (deduplicate)
476
+ - [ ] C.2 PRD Traceability: covered fully by B1 — do NOT create new findings here; deduplicate against B1 findings
383
477
  - [ ] C.3 Business Dictionary terms used → same as B2
384
478
  - [ ] C.4 Banned Terms: 0 banned terms → **critical**, auto-fixable
385
479
  - [ ] C.5 NHÓM Grouping: if ≥3 SCs, grouped by business theme → **major**, auto-fixable
386
480
 
387
481
  ### B5 — Metadata & Structural Check
388
482
 
389
- - [ ] File header has all `@trace.*` fields → **minor**, auto-fixable
483
+ - [ ] File header has all required `@trace.*` fields — check each explicitly: `@trace.id`, `@trace.title`, `@trace.revision`, `@trace.domain`, `@trace.service`, `@trace.module`, `@trace.status`, `@trace.author`, `@trace.created_at`, `@trace.prd`, `@trace.prd_version`, `@trace.bdd_version`, `@trace.business_rules`, `@trace.dataset` → **minor** per missing field, auto-fixable
484
+ - Note: `@trace.revision` is always `1` (static field — see generate-bdd.tmpl). Only check for presence; do NOT flag value as stale.
390
485
  - [ ] Every scenario has `# @trace.scenario`, `# @trace.sc_version`, `# @trace.business_rules`, `# Side-effects:` → **minor**, auto-fixable
391
486
  - [ ] Coverage Matrix at end of file → **major**, auto-fixable (AI regenerates)
392
487
  - [ ] Pre-merge Checklist at end of file → **minor**, auto-fixable
@@ -467,21 +562,23 @@ Suggest the logical next command based on workflow phase:
467
562
 
468
563
  | Current command | Suggest next |
469
564
  |-------------------------|-----------------------------------------------|
565
+ | /setup-ai-first | `/define-product` to start your first feature |
470
566
  | /define-product | `/generate-prd {product-definition-file}` |
471
567
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
472
568
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
473
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
569
+ | /review-context (PRD) | FE/App: `/generate-design-spec {prd-file}` (then BDD after sign-off); BE: `/generate-bdd {prd-file}` directly; fix PRD if NEEDS_FIX |
570
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
474
571
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
475
572
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
476
573
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
477
574
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
478
- | /generate-code | `/generate-tests {UC-ID}` |
575
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
479
576
  | /generate-tests | `/run-tests {UC-ID}` |
480
577
  | /run-tests (passing) | `/review-code {UC-ID}` |
481
578
  | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
482
579
  | /review-code | `/smoke-test {UC-ID}` or create PR |
483
580
  | /smoke-test | Create PR and link to ticket |
484
- | /validate-traces | `/generate-code {UC-ID}` for gaps |
581
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
485
582
  | /fix-bug | Create PR and link to ticket |
486
583
  | /debug | `/fix-bug {ticket-id}` if fix needed |
487
584
 
@@ -500,7 +597,9 @@ Mode: {PRD | BDD}
500
597
  Findings: {total} | 🔴 Critical: {N} | 🟡 Major: {N} | 🟢 Minor: {N}
501
598
  Auto-fixable: {N} | Needs human decision: {N}
502
599
 
503
- Findings file: {paths.refinement_dir}/{slug}-findings.yaml
600
+ Findings file:
601
+ {If PRD}: {paths.refinement_dir}/{prd-slug}-review-context-findings.yaml
602
+ {If BDD}: {paths.refinement_dir}/{uc-id}-review-bdd-findings.yaml
504
603
 
505
604
  Next options:
506
605
  A) Quick fix : /review-context --fix {target-file}
@@ -536,6 +635,7 @@ For each finding where `auto_fixable: true`, in order (critical → major → mi
536
635
 
537
636
  | check_id | What to apply |
538
637
  |----------|--------------|
638
+ | P0.3 (Missing status) | Add `@trace.status: draft` to frontmatter |
539
639
  | P1 (Banned term) | Replace every banned term occurrence with canonical term |
540
640
  | P4 (Structure) | Add missing section/metadata skeleton |
541
641
 
@@ -557,7 +657,7 @@ After applying each finding, mark it `status: "applied_automatically"` in the fi
557
657
 
558
658
  ### Phase 3 — Version bump
559
659
 
560
- - **PRD**: if ≥1 finding applied → bump minor version, add Changelog entry:
660
+ - **PRD**: if ≥1 finding applied → bump **minor** version (auto-fix only applies P1 banned-term replacements and P4 skeleton additions — never alters UC structure or BR content, so minor bump is always correct), add Changelog entry:
561
661
  `Auto-fix: applied {N} auto-fixable review-context findings`
562
662
  - **BDD**: if ≥1 finding applied → increment `@trace.bdd_version` by 0.1
563
663
 
@@ -577,7 +677,9 @@ Still pending (needs human decision): {N}
577
677
  {If PRD}: Version bumped: {old} → {new}
578
678
  {If BDD}: bdd_version: {old} → {new}
579
679
 
580
- Findings file: {paths.refinement_dir}/{slug}-findings.yaml
680
+ Findings file:
681
+ {If PRD}: {paths.refinement_dir}/{prd-slug}-review-context-findings.yaml
682
+ {If BDD}: {paths.refinement_dir}/{uc-id}-review-bdd-findings.yaml
581
683
  Re-run /review-context {file} to confirm 0 remaining critical findings.
582
684
  ```
583
685
 
@@ -596,8 +698,10 @@ Open findings file in Review Board → then run: /review-context --resume {file}
596
698
 
597
699
  ### Phase 1 — Read accepted findings
598
700
 
599
- 1. Derive findings filename from target file (same rule as above).
600
- 2. Read `{paths.refinement_dir}/{slug}-findings.yaml`.
701
+ 1. Derive findings filename from target file using the same rule as Detect Review Mode:
702
+ - PRD: `{paths.refinement_dir}/{prd-slug}-review-context-findings.yaml`
703
+ - BDD: `{paths.refinement_dir}/{uc-id}-review-bdd-findings.yaml`
704
+ 2. Read the findings file.
601
705
  3. Collect findings where `status: "accepted"` or `status: "modified"`.
602
706
  4. If none → report "No accepted findings. File unchanged." and stop.
603
707
 
@@ -608,6 +712,7 @@ Apply in order: critical → major → minor.
608
712
  **For PRD findings:**
609
713
  | check_id | What to do |
610
714
  |----------|-----------|
715
+ | P0.3 (Missing status) | Add `@trace.status: draft` to frontmatter |
611
716
  | P1 (Banned term) | Replace every occurrence of banned term with canonical term |
612
717
  | P2 (Ambiguity) | Apply the fix stated in `suggestion` or `modified` note |
613
718
  | P3 (Conflict) | Apply the resolution stated in the modified note |
@@ -627,6 +732,7 @@ Apply in order: critical → major → minor.
627
732
  | B6 (Side effects) | Add missing `And <side-effect>` to Then block |
628
733
 
629
734
  → After applying, increment `@trace.bdd_version` in file header by 0.1.
735
+ → Also update `{paths.trace_dir}/{UC-ID}.tsv`: set `bdd_version` column to the new `@trace.bdd_version` value for all rows, and set `last_updated` to today's date.
630
736
 
631
737
  ### Phase 3 — Report
632
738
 
@@ -36,6 +36,44 @@ Derive the output findings filename:
36
36
 
37
37
  ## PRD Review Mode
38
38
 
39
+ ### P0 — Umbrella Routing Check (umbrella mode only)
40
+
41
+ *Skip this check entirely if `setup.mode` is not `"umbrella"` (i.e., `services` section absent from project-context.yaml).*
42
+
43
+ When `setup.mode = umbrella`, the PRD must have correct routing metadata so context-loader Step 1.5 can direct generated output to the right service submodule. Run these checks **before P1–P5**:
44
+
45
+ **P0.1 — `@trace.domain` presence**
46
+ - Read the PRD frontmatter block (lines starting with `@trace.` at top of file)
47
+ - If `@trace.domain` is **absent** → **critical** finding:
48
+ - `finding`: "`@trace.domain` is missing. Dev team's umbrella routing depends on this field to route BDD and code output to the correct service submodule."
49
+ - `suggestion`: "Add `@trace.domain: {domain}` to the PRD frontmatter. Use one of the domain keys defined in the umbrella's `project-context.yaml` services section."
50
+ - `auto_fixable: false` — PO must confirm the correct domain name
51
+
52
+ **P0.2 — `@trace.domain` matches a service key**
53
+ - If `@trace.domain` is present, check if its value matches any key in the `services` section of project-context.yaml
54
+ - If **no match found** → **critical** finding:
55
+ - `finding`: "`@trace.domain: {value}` does not match any key in the umbrella's `services` config. Routing will fall back to default paths and BDD may be generated to the wrong location."
56
+ - `suggestion`: "Either update `@trace.domain` to match an existing service key ({list known keys}), or add a new entry to `services` in project-context.yaml for domain `{value}`."
57
+ - `auto_fixable: false`
58
+ - If `services` section is not yet configured (empty/placeholder) → **major** finding:
59
+ - `finding`: "Umbrella `services` section is not yet configured. Cannot verify domain routing."
60
+ - `suggestion`: "Update `.agent/project-context.yaml` services section with domain-to-submodule mapping before generating BDD."
61
+ - `auto_fixable: false`
62
+
63
+ **P0.3 — `@trace.status` check**
64
+ - If `@trace.status` is absent → **minor**, `auto_fixable: true` (add `@trace.status: draft`)
65
+ - If `@trace.status: draft` → **major**, `auto_fixable: false`:
66
+ - `finding`: "PRD status is `draft`. Dev team should not generate BDD from an unapproved PRD."
67
+ - `suggestion`: "PO/SA should review and update status to `approved` before dev team proceeds."
68
+
69
+ > **P0 is a gate check:** If P0.1 or P0.2 yields a critical finding, display a warning before proceeding:
70
+ > ```
71
+ > ⚠️ ROUTING WARNING: @trace.domain issue detected.
72
+ > BDD/code generated from this PRD may land in the wrong service submodule.
73
+ > Resolve P0 findings before running /generate-bdd.
74
+ > ```
75
+ > Then continue with P1–P5 (do not abort — PO may be reviewing early-stage PRDs).
76
+
39
77
  ### P1 — Terminology Check (Business Dictionary)
40
78
 
41
79
  Load `{paths.business_dictionary}`.
@@ -135,14 +173,15 @@ Using `{paths.business_dictionary}` and `{paths.core_entities}`:
135
173
  ### B4 — Compliance Checks (C.1–C.5)
136
174
 
137
175
  - [ ] C.1 Wireframe Coverage: every screen component/action has ≥1 SC → finding per missing item
138
- - [ ] C.2 PRD Traceability: same as B1 (deduplicate)
176
+ - [ ] C.2 PRD Traceability: covered fully by B1 — do NOT create new findings here; deduplicate against B1 findings
139
177
  - [ ] C.3 Business Dictionary terms used → same as B2
140
178
  - [ ] C.4 Banned Terms: 0 banned terms → **critical**, auto-fixable
141
179
  - [ ] C.5 NHÓM Grouping: if ≥3 SCs, grouped by business theme → **major**, auto-fixable
142
180
 
143
181
  ### B5 — Metadata & Structural Check
144
182
 
145
- - [ ] File header has all `@trace.*` fields → **minor**, auto-fixable
183
+ - [ ] File header has all required `@trace.*` fields — check each explicitly: `@trace.id`, `@trace.title`, `@trace.revision`, `@trace.domain`, `@trace.service`, `@trace.module`, `@trace.status`, `@trace.author`, `@trace.created_at`, `@trace.prd`, `@trace.prd_version`, `@trace.bdd_version`, `@trace.business_rules`, `@trace.dataset` → **minor** per missing field, auto-fixable
184
+ - Note: `@trace.revision` is always `1` (static field — see generate-bdd.tmpl). Only check for presence; do NOT flag value as stale.
146
185
  - [ ] Every scenario has `# @trace.scenario`, `# @trace.sc_version`, `# @trace.business_rules`, `# Side-effects:` → **minor**, auto-fixable
147
186
  - [ ] Coverage Matrix at end of file → **major**, auto-fixable (AI regenerates)
148
187
  - [ ] Pre-merge Checklist at end of file → **minor**, auto-fixable
@@ -203,7 +242,9 @@ Mode: {PRD | BDD}
203
242
  Findings: {total} | 🔴 Critical: {N} | 🟡 Major: {N} | 🟢 Minor: {N}
204
243
  Auto-fixable: {N} | Needs human decision: {N}
205
244
 
206
- Findings file: {paths.refinement_dir}/{slug}-findings.yaml
245
+ Findings file:
246
+ {If PRD}: {paths.refinement_dir}/{prd-slug}-review-context-findings.yaml
247
+ {If BDD}: {paths.refinement_dir}/{uc-id}-review-bdd-findings.yaml
207
248
 
208
249
  Next options:
209
250
  A) Quick fix : /review-context --fix {target-file}
@@ -239,6 +280,7 @@ For each finding where `auto_fixable: true`, in order (critical → major → mi
239
280
 
240
281
  | check_id | What to apply |
241
282
  |----------|--------------|
283
+ | P0.3 (Missing status) | Add `@trace.status: draft` to frontmatter |
242
284
  | P1 (Banned term) | Replace every banned term occurrence with canonical term |
243
285
  | P4 (Structure) | Add missing section/metadata skeleton |
244
286
 
@@ -260,7 +302,7 @@ After applying each finding, mark it `status: "applied_automatically"` in the fi
260
302
 
261
303
  ### Phase 3 — Version bump
262
304
 
263
- - **PRD**: if ≥1 finding applied → bump minor version, add Changelog entry:
305
+ - **PRD**: if ≥1 finding applied → bump **minor** version (auto-fix only applies P1 banned-term replacements and P4 skeleton additions — never alters UC structure or BR content, so minor bump is always correct), add Changelog entry:
264
306
  `Auto-fix: applied {N} auto-fixable review-context findings`
265
307
  - **BDD**: if ≥1 finding applied → increment `@trace.bdd_version` by 0.1
266
308
 
@@ -280,7 +322,9 @@ Still pending (needs human decision): {N}
280
322
  {If PRD}: Version bumped: {old} → {new}
281
323
  {If BDD}: bdd_version: {old} → {new}
282
324
 
283
- Findings file: {paths.refinement_dir}/{slug}-findings.yaml
325
+ Findings file:
326
+ {If PRD}: {paths.refinement_dir}/{prd-slug}-review-context-findings.yaml
327
+ {If BDD}: {paths.refinement_dir}/{uc-id}-review-bdd-findings.yaml
284
328
  Re-run /review-context {file} to confirm 0 remaining critical findings.
285
329
  ```
286
330
 
@@ -299,8 +343,10 @@ Open findings file in Review Board → then run: /review-context --resume {file}
299
343
 
300
344
  ### Phase 1 — Read accepted findings
301
345
 
302
- 1. Derive findings filename from target file (same rule as above).
303
- 2. Read `{paths.refinement_dir}/{slug}-findings.yaml`.
346
+ 1. Derive findings filename from target file using the same rule as Detect Review Mode:
347
+ - PRD: `{paths.refinement_dir}/{prd-slug}-review-context-findings.yaml`
348
+ - BDD: `{paths.refinement_dir}/{uc-id}-review-bdd-findings.yaml`
349
+ 2. Read the findings file.
304
350
  3. Collect findings where `status: "accepted"` or `status: "modified"`.
305
351
  4. If none → report "No accepted findings. File unchanged." and stop.
306
352
 
@@ -311,6 +357,7 @@ Apply in order: critical → major → minor.
311
357
  **For PRD findings:**
312
358
  | check_id | What to do |
313
359
  |----------|-----------|
360
+ | P0.3 (Missing status) | Add `@trace.status: draft` to frontmatter |
314
361
  | P1 (Banned term) | Replace every occurrence of banned term with canonical term |
315
362
  | P2 (Ambiguity) | Apply the fix stated in `suggestion` or `modified` note |
316
363
  | P3 (Conflict) | Apply the resolution stated in the modified note |
@@ -330,6 +377,7 @@ Apply in order: critical → major → minor.
330
377
  | B6 (Side effects) | Add missing `And <side-effect>` to Then block |
331
378
 
332
379
  → After applying, increment `@trace.bdd_version` in file header by 0.1.
380
+ → Also update `{paths.trace_dir}/{UC-ID}.tsv`: set `bdd_version` column to the new `@trace.bdd_version` value for all rows, and set `last_updated` to today's date.
333
381
 
334
382
  ### Phase 3 — Report
335
383