@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
@@ -31,8 +31,55 @@
31
31
 
32
32
  ---
33
33
 
34
+ ## Step 0 — Detect Platform & Route Output
35
+
36
+ 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).
37
+
38
+ | Platform | `active_tech_design` | Output file |
39
+ |----------|----------------------|-------------|
40
+ | `system` / backend | **`be`** — the cross-team **API contract** (authoritative) | `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md` |
41
+ | `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` |
42
+
43
+ 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.
44
+
45
+ ---
46
+
47
+ ## Step 0.5 — FE/App Precondition Gate
48
+
49
+ *Skip this entire step for BE (`active_tech_design = be`).*
50
+
51
+ 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:
52
+
53
+ 1. **System BDD** — locate `{paths.specs_dir}/{domain}/system/{TICKET-ID}*.feature`.
54
+ If not found → HALT:
55
+ ```
56
+ ❌ Cannot generate FE tech-design — System BDD not found for {TICKET-ID}.
57
+ The FE design needs the system-level (BE-facing) behavior first.
58
+ → PO/BE: /generate-bdd {prd-file} (produces the `system/` platform BDD)
59
+ ```
60
+ 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`.
61
+ - Not found → HALT:
62
+ ```
63
+ ❌ Cannot generate FE tech-design — BE API contract not found.
64
+ The FE integration layer maps to the BE contract; it must exist first.
65
+ → BE: /generate-tech-docs {system .feature} → /review-tech-docs (approve) → publish to spec repo
66
+ ```
67
+ - Found but `@trace.status` ≠ `approved` → WARN and ask:
68
+ ```
69
+ ⚠️ BE contract {UC-ID}-tech-design.md is status: {status} (not approved) — it may still change.
70
+ Designing the FE integration against a non-final contract risks rework.
71
+ Continue anyway? (Y/N)
72
+ ```
73
+ - Y → proceed (accept risk) · N → stop, wait for BE to approve.
74
+
75
+ Store `system_bdd_path` and `be_contract_path` — they are the primary inputs for the FE §3/§4 below.
76
+
77
+ ---
78
+
34
79
  ## Brownfield Check
35
80
 
81
+ *BE (`active_tech_design = be`) only — for FE the "existing contract" is the BE doc loaded in Step 0.5.*
82
+
36
83
  Read the source `.feature` file header for `@trace.api_source`.
37
84
  Also check the source PRD Metadata table for `| **API Source** | existing |`.
38
85
 
@@ -49,10 +96,11 @@ If `active_mode = reverse-document` → load bảng "Existing API Contract" từ
49
96
 
50
97
  ## CHECKPOINT — Tech Design Plan
51
98
 
52
- Before generating, scan the feature file for scenario count, referenced BRs, and entities. Display and wait for Y:
99
+ 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:
53
100
 
101
+ **If `active_tech_design = be`:**
54
102
  ```
55
- Tech Design Plan — {UC-ID}
103
+ Tech Design Plan — {UC-ID} (BE · API contract)
56
104
  ──────────────────────────────────────────────────────
57
105
  UC : {UC-ID} — {feature title}
58
106
  Service : {trace.service}
@@ -76,12 +124,42 @@ Sections to generate:
76
124
  Proceed? (Y/N)
77
125
  ```
78
126
 
127
+ **If `active_tech_design = fe`:**
128
+ ```
129
+ Tech Design Plan — {UC-ID} (FE · {platform} · client design)
130
+ ──────────────────────────────────────────────────────
131
+ UC : {UC-ID} — {feature title}
132
+ Service : {trace.service} Module: {trace.module} ({platform})
133
+ Inputs : System BDD → {system_bdd_path}
134
+ BE contract → {be_contract_path} (status: {be status})
135
+ Scenarios : {N} FE scenarios | BDD ver: {trace.bdd_version}
136
+ Output : {paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design-{platform}.md
137
+
138
+ Sections to generate:
139
+ §1 Overview (FE scope of this UC)
140
+ §2 Component Architecture (tree + reuse from figma-components catalog)
141
+ §2b Test Selectors (stable test-id cho element có action — QC contract, attr theo platform)
142
+ §3 State Management (store/slices/state shape ← System BDD Then-clauses)
143
+ §4 API Integration Layer (port/adapter: each BE endpoint → FE service → DTO/model)
144
+ §5 Routing / Navigation
145
+ §6 Data Fetching & Client Caching (query keys, invalidation, optimistic updates)
146
+ §7 Error & Loading States (per scenario)
147
+ §8 Cross-Cutting (auth token, i18n, feature flags)
148
+ {§9 Offline / platform specifics — app only}
149
+ ──────────────────────────────────────────────────────
150
+ Proceed? (Y/N)
151
+ ```
152
+
79
153
  Wait for explicit "Y" before generating.
80
154
 
81
155
  ---
82
156
 
83
157
  ## Generate
84
158
 
159
+ Generate the document for the resolved `active_tech_design`.
160
+
161
+ ### Path A — BE API contract (`active_tech_design = be`)
162
+
85
163
  Write `{paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md`:
86
164
 
87
165
  ```markdown
@@ -152,17 +230,111 @@ External calls, events produced/consumed.
152
230
  | 1 | {YYYY-MM-DD} | Initial generation from {UC-ID}.feature (BDD v{bdd_version}) |
153
231
  ```
154
232
 
155
- ## Publishshare the contract (umbrella + shared spec repo)
233
+ ### Path B FE/App client technical design (`active_tech_design = fe`)
234
+
235
+ 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.
236
+
237
+ ```markdown
238
+ # FE Technical Design — {UC-ID} ({platform}): {Feature}
239
+
240
+ ---
241
+ @trace.id: {UC-ID}
242
+ @trace.domain: {domain}
243
+ @trace.platform: {web | app}
244
+ @trace.service: {read @trace.service from the .feature file header}
245
+ @trace.module: {read @trace.module — e.g. react / nextjs / vue / angular / flutter}
246
+ @trace.prd: {TICKET-ID}
247
+ @trace.bdd_version: {read @trace.bdd_version from the FE .feature header}
248
+ @trace.system_bdd: {system_bdd_path}
249
+ @trace.be_contract: {UC-ID}-tech-design.md # the BE API contract this design consumes
250
+ @trace.testid_attr: {data-testid (web) | testID (react-native) | Key/Semantics (flutter) | accessibilityIdentifier (native-ios)}
251
+ @trace.revision: 1
252
+ @trace.status: draft
253
+ @trace.generated_at: {YYYY-MM-DD}
254
+ ---
255
+
256
+ ## §1. Overview
257
+
258
+ {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.}
259
+
260
+ ## §2. Component Architecture
261
+
262
+ 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.
263
+
264
+ | Component | Type | Reuse (catalog) / New | Responsibility |
265
+ |-----------|------|-----------------------|----------------|
266
+ | {Name} | container/presentational | {catalog name \| NEW} | {what it renders / handles} |
267
+
268
+ ## §2b. Test Selectors — Element IDs cho element CÓ ACTION (QC contract)
269
+
270
+ 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).
271
+
272
+ - **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).
273
+ - **Attribute theo platform** (`@trace.testid_attr`): web `data-testid` · React Native `testID` · Flutter `Key('id')` + `Semantics(identifier:)` · native iOS `accessibilityIdentifier`.
274
+ - **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.
275
+ - Chỉ gán cho element **có action**; element tĩnh (label, text thuần) không cần.
276
+
277
+ | Test-ID | Element | Component (§2) | Action | Serves SC |
278
+ |---------|---------|----------------|--------|-----------|
279
+ | `{uc}-{screen}-{element}-{type}` | {Submit button} | {LoginForm} | {submit login} | SC1, SC3 |
280
+
281
+ > 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.
282
+ >
283
+ > **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**.
284
+
285
+ ## §3. State Management
286
+
287
+ State shape suy ra từ System BDD `Then` clauses + response shapes trong BE contract. Nêu store/slices, server-state vs UI-state.
288
+
289
+ | Slice / Key | Shape | Nguồn (BE field / local) | Updated by |
290
+ |-------------|-------|--------------------------|------------|
291
+
292
+ ## §4. API Integration Layer (port/adapter)
293
+
294
+ **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`.
295
+
296
+ | FE service method | BE endpoint (từ contract) | Request map | Response → model | Error → UI |
297
+ |-------------------|---------------------------|-------------|------------------|-----------|
298
+ | {svc.getX()} | {GET /api/v1/...} | {params} | {DTO → ViewModel} | {4xx/5xx → state/toast} |
299
+
300
+ ## §5. Routing / Navigation
301
+
302
+ Routes / màn hình, params, guards (auth/role), lazy-load.
303
+
304
+ ## §6. Data Fetching & Client Caching
305
+
306
+ Query keys, cache invalidation triggers, optimistic updates, refetch policy (client-side — KHÔNG phải server cache).
307
+
308
+ ## §7. Error & Loading States
309
+
310
+ | Scenario (BDD) | Loading UI | Error UI | Empty state |
311
+ |----------------|-----------|----------|-------------|
312
+
313
+ ## §8. Cross-Cutting
314
+
315
+ Auth token injection/refresh, i18n keys, feature flags, analytics events.
316
+
317
+ {## §9. Offline / Platform Specifics — app only}
318
+ {Cached-data behavior, offline banner, background sync, platform permissions.}
319
+
320
+ ## Changelog
321
+
322
+ | Revision | Date | Changes |
323
+ |----------|------|---------|
324
+ | 1 | {YYYY-MM-DD} | Initial FE design from {UC-ID} ({platform}) BDD v{bdd_version}, mapping BE contract {UC-ID}-tech-design.md |
325
+ ```
326
+
327
+ ## Publish — share the doc (umbrella + shared spec repo)
156
328
 
157
- 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):
329
+ 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:
158
330
 
159
331
  ```bash
160
332
  cd {spec_source}
161
- git add specs/tech-docs/{domain}/{UC-ID}-tech-design.md
162
- git commit -m "docs({UC-ID}): tech design / API contract"
163
- git push origin {spec_branch} # the branch FE/App track in .gitmodules
333
+ git add {tech_design_path} # be: {UC-ID}-tech-design.md · fe: {UC-ID}-tech-design-{platform}.md
334
+ git commit -m "docs({UC-ID}): {be: tech design / API contract | fe: FE tech design ({platform})}"
335
+ git push origin {spec_branch} # the branch teammates track in .gitmodules
164
336
  cd -
165
- git add {spec_source} && git commit -m "chore: bump spec pointer ({UC-ID} tech design)"
337
+ git add {spec_source} && git commit -m "chore: bump spec pointer ({UC-ID} {be|fe} tech design)"
166
338
  ```
167
339
 
168
340
  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.
@@ -172,10 +344,12 @@ If `tech_docs_dir` is **local** — i.e. no `setup.spec_source` (single-repo, or
172
344
  {{include:steps/report-footer.md}}
173
345
 
174
346
  ```
175
- /generate-tech-docs Complete — {UC-ID}
176
- File: {paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md
177
- Next: /review-tech-docs {paths.tech_docs_dir}/{domain}/{UC-ID}-tech-design.md
347
+ /generate-tech-docs Complete — {UC-ID} ({active_tech_design: BE API contract | FE {platform} client design})
348
+ File: {tech_design_path}
349
+ Next: /review-tech-docs {tech_design_path}
178
350
  ← SA/Lead review required before code generation
179
- → 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
180
- → after approved: /generate-code {paths.specs_dir}/{domain}/{UC-ID}-{slug}.feature
351
+ → if it lives in the shared spec repo: commit + push to the spec submodule (see Publish above) so teammates `/sync` can read it
352
+ → after approved:
353
+ BE → /generate-code {system .feature}
354
+ FE → /generate-code {web|app .feature} --phase=integration (wires real API per §4 of this doc)
181
355
  ```
package/commands/learn.md CHANGED
@@ -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
  ```