@anhth2/spec-driven-dev-plugin 0.11.0 → 0.14.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 (173) hide show
  1. package/commands/debug.md +47 -7
  2. package/commands/define-product.md +47 -7
  3. package/commands/dev-gen-test.md +65 -17
  4. package/commands/dev-run-test.md +66 -18
  5. package/commands/dev-run-test.tmpl +1 -1
  6. package/commands/dev-smoke-test.md +47 -7
  7. package/commands/fix-bug.md +83 -13
  8. package/commands/fix-bug.tmpl +36 -6
  9. package/commands/generate-bdd.md +74 -21
  10. package/commands/generate-bdd.tmpl +9 -4
  11. package/commands/generate-code.md +118 -35
  12. package/commands/generate-code.tmpl +53 -18
  13. package/commands/generate-design-spec.md +47 -7
  14. package/commands/generate-prd.md +47 -7
  15. package/commands/generate-spec-manifest.md +47 -7
  16. package/commands/generate-tech-docs.md +234 -20
  17. package/commands/generate-tech-docs.tmpl +187 -13
  18. package/commands/learn.md +47 -7
  19. package/commands/map-testids.md +564 -0
  20. package/commands/map-testids.tmpl +81 -0
  21. package/commands/propose-scenario.md +78 -18
  22. package/commands/propose-scenario.tmpl +31 -11
  23. package/commands/qc-analyze.md +67 -12
  24. package/commands/qc-analyze.tmpl +20 -5
  25. package/commands/qc-design-test.md +51 -10
  26. package/commands/qc-design-test.tmpl +4 -3
  27. package/commands/qc-plan.md +50 -10
  28. package/commands/qc-plan.tmpl +3 -3
  29. package/commands/qc-report.md +60 -8
  30. package/commands/qc-report.tmpl +13 -1
  31. package/commands/qc-review.md +49 -9
  32. package/commands/qc-review.tmpl +2 -2
  33. package/commands/qc-run-test.md +75 -20
  34. package/commands/qc-run-test.tmpl +10 -3
  35. package/commands/refine-prd.md +47 -7
  36. package/commands/report-bug.md +63 -9
  37. package/commands/report-bug.tmpl +16 -2
  38. package/commands/review-code.md +47 -7
  39. package/commands/review-context.md +47 -7
  40. package/commands/review-tech-docs.md +50 -9
  41. package/commands/review-tech-docs.tmpl +3 -2
  42. package/commands/setup-ai-first.md +37 -4
  43. package/commands/setup-ai-first.tmpl +2 -2
  44. package/commands/sync.md +47 -11
  45. package/commands/sync.tmpl +12 -9
  46. package/commands/update-framework.md +35 -2
  47. package/commands/validate-traces.md +98 -40
  48. package/commands/validate-traces.tmpl +51 -33
  49. package/core/FRAMEWORK_VERSION +1 -1
  50. package/core/commands/debug.md +47 -7
  51. package/core/commands/define-product.md +47 -7
  52. package/core/commands/dev-gen-test.md +65 -17
  53. package/core/commands/dev-run-test.md +66 -18
  54. package/core/commands/dev-smoke-test.md +47 -7
  55. package/core/commands/fix-bug.md +83 -13
  56. package/core/commands/generate-bdd.md +74 -21
  57. package/core/commands/generate-code.md +118 -35
  58. package/core/commands/generate-design-spec.md +47 -7
  59. package/core/commands/generate-prd.md +47 -7
  60. package/core/commands/generate-spec-manifest.md +47 -7
  61. package/core/commands/generate-tech-docs.md +234 -20
  62. package/core/commands/learn.md +47 -7
  63. package/core/commands/map-testids.md +564 -0
  64. package/core/commands/propose-scenario.md +78 -18
  65. package/core/commands/qc-analyze.md +67 -12
  66. package/core/commands/qc-design-test.md +51 -10
  67. package/core/commands/qc-plan.md +50 -10
  68. package/core/commands/qc-report.md +60 -8
  69. package/core/commands/qc-review.md +49 -9
  70. package/core/commands/qc-run-test.md +75 -20
  71. package/core/commands/refine-prd.md +47 -7
  72. package/core/commands/report-bug.md +63 -9
  73. package/core/commands/review-code.md +47 -7
  74. package/core/commands/review-context.md +47 -7
  75. package/core/commands/review-tech-docs.md +50 -9
  76. package/core/commands/setup-ai-first.md +37 -4
  77. package/core/commands/sync.md +47 -11
  78. package/core/commands/update-framework.md +35 -2
  79. package/core/commands/validate-traces.md +98 -40
  80. package/core/modules/qc-playwright/stack-profile.yaml +4 -3
  81. package/core/skills/code/SKILL.md +82 -9
  82. package/core/skills/debug/SKILL.md +117 -11
  83. package/core/skills/design-spec/SKILL.md +47 -7
  84. package/core/skills/discovery/SKILL.md +47 -7
  85. package/core/skills/prd/SKILL.md +70 -4
  86. package/core/skills/qc/qa-analyst/acceptance-criteria.md +5 -1
  87. package/core/skills/qc/qa-analyst/business-rules.md +6 -2
  88. package/core/skills/qc/qa-analyst/data-flow.md +6 -2
  89. package/core/skills/qc/qa-analyst/spec-breakdown.md +7 -3
  90. package/core/skills/qc/qa-designer/e2e/journey.md +1 -1
  91. package/core/skills/qc/qa-designer/exploratory/charter.md +2 -2
  92. package/core/skills/qc/qa-designer/exploratory/explore-to-functional.md +1 -1
  93. package/core/skills/qc/qa-designer/functional/api.md +1 -1
  94. package/core/skills/qc/qa-designer/functional/gui-feature.md +1 -1
  95. package/core/skills/qc/qa-designer/functional/gui-screen.md +1 -1
  96. package/core/skills/qc/qa-designer/integration/api.md +1 -1
  97. package/core/skills/qc/qa-designer/integration/db.md +1 -1
  98. package/core/skills/qc/qa-designer/integration/gui.md +1 -1
  99. package/core/skills/qc/qa-designer/integration/kafka.md +1 -1
  100. package/core/skills/qc/qa-designer/non-functional.md +1 -1
  101. package/core/skills/qc/qa-planner/test-plan.md +4 -4
  102. package/core/skills/qc/qa-runner/exploratory/session.md +2 -2
  103. package/core/skills/setup-ai-first/SKILL.md +35 -2
  104. package/core/skills/spec/SKILL.md +70 -4
  105. package/core/skills/test/SKILL.md +129 -16
  106. package/core/steps/context-loader.md +12 -5
  107. package/core/steps/report-footer.md +35 -2
  108. package/core/steps/trace-mirror.md +18 -10
  109. package/core/templates/project-context.yaml +27 -6
  110. package/docs/01-getting-started/core-concepts.md +7 -7
  111. package/docs/01-getting-started/installation.md +4 -2
  112. package/docs/01-getting-started/quickstart.md +1 -1
  113. package/docs/02-guides/README.md +1 -2
  114. package/docs/02-guides/developer/README.md +1 -1
  115. package/docs/02-guides/developer/bdd-and-trace.md +10 -8
  116. package/docs/02-guides/developer/commands.md +4 -4
  117. package/docs/02-guides/developer/scenarios.md +26 -14
  118. package/docs/02-guides/developer/workflow.md +81 -19
  119. package/docs/02-guides/product-owner/README.md +6 -4
  120. package/docs/02-guides/product-owner/commands.md +1 -1
  121. package/docs/02-guides/product-owner/scenarios.md +80 -1
  122. package/docs/02-guides/tester/README.md +13 -10
  123. package/docs/02-guides/tester/bug-reporting.md +2 -2
  124. package/docs/02-guides/tester/qc-automation.md +165 -0
  125. package/docs/02-guides/tester/reading-specs.md +4 -4
  126. package/docs/02-guides/tester/scenarios.md +5 -5
  127. package/docs/02-guides/tester/spec-manifest.md +17 -12
  128. package/docs/02-guides/tester/test-checklist.md +3 -3
  129. package/docs/02-guides/tester/workflow.md +12 -14
  130. package/docs/03-concepts/architecture.md +7 -4
  131. package/docs/03-concepts/pipeline.md +37 -12
  132. package/docs/03-concepts/traceability.md +19 -18
  133. package/docs/04-operations/README.md +1 -1
  134. package/docs/04-operations/bug-flow.md +46 -5
  135. package/docs/04-operations/sync-and-update.md +186 -24
  136. package/docs/05-reference/README.md +3 -0
  137. package/docs/05-reference/command-cheatsheet.md +147 -0
  138. package/docs/05-reference/commands.md +73 -70
  139. package/docs/05-reference/modules.md +4 -4
  140. package/docs/05-reference/trace-schema.md +23 -16
  141. package/docs/README.md +3 -5
  142. package/modules/qc-playwright/stack-profile.yaml +4 -3
  143. package/package.json +1 -1
  144. package/skills/code/SKILL.md +82 -9
  145. package/skills/debug/SKILL.md +117 -11
  146. package/skills/design-spec/SKILL.md +47 -7
  147. package/skills/discovery/SKILL.md +47 -7
  148. package/skills/prd/SKILL.md +70 -4
  149. package/skills/qc/qa-analyst/acceptance-criteria.md +5 -1
  150. package/skills/qc/qa-analyst/business-rules.md +6 -2
  151. package/skills/qc/qa-analyst/data-flow.md +6 -2
  152. package/skills/qc/qa-analyst/spec-breakdown.md +7 -3
  153. package/skills/qc/qa-designer/e2e/journey.md +1 -1
  154. package/skills/qc/qa-designer/exploratory/charter.md +2 -2
  155. package/skills/qc/qa-designer/exploratory/explore-to-functional.md +1 -1
  156. package/skills/qc/qa-designer/functional/api.md +1 -1
  157. package/skills/qc/qa-designer/functional/gui-feature.md +1 -1
  158. package/skills/qc/qa-designer/functional/gui-screen.md +1 -1
  159. package/skills/qc/qa-designer/integration/api.md +1 -1
  160. package/skills/qc/qa-designer/integration/db.md +1 -1
  161. package/skills/qc/qa-designer/integration/gui.md +1 -1
  162. package/skills/qc/qa-designer/integration/kafka.md +1 -1
  163. package/skills/qc/qa-designer/non-functional.md +1 -1
  164. package/skills/qc/qa-planner/test-plan.md +4 -4
  165. package/skills/qc/qa-runner/exploratory/session.md +2 -2
  166. package/skills/setup-ai-first/SKILL.md +35 -2
  167. package/skills/spec/SKILL.md +70 -4
  168. package/skills/test/SKILL.md +129 -16
  169. package/steps/context-loader.md +12 -5
  170. package/steps/report-footer.md +35 -2
  171. package/steps/trace-mirror.md +18 -10
  172. package/templates/project-context.yaml +27 -6
  173. package/docs/02-guides/qc-automation.md +0 -92
@@ -130,6 +130,8 @@ Read `.agent/project-context.yaml`. Extract and store:
130
130
  - `paths.specs_dir` → BDD specs root
131
131
  - `paths.prd_dir` → PRD documents root
132
132
  - `paths.refinement_dir` → findings/review output dir
133
+ - `paths.qc_dir` → QC automation artifacts root (visible top-level, one subfolder per UC: `{qc_dir}/{UC-ID}/`)
134
+ - `paths.qc_skills_dir` → where qc-* commands load QC skills from (default bundled `.agent/skills/qc`; override to the QC team's own repo/submodule so framework upgrade won't overwrite them)
133
135
  - `paths.product_definitions_dir` → product definitions root
134
136
  - `paths.domain_knowledge_dir` → domain knowledge root
135
137
  - `paths.business_dictionary` → path to business-dictionary.md
@@ -142,6 +144,8 @@ If `paths` section is absent, use these defaults:
142
144
  - `specs_dir` = `specs/bdd`
143
145
  - `prd_dir` = `specs/prd`
144
146
  - `refinement_dir` = `.agent/review`
147
+ - `qc_dir` = `docs`
148
+ - `qc_skills_dir` = `.agent/skills/qc`
145
149
  - `product_definitions_dir` = `specs/product-definition`
146
150
  - `domain_knowledge_dir` = `specs/domain-knowledge`
147
151
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
@@ -167,7 +171,7 @@ If `services` section is present:
167
171
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
168
172
 
169
173
  **2. Route to service** — if active domain matches a key in `services`:
170
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
174
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, ALL BDD (web/app/**system**) is a shared cross-team artifact → leave `specs_dir` for step 4 to route to the spec repo; do NOT pin it per-service here.
171
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.
172
176
  - Store `active_service` = `services.{domain}.path`
173
177
  - Store `active_service_module` = `services.{domain}.module`
@@ -178,6 +182,7 @@ If `services` section is present:
178
182
  - Set `active_service = unresolved`
179
183
 
180
184
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
185
+ - Override `paths.specs_dir` → `{spec_source}/specs/bdd` — **always when `spec_source` is set.** All BDD (web/app/**system**) lives in the shared spec repo so every umbrella (FE/App/BE) reads the same scenarios; the FE tech-design gate + `/generate-code --phase=ui`/`--phase=integration` resolve the `system/` BDD here. *(Per-service `specs/bdd` only when there is no `spec_source`.)*
181
186
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
182
187
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
183
188
  - 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.)*
@@ -186,8 +191,10 @@ If `services` section is present:
186
191
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
187
192
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
188
193
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
194
+ - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
195
+ - Override `paths.trace_dir` → `{spec_source}/.trace` — **always when `spec_source` is set.** Trace TSVs are consolidated in the spec repo (single authoritative location, no per-service split) so the PM/PO has one place to manage status. Code-side commands (`/generate-code`, `/dev-run-test`, `/qc-run-test`) run from `service_root` but **write their trace row into `{spec_source}/.trace`** — like they already push `feedback/` there. *(Per-service `.trace` only when there is no `spec_source`.)*
189
196
 
190
- > **Why under `spec_source`:** PRD, design-spec, domain knowledge, the **API contract (tech-docs)**, and tester feedback are all **cross-team artifacts** — they must live in the **shared spec repo** so every umbrella (FE/App/BE) reads the same source via `/sync`. Tech-docs specifically: BE authors the tech-design (API contract), commits + pushes it into the spec submodule (2-layer commit), and FE/App pull it on their next `/sync` to wire the real API in `/generate-code --phase=integration`. In single-service mode (no `spec_source`), these default under the repo root — still shared, same repo.
197
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, **all BDD (web/app/system)**, the **API contract (tech-docs)**, tester feedback, **and the `.trace/` coverage state** are all **cross-team artifacts** — they live in the **shared spec repo** so every umbrella (FE/App/BE) and the PM read one source via `/sync`. The service submodule holds only **code** (+ build/test tooling). `.trace/` and `feedback/` are the dev/QC **write areas** in the spec repo (the PRD/BDD/design-spec/tech-docs there stay read-only for dev/QC only PO edits those). In single-service mode (no `spec_source`), everything defaults under the repo root — still one repo.
191
198
 
192
199
  ---
193
200
 
@@ -207,12 +214,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
207
214
  |----------|--------|
208
215
  | `conventions.test_command` | service's `conventions.test_command` |
209
216
  | `conventions.build_command` | service's `conventions.build_command` |
210
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
211
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
217
+ | `paths.trace_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/.trace`); ignore any service-level `trace_dir`.** Only when there is no `spec_source`: `{active_service}/{service paths.trace_dir}` (default `{active_service}/.trace`). |
218
+ | `paths.specs_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/specs/bdd`); ignore any service-level `specs_dir`** (BDD is cross-team, never per-service in this mode). Only when there is no `spec_source`: `{active_service}/{service paths.specs_dir}` if set, else the Step 1.5 override. |
212
219
 
213
220
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
214
221
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
215
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
222
+ - **Source/test files** are written relative to `service_root`; **trace TSVs** are written to `{paths.trace_dir}` (the spec repo when `spec_source` is set — a cross-repo write, committed/pushed to the spec submodule like `feedback/`).
216
223
 
217
224
  **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).
218
225
 
@@ -536,6 +543,36 @@ Output Artifacts:
536
543
 
537
544
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
538
545
 
546
+ ## Pipeline Position
547
+
548
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
549
+ so the user always sees where this command sits in the end-to-end flow:
550
+
551
+ ```
552
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
553
+ ```
554
+
555
+ Find the current command in this phase legend and mark **its** phase in the map above:
556
+
557
+ | Phase | Commands |
558
+ |-------|----------|
559
+ | Discovery | `/define-product` |
560
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
561
+ | Design Spec | `/generate-design-spec` |
562
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
563
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
564
+ | Code | `/generate-code` · `/review-code` |
565
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
566
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
567
+ | Trace Audit | `/validate-traces` |
568
+
569
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
570
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
571
+
572
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
573
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
574
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
575
+
539
576
  ## Next Command Suggestion
540
577
 
541
578
  Suggest the logical next command based on workflow phase:
@@ -577,10 +614,13 @@ Suggest the logical next command based on workflow phase:
577
614
  Format the footer as:
578
615
  ```
579
616
  ---
580
- Status : {badge}
617
+ Status : {badge}
581
618
  {Output Artifacts block}
582
- Next : {suggested command with example arguments}
619
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
620
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
621
+ Next : {suggested command with example arguments}
583
622
  ```
623
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
584
624
 
585
625
 
586
626
  ```
@@ -146,6 +146,8 @@ Read `.agent/project-context.yaml`. Extract and store:
146
146
  - `paths.specs_dir` → BDD specs root
147
147
  - `paths.prd_dir` → PRD documents root
148
148
  - `paths.refinement_dir` → findings/review output dir
149
+ - `paths.qc_dir` → QC automation artifacts root (visible top-level, one subfolder per UC: `{qc_dir}/{UC-ID}/`)
150
+ - `paths.qc_skills_dir` → where qc-* commands load QC skills from (default bundled `.agent/skills/qc`; override to the QC team's own repo/submodule so framework upgrade won't overwrite them)
149
151
  - `paths.product_definitions_dir` → product definitions root
150
152
  - `paths.domain_knowledge_dir` → domain knowledge root
151
153
  - `paths.business_dictionary` → path to business-dictionary.md
@@ -158,6 +160,8 @@ If `paths` section is absent, use these defaults:
158
160
  - `specs_dir` = `specs/bdd`
159
161
  - `prd_dir` = `specs/prd`
160
162
  - `refinement_dir` = `.agent/review`
163
+ - `qc_dir` = `docs`
164
+ - `qc_skills_dir` = `.agent/skills/qc`
161
165
  - `product_definitions_dir` = `specs/product-definition`
162
166
  - `domain_knowledge_dir` = `specs/domain-knowledge`
163
167
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
@@ -183,7 +187,7 @@ If `services` section is present:
183
187
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
184
188
 
185
189
  **2. Route to service** — if active domain matches a key in `services`:
186
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
190
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, ALL BDD (web/app/**system**) is a shared cross-team artifact → leave `specs_dir` for step 4 to route to the spec repo; do NOT pin it per-service here.
187
191
  - 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.
188
192
  - Store `active_service` = `services.{domain}.path`
189
193
  - Store `active_service_module` = `services.{domain}.module`
@@ -194,6 +198,7 @@ If `services` section is present:
194
198
  - Set `active_service = unresolved`
195
199
 
196
200
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
201
+ - Override `paths.specs_dir` → `{spec_source}/specs/bdd` — **always when `spec_source` is set.** All BDD (web/app/**system**) lives in the shared spec repo so every umbrella (FE/App/BE) reads the same scenarios; the FE tech-design gate + `/generate-code --phase=ui`/`--phase=integration` resolve the `system/` BDD here. *(Per-service `specs/bdd` only when there is no `spec_source`.)*
197
202
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
198
203
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
199
204
  - 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.)*
@@ -202,8 +207,10 @@ If `services` section is present:
202
207
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
203
208
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
204
209
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
210
+ - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
211
+ - Override `paths.trace_dir` → `{spec_source}/.trace` — **always when `spec_source` is set.** Trace TSVs are consolidated in the spec repo (single authoritative location, no per-service split) so the PM/PO has one place to manage status. Code-side commands (`/generate-code`, `/dev-run-test`, `/qc-run-test`) run from `service_root` but **write their trace row into `{spec_source}/.trace`** — like they already push `feedback/` there. *(Per-service `.trace` only when there is no `spec_source`.)*
205
212
 
206
- > **Why under `spec_source`:** PRD, design-spec, domain knowledge, the **API contract (tech-docs)**, and tester feedback are all **cross-team artifacts** — they must live in the **shared spec repo** so every umbrella (FE/App/BE) reads the same source via `/sync`. Tech-docs specifically: BE authors the tech-design (API contract), commits + pushes it into the spec submodule (2-layer commit), and FE/App pull it on their next `/sync` to wire the real API in `/generate-code --phase=integration`. In single-service mode (no `spec_source`), these default under the repo root — still shared, same repo.
213
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, **all BDD (web/app/system)**, the **API contract (tech-docs)**, tester feedback, **and the `.trace/` coverage state** are all **cross-team artifacts** — they live in the **shared spec repo** so every umbrella (FE/App/BE) and the PM read one source via `/sync`. The service submodule holds only **code** (+ build/test tooling). `.trace/` and `feedback/` are the dev/QC **write areas** in the spec repo (the PRD/BDD/design-spec/tech-docs there stay read-only for dev/QC only PO edits those). In single-service mode (no `spec_source`), everything defaults under the repo root — still one repo.
207
214
 
208
215
  ---
209
216
 
@@ -223,12 +230,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
223
230
  |----------|--------|
224
231
  | `conventions.test_command` | service's `conventions.test_command` |
225
232
  | `conventions.build_command` | service's `conventions.build_command` |
226
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
227
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
233
+ | `paths.trace_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/.trace`); ignore any service-level `trace_dir`.** Only when there is no `spec_source`: `{active_service}/{service paths.trace_dir}` (default `{active_service}/.trace`). |
234
+ | `paths.specs_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/specs/bdd`); ignore any service-level `specs_dir`** (BDD is cross-team, never per-service in this mode). Only when there is no `spec_source`: `{active_service}/{service paths.specs_dir}` if set, else the Step 1.5 override. |
228
235
 
229
236
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
230
237
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
231
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
238
+ - **Source/test files** are written relative to `service_root`; **trace TSVs** are written to `{paths.trace_dir}` (the spec repo when `spec_source` is set — a cross-repo write, committed/pushed to the spec submodule like `feedback/`).
232
239
 
233
240
  **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).
234
241
 
@@ -405,10 +412,57 @@ After completing all steps, you have loaded:
405
412
  Proceed to the next step of the calling command.
406
413
 
407
414
 
415
+ ---
416
+
417
+ ## Step 0 — Detect Platform & Route Output
418
+
419
+ Read `@trace.platform` from the feature file header (`web` | `app` | `system`). If absent, fall back to `platform_type` from context (`web-frontend`/`mobile` → FE; `backend` → BE).
420
+
421
+ | Platform | `active_tech_design` | Output file |
422
+ |----------|----------------------|-------------|
423
+ | `system` / backend | **`be`** — the cross-team **API contract** (authoritative) | `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md` |
424
+ | `web` / `app` (web-frontend / mobile) | **`fe`** — the **client technical design** (consumes the BE contract) | `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design-{platform}.md` |
425
+
426
+ Store `active_tech_design` and `tech_design_path`. The `-{platform}` suffix (mirroring design-spec) keeps the FE doc from colliding with the BE contract — both live in the shared spec repo when `spec_source` is set.
427
+
428
+ ---
429
+
430
+ ## Step 0.5 — FE/App Precondition Gate
431
+
432
+ *Skip this entire step for BE (`active_tech_design = be`).*
433
+
434
+ An FE/App technical design is a **derived** artifact: its API-integration layer maps onto the locked BE contract, and its state/error model comes from the system behavior. Both upstream inputs MUST exist first — **HALT** if either is missing:
435
+
436
+ 1. **System BDD** — locate `{paths.specs_dir}/{domain}/system/{TICKET-ID}*.feature`.
437
+ If not found → HALT:
438
+ ```
439
+ ❌ Cannot generate FE tech-design — System BDD not found for {TICKET-ID}.
440
+ The FE design needs the system-level (BE-facing) behavior first.
441
+ → PO/BE: /generate-bdd {prd-file} (produces the `system/` platform BDD)
442
+ ```
443
+ 2. **BE tech-docs (API contract)** — locate the BE doc `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md` and read its `@trace.status`.
444
+ - Not found → HALT:
445
+ ```
446
+ ❌ Cannot generate FE tech-design — BE API contract not found.
447
+ The FE integration layer maps to the BE contract; it must exist first.
448
+ → BE: /generate-tech-docs {system .feature} → /review-tech-docs (approve) → publish to spec repo
449
+ ```
450
+ - Found but `@trace.status` ≠ `approved` → WARN and ask:
451
+ ```
452
+ ⚠️ BE contract {UC-ID}-tech-design.md is status: {status} (not approved) — it may still change.
453
+ Designing the FE integration against a non-final contract risks rework.
454
+ Continue anyway? (Y/N)
455
+ ```
456
+ - Y → proceed (accept risk) · N → stop, wait for BE to approve.
457
+
458
+ Store `system_bdd_path` and `be_contract_path` — they are the primary inputs for the FE §3/§4 below.
459
+
408
460
  ---
409
461
 
410
462
  ## Brownfield Check
411
463
 
464
+ *BE (`active_tech_design = be`) only — for FE the "existing contract" is the BE doc loaded in Step 0.5.*
465
+
412
466
  Read the source `.feature` file header for `@trace.api_source`.
413
467
  Also check the source PRD Metadata table for `| **API Source** | existing |`.
414
468
 
@@ -425,10 +479,11 @@ If `active_mode = reverse-document` → load bảng "Existing API Contract" từ
425
479
 
426
480
  ## CHECKPOINT — Tech Design Plan
427
481
 
428
- Before generating, scan the feature file for scenario count, referenced BRs, and entities. Display and wait for Y:
482
+ Before generating, scan the feature file for scenario count, referenced BRs, and entities. Display the plan for the resolved `active_tech_design` and wait for Y:
429
483
 
484
+ **If `active_tech_design = be`:**
430
485
  ```
431
- Tech Design Plan — {UC-ID}
486
+ Tech Design Plan — {UC-ID} (BE · API contract)
432
487
  ──────────────────────────────────────────────────────
433
488
  UC : {UC-ID} — {feature title}
434
489
  Service : {trace.service}
@@ -452,12 +507,42 @@ Sections to generate:
452
507
  Proceed? (Y/N)
453
508
  ```
454
509
 
510
+ **If `active_tech_design = fe`:**
511
+ ```
512
+ Tech Design Plan — {UC-ID} (FE · {platform} · client design)
513
+ ──────────────────────────────────────────────────────
514
+ UC : {UC-ID} — {feature title}
515
+ Service : {trace.service} Module: {trace.module} ({platform})
516
+ Inputs : System BDD → {system_bdd_path}
517
+ BE contract → {be_contract_path} (status: {be status})
518
+ Scenarios : {N} FE scenarios | BDD ver: {trace.bdd_version}
519
+ Output : {paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design-{platform}.md
520
+
521
+ Sections to generate:
522
+ §1 Overview (FE scope of this UC)
523
+ §2 Component Architecture (tree + reuse from figma-components catalog)
524
+ §2b Test Selectors (stable test-id cho element có action — QC contract, attr theo platform)
525
+ §3 State Management (store/slices/state shape ← System BDD Then-clauses)
526
+ §4 API Integration Layer (port/adapter: each BE endpoint → FE service → DTO/model)
527
+ §5 Routing / Navigation
528
+ §6 Data Fetching & Client Caching (query keys, invalidation, optimistic updates)
529
+ §7 Error & Loading States (per scenario)
530
+ §8 Cross-Cutting (auth token, i18n, feature flags)
531
+ {§9 Offline / platform specifics — app only}
532
+ ──────────────────────────────────────────────────────
533
+ Proceed? (Y/N)
534
+ ```
535
+
455
536
  Wait for explicit "Y" before generating.
456
537
 
457
538
  ---
458
539
 
459
540
  ## Generate
460
541
 
542
+ Generate the document for the resolved `active_tech_design`.
543
+
544
+ ### Path A — BE API contract (`active_tech_design = be`)
545
+
461
546
  Write `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`:
462
547
 
463
548
  ```markdown
@@ -528,17 +613,111 @@ External calls, events produced/consumed.
528
613
  | 1 | {YYYY-MM-DD} | Initial generation from {UC-ID}.feature (BDD v{bdd_version}) |
529
614
  ```
530
615
 
531
- ## Publishshare the contract (umbrella + shared spec repo)
616
+ ### Path B FE/App client technical design (`active_tech_design = fe`)
617
+
618
+ Write `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design-{platform}.md`. The §4 integration layer maps **directly onto the BE contract** loaded in Step 0.5 — every FE service method must trace to a real endpoint in `{be_contract_path}` (no invented endpoints). State and error models in §3/§7 derive from the **System BDD** `Then` clauses.
619
+
620
+ ```markdown
621
+ # FE Technical Design — {UC-ID} ({platform}): {Feature}
622
+
623
+ ---
624
+ @trace.id: {UC-ID}
625
+ @trace.domain: {domain}
626
+ @trace.platform: {web | app}
627
+ @trace.service: {read @trace.service from the .feature file header}
628
+ @trace.module: {read @trace.module — e.g. react / nextjs / vue / angular / flutter}
629
+ @trace.prd: {TICKET-ID}
630
+ @trace.bdd_version: {read @trace.bdd_version from the FE .feature header}
631
+ @trace.system_bdd: {system_bdd_path}
632
+ @trace.be_contract: {UC-ID}-tech-design.md # the BE API contract this design consumes
633
+ @trace.testid_attr: {data-testid (web) | testID (react-native) | Key/Semantics (flutter) | accessibilityIdentifier (native-ios)}
634
+ @trace.revision: 1
635
+ @trace.status: draft
636
+ @trace.generated_at: {YYYY-MM-DD}
637
+ ---
638
+
639
+ ## §1. Overview
640
+
641
+ {FE scope của UC: màn hình/luồng nào, render gì, tích hợp API nào. Nêu rõ design này map theo BE contract {UC-ID}-tech-design.md.}
642
+
643
+ ## §2. Component Architecture
644
+
645
+ Component tree (container vs presentational). Ưu tiên tái dùng từ figma-components catalog (Step 6-B context); chỉ tạo mới khi không có sẵn.
646
+
647
+ | Component | Type | Reuse (catalog) / New | Responsibility |
648
+ |-----------|------|-----------------------|----------------|
649
+ | {Name} | container/presentational | {catalog name \| NEW} | {what it renders / handles} |
650
+
651
+ ## §2b. Test Selectors — Element IDs cho element CÓ ACTION (QC contract)
652
+
653
+ Mỗi element tương tác (button, input, link, select, toggle, form-submit…) được gán **test-id ổn định** để QC locate **trực tiếp** — không scan/giả lập runtime. Đây là contract giữa FE code (emit id) và QC Page Object (đọc id).
654
+
655
+ - **Quy ước (semantic-stable):** `{uc-lower}-{screen}-{element}-{type}` — vd `ft001-login-submit-btn`, `ft001-login-email-input`. **KHÔNG** nhúng số scenario (đổi khi renumber).
656
+ - **Attribute theo platform** (`@trace.testid_attr`): web `data-testid` · React Native `testID` · Flutter `Key('id')` + `Semantics(identifier:)` · native iOS `accessibilityIdentifier`.
657
+ - **Cross-platform (web ↔ app):** cùng một element logic dùng **CÙNG test-id value** trên cả web và app — chỉ *attribute* khác theo platform. Mỗi platform có file tech-design riêng (`-web.md` / `-app.md`) với §2b riêng, nhưng id value phải khớp để QC tái dùng logic test và 2 doc không lệch. Khi gen platform thứ hai, **đọc §2b của file platform kia** và tái dùng id đã có; chỉ thêm id cho element mà platform này có riêng.
658
+ - Chỉ gán cho element **có action**; element tĩnh (label, text thuần) không cần.
659
+
660
+ | Test-ID | Element | Component (§2) | Action | Serves SC |
661
+ |---------|---------|----------------|--------|-----------|
662
+ | `{uc}-{screen}-{element}-{type}` | {Submit button} | {LoginForm} | {submit login} | SC1, SC3 |
663
+
664
+ > QC: Page Object locator lấy test-id từ bảng này (ưu tiên `data-testid`/attribute tương ứng). Element có action mà **chưa** có test-id ở đây → QC fallback role/text (chậm hơn) và nên bổ sung vào bảng này.
665
+ >
666
+ > **Element từ component reuse / code có sẵn (brownfield):** id sống ở **usage site**, component dùng chung phải *forward* được test-id. Đừng tự bịa ở đây — chạy `/map-testids {UC-ID}` để reverse-document id đang có, gán id còn thiếu, patch forwarding + ghi catalog, rồi điền §2b này. Lệnh này chỉ tự gán id cho component **mới**.
667
+
668
+ ## §3. State Management
669
+
670
+ State shape suy ra từ System BDD `Then` clauses + response shapes trong BE contract. Nêu store/slices, server-state vs UI-state.
671
+
672
+ | Slice / Key | Shape | Nguồn (BE field / local) | Updated by |
673
+ |-------------|-------|--------------------------|------------|
674
+
675
+ ## §4. API Integration Layer (port/adapter)
676
+
677
+ **Mỗi method phải map tới một endpoint CÓ THẬT trong BE contract `{UC-ID}-tech-design.md`.** Đây là hợp đồng thay thế mock adapter của `/generate-code --phase=ui`.
678
+
679
+ | FE service method | BE endpoint (từ contract) | Request map | Response → model | Error → UI |
680
+ |-------------------|---------------------------|-------------|------------------|-----------|
681
+ | {svc.getX()} | {GET /api/v1/...} | {params} | {DTO → ViewModel} | {4xx/5xx → state/toast} |
682
+
683
+ ## §5. Routing / Navigation
684
+
685
+ Routes / màn hình, params, guards (auth/role), lazy-load.
686
+
687
+ ## §6. Data Fetching & Client Caching
688
+
689
+ Query keys, cache invalidation triggers, optimistic updates, refetch policy (client-side — KHÔNG phải server cache).
690
+
691
+ ## §7. Error & Loading States
692
+
693
+ | Scenario (BDD) | Loading UI | Error UI | Empty state |
694
+ |----------------|-----------|----------|-------------|
695
+
696
+ ## §8. Cross-Cutting
697
+
698
+ Auth token injection/refresh, i18n keys, feature flags, analytics events.
699
+
700
+ {## §9. Offline / Platform Specifics — app only}
701
+ {Cached-data behavior, offline banner, background sync, platform permissions.}
702
+
703
+ ## Changelog
704
+
705
+ | Revision | Date | Changes |
706
+ |----------|------|---------|
707
+ | 1 | {YYYY-MM-DD} | Initial FE design from {UC-ID} ({platform}) BDD v{bdd_version}, mapping BE contract {UC-ID}-tech-design.md |
708
+ ```
709
+
710
+ ## Publish — share the doc (umbrella + shared spec repo)
532
711
 
533
- If `paths.tech_docs_dir` resolved **under `setup.spec_source`** (e.g. `{spec_source}/specs/tech-docs`), the tech-doc was just written **inside the spec submodule**. It is the cross-team **API contract** FE/App read it via their own `/sync`. Publish it so they can (2-layer commit):
712
+ If `paths.tech_docs_dir` resolved **under `setup.spec_source`** (e.g. `{spec_source}/specs/tech-docs`), the doc was just written **inside the spec submodule**. Publish it (2-layer commit) so the rest of the team reads it via `/sync` — the BE doc is the cross-team **API contract**; the FE doc is the **client design** other FE/App devs (and reviewers) consume:
534
713
 
535
714
  ```bash
536
715
  cd {spec_source}
537
- git add specs/tech-docs/{domain}/{UC-ID}-tech-design.md
538
- git commit -m "docs({UC-ID}): tech design / API contract"
539
- git push origin {spec_branch} # the branch FE/App track in .gitmodules
716
+ git add {tech_design_path} # be: {UC-ID}-tech-design.md · fe: {UC-ID}-tech-design-{platform}.md
717
+ git commit -m "docs({UC-ID}): {be: tech design / API contract | fe: FE tech design ({platform})}"
718
+ git push origin {spec_branch} # the branch teammates track in .gitmodules
540
719
  cd -
541
- git add {spec_source} && git commit -m "chore: bump spec pointer ({UC-ID} tech design)"
720
+ git add {spec_source} && git commit -m "chore: bump spec pointer ({UC-ID} {be|fe} tech design)"
542
721
  ```
543
722
 
544
723
  If `tech_docs_dir` is **local** — i.e. no `setup.spec_source` (single-repo, or a pure multi-service BE repo with no shared spec module) — skip this; no cross-repo publish needed. Whenever `spec_source` is set, tech-docs route to the spec submodule and this publish step applies.
@@ -567,6 +746,36 @@ Output Artifacts:
567
746
 
568
747
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
569
748
 
749
+ ## Pipeline Position
750
+
751
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
752
+ so the user always sees where this command sits in the end-to-end flow:
753
+
754
+ ```
755
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
756
+ ```
757
+
758
+ Find the current command in this phase legend and mark **its** phase in the map above:
759
+
760
+ | Phase | Commands |
761
+ |-------|----------|
762
+ | Discovery | `/define-product` |
763
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
764
+ | Design Spec | `/generate-design-spec` |
765
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
766
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
767
+ | Code | `/generate-code` · `/review-code` |
768
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
769
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
770
+ | Trace Audit | `/validate-traces` |
771
+
772
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
773
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
774
+
775
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
776
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
777
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
778
+
570
779
  ## Next Command Suggestion
571
780
 
572
781
  Suggest the logical next command based on workflow phase:
@@ -608,17 +817,22 @@ Suggest the logical next command based on workflow phase:
608
817
  Format the footer as:
609
818
  ```
610
819
  ---
611
- Status : {badge}
820
+ Status : {badge}
612
821
  {Output Artifacts block}
613
- Next : {suggested command with example arguments}
822
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
823
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
824
+ Next : {suggested command with example arguments}
614
825
  ```
826
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
615
827
 
616
828
 
617
829
  ```
618
- /generate-tech-docs Complete — {UC-ID}
619
- File: {paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md
620
- Next: /review-tech-docs {paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md
830
+ /generate-tech-docs Complete — {UC-ID} ({active_tech_design: BE API contract | FE {platform} client design})
831
+ File: {tech_design_path}
832
+ Next: /review-tech-docs {tech_design_path}
621
833
  ← SA/Lead review required before code generation
622
- → if tech-docs live in the shared spec repo: commit + push to the spec submodule (see Publish above) so FE/App `/sync` can read the contract
623
- → after approved: /generate-code {paths.specs_dir}/{domain}/{UC-ID}-{slug}.feature
834
+ → if it lives in the shared spec repo: commit + push to the spec submodule (see Publish above) so teammates `/sync` can read it
835
+ → after approved:
836
+ BE → /generate-code {system .feature}
837
+ FE → /generate-code {web|app .feature} --phase=integration (wires real API per §4 of this doc)
624
838
  ```
@@ -134,6 +134,8 @@ Read `.agent/project-context.yaml`. Extract and store:
134
134
  - `paths.specs_dir` → BDD specs root
135
135
  - `paths.prd_dir` → PRD documents root
136
136
  - `paths.refinement_dir` → findings/review output dir
137
+ - `paths.qc_dir` → QC automation artifacts root (visible top-level, one subfolder per UC: `{qc_dir}/{UC-ID}/`)
138
+ - `paths.qc_skills_dir` → where qc-* commands load QC skills from (default bundled `.agent/skills/qc`; override to the QC team's own repo/submodule so framework upgrade won't overwrite them)
137
139
  - `paths.product_definitions_dir` → product definitions root
138
140
  - `paths.domain_knowledge_dir` → domain knowledge root
139
141
  - `paths.business_dictionary` → path to business-dictionary.md
@@ -146,6 +148,8 @@ If `paths` section is absent, use these defaults:
146
148
  - `specs_dir` = `specs/bdd`
147
149
  - `prd_dir` = `specs/prd`
148
150
  - `refinement_dir` = `.agent/review`
151
+ - `qc_dir` = `docs`
152
+ - `qc_skills_dir` = `.agent/skills/qc`
149
153
  - `product_definitions_dir` = `specs/product-definition`
150
154
  - `domain_knowledge_dir` = `specs/domain-knowledge`
151
155
  - `business_dictionary` = `specs/domain-knowledge/business-dictionary.md`
@@ -171,7 +175,7 @@ If `services` section is present:
171
175
  - If `$ARGUMENTS` contains a path, extract the segment after `prd_dir`
172
176
 
173
177
  **2. Route to service** — if active domain matches a key in `services`:
174
- - Override `paths.specs_dir` → `services.{domain}.specs_dir`
178
+ - Override `paths.specs_dir` → `services.{domain}.specs_dir` — **only if `setup.spec_source` is NOT set.** When `spec_source` IS set, ALL BDD (web/app/**system**) is a shared cross-team artifact → leave `specs_dir` for step 4 to route to the spec repo; do NOT pin it per-service here.
175
179
  - 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
180
  - Store `active_service` = `services.{domain}.path`
177
181
  - Store `active_service_module` = `services.{domain}.module`
@@ -182,6 +186,7 @@ If `services` section is present:
182
186
  - Set `active_service = unresolved`
183
187
 
184
188
  **4. Spec source auto-override** — if `setup.spec_source` is set AND the corresponding path was not already explicitly set in `paths:`:
189
+ - Override `paths.specs_dir` → `{spec_source}/specs/bdd` — **always when `spec_source` is set.** All BDD (web/app/**system**) lives in the shared spec repo so every umbrella (FE/App/BE) reads the same scenarios; the FE tech-design gate + `/generate-code --phase=ui`/`--phase=integration` resolve the `system/` BDD here. *(Per-service `specs/bdd` only when there is no `spec_source`.)*
185
190
  - Override `paths.prd_dir` → `{spec_source}/specs/prd`
186
191
  - Override `paths.design_spec_dir` → `{spec_source}/specs/design-spec`
187
192
  - 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.)*
@@ -190,8 +195,10 @@ If `services` section is present:
190
195
  - Override `paths.core_entities` → `{spec_source}/specs/domain-knowledge/core-entities.md`
191
196
  - Override `paths.bug_reports_dir` → `{spec_source}/feedback/bug-reports`
192
197
  - Override `paths.bdd_proposals_dir` → `{spec_source}/feedback/bdd-proposals`
198
+ - Override `paths.prd_change_requests_dir` → `{spec_source}/feedback/prd-change-requests`
199
+ - Override `paths.trace_dir` → `{spec_source}/.trace` — **always when `spec_source` is set.** Trace TSVs are consolidated in the spec repo (single authoritative location, no per-service split) so the PM/PO has one place to manage status. Code-side commands (`/generate-code`, `/dev-run-test`, `/qc-run-test`) run from `service_root` but **write their trace row into `{spec_source}/.trace`** — like they already push `feedback/` there. *(Per-service `.trace` only when there is no `spec_source`.)*
193
200
 
194
- > **Why under `spec_source`:** PRD, design-spec, domain knowledge, the **API contract (tech-docs)**, and tester feedback are all **cross-team artifacts** — they must live in the **shared spec repo** so every umbrella (FE/App/BE) reads the same source via `/sync`. Tech-docs specifically: BE authors the tech-design (API contract), commits + pushes it into the spec submodule (2-layer commit), and FE/App pull it on their next `/sync` to wire the real API in `/generate-code --phase=integration`. In single-service mode (no `spec_source`), these default under the repo root — still shared, same repo.
201
+ > **Why under `spec_source`:** PRD, design-spec, domain knowledge, **all BDD (web/app/system)**, the **API contract (tech-docs)**, tester feedback, **and the `.trace/` coverage state** are all **cross-team artifacts** — they live in the **shared spec repo** so every umbrella (FE/App/BE) and the PM read one source via `/sync`. The service submodule holds only **code** (+ build/test tooling). `.trace/` and `feedback/` are the dev/QC **write areas** in the spec repo (the PRD/BDD/design-spec/tech-docs there stay read-only for dev/QC only PO edits those). In single-service mode (no `spec_source`), everything defaults under the repo root — still one repo.
195
202
 
196
203
  ---
197
204
 
@@ -211,12 +218,12 @@ When `active_service` has been resolved to a real path in Step 1.5 (e.g., `user-
211
218
  |----------|--------|
212
219
  | `conventions.test_command` | service's `conventions.test_command` |
213
220
  | `conventions.build_command` | service's `conventions.build_command` |
214
- | `paths.trace_dir` | `{active_service}/{service paths.trace_dir}` default: `{active_service}/.trace` |
215
- | `paths.specs_dir` | `{active_service}/{service paths.specs_dir}` (if set in service config, else keep Step 1.5 override) |
221
+ | `paths.trace_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/.trace`); ignore any service-level `trace_dir`.** Only when there is no `spec_source`: `{active_service}/{service paths.trace_dir}` (default `{active_service}/.trace`). |
222
+ | `paths.specs_dir` | **If `spec_source` is set → keep the Step 4 spec-repo route (`{spec_source}/specs/bdd`); ignore any service-level `specs_dir`** (BDD is cross-team, never per-service in this mode). Only when there is no `spec_source`: `{active_service}/{service paths.specs_dir}` if set, else the Step 1.5 override. |
216
223
 
217
224
  **3. Store** `service_root = {active_service}` as the working directory anchor for all downstream commands:
218
225
  - Shell commands (`/dev-run-test`, `/dev-gen-test`) run **from within** `service_root`
219
- - File write operations (test files, trace TSVs) use paths **relative to** `service_root`
226
+ - **Source/test files** are written relative to `service_root`; **trace TSVs** are written to `{paths.trace_dir}` (the spec repo when `spec_source` is set — a cross-repo write, committed/pushed to the spec submodule like `feedback/`).
220
227
 
221
228
  **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).
222
229
 
@@ -520,6 +527,36 @@ Output Artifacts:
520
527
 
521
528
  If no files were written (e.g., review or analysis commands) → write `Output Artifacts: none (read-only)`.
522
529
 
530
+ ## Pipeline Position
531
+
532
+ Print a one-line map of the pipeline with the CURRENT command's phase marked `◀ bạn ở đây`,
533
+ so the user always sees where this command sits in the end-to-end flow:
534
+
535
+ ```
536
+ Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
537
+ ```
538
+
539
+ Find the current command in this phase legend and mark **its** phase in the map above:
540
+
541
+ | Phase | Commands |
542
+ |-------|----------|
543
+ | Discovery | `/define-product` |
544
+ | PRD | `/generate-prd` · `/refine-prd` · `/review-context` (PRD) |
545
+ | Design Spec | `/generate-design-spec` |
546
+ | BDD | `/generate-bdd` · `/review-context` (BDD) |
547
+ | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
548
+ | Code | `/generate-code` · `/review-code` |
549
+ | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
550
+ | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
551
+ | Trace Audit | `/validate-traces` |
552
+
553
+ For a **review command**, also append the 3-step review loop with the current step marked, e.g.:
554
+ `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
555
+
556
+ **Cross-cutting commands** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
557
+ `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) sit outside the linear pipeline —
558
+ **omit the Pipeline line entirely** for these (do not force-fit them onto the map).
559
+
523
560
  ## Next Command Suggestion
524
561
 
525
562
  Suggest the logical next command based on workflow phase:
@@ -561,10 +598,13 @@ Suggest the logical next command based on workflow phase:
561
598
  Format the footer as:
562
599
  ```
563
600
  ---
564
- Status : {badge}
601
+ Status : {badge}
565
602
  {Output Artifacts block}
566
- Next : {suggested command with example arguments}
603
+ Pipeline : Discovery PRD [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
604
+ (review cmd) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
605
+ Next : {suggested command with example arguments}
567
606
  ```
607
+ *(Omit the `Pipeline` line for cross-cutting commands listed above.)*
568
608
 
569
609
 
570
610
  ```