@anhth2/spec-driven-dev-plugin 0.9.2 → 0.11.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 (223) hide show
  1. package/commands/debug.md +50 -20
  2. package/commands/define-product.md +49 -19
  3. package/commands/{generate-tests.md → dev-gen-test.md} +85 -23
  4. package/commands/{generate-tests.tmpl → dev-gen-test.tmpl} +18 -4
  5. package/{core/commands/run-tests.md → commands/dev-run-test.md} +102 -21
  6. package/commands/{run-tests.tmpl → dev-run-test.tmpl} +35 -2
  7. package/commands/{smoke-test.md → dev-smoke-test.md} +54 -24
  8. package/commands/{smoke-test.tmpl → dev-smoke-test.tmpl} +5 -5
  9. package/commands/fix-bug.md +50 -20
  10. package/commands/generate-bdd.md +78 -21
  11. package/commands/generate-bdd.tmpl +11 -2
  12. package/commands/generate-code.md +123 -23
  13. package/commands/generate-code.tmpl +56 -4
  14. package/commands/generate-design-spec.md +142 -47
  15. package/commands/generate-design-spec.tmpl +93 -28
  16. package/commands/generate-prd.md +49 -19
  17. package/commands/generate-spec-manifest.md +49 -19
  18. package/commands/generate-tech-docs.md +50 -20
  19. package/commands/generate-tech-docs.tmpl +1 -1
  20. package/commands/learn.md +50 -20
  21. package/commands/propose-scenario.md +50 -20
  22. package/commands/propose-scenario.tmpl +1 -1
  23. package/commands/qc-analyze.md +514 -0
  24. package/commands/qc-analyze.tmpl +71 -0
  25. package/commands/qc-design-test.md +510 -0
  26. package/commands/qc-design-test.tmpl +67 -0
  27. package/commands/qc-plan.md +492 -0
  28. package/commands/qc-plan.tmpl +49 -0
  29. package/commands/qc-report.md +491 -0
  30. package/commands/qc-report.tmpl +48 -0
  31. package/commands/qc-review.md +496 -0
  32. package/commands/qc-review.tmpl +53 -0
  33. package/commands/qc-run-test.md +538 -0
  34. package/commands/qc-run-test.tmpl +77 -0
  35. package/commands/refine-prd.md +203 -24
  36. package/commands/refine-prd.tmpl +16 -5
  37. package/commands/report-bug.md +49 -19
  38. package/commands/review-code.md +51 -21
  39. package/commands/review-code.tmpl +1 -1
  40. package/commands/review-context.md +198 -20
  41. package/commands/review-context.tmpl +11 -1
  42. package/commands/review-tech-docs.md +49 -19
  43. package/commands/setup-ai-first.md +14 -7
  44. package/commands/sync.md +30 -20
  45. package/commands/sync.tmpl +16 -13
  46. package/commands/update-framework.md +14 -7
  47. package/commands/validate-traces.md +106 -45
  48. package/commands/validate-traces.tmpl +57 -26
  49. package/core/FRAMEWORK_VERSION +1 -1
  50. package/core/commands/debug.md +50 -20
  51. package/core/commands/define-product.md +49 -19
  52. package/core/commands/{generate-tests.md → dev-gen-test.md} +85 -23
  53. package/{commands/run-tests.md → core/commands/dev-run-test.md} +102 -21
  54. package/core/commands/{smoke-test.md → dev-smoke-test.md} +54 -24
  55. package/core/commands/fix-bug.md +50 -20
  56. package/core/commands/generate-bdd.md +78 -21
  57. package/core/commands/generate-code.md +123 -23
  58. package/core/commands/generate-design-spec.md +142 -47
  59. package/core/commands/generate-prd.md +49 -19
  60. package/core/commands/generate-spec-manifest.md +49 -19
  61. package/core/commands/generate-tech-docs.md +50 -20
  62. package/core/commands/learn.md +50 -20
  63. package/core/commands/propose-scenario.md +50 -20
  64. package/core/commands/qc-analyze.md +514 -0
  65. package/core/commands/qc-design-test.md +510 -0
  66. package/core/commands/qc-plan.md +492 -0
  67. package/core/commands/qc-report.md +491 -0
  68. package/core/commands/qc-review.md +496 -0
  69. package/core/commands/qc-run-test.md +538 -0
  70. package/core/commands/refine-prd.md +203 -24
  71. package/core/commands/report-bug.md +49 -19
  72. package/core/commands/review-code.md +51 -21
  73. package/core/commands/review-context.md +198 -20
  74. package/core/commands/review-tech-docs.md +49 -19
  75. package/core/commands/setup-ai-first.md +14 -7
  76. package/core/commands/sync.md +30 -20
  77. package/core/commands/update-framework.md +14 -7
  78. package/core/commands/validate-traces.md +106 -45
  79. package/core/modules/qc-playwright/stack-profile.yaml +65 -0
  80. package/core/skills/code/SKILL.md +63 -26
  81. package/core/skills/debug/SKILL.md +78 -34
  82. package/core/skills/design-spec/SKILL.md +49 -19
  83. package/core/skills/discovery/SKILL.md +49 -19
  84. package/core/skills/prd/SKILL.md +28 -14
  85. package/core/skills/qc/qa-analyst/DOC_GAPS.template.md +63 -0
  86. package/core/skills/qc/qa-analyst/acceptance-criteria.md +56 -0
  87. package/core/skills/qc/qa-analyst/business-rules.md +55 -0
  88. package/core/skills/qc/qa-analyst/data-flow.md +60 -0
  89. package/core/skills/qc/qa-analyst/spec-breakdown.md +57 -0
  90. package/core/skills/qc/qa-designer/e2e/journey.md +41 -0
  91. package/core/skills/qc/qa-designer/exploratory/charter.md +68 -0
  92. package/core/skills/qc/qa-designer/exploratory/explore-to-functional.md +43 -0
  93. package/core/skills/qc/qa-designer/functional/api.md +45 -0
  94. package/core/skills/qc/qa-designer/functional/gui-feature.md +46 -0
  95. package/core/skills/qc/qa-designer/functional/gui-screen.md +52 -0
  96. package/core/skills/qc/qa-designer/integration/api.md +42 -0
  97. package/core/skills/qc/qa-designer/integration/db.md +39 -0
  98. package/core/skills/qc/qa-designer/integration/gui.md +40 -0
  99. package/core/skills/qc/qa-designer/integration/kafka.md +40 -0
  100. package/core/skills/qc/qa-designer/non-functional.md +40 -0
  101. package/core/skills/qc/qa-planner/test-plan.md +120 -0
  102. package/core/skills/qc/qa-reviewer/script/e2e.md +87 -0
  103. package/core/skills/qc/qa-reviewer/script/exploratory.md +45 -0
  104. package/core/skills/qc/qa-reviewer/script/functional.md +101 -0
  105. package/core/skills/qc/qa-reviewer/script/integration.md +91 -0
  106. package/core/skills/qc/qa-reviewer/script/non-functional.md +126 -0
  107. package/core/skills/qc/qa-reviewer/test-case/e2e.md +73 -0
  108. package/core/skills/qc/qa-reviewer/test-case/exploratory.md +43 -0
  109. package/core/skills/qc/qa-reviewer/test-case/functional.md +76 -0
  110. package/core/skills/qc/qa-reviewer/test-case/integration.md +69 -0
  111. package/core/skills/qc/qa-reviewer/test-case/non-functional.md +73 -0
  112. package/core/skills/qc/qa-runner/e2e.md +49 -0
  113. package/core/skills/qc/qa-runner/exploratory/session.md +36 -0
  114. package/core/skills/qc/qa-runner/functional/api.md +35 -0
  115. package/core/skills/qc/qa-runner/functional/gui-feature.md +51 -0
  116. package/core/skills/qc/qa-runner/functional/gui-screen.md +55 -0
  117. package/core/skills/qc/qa-runner/integration.md +47 -0
  118. package/core/skills/qc/qa-runner/non-functional.md +49 -0
  119. package/core/skills/qc/qa-runner/report/report.md +37 -0
  120. package/core/skills/setup-ai-first/SKILL.md +14 -7
  121. package/core/skills/spec/SKILL.md +28 -14
  122. package/core/skills/test/SKILL.md +121 -54
  123. package/core/steps/capture-lesson.md +1 -1
  124. package/core/steps/context-loader.md +35 -12
  125. package/core/steps/report-footer.md +14 -7
  126. package/core/steps/review-fanout.md +138 -0
  127. package/core/steps/spawn-agent.md +1 -1
  128. package/core/steps/trace-mirror.md +18 -0
  129. package/core/templates/design-spec.template.md +16 -8
  130. package/core/templates/project-context.yaml +8 -0
  131. package/docs/01-getting-started/README.md +19 -0
  132. package/docs/01-getting-started/core-concepts.md +102 -0
  133. package/docs/01-getting-started/installation.md +154 -0
  134. package/docs/01-getting-started/quickstart.md +85 -0
  135. package/docs/02-guides/README.md +27 -0
  136. package/docs/02-guides/developer/README.md +46 -0
  137. package/docs/02-guides/developer/bdd-and-trace.md +123 -0
  138. package/docs/02-guides/developer/commands.md +76 -0
  139. package/docs/02-guides/developer/pr-checklist.md +15 -0
  140. package/docs/02-guides/developer/scenarios.md +448 -0
  141. package/docs/02-guides/developer/workflow.md +59 -0
  142. package/docs/02-guides/product-owner/README.md +77 -0
  143. package/docs/02-guides/product-owner/commands.md +30 -0
  144. package/docs/02-guides/product-owner/handoff-checklist.md +42 -0
  145. package/docs/02-guides/product-owner/prd-writing-rules.md +45 -0
  146. package/docs/02-guides/product-owner/scenarios.md +357 -0
  147. package/docs/02-guides/qc-automation.md +92 -0
  148. package/docs/02-guides/tester/README.md +72 -0
  149. package/docs/02-guides/tester/bug-reporting.md +117 -0
  150. package/docs/02-guides/tester/reading-specs.md +79 -0
  151. package/docs/02-guides/tester/scenarios.md +186 -0
  152. package/docs/02-guides/tester/spec-manifest.md +124 -0
  153. package/docs/02-guides/tester/test-checklist.md +31 -0
  154. package/docs/02-guides/tester/workflow.md +79 -0
  155. package/docs/03-concepts/README.md +19 -0
  156. package/docs/03-concepts/architecture.md +243 -0
  157. package/docs/03-concepts/pipeline.md +249 -0
  158. package/docs/03-concepts/traceability.md +148 -0
  159. package/docs/04-operations/README.md +33 -0
  160. package/docs/04-operations/bug-flow.md +321 -0
  161. package/docs/04-operations/publishing.md +137 -0
  162. package/docs/04-operations/sync-and-update.md +328 -0
  163. package/docs/05-reference/README.md +29 -0
  164. package/docs/05-reference/commands.md +229 -0
  165. package/docs/05-reference/modules.md +110 -0
  166. package/docs/05-reference/trace-schema.md +146 -0
  167. package/docs/README.md +51 -0
  168. package/modules/qc-playwright/stack-profile.yaml +65 -0
  169. package/package.json +2 -2
  170. package/skills/code/SKILL.md +63 -26
  171. package/skills/debug/SKILL.md +78 -34
  172. package/skills/debug/SKILL.tmpl +1 -1
  173. package/skills/design-spec/SKILL.md +49 -19
  174. package/skills/discovery/SKILL.md +49 -19
  175. package/skills/prd/SKILL.md +28 -14
  176. package/skills/qc/qa-analyst/DOC_GAPS.template.md +63 -0
  177. package/skills/qc/qa-analyst/acceptance-criteria.md +56 -0
  178. package/skills/qc/qa-analyst/business-rules.md +55 -0
  179. package/skills/qc/qa-analyst/data-flow.md +60 -0
  180. package/skills/qc/qa-analyst/spec-breakdown.md +57 -0
  181. package/skills/qc/qa-designer/e2e/journey.md +41 -0
  182. package/skills/qc/qa-designer/exploratory/charter.md +68 -0
  183. package/skills/qc/qa-designer/exploratory/explore-to-functional.md +43 -0
  184. package/skills/qc/qa-designer/functional/api.md +45 -0
  185. package/skills/qc/qa-designer/functional/gui-feature.md +46 -0
  186. package/skills/qc/qa-designer/functional/gui-screen.md +52 -0
  187. package/skills/qc/qa-designer/integration/api.md +42 -0
  188. package/skills/qc/qa-designer/integration/db.md +39 -0
  189. package/skills/qc/qa-designer/integration/gui.md +40 -0
  190. package/skills/qc/qa-designer/integration/kafka.md +40 -0
  191. package/skills/qc/qa-designer/non-functional.md +40 -0
  192. package/skills/qc/qa-planner/test-plan.md +120 -0
  193. package/skills/qc/qa-reviewer/script/e2e.md +87 -0
  194. package/skills/qc/qa-reviewer/script/exploratory.md +45 -0
  195. package/skills/qc/qa-reviewer/script/functional.md +101 -0
  196. package/skills/qc/qa-reviewer/script/integration.md +91 -0
  197. package/skills/qc/qa-reviewer/script/non-functional.md +126 -0
  198. package/skills/qc/qa-reviewer/test-case/e2e.md +73 -0
  199. package/skills/qc/qa-reviewer/test-case/exploratory.md +43 -0
  200. package/skills/qc/qa-reviewer/test-case/functional.md +76 -0
  201. package/skills/qc/qa-reviewer/test-case/integration.md +69 -0
  202. package/skills/qc/qa-reviewer/test-case/non-functional.md +73 -0
  203. package/skills/qc/qa-runner/e2e.md +49 -0
  204. package/skills/qc/qa-runner/exploratory/session.md +36 -0
  205. package/skills/qc/qa-runner/functional/api.md +35 -0
  206. package/skills/qc/qa-runner/functional/gui-feature.md +51 -0
  207. package/skills/qc/qa-runner/functional/gui-screen.md +55 -0
  208. package/skills/qc/qa-runner/integration.md +47 -0
  209. package/skills/qc/qa-runner/non-functional.md +49 -0
  210. package/skills/qc/qa-runner/report/report.md +37 -0
  211. package/skills/setup-ai-first/SKILL.md +14 -7
  212. package/skills/spec/SKILL.md +28 -14
  213. package/skills/test/SKILL.md +121 -54
  214. package/skills/test/SKILL.tmpl +9 -9
  215. package/steps/capture-lesson.md +1 -1
  216. package/steps/context-loader.md +35 -12
  217. package/steps/report-footer.md +14 -7
  218. package/steps/review-fanout.md +138 -0
  219. package/steps/spawn-agent.md +1 -1
  220. package/steps/trace-mirror.md +18 -0
  221. package/templates/design-spec.template.md +16 -8
  222. package/templates/project-context.yaml +8 -0
  223. package/ARCHITECTURE.md +0 -247
@@ -163,7 +163,7 @@ If `services` section is present:
163
163
 
164
164
  **2. Route to service** — if active domain matches a key in `services`:
165
165
  - Override `paths.specs_dir` → `services.{domain}.specs_dir`
166
- - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
166
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, the tech-design (API contract) is a cross-team artifact and must live in the shared spec repo (handled in step 4), so leave `tech_docs_dir` for step 4 to route — do NOT pin it per-service here.
167
167
  - Store `active_service` = `services.{domain}.path`
168
168
  - Store `active_service_module` = `services.{domain}.module`
169
169
  - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
@@ -175,7 +175,7 @@ If `services` section is present:
175
175
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
176
176
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
177
177
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
178
- - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **only if step 2 did not already route it to a service** (multi-service umbrellas keep per-service tech-docs). This publishes the BE-authored API contract into the shared spec repo so FE/App can read it via the spec submodule at `/generate-code --phase=integration`.
178
+ - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **always when `spec_source` is set** (step 2 no longer pins tech-docs per-service in this case). The tech-design IS the cross-team API contract: BE authors it here, and FE/App read it from the same spec submodule at `/generate-code --phase=integration`. *(Per-service tech-docs only happen when there is no `spec_source` — a pure multi-service BE repo with no shared spec module.)*
179
179
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
180
180
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
181
181
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
@@ -206,7 +206,7 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
206
206
  | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
207
207
 
208
208
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
209
- - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
209
+ - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
210
210
  - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
211
211
 
212
212
  **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
@@ -221,19 +221,41 @@ If the file does not exist → skip silently.
221
221
 
222
222
  ---
223
223
 
224
- ## Step 3 — [CRITICAL] Load CLAUDE.md
224
+ ## Step 3 — [CRITICAL] Load CLAUDE.md (layered: root + service overlay)
225
225
 
226
226
  *This is the highest-priority context — it defines HOW to write code and documents for this project.*
227
227
 
228
- Read `CLAUDE.md`. Extract and store:
228
+ CLAUDE.md is loaded in **two layers** so umbrella-wide rules and service-specific
229
+ architecture/coding standards compose correctly. The agent always sits at the umbrella
230
+ root, but the implementation code lives in a service submodule with its OWN stack,
231
+ architecture, and conventions — so the service's CLAUDE.md must win for code generation.
232
+
233
+ **Layer 1 — [BASE] Root CLAUDE.md (umbrella-wide).**
234
+ Read `CLAUDE.md` at the repo root. Treat its contents as the **shared baseline** for the
235
+ whole umbrella — git conventions, data-protection posture, cross-cutting rules, and (in
236
+ single-service mode) the project's only architecture + coding standards.
237
+
238
+ **Layer 2 — [OVERLAY] Service CLAUDE.md (umbrella mode only).**
239
+ *Run only if `service_root` was set in Step 1.6 (i.e. a real service was routed to).*
240
+ Read `{service_root}/CLAUDE.md`. This file defines the architecture + coding standards of
241
+ the **actual stack being implemented** (e.g. `user-service` = java-spring, `web` = nextjs).
242
+ Overlay it on top of Layer 1: **on any conflict, the service value WINS** for architecture,
243
+ coding standards, and error handling. Layer-1 values that the service does not redefine
244
+ (e.g. git conventions, banned patterns shared org-wide) remain in effect.
245
+
246
+ From the **merged** result, extract and store:
229
247
 
230
248
  - **§1 Project Overview** → project name, language, framework, build/test commands, domains
231
- - **§2 Architecture** → layer order (e.g., Controller → Facade → Service → Repository), architectural rules
232
- - **§3 Coding Standards** → naming conventions (classes, methods), response wrapper type, forbidden patterns
233
- - **§5 Error Handling** → exception types, HTTP status code mapping, not-found exception class name
234
- - **§7 Git Conventions** → branch naming pattern, commit message format
249
+ - **§2 Architecture** → layer order (e.g., Controller → Facade → Service → Repository), architectural rules — *service overlay wins*
250
+ - **§3 Coding Standards** → naming conventions (classes, methods), response wrapper type, forbidden patterns — *service overlay wins*
251
+ - **§5 Error Handling** → exception types, HTTP status code mapping, not-found exception class name — *service overlay wins*
252
+ - **§7 Git Conventions** → branch naming pattern, commit message format — *root baseline unless service redefines*
235
253
 
236
- If `CLAUDE.md` does not exist → note it as missing and continue with project-context.yaml data only.
254
+ **Resolution rules:**
255
+ - If both layers exist → merge as above; record `claude_md_source = root + {service_root}`.
256
+ - If only the service overlay exists (no root CLAUDE.md) → use the service file alone; `claude_md_source = {service_root}`.
257
+ - If `service_root` is set but `{service_root}/CLAUDE.md` is **missing** → fall back to root CLAUDE.md and flag ⚠️ in the Step 7 recap (the service has no architecture/coding-standards definition — code generation will use umbrella defaults, which may be the wrong stack).
258
+ - If neither exists → note CLAUDE.md as missing and continue with project-context.yaml data only.
237
259
 
238
260
  ---
239
261
 
@@ -299,7 +321,7 @@ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
299
321
 
300
322
  If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
301
323
 
302
- 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).
324
+ These two variables (`active_module`, `platform_type`) are the canonical source for all branching logic in commands that need platform-specific behavior (dev-gen-test, debug, fix-bug, dev-smoke-test).
303
325
 
304
326
  ---
305
327
 
@@ -333,7 +355,8 @@ Output exactly this block:
333
355
  [CTX LOADED]
334
356
  Stack : {language} / {framework} / {database}
335
357
  Platform : {active_module} ({platform_type})
336
- Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
358
+ Layers : {layer order from merged CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
359
+ CLAUDE.md : {root + {service_root} | {service_root} only | root only | ⚠️ service overlay MISSING — using root | missing}
337
360
  Ticket : {ticket_prefix}-
338
361
  Dict : {loaded — N canonical terms, M banned terms | missing}
339
362
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
@@ -363,15 +386,164 @@ Proceed to the next step of the calling command.
363
386
 
364
387
  ---
365
388
 
366
- ## Analyze — 4 Lenses (run all four)
389
+ ## Review Procedure
390
+ # Exhaustive Review Fan-Out + Completeness Convergence
391
+
392
+ **Why this exists:** A single-pass review never lists every issue at once — the model
393
+ stops at "enough" findings, so each later review round surfaces *new* problems
394
+ (whack-a-mole). This procedure forces the review to **converge in one command run**:
395
+ fan out across review dimensions in parallel, then loop a completeness critic until a
396
+ round produces nothing new, *before* writing the findings file.
397
+
398
+ The calling command supplies two things:
399
+ - **DIMENSIONS** — the list of review dimensions to fan out over
400
+ (`/refine-prd` → the 4 lenses; `/review-context` → the P-checks or B-checks).
401
+ - **FINDINGS SCHEMA** — the YAML shape each finding must follow (defined in the command).
402
+
403
+ > **Sub-agent mode bypass:** If Gate Step 0 set `_agent_mode: true`, this whole
404
+ > procedure is **skipped** — the orchestrator is already running one dimension/UC per
405
+ > sub-agent. Run the command's checks directly on the scoped section and return findings.
406
+
407
+ ---
408
+
409
+ ## Phase 1 — Parallel dimension scan
410
+
411
+ **How many sub-agents:** the agent *count* is not the completeness lever — breadth is
412
+ fixed by the DIMENSION taxonomy (adding agents to the same dimension just re-finds the
413
+ same issues), and *depth* is owned by the Phase 2 critic loop. Pick the **fan-out
414
+ granularity** by target size, reusing the `steps/spawn-agent.md` thresholds:
415
+
416
+ | Target size | Granularity | Agent count |
417
+ |-------------|-------------|-------------|
418
+ | ≤ 3 UCs **and** ≤ 300 lines | one agent per DIMENSION over the whole file | = number of dimensions |
419
+ | > 3 UCs **or** > 300 lines | one agent per **DIMENSION × UC-scope** (UCs + a PRD-global scope), batched to fit the agent cap | `dimensions × (UCs + 1)`, capped (see below) |
420
+
421
+ The larger granularity keeps each sub-agent's context small and its scan exhaustive on a
422
+ single UC — which is what prevents misses on big PRDs.
423
+
424
+ > **Global (non-UC) sections — required in `DIMENSION × UC` mode.** Per-UC agents only
425
+ > see one UC each, so PRD-wide sections that belong to no UC (scope, success metrics,
426
+ > problem statement, terminology, glossary, changelog) would go unscanned. Whenever you
427
+ > fan out per UC, also include a **"PRD-global"** scope (the non-UC sections, findings get
428
+ > `uc_id: ""`) alongside the UC list. So the natural agent count is `dimensions × (UCs + 1)`.
429
+ > (Not needed in the whole-file mode — there each agent already sees the global sections.)
430
+
431
+ ### Agent cap — batch UCs when the fan-out gets too wide
432
+
433
+ `dimensions × (UCs + 1)` can explode on large PRDs (e.g. 6 checks × (8 UCs + 1) = 54
434
+ agents). Cap the wave at **`AGENT_CAP = 12`** agents and batch UC scopes to fit:
435
+
436
+ 1. Build the scope list = `[UC1, UC2, …, UCn, PRD-global]` (length `UCs + 1`).
437
+ 2. Compute scopes-per-agent-bucket: `groups = max(1, floor(AGENT_CAP / dimensions))`.
438
+ - If `groups ≥ UCs + 1` → no batching needed, run one agent per `DIMENSION × scope`.
439
+ - Else split the scope list into `groups` contiguous buckets of roughly equal size
440
+ (keep `PRD-global` in its own bucket if it fits; otherwise append it to the last
441
+ bucket). Each agent then handles **one DIMENSION over one bucket of UCs**.
442
+ 3. Resulting wave size = `dimensions × groups ≤ AGENT_CAP`.
443
+
444
+ A batched agent reviews several UCs at once — still scoped far tighter than the whole
445
+ file, so coverage stays high. `AGENT_CAP` is the only knob; raise it if the host allows
446
+ more concurrency, lower it to save tokens. Whole-file mode (≤ 3 UCs) never hits the cap.
447
+
448
+ Spawn the chosen sub-agents using the Agent tool (send them in a single message so they
449
+ run concurrently). Each sub-agent gets a **fresh context window** and scans its scope
450
+ through its **one** dimension only — deeper coverage than one session juggling every
451
+ dimension at once (avoids lost-in-the-middle).
452
+
453
+ Sub-agent prompt template (fill the braces):
454
+
455
+ ```
456
+ You are a {DIMENSION_NAME} reviewer. Read the full target file at {target_file}.
457
+ Scope: review ONLY through the {DIMENSION_NAME} lens/check — {DIMENSION_DESCRIPTION}.
458
+ Be exhaustive: scan every section, every UC, every AC/BR/scenario. Do not stop early.
459
+ Project context (terminology, entities, architecture):
460
+ {slim_context — banned terms, canonical entities, layer order, domains}
461
+
462
+ Return a JSON array of findings, each:
463
+ { "dimension": "{DIMENSION_NAME}", "severity": "critical|major|minor",
464
+ "section": "...", "uc_id": "...", "quote": "<verbatim ≤120 chars>",
465
+ "finding": "...", "suggestion": "...", "auto_fixable": true|false }
466
+ Return [] if this dimension is clean. Return ONLY the JSON array.
467
+ ```
468
+
469
+ Collect every sub-agent's array into one consolidated list `ALL_FINDINGS`.
470
+
471
+ ---
472
+
473
+ ## Phase 2 — Completeness-critic convergence loop
474
+
475
+ This is the anti-whack-a-mole step. Repeat until **two consecutive rounds add zero new
476
+ findings**, or a hard cap of **3 rounds**, whichever comes first:
477
+
478
+ 1. Spawn one **completeness-critic** sub-agent with the Agent tool. Give it:
479
+ - the full target file (`{target_file}`),
480
+ - the current `ALL_FINDINGS` list (so it knows what is already captured),
481
+ - the same slim context.
482
+ Prompt it:
483
+ ```
484
+ Here is a document and a list of issues already found. Read the WHOLE document.
485
+ List ONLY real, additional issues NOT already in the list — gaps, ambiguities,
486
+ contradictions, missing edge/negative paths, coverage holes, terminology drift,
487
+ structural omissions, and any issue that a fix to an existing finding would expose.
488
+ Do NOT repeat anything already listed. Return the same finding JSON shape, or [] if
489
+ nothing new.
490
+ ```
491
+ 2. Append any genuinely new findings (not already in `ALL_FINDINGS`) to the list.
492
+ 3. If this round returned 0 new → increment the dry-round counter; else reset it to 0.
493
+ 4. Stop when dry-round counter reaches 2, or after 3 rounds total.
494
+
495
+ Record `convergence_rounds` (how many critic rounds ran) for the report.
496
+
497
+ ---
498
+
499
+ ## Phase 3 — Dedup, resolve conflicts, merge
500
+
501
+ Sub-agents run **blind to each other** (independence = diverse coverage). They never
502
+ talk or reconcile among themselves — all duplicate/conflict resolution happens **here in
503
+ the orchestrator**, where the full set is visible.
504
+
505
+ 1. **Deduplicate** `ALL_FINDINGS`: two findings are duplicates if they target the same
506
+ `section` + `uc_id` and describe the same underlying issue. Keep the one with the
507
+ richer `suggestion`; if they differ on severity, keep the **higher** severity.
508
+ 2. **Resolve conflicts** — group remaining findings by `section` + `uc_id` and check for
509
+ contradictions (two findings whose `suggestion`s cannot both be applied, or that
510
+ propose opposite fixes for the same spot):
511
+ - If the two suggestions can be **merged** into one coherent fix → merge them into a
512
+ single finding.
513
+ - If they are **mutually exclusive** → emit **one** finding that states both options
514
+ and set `auto_fixable: false` with `status: "needs_discussion"` (PRD) /
515
+ `status: "pending"` (review) so a human picks — never silently drop one side.
516
+ - If a finding is **invalidated** by another (e.g. a structural finding says a section
517
+ is missing, but another quotes content from it) → drop the invalid one.
518
+ 3. **Sort** by severity (critical → major → minor), then by `section` order in the file.
519
+ 4. **Assign stable IDs** `F001, F002, …` in that sorted order.
520
+ 5. Map each finding's `dimension` into the command's schema field
521
+ (`lens` for `/refine-prd`; `check_id` for `/review-context`).
522
+ 6. Write the **single** findings file in the FINDINGS SCHEMA the command defines.
523
+
524
+ In the command's final report, add one line:
525
+ ```
526
+ Convergence: {convergence_rounds} critic round(s) — findings file is complete; re-running should surface 0 new issues.
527
+ ```
528
+
529
+
530
+ ---
531
+
532
+ ## Analyze — 4 Lenses (fan out over all four, then converge)
367
533
 
368
- **QA Lens**: Are ACs testable? Edge cases specified? Boundary conditions defined?
534
+ Run the review through the **Review Procedure** above (`steps/review-fanout.md`).
369
535
 
370
- **DEV Lens**: Are API inputs/outputs clear? Business rules unambiguous? Cross-service deps fully described? Any technical risk?
536
+ **DIMENSIONS** = the 4 lenses below fan out one sub-agent per lens, each scanning the
537
+ full PRD through its single lens:
371
538
 
372
- **SA Lens**: Fits existing architecture? Security/auth implications? Data modeling clear?
539
+ - **QA Lens**: Are ACs testable? Edge cases specified? Boundary conditions defined?
540
+ - **DEV Lens**: Are API inputs/outputs clear? Business rules unambiguous? Cross-service deps fully described? Any technical risk?
541
+ - **SA Lens**: Fits existing architecture? Security/auth implications? Data modeling clear?
542
+ - **PO Lens**: Scope bounded? Priorities clear? Success metrics defined? Scope creep risk?
373
543
 
374
- **PO Lens**: Scope bounded? Priorities clear? Success metrics defined? Scope creep risk?
544
+ The completeness-critic loop (Phase 2) is what guarantees the findings file is complete
545
+ in one run — re-running `/refine-prd` should surface **0 new** findings. Map each
546
+ dimension into the `lens` field of the schema below.
375
547
 
376
548
  ## Output File
377
549
 
@@ -449,15 +621,22 @@ Suggest the logical next command based on workflow phase:
449
621
  | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
450
622
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
451
623
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
624
+ | /qc-analyze | `/qc-plan {UC-ID}` (resolve 🔴 blocker gaps first) |
625
+ | /qc-plan | `/qc-design-test {UC-ID}` |
626
+ | /qc-design-test | `/qc-review {UC-ID}` (test-case review) |
627
+ | /qc-review (test-case) | `/qc-run-test {UC-ID}` if APPROVED; fix TCs if NEEDS_FIX |
628
+ | /qc-run-test | `/qc-report {UC-ID}` then `/qc-review {UC-ID}` (script review) |
629
+ | /qc-review (script) | `/qc-report {UC-ID}` then create PR if APPROVED |
630
+ | /qc-report | `/validate-traces {UC-ID}` to refresh Living Docs (qc_status) |
452
631
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
453
632
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
454
- | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
455
- | /generate-tests | `/run-tests {UC-ID}` |
456
- | /run-tests (passing) | `/review-code {UC-ID}` |
457
- | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
458
- | /review-code | `/smoke-test {UC-ID}` or create PR |
459
- | /smoke-test | Create PR and link to ticket |
460
- | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
633
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/dev-gen-test {UC-ID}` |
634
+ | /dev-gen-test | `/dev-run-test {UC-ID}` |
635
+ | /dev-run-test (passing) | `/review-code {UC-ID}` |
636
+ | /dev-run-test (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
637
+ | /review-code | `/dev-smoke-test {UC-ID}` or create PR |
638
+ | /dev-smoke-test | Create PR and link to ticket |
639
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; all OK → create PR |
461
640
  | /fix-bug | Create PR and link to ticket |
462
641
  | /debug | `/fix-bug {ticket-id}` if fix needed |
463
642
  | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
@@ -10,15 +10,26 @@
10
10
 
11
11
  ---
12
12
 
13
- ## Analyze — 4 Lenses (run all four)
13
+ ## Review Procedure
14
+ {{include:steps/review-fanout.md}}
14
15
 
15
- **QA Lens**: Are ACs testable? Edge cases specified? Boundary conditions defined?
16
+ ---
17
+
18
+ ## Analyze — 4 Lenses (fan out over all four, then converge)
19
+
20
+ Run the review through the **Review Procedure** above (`steps/review-fanout.md`).
16
21
 
17
- **DEV Lens**: Are API inputs/outputs clear? Business rules unambiguous? Cross-service deps fully described? Any technical risk?
22
+ **DIMENSIONS** = the 4 lenses below fan out one sub-agent per lens, each scanning the
23
+ full PRD through its single lens:
18
24
 
19
- **SA Lens**: Fits existing architecture? Security/auth implications? Data modeling clear?
25
+ - **QA Lens**: Are ACs testable? Edge cases specified? Boundary conditions defined?
26
+ - **DEV Lens**: Are API inputs/outputs clear? Business rules unambiguous? Cross-service deps fully described? Any technical risk?
27
+ - **SA Lens**: Fits existing architecture? Security/auth implications? Data modeling clear?
28
+ - **PO Lens**: Scope bounded? Priorities clear? Success metrics defined? Scope creep risk?
20
29
 
21
- **PO Lens**: Scope bounded? Priorities clear? Success metrics defined? Scope creep risk?
30
+ The completeness-critic loop (Phase 2) is what guarantees the findings file is complete
31
+ in one run — re-running `/refine-prd` should surface **0 new** findings. Map each
32
+ dimension into the `lens` field of the schema below.
22
33
 
23
34
  ## Output File
24
35
 
@@ -172,7 +172,7 @@ If `services` section is present:
172
172
 
173
173
  **2. Route to service** — if active domain matches a key in `services`:
174
174
  - Override `paths.specs_dir` → `services.{domain}.specs_dir`
175
- - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
175
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, the tech-design (API contract) is a cross-team artifact and must live in the shared spec repo (handled in step 4), so leave `tech_docs_dir` for step 4 to route — do NOT pin it per-service here.
176
176
  - Store `active_service` = `services.{domain}.path`
177
177
  - Store `active_service_module` = `services.{domain}.module`
178
178
  - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
@@ -184,7 +184,7 @@ If `services` section is present:
184
184
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
185
185
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
186
186
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
187
- - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **only if step 2 did not already route it to a service** (multi-service umbrellas keep per-service tech-docs). This publishes the BE-authored API contract into the shared spec repo so FE/App can read it via the spec submodule at `/generate-code --phase=integration`.
187
+ - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **always when `spec_source` is set** (step 2 no longer pins tech-docs per-service in this case). The tech-design IS the cross-team API contract: BE authors it here, and FE/App read it from the same spec submodule at `/generate-code --phase=integration`. *(Per-service tech-docs only happen when there is no `spec_source` — a pure multi-service BE repo with no shared spec module.)*
188
188
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
189
189
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
190
190
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
@@ -215,7 +215,7 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
215
215
  | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
216
216
 
217
217
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
218
- - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
218
+ - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
219
219
  - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
220
220
 
221
221
  **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
@@ -230,19 +230,41 @@ If the file does not exist → skip silently.
230
230
 
231
231
  ---
232
232
 
233
- ## Step 3 — [CRITICAL] Load CLAUDE.md
233
+ ## Step 3 — [CRITICAL] Load CLAUDE.md (layered: root + service overlay)
234
234
 
235
235
  *This is the highest-priority context — it defines HOW to write code and documents for this project.*
236
236
 
237
- Read `CLAUDE.md`. Extract and store:
237
+ CLAUDE.md is loaded in **two layers** so umbrella-wide rules and service-specific
238
+ architecture/coding standards compose correctly. The agent always sits at the umbrella
239
+ root, but the implementation code lives in a service submodule with its OWN stack,
240
+ architecture, and conventions — so the service's CLAUDE.md must win for code generation.
241
+
242
+ **Layer 1 — [BASE] Root CLAUDE.md (umbrella-wide).**
243
+ Read `CLAUDE.md` at the repo root. Treat its contents as the **shared baseline** for the
244
+ whole umbrella — git conventions, data-protection posture, cross-cutting rules, and (in
245
+ single-service mode) the project's only architecture + coding standards.
246
+
247
+ **Layer 2 — [OVERLAY] Service CLAUDE.md (umbrella mode only).**
248
+ *Run only if `service_root` was set in Step 1.6 (i.e. a real service was routed to).*
249
+ Read `{service_root}/CLAUDE.md`. This file defines the architecture + coding standards of
250
+ the **actual stack being implemented** (e.g. `user-service` = java-spring, `web` = nextjs).
251
+ Overlay it on top of Layer 1: **on any conflict, the service value WINS** for architecture,
252
+ coding standards, and error handling. Layer-1 values that the service does not redefine
253
+ (e.g. git conventions, banned patterns shared org-wide) remain in effect.
254
+
255
+ From the **merged** result, extract and store:
238
256
 
239
257
  - **§1 Project Overview** → project name, language, framework, build/test commands, domains
240
- - **§2 Architecture** → layer order (e.g., Controller → Facade → Service → Repository), architectural rules
241
- - **§3 Coding Standards** → naming conventions (classes, methods), response wrapper type, forbidden patterns
242
- - **§5 Error Handling** → exception types, HTTP status code mapping, not-found exception class name
243
- - **§7 Git Conventions** → branch naming pattern, commit message format
258
+ - **§2 Architecture** → layer order (e.g., Controller → Facade → Service → Repository), architectural rules — *service overlay wins*
259
+ - **§3 Coding Standards** → naming conventions (classes, methods), response wrapper type, forbidden patterns — *service overlay wins*
260
+ - **§5 Error Handling** → exception types, HTTP status code mapping, not-found exception class name — *service overlay wins*
261
+ - **§7 Git Conventions** → branch naming pattern, commit message format — *root baseline unless service redefines*
244
262
 
245
- If `CLAUDE.md` does not exist → note it as missing and continue with project-context.yaml data only.
263
+ **Resolution rules:**
264
+ - If both layers exist → merge as above; record `claude_md_source = root + {service_root}`.
265
+ - If only the service overlay exists (no root CLAUDE.md) → use the service file alone; `claude_md_source = {service_root}`.
266
+ - If `service_root` is set but `{service_root}/CLAUDE.md` is **missing** → fall back to root CLAUDE.md and flag ⚠️ in the Step 7 recap (the service has no architecture/coding-standards definition — code generation will use umbrella defaults, which may be the wrong stack).
267
+ - If neither exists → note CLAUDE.md as missing and continue with project-context.yaml data only.
246
268
 
247
269
  ---
248
270
 
@@ -308,7 +330,7 @@ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
308
330
 
309
331
  If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
310
332
 
311
- 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).
333
+ These two variables (`active_module`, `platform_type`) are the canonical source for all branching logic in commands that need platform-specific behavior (dev-gen-test, debug, fix-bug, dev-smoke-test).
312
334
 
313
335
  ---
314
336
 
@@ -342,7 +364,8 @@ Output exactly this block:
342
364
  [CTX LOADED]
343
365
  Stack : {language} / {framework} / {database}
344
366
  Platform : {active_module} ({platform_type})
345
- Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
367
+ Layers : {layer order from merged CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
368
+ CLAUDE.md : {root + {service_root} | {service_root} only | root only | ⚠️ service overlay MISSING — using root | missing}
346
369
  Ticket : {ticket_prefix}-
347
370
  Dict : {loaded — N canonical terms, M banned terms | missing}
348
371
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
@@ -485,15 +508,22 @@ Suggest the logical next command based on workflow phase:
485
508
  | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
486
509
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
487
510
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
511
+ | /qc-analyze | `/qc-plan {UC-ID}` (resolve 🔴 blocker gaps first) |
512
+ | /qc-plan | `/qc-design-test {UC-ID}` |
513
+ | /qc-design-test | `/qc-review {UC-ID}` (test-case review) |
514
+ | /qc-review (test-case) | `/qc-run-test {UC-ID}` if APPROVED; fix TCs if NEEDS_FIX |
515
+ | /qc-run-test | `/qc-report {UC-ID}` then `/qc-review {UC-ID}` (script review) |
516
+ | /qc-review (script) | `/qc-report {UC-ID}` then create PR if APPROVED |
517
+ | /qc-report | `/validate-traces {UC-ID}` to refresh Living Docs (qc_status) |
488
518
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
489
519
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
490
- | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
491
- | /generate-tests | `/run-tests {UC-ID}` |
492
- | /run-tests (passing) | `/review-code {UC-ID}` |
493
- | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
494
- | /review-code | `/smoke-test {UC-ID}` or create PR |
495
- | /smoke-test | Create PR and link to ticket |
496
- | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
520
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/dev-gen-test {UC-ID}` |
521
+ | /dev-gen-test | `/dev-run-test {UC-ID}` |
522
+ | /dev-run-test (passing) | `/review-code {UC-ID}` |
523
+ | /dev-run-test (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
524
+ | /review-code | `/dev-smoke-test {UC-ID}` or create PR |
525
+ | /dev-smoke-test | Create PR and link to ticket |
526
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; all OK → create PR |
497
527
  | /fix-bug | Create PR and link to ticket |
498
528
  | /debug | `/fix-bug {ticket-id}` if fix needed |
499
529
  | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
@@ -165,7 +165,7 @@ If `services` section is present:
165
165
 
166
166
  **2. Route to service** — if active domain matches a key in `services`:
167
167
  - Override `paths.specs_dir` → `services.{domain}.specs_dir`
168
- - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir`
168
+ - Override `paths.tech_docs_dir` → `services.{domain}.tech_docs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, the tech-design (API contract) is a cross-team artifact and must live in the shared spec repo (handled in step 4), so leave `tech_docs_dir` for step 4 to route — do NOT pin it per-service here.
169
169
  - Store `active_service` = `services.{domain}.path`
170
170
  - Store `active_service_module` = `services.{domain}.module`
171
171
  - If service has its own `module` → use it as `active_module` (overrides `tech_stack.module`)
@@ -177,7 +177,7 @@ If `services` section is present:
177
177
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
178
178
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
179
179
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
180
- - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **only if step 2 did not already route it to a service** (multi-service umbrellas keep per-service tech-docs). This publishes the BE-authored API contract into the shared spec repo so FE/App can read it via the spec submodule at `/generate-code --phase=integration`.
180
+ - Override `paths.tech_docs_dir` → `{spec_source}/specs/tech-docs` — **always when `spec_source` is set** (step 2 no longer pins tech-docs per-service in this case). The tech-design IS the cross-team API contract: BE authors it here, and FE/App read it from the same spec submodule at `/generate-code --phase=integration`. *(Per-service tech-docs only happen when there is no `spec_source` — a pure multi-service BE repo with no shared spec module.)*
181
181
  - Override `paths.domain_knowledge_dir` → `{spec_source}/specs/domain-knowledge`
182
182
  - Override `paths.business_dictionary` → `{spec_source}/specs/domain-knowledge/business-dictionary.md`
183
183
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
@@ -208,7 +208,7 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
208
208
  | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
209
209
 
210
210
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
211
- - Shell commands (`/run-tests`, `/generate-tests`) run **from within** `service_root`
211
+ - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
212
212
  - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
213
213
 
214
214
  **4. If service config not found** — keep umbrella defaults, still set `service_root = {active_service}` (path anchor is always needed even without a config override).
@@ -223,19 +223,41 @@ If the file does not exist → skip silently.
223
223
 
224
224
  ---
225
225
 
226
- ## Step 3 — [CRITICAL] Load CLAUDE.md
226
+ ## Step 3 — [CRITICAL] Load CLAUDE.md (layered: root + service overlay)
227
227
 
228
228
  *This is the highest-priority context — it defines HOW to write code and documents for this project.*
229
229
 
230
- Read `CLAUDE.md`. Extract and store:
230
+ CLAUDE.md is loaded in **two layers** so umbrella-wide rules and service-specific
231
+ architecture/coding standards compose correctly. The agent always sits at the umbrella
232
+ root, but the implementation code lives in a service submodule with its OWN stack,
233
+ architecture, and conventions — so the service's CLAUDE.md must win for code generation.
234
+
235
+ **Layer 1 — [BASE] Root CLAUDE.md (umbrella-wide).**
236
+ Read `CLAUDE.md` at the repo root. Treat its contents as the **shared baseline** for the
237
+ whole umbrella — git conventions, data-protection posture, cross-cutting rules, and (in
238
+ single-service mode) the project's only architecture + coding standards.
239
+
240
+ **Layer 2 — [OVERLAY] Service CLAUDE.md (umbrella mode only).**
241
+ *Run only if `service_root` was set in Step 1.6 (i.e. a real service was routed to).*
242
+ Read `{service_root}/CLAUDE.md`. This file defines the architecture + coding standards of
243
+ the **actual stack being implemented** (e.g. `user-service` = java-spring, `web` = nextjs).
244
+ Overlay it on top of Layer 1: **on any conflict, the service value WINS** for architecture,
245
+ coding standards, and error handling. Layer-1 values that the service does not redefine
246
+ (e.g. git conventions, banned patterns shared org-wide) remain in effect.
247
+
248
+ From the **merged** result, extract and store:
231
249
 
232
250
  - **§1 Project Overview** → project name, language, framework, build/test commands, domains
233
- - **§2 Architecture** → layer order (e.g., Controller → Facade → Service → Repository), architectural rules
234
- - **§3 Coding Standards** → naming conventions (classes, methods), response wrapper type, forbidden patterns
235
- - **§5 Error Handling** → exception types, HTTP status code mapping, not-found exception class name
236
- - **§7 Git Conventions** → branch naming pattern, commit message format
251
+ - **§2 Architecture** → layer order (e.g., Controller → Facade → Service → Repository), architectural rules — *service overlay wins*
252
+ - **§3 Coding Standards** → naming conventions (classes, methods), response wrapper type, forbidden patterns — *service overlay wins*
253
+ - **§5 Error Handling** → exception types, HTTP status code mapping, not-found exception class name — *service overlay wins*
254
+ - **§7 Git Conventions** → branch naming pattern, commit message format — *root baseline unless service redefines*
237
255
 
238
- If `CLAUDE.md` does not exist → note it as missing and continue with project-context.yaml data only.
256
+ **Resolution rules:**
257
+ - If both layers exist → merge as above; record `claude_md_source = root + {service_root}`.
258
+ - If only the service overlay exists (no root CLAUDE.md) → use the service file alone; `claude_md_source = {service_root}`.
259
+ - If `service_root` is set but `{service_root}/CLAUDE.md` is **missing** → fall back to root CLAUDE.md and flag ⚠️ in the Step 7 recap (the service has no architecture/coding-standards definition — code generation will use umbrella defaults, which may be the wrong stack).
260
+ - If neither exists → note CLAUDE.md as missing and continue with project-context.yaml data only.
239
261
 
240
262
  ---
241
263
 
@@ -301,7 +323,7 @@ active_module = tech_stack.module (e.g. "java-spring", "react", "flutter")
301
323
 
302
324
  If `tech_stack.module` is blank or not recognized → set `platform_type = "unknown"` and flag as ⚠️ in the Step 7 recap.
303
325
 
304
- 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).
326
+ These two variables (`active_module`, `platform_type`) are the canonical source for all branching logic in commands that need platform-specific behavior (dev-gen-test, debug, fix-bug, dev-smoke-test).
305
327
 
306
328
  ---
307
329
 
@@ -335,7 +357,8 @@ Output exactly this block:
335
357
  [CTX LOADED]
336
358
  Stack : {language} / {framework} / {database}
337
359
  Platform : {active_module} ({platform_type})
338
- Layers : {layer order from CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
360
+ Layers : {layer order from merged CLAUDE.md §2, e.g., Controller → Facade → Service → Repository}
361
+ CLAUDE.md : {root + {service_root} | {service_root} only | root only | ⚠️ service overlay MISSING — using root | missing}
339
362
  Ticket : {ticket_prefix}-
340
363
  Dict : {loaded — N canonical terms, M banned terms | missing}
341
364
  Entities : {loaded — EntityA, EntityB, EntityC | missing}
@@ -447,15 +470,22 @@ Suggest the logical next command based on workflow phase:
447
470
  | /generate-design-spec | Designer review → Figma links confirmed → PO + Designer sign-off → `/generate-bdd {prd-file}` |
448
471
  | /generate-bdd | `/review-context {feature-file}` to verify coverage |
449
472
  | /review-context (BDD) | `/generate-tech-docs {UC-ID}` if APPROVED; regenerate if NEEDS_FIX |
473
+ | /qc-analyze | `/qc-plan {UC-ID}` (resolve 🔴 blocker gaps first) |
474
+ | /qc-plan | `/qc-design-test {UC-ID}` |
475
+ | /qc-design-test | `/qc-review {UC-ID}` (test-case review) |
476
+ | /qc-review (test-case) | `/qc-run-test {UC-ID}` if APPROVED; fix TCs if NEEDS_FIX |
477
+ | /qc-run-test | `/qc-report {UC-ID}` then `/qc-review {UC-ID}` (script review) |
478
+ | /qc-review (script) | `/qc-report {UC-ID}` then create PR if APPROVED |
479
+ | /qc-report | `/validate-traces {UC-ID}` to refresh Living Docs (qc_status) |
450
480
  | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
451
481
  | /review-tech-docs | `/generate-code {feature-file}` if APPROVED; fix doc if NEEDS_FIX |
452
- | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/generate-tests {UC-ID}` |
453
- | /generate-tests | `/run-tests {UC-ID}` |
454
- | /run-tests (passing) | `/review-code {UC-ID}` |
455
- | /run-tests (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
456
- | /review-code | `/smoke-test {UC-ID}` or create PR |
457
- | /smoke-test | Create PR and link to ticket |
458
- | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/generate-tests {UC-ID}`; all OK → create PR |
482
+ | /generate-code | First gen → `/review-code {UC-ID}`; re-gen → `/dev-gen-test {UC-ID}` |
483
+ | /dev-gen-test | `/dev-run-test {UC-ID}` |
484
+ | /dev-run-test (passing) | `/review-code {UC-ID}` |
485
+ | /dev-run-test (failing) | `/fix-bug {ticket-id}` or `/debug {error}` |
486
+ | /review-code | `/dev-smoke-test {UC-ID}` or create PR |
487
+ | /dev-smoke-test | Create PR and link to ticket |
488
+ | /validate-traces | DRIFT/UNTRACKED → `/generate-code {UC-ID}`; GAP → `/dev-gen-test {UC-ID}`; all OK → create PR |
459
489
  | /fix-bug | Create PR and link to ticket |
460
490
  | /debug | `/fix-bug {ticket-id}` if fix needed |
461
491
  | /report-bug | Send to dev (`/fix-bug {BUG-ID}`); if coverage gap → `/propose-scenario {UC-ID}` |
@@ -491,7 +521,7 @@ Output Artifacts: none (read-only)
491
521
  Verdict: APPROVED ✅ | NEEDS_FIX ❌
492
522
 
493
523
  If APPROVED ✅:
494
- Next: /generate-tests {UC-ID}
524
+ Next: /dev-gen-test {UC-ID}
495
525
 
496
526
  If NEEDS_FIX ❌:
497
527
  - Small fix (1–3 lines, no logic change) → fix inline → re-run /review-code {UC-ID}
@@ -570,7 +600,7 @@ If `lessons_path` does not exist, create it with this header first:
570
600
  | code-gen | /generate-code output |
571
601
  | bdd | /generate-bdd output |
572
602
  | tech-docs | /generate-tech-docs output |
573
- | tests | /generate-tests output |
603
+ | tests | /dev-gen-test output |
574
604
  | prd | /generate-prd, /refine-prd output |
575
605
  | general | every command |
576
606
 
@@ -78,7 +78,7 @@ Output Artifacts: none (read-only)
78
78
  Verdict: APPROVED ✅ | NEEDS_FIX ❌
79
79
 
80
80
  If APPROVED ✅:
81
- Next: /generate-tests {UC-ID}
81
+ Next: /dev-gen-test {UC-ID}
82
82
 
83
83
  If NEEDS_FIX ❌:
84
84
  - Small fix (1–3 lines, no logic change) → fix inline → re-run /review-code {UC-ID}