@anhth2/spec-driven-dev-plugin 0.7.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 (69) hide show
  1. package/bin/index.js +105 -0
  2. package/commands/debug.md +37 -1
  3. package/commands/define-product.md +37 -1
  4. package/commands/fix-bug.md +37 -1
  5. package/commands/generate-bdd.md +37 -1
  6. package/commands/generate-code.md +37 -1
  7. package/commands/generate-design-spec.md +754 -0
  8. package/commands/generate-design-spec.tmpl +399 -0
  9. package/commands/generate-prd.md +58 -1
  10. package/commands/generate-prd.tmpl +21 -0
  11. package/commands/generate-spec-manifest.md +519 -0
  12. package/commands/generate-spec-manifest.tmpl +164 -0
  13. package/commands/generate-tech-docs.md +37 -1
  14. package/commands/generate-tests.md +37 -1
  15. package/commands/refine-prd.md +37 -1
  16. package/commands/review-code.md +37 -1
  17. package/commands/review-context.md +77 -1
  18. package/commands/review-context.tmpl +40 -0
  19. package/commands/review-tech-docs.md +37 -1
  20. package/commands/run-tests.md +37 -1
  21. package/commands/setup-ai-first.md +132 -4
  22. package/commands/setup-ai-first.tmpl +130 -3
  23. package/commands/smoke-test.md +37 -1
  24. package/commands/validate-traces.md +37 -1
  25. package/core/FRAMEWORK_VERSION +1 -1
  26. package/core/commands/debug.md +37 -1
  27. package/core/commands/define-product.md +37 -1
  28. package/core/commands/fix-bug.md +37 -1
  29. package/core/commands/generate-bdd.md +37 -1
  30. package/core/commands/generate-code.md +37 -1
  31. package/core/commands/generate-design-spec.md +754 -0
  32. package/core/commands/generate-prd.md +58 -1
  33. package/core/commands/generate-spec-manifest.md +519 -0
  34. package/core/commands/generate-tech-docs.md +37 -1
  35. package/core/commands/generate-tests.md +37 -1
  36. package/core/commands/refine-prd.md +37 -1
  37. package/core/commands/review-code.md +37 -1
  38. package/core/commands/review-context.md +77 -1
  39. package/core/commands/review-tech-docs.md +37 -1
  40. package/core/commands/run-tests.md +37 -1
  41. package/core/commands/setup-ai-first.md +132 -4
  42. package/core/commands/smoke-test.md +37 -1
  43. package/core/commands/validate-traces.md +37 -1
  44. package/core/skills/code/SKILL.md +39 -2
  45. package/core/skills/debug/SKILL.md +41 -3
  46. package/core/skills/design-spec/SKILL.md +450 -0
  47. package/core/skills/discovery/SKILL.md +37 -1
  48. package/core/skills/prd/SKILL.md +4 -2
  49. package/core/skills/setup-ai-first/SKILL.md +2 -1
  50. package/core/skills/spec/SKILL.md +4 -2
  51. package/core/skills/test/SKILL.md +76 -3
  52. package/core/steps/context-loader.md +35 -0
  53. package/core/steps/report-footer.md +2 -1
  54. package/core/templates/design-spec.template.md +209 -0
  55. package/core/templates/project-context.yaml +29 -0
  56. package/package.json +1 -1
  57. package/skills/code/SKILL.md +39 -2
  58. package/skills/debug/SKILL.md +41 -3
  59. package/skills/design-spec/SKILL.md +450 -0
  60. package/skills/design-spec/SKILL.tmpl +95 -0
  61. package/skills/discovery/SKILL.md +37 -1
  62. package/skills/prd/SKILL.md +4 -2
  63. package/skills/setup-ai-first/SKILL.md +2 -1
  64. package/skills/spec/SKILL.md +4 -2
  65. package/skills/test/SKILL.md +76 -3
  66. package/steps/context-loader.md +35 -0
  67. package/steps/report-footer.md +2 -1
  68. package/templates/design-spec.template.md +209 -0
  69. package/templates/project-context.yaml +29 -0
@@ -152,6 +152,7 @@ Read `.agent/project-context.yaml`. Extract and store:
152
152
  - `paths.core_entities` → path to core-entities.md
153
153
  - `paths.tech_docs_dir` → technical documentation root
154
154
  - `paths.trace_dir` → trace state directory
155
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
155
156
 
156
157
  If `paths` section is absent, use these defaults:
157
158
  - `specs_dir` = `specs/bdd`
@@ -163,11 +164,44 @@ If `paths` section is absent, use these defaults:
163
164
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
164
165
  - `tech_docs_dir` = `specs/tech-docs`
165
166
  - `trace_dir` = `.trace`
167
+ - `design_spec_dir` = `specs/design-spec`
166
168
 
167
169
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
168
170
 
169
171
  ---
170
172
 
173
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
174
+
175
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
176
+
177
+ If `services` section is present:
178
+
179
+ **1. Detect active domain** (in priority order):
180
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
181
+ - Extract from target file path: segment immediately after `prd_dir` base path
182
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
183
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
184
+
185
+ **2. Route to service** — if active domain matches a key in `services`:
186
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
187
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
188
+ - Store `active_service` = `services.{domain}.path`
189
+ - Store `active_service_module` = `services.{domain}.module`
190
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
191
+
192
+ **3. Fallback** — if domain not detected or no matching service key:
193
+ - Keep default paths from Step 1
194
+ - Set `active_service = unresolved`
195
+
196
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
197
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
198
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
199
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
200
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
201
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
202
+
203
+ ---
204
+
171
205
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
172
206
 
173
207
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -273,6 +307,7 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
273
307
  Ticket : {ticket_prefix}-
274
308
  Dict : {loaded — N canonical terms, M banned terms | missing}
275
309
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
310
+ Service : {active_service} ({active_service_module}) | single-service
276
311
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
277
312
  ```
278
313
 
@@ -406,7 +441,8 @@ Suggest the logical next command based on workflow phase:
406
441
  | /define-product | `/generate-prd {product-definition-file}` |
407
442
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
408
443
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
409
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
444
+ | /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 |
445
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
410
446
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
411
447
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
412
448
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
@@ -131,6 +131,7 @@ Read `.agent/project-context.yaml`. Extract and store:
131
131
  - `paths.core_entities` → path to core-entities.md
132
132
  - `paths.tech_docs_dir` → technical documentation root
133
133
  - `paths.trace_dir` → trace state directory
134
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
134
135
 
135
136
  If `paths` section is absent, use these defaults:
136
137
  - `specs_dir` = `specs/bdd`
@@ -142,11 +143,44 @@ If `paths` section is absent, use these defaults:
142
143
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
143
144
  - `tech_docs_dir` = `specs/tech-docs`
144
145
  - `trace_dir` = `.trace`
146
+ - `design_spec_dir` = `specs/design-spec`
145
147
 
146
148
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
147
149
 
148
150
  ---
149
151
 
152
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
153
+
154
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
155
+
156
+ If `services` section is present:
157
+
158
+ **1. Detect active domain** (in priority order):
159
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
160
+ - Extract from target file path: segment immediately after `prd_dir` base path
161
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
162
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
163
+
164
+ **2. Route to service** — if active domain matches a key in `services`:
165
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
166
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
167
+ - Store `active_service` = `services.{domain}.path`
168
+ - Store `active_service_module` = `services.{domain}.module`
169
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
170
+
171
+ **3. Fallback** — if domain not detected or no matching service key:
172
+ - Keep default paths from Step 1
173
+ - Set `active_service = unresolved`
174
+
175
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
176
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
177
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
178
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
179
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
180
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
181
+
182
+ ---
183
+
150
184
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
151
185
 
152
186
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -252,6 +286,7 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
252
286
  Ticket : {ticket_prefix}-
253
287
  Dict : {loaded — N canonical terms, M banned terms | missing}
254
288
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
289
+ Service : {active_service} ({active_service_module}) | single-service
255
290
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
256
291
  ```
257
292
 
@@ -762,7 +797,8 @@ Suggest the logical next command based on workflow phase:
762
797
  | /define-product | `/generate-prd {product-definition-file}` |
763
798
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
764
799
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
765
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
800
+ | /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 |
801
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
766
802
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
767
803
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
768
804
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
@@ -131,6 +131,7 @@ Read `.agent/project-context.yaml`. Extract and store:
131
131
  - `paths.core_entities` → path to core-entities.md
132
132
  - `paths.tech_docs_dir` → technical documentation root
133
133
  - `paths.trace_dir` → trace state directory
134
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
134
135
 
135
136
  If `paths` section is absent, use these defaults:
136
137
  - `specs_dir` = `specs/bdd`
@@ -142,11 +143,44 @@ If `paths` section is absent, use these defaults:
142
143
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
143
144
  - `tech_docs_dir` = `specs/tech-docs`
144
145
  - `trace_dir` = `.trace`
146
+ - `design_spec_dir` = `specs/design-spec`
145
147
 
146
148
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
147
149
 
148
150
  ---
149
151
 
152
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
153
+
154
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
155
+
156
+ If `services` section is present:
157
+
158
+ **1. Detect active domain** (in priority order):
159
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
160
+ - Extract from target file path: segment immediately after `prd_dir` base path
161
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
162
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
163
+
164
+ **2. Route to service** — if active domain matches a key in `services`:
165
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
166
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
167
+ - Store `active_service` = `services.{domain}.path`
168
+ - Store `active_service_module` = `services.{domain}.module`
169
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
170
+
171
+ **3. Fallback** — if domain not detected or no matching service key:
172
+ - Keep default paths from Step 1
173
+ - Set `active_service = unresolved`
174
+
175
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
176
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
177
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
178
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
179
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
180
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
181
+
182
+ ---
183
+
150
184
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
151
185
 
152
186
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -252,6 +286,7 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
252
286
  Ticket : {ticket_prefix}-
253
287
  Dict : {loaded — N canonical terms, M banned terms | missing}
254
288
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
289
+ Service : {active_service} ({active_service_module}) | single-service
255
290
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
256
291
  ```
257
292
 
@@ -349,7 +384,8 @@ Suggest the logical next command based on workflow phase:
349
384
  | /define-product | `/generate-prd {product-definition-file}` |
350
385
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
351
386
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
352
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
387
+ | /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 |
388
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
353
389
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
354
390
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
355
391
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
@@ -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`
@@ -144,11 +145,44 @@ If `paths` section is absent, use these defaults:
144
145
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
145
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`.
@@ -254,6 +288,7 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
254
288
  Ticket : {ticket_prefix}-
255
289
  Dict : {loaded — N canonical terms, M banned terms | missing}
256
290
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
291
+ Service : {active_service} ({active_service_module}) | single-service
257
292
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
258
293
  ```
259
294
 
@@ -355,7 +390,8 @@ Suggest the logical next command based on workflow phase:
355
390
  | /define-product | `/generate-prd {product-definition-file}` |
356
391
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
357
392
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
358
- | /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}` |
359
395
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
360
396
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
361
397
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
@@ -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`
@@ -149,11 +150,44 @@ If `paths` section is absent, use these defaults:
149
150
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
150
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`.
@@ -259,6 +293,7 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
259
293
  Ticket : {ticket_prefix}-
260
294
  Dict : {loaded — N canonical terms, M banned terms | missing}
261
295
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
296
+ Service : {active_service} ({active_service_module}) | single-service
262
297
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
263
298
  ```
264
299
 
@@ -301,6 +336,44 @@ Derive the output findings filename:
301
336
 
302
337
  ## PRD Review Mode
303
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
+
304
377
  ### P1 — Terminology Check (Business Dictionary)
305
378
 
306
379
  Load `{paths.business_dictionary}`.
@@ -493,7 +566,8 @@ Suggest the logical next command based on workflow phase:
493
566
  | /define-product | `/generate-prd {product-definition-file}` |
494
567
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
495
568
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
496
- | /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}` |
497
571
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
498
572
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
499
573
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
@@ -561,6 +635,7 @@ For each finding where `auto_fixable: true`, in order (critical → major → mi
561
635
 
562
636
  | check_id | What to apply |
563
637
  |----------|--------------|
638
+ | P0.3 (Missing status) | Add `@trace.status: draft` to frontmatter |
564
639
  | P1 (Banned term) | Replace every banned term occurrence with canonical term |
565
640
  | P4 (Structure) | Add missing section/metadata skeleton |
566
641
 
@@ -637,6 +712,7 @@ Apply in order: critical → major → minor.
637
712
  **For PRD findings:**
638
713
  | check_id | What to do |
639
714
  |----------|-----------|
715
+ | P0.3 (Missing status) | Add `@trace.status: draft` to frontmatter |
640
716
  | P1 (Banned term) | Replace every occurrence of banned term with canonical term |
641
717
  | P2 (Ambiguity) | Apply the fix stated in `suggestion` or `modified` note |
642
718
  | P3 (Conflict) | Apply the resolution stated in the modified note |
@@ -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}`.
@@ -242,6 +280,7 @@ For each finding where `auto_fixable: true`, in order (critical → major → mi
242
280
 
243
281
  | check_id | What to apply |
244
282
  |----------|--------------|
283
+ | P0.3 (Missing status) | Add `@trace.status: draft` to frontmatter |
245
284
  | P1 (Banned term) | Replace every banned term occurrence with canonical term |
246
285
  | P4 (Structure) | Add missing section/metadata skeleton |
247
286
 
@@ -318,6 +357,7 @@ Apply in order: critical → major → minor.
318
357
  **For PRD findings:**
319
358
  | check_id | What to do |
320
359
  |----------|-----------|
360
+ | P0.3 (Missing status) | Add `@trace.status: draft` to frontmatter |
321
361
  | P1 (Banned term) | Replace every occurrence of banned term with canonical term |
322
362
  | P2 (Ambiguity) | Apply the fix stated in `suggestion` or `modified` note |
323
363
  | P3 (Conflict) | Apply the resolution stated in the modified note |
@@ -135,6 +135,7 @@ Read `.agent/project-context.yaml`. Extract and store:
135
135
  - `paths.core_entities` → path to core-entities.md
136
136
  - `paths.tech_docs_dir` → technical documentation root
137
137
  - `paths.trace_dir` → trace state directory
138
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
138
139
 
139
140
  If `paths` section is absent, use these defaults:
140
141
  - `specs_dir` = `specs/bdd`
@@ -146,11 +147,44 @@ If `paths` section is absent, use these defaults:
146
147
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
147
148
  - `tech_docs_dir` = `specs/tech-docs`
148
149
  - `trace_dir` = `.trace`
150
+ - `design_spec_dir` = `specs/design-spec`
149
151
 
150
152
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
151
153
 
152
154
  ---
153
155
 
156
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
157
+
158
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
159
+
160
+ If `services` section is present:
161
+
162
+ **1. Detect active domain** (in priority order):
163
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
164
+ - Extract from target file path: segment immediately after `prd_dir` base path
165
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
166
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
167
+
168
+ **2. Route to service** — if active domain matches a key in `services`:
169
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
170
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
171
+ - Store `active_service` = `services.{domain}.path`
172
+ - Store `active_service_module` = `services.{domain}.module`
173
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
174
+
175
+ **3. Fallback** — if domain not detected or no matching service key:
176
+ - Keep default paths from Step 1
177
+ - Set `active_service = unresolved`
178
+
179
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
180
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
181
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
182
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
183
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
184
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
185
+
186
+ ---
187
+
154
188
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
155
189
 
156
190
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -256,6 +290,7 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
256
290
  Ticket : {ticket_prefix}-
257
291
  Dict : {loaded — N canonical terms, M banned terms | missing}
258
292
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
293
+ Service : {active_service} ({active_service_module}) | single-service
259
294
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
260
295
  ```
261
296
 
@@ -453,7 +488,8 @@ Suggest the logical next command based on workflow phase:
453
488
  | /define-product | `/generate-prd {product-definition-file}` |
454
489
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
455
490
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
456
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
491
+ | /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 |
492
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
457
493
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
458
494
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
459
495
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
@@ -131,6 +131,7 @@ Read `.agent/project-context.yaml`. Extract and store:
131
131
  - `paths.core_entities` → path to core-entities.md
132
132
  - `paths.tech_docs_dir` → technical documentation root
133
133
  - `paths.trace_dir` → trace state directory
134
+ - `paths.design_spec_dir` → Design Spec documents root (FE/App only)
134
135
 
135
136
  If `paths` section is absent, use these defaults:
136
137
  - `specs_dir` = `specs/bdd`
@@ -142,11 +143,44 @@ If `paths` section is absent, use these defaults:
142
143
  - `core_entities` = `specs/domain-knowledge/core-entities.md`
143
144
  - `tech_docs_dir` = `specs/tech-docs`
144
145
  - `trace_dir` = `.trace`
146
+ - `design_spec_dir` = `specs/design-spec`
145
147
 
146
148
  If `tech_stack.module` is set, also load `.agent/modules/{module}/stack-profile.yaml` if it exists.
147
149
 
148
150
  ---
149
151
 
152
+ ## Step 1.5 — [SERVICE ROUTING] Resolve service paths (umbrella mode)
153
+
154
+ *Skip this step entirely if `setup.mode` is not `"umbrella"` and `services` section is absent from project-context.yaml.*
155
+
156
+ If `services` section is present:
157
+
158
+ **1. Detect active domain** (in priority order):
159
+ - Read `@trace.domain` from target file frontmatter (if Gate loaded a target file)
160
+ - Extract from target file path: segment immediately after `prd_dir` base path
161
+ *(e.g., `specs/prd/user/FEAT-01.md` → domain = `user`)*
162
+ - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
163
+
164
+ **2. Route to service** — if active domain matches a key in `services`:
165
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir`
166
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
167
+ - Store `active_service` = `services.{domain}.path`
168
+ - Store `active_service_module` = `services.{domain}.module`
169
+ - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
170
+
171
+ **3. Fallback** — if domain not detected or no matching service key:
172
+ - Keep default paths from Step 1
173
+ - Set `active_service = unresolved`
174
+
175
+ **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
176
+ - Override `paths.prd_dir` → `{spec_source}/specs/prd`
177
+ - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
178
+ - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
179
+ - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
180
+ - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
181
+
182
+ ---
183
+
150
184
  ## Step 2 — [PROJECT-CONFIG] Load module stack profile (conditional)
151
185
 
152
186
  If `tech_stack.module` is set, read `.agent/modules/{module}/stack-profile.yaml`.
@@ -252,6 +286,7 @@ Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Ser
252
286
  Ticket : {ticket_prefix}-
253
287
  Dict : {loaded — N canonical terms, M banned terms | missing}
254
288
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
289
+ Service : {active_service} ({active_service_module}) | single-service
255
290
  Status : {FULL | PARTIAL — missing: CLAUDE.md / business-dict / core-entities | MINIMAL}
256
291
  ```
257
292
 
@@ -444,7 +479,8 @@ Suggest the logical next command based on workflow phase:
444
479
  | /define-product | `/generate-prd {product-definition-file}` |
445
480
  | /generate-prd | `/refine-prd {prd-file}` then `/review-context {prd-file}` |
446
481
  | /refine-prd | Open Review Board → update PRD → `/review-context {prd-file}` |
447
- | /review-context (PRD) | `/generate-bdd {prd-file}` if APPROVED; fix PRD if NEEDS_FIX |
482
+ | /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 |
483
+ | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
448
484
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
449
485
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
450
486
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |