@anhth2/spec-driven-dev-plugin 0.12.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 (130) hide show
  1. package/commands/debug.md +42 -7
  2. package/commands/define-product.md +42 -7
  3. package/commands/dev-gen-test.md +60 -17
  4. package/commands/dev-run-test.md +61 -18
  5. package/commands/dev-run-test.tmpl +1 -1
  6. package/commands/dev-smoke-test.md +42 -7
  7. package/commands/fix-bug.md +42 -7
  8. package/commands/generate-bdd.md +67 -21
  9. package/commands/generate-bdd.tmpl +7 -4
  10. package/commands/generate-code.md +113 -35
  11. package/commands/generate-code.tmpl +53 -18
  12. package/commands/generate-design-spec.md +42 -7
  13. package/commands/generate-prd.md +42 -7
  14. package/commands/generate-spec-manifest.md +42 -7
  15. package/commands/generate-tech-docs.md +229 -20
  16. package/commands/generate-tech-docs.tmpl +187 -13
  17. package/commands/learn.md +42 -7
  18. package/commands/map-testids.md +564 -0
  19. package/commands/map-testids.tmpl +81 -0
  20. package/commands/propose-scenario.md +42 -7
  21. package/commands/qc-analyze.md +42 -7
  22. package/commands/qc-design-test.md +44 -8
  23. package/commands/qc-design-test.tmpl +2 -1
  24. package/commands/qc-plan.md +42 -7
  25. package/commands/qc-report.md +42 -7
  26. package/commands/qc-review.md +42 -7
  27. package/commands/qc-run-test.md +62 -18
  28. package/commands/qc-run-test.tmpl +2 -1
  29. package/commands/refine-prd.md +42 -7
  30. package/commands/report-bug.md +42 -7
  31. package/commands/review-code.md +42 -7
  32. package/commands/review-context.md +42 -7
  33. package/commands/review-tech-docs.md +45 -9
  34. package/commands/review-tech-docs.tmpl +3 -2
  35. package/commands/setup-ai-first.md +37 -4
  36. package/commands/setup-ai-first.tmpl +2 -2
  37. package/commands/sync.md +35 -2
  38. package/commands/update-framework.md +35 -2
  39. package/commands/validate-traces.md +85 -40
  40. package/commands/validate-traces.tmpl +43 -33
  41. package/core/FRAMEWORK_VERSION +1 -1
  42. package/core/commands/debug.md +42 -7
  43. package/core/commands/define-product.md +42 -7
  44. package/core/commands/dev-gen-test.md +60 -17
  45. package/core/commands/dev-run-test.md +61 -18
  46. package/core/commands/dev-smoke-test.md +42 -7
  47. package/core/commands/fix-bug.md +42 -7
  48. package/core/commands/generate-bdd.md +67 -21
  49. package/core/commands/generate-code.md +113 -35
  50. package/core/commands/generate-design-spec.md +42 -7
  51. package/core/commands/generate-prd.md +42 -7
  52. package/core/commands/generate-spec-manifest.md +42 -7
  53. package/core/commands/generate-tech-docs.md +229 -20
  54. package/core/commands/learn.md +42 -7
  55. package/core/commands/map-testids.md +564 -0
  56. package/core/commands/propose-scenario.md +42 -7
  57. package/core/commands/qc-analyze.md +42 -7
  58. package/core/commands/qc-design-test.md +44 -8
  59. package/core/commands/qc-plan.md +42 -7
  60. package/core/commands/qc-report.md +42 -7
  61. package/core/commands/qc-review.md +42 -7
  62. package/core/commands/qc-run-test.md +62 -18
  63. package/core/commands/refine-prd.md +42 -7
  64. package/core/commands/report-bug.md +42 -7
  65. package/core/commands/review-code.md +42 -7
  66. package/core/commands/review-context.md +42 -7
  67. package/core/commands/review-tech-docs.md +45 -9
  68. package/core/commands/setup-ai-first.md +37 -4
  69. package/core/commands/sync.md +35 -2
  70. package/core/commands/update-framework.md +35 -2
  71. package/core/commands/validate-traces.md +85 -40
  72. package/core/modules/qc-playwright/stack-profile.yaml +1 -0
  73. package/core/skills/code/SKILL.md +77 -9
  74. package/core/skills/debug/SKILL.md +112 -11
  75. package/core/skills/design-spec/SKILL.md +42 -7
  76. package/core/skills/discovery/SKILL.md +42 -7
  77. package/core/skills/prd/SKILL.md +70 -4
  78. package/core/skills/setup-ai-first/SKILL.md +35 -2
  79. package/core/skills/spec/SKILL.md +70 -4
  80. package/core/skills/test/SKILL.md +119 -16
  81. package/core/steps/context-loader.md +7 -5
  82. package/core/steps/report-footer.md +35 -2
  83. package/core/steps/trace-mirror.md +18 -10
  84. package/core/templates/project-context.yaml +8 -5
  85. package/docs/01-getting-started/core-concepts.md +7 -7
  86. package/docs/01-getting-started/installation.md +2 -2
  87. package/docs/01-getting-started/quickstart.md +1 -1
  88. package/docs/02-guides/README.md +1 -2
  89. package/docs/02-guides/developer/README.md +1 -1
  90. package/docs/02-guides/developer/bdd-and-trace.md +10 -8
  91. package/docs/02-guides/developer/commands.md +3 -3
  92. package/docs/02-guides/developer/scenarios.md +26 -14
  93. package/docs/02-guides/developer/workflow.md +80 -20
  94. package/docs/02-guides/product-owner/README.md +6 -4
  95. package/docs/02-guides/product-owner/commands.md +1 -1
  96. package/docs/02-guides/product-owner/scenarios.md +80 -1
  97. package/docs/02-guides/tester/README.md +12 -11
  98. package/docs/02-guides/tester/bug-reporting.md +1 -1
  99. package/docs/02-guides/{qc-automation.md → tester/qc-automation.md} +14 -6
  100. package/docs/02-guides/tester/reading-specs.md +4 -4
  101. package/docs/02-guides/tester/scenarios.md +5 -5
  102. package/docs/02-guides/tester/spec-manifest.md +17 -12
  103. package/docs/02-guides/tester/test-checklist.md +3 -3
  104. package/docs/02-guides/tester/workflow.md +8 -11
  105. package/docs/03-concepts/architecture.md +5 -4
  106. package/docs/03-concepts/pipeline.md +18 -6
  107. package/docs/03-concepts/traceability.md +17 -17
  108. package/docs/04-operations/README.md +1 -1
  109. package/docs/04-operations/bug-flow.md +4 -4
  110. package/docs/04-operations/sync-and-update.md +163 -38
  111. package/docs/05-reference/README.md +3 -0
  112. package/docs/05-reference/command-cheatsheet.md +147 -0
  113. package/docs/05-reference/commands.md +72 -69
  114. package/docs/05-reference/modules.md +2 -2
  115. package/docs/05-reference/trace-schema.md +15 -14
  116. package/docs/README.md +3 -5
  117. package/modules/qc-playwright/stack-profile.yaml +1 -0
  118. package/package.json +1 -1
  119. package/skills/code/SKILL.md +77 -9
  120. package/skills/debug/SKILL.md +112 -11
  121. package/skills/design-spec/SKILL.md +42 -7
  122. package/skills/discovery/SKILL.md +42 -7
  123. package/skills/prd/SKILL.md +70 -4
  124. package/skills/setup-ai-first/SKILL.md +35 -2
  125. package/skills/spec/SKILL.md +70 -4
  126. package/skills/test/SKILL.md +119 -16
  127. package/steps/context-loader.md +7 -5
  128. package/steps/report-footer.md +35 -2
  129. package/steps/trace-mirror.md +18 -10
  130. package/templates/project-context.yaml +8 -5
@@ -1,18 +1,26 @@
1
1
  # Refresh Living Docs panel mirror *(local, umbrella mode)*
2
2
 
3
3
  *Skip entirely in single-service mode (no `services` and no `setup.spec_source`) — there
4
- the service `.trace/` IS the panel location, so nothing to mirror.*
4
+ the repo's own `.trace/` IS the panel location, so nothing to mirror.*
5
5
 
6
- After updating the authoritative service TSV(s) at `{paths.trace_dir}`:
6
+ After updating the authoritative TSV(s) at `{paths.trace_dir}`:
7
7
 
8
- 1. Resolve `panel_mirror = ./.trace` at the **current workspace root** (where this command runs).
8
+ **When `setup.spec_source` is set (consolidated trace the common case):**
9
+ `{paths.trace_dir}` resolves to `{spec_source}/.trace` — the single authoritative location.
10
+ This command runs from `service_root`, so the write is **cross-repo into the spec submodule**;
11
+ commit/push the spec submodule for the trace update (same as `feedback/`).
12
+ 1. Resolve `panel_mirror = ./.trace` at the **current workspace root**.
9
13
  2. If `panel_mirror` resolves to a different path than `{paths.trace_dir}`, copy each
10
- just-updated `{UC-ID}.tsv` → `{panel_mirror}/{service-name}/{UC-ID}.tsv`
11
- (create the dir; overwrite). Use `active_service` for `{service-name}`.
14
+ just-updated `{UC-ID}.tsv` → `{panel_mirror}/{UC-ID}.tsv` (create the dir; overwrite).
15
+ No per-service namespacing — there is one trace set; the owning service is carried in each
16
+ row's `@trace.service`.
17
+
18
+ **Legacy (no `spec_source` — per-service trace):**
19
+ Copy each just-updated `{UC-ID}.tsv` → `{panel_mirror}/{service-name}/{UC-ID}.tsv`
20
+ (namespaced by `active_service`).
12
21
 
13
22
  This keeps the open workspace's Living Docs panel current **between syncs** — it is a
14
- **local convenience mirror only**. The *canonical* report in the spec module
15
- (`{spec_source}/.living-docs/`) and the merged `trace-report.json` are rebuilt by
16
- `/sync` or `/validate-traces` (those need every service's data, so a single per-UC
17
- command cannot produce them). For orchestrated commands, do this once in the orchestrator
18
- after all sub-agents return — not inside each sub-agent.
23
+ **local convenience mirror only**. The merged `trace-report.json` (canonical, in
24
+ `{spec_source}/.living-docs/`) is rebuilt by `/sync` or `/validate-traces`. For orchestrated
25
+ commands, do this once in the orchestrator after all sub-agents return — not inside each
26
+ sub-agent.
@@ -111,19 +111,22 @@ domains:
111
111
  # mode: umbrella # "umbrella" | "single" (default: single)
112
112
  # spec_source: "{{SPEC_SUBMODULE_PATH}}" # path to PO spec submodule, e.g. "free-trial-specs"
113
113
  #
114
- # When spec_source is set, context-loader auto-derives:
114
+ # When spec_source is set, context-loader auto-derives (ALL specs live in the spec repo;
115
+ # service submodules hold only code + .trace/):
116
+ # specs_dir → {spec_source}/specs/bdd # ALL BDD (web/app/system) — cross-team
115
117
  # prd_dir → {spec_source}/specs/prd
116
118
  # design_spec_dir → {spec_source}/specs/design-spec
117
- # tech_docs_dir → {spec_source}/specs/tech-docs # shared API contract (per-service tech_docs_dir below wins in multi-service)
119
+ # tech_docs_dir → {spec_source}/specs/tech-docs # BE API contract + FE tech-design
118
120
  # domain_knowledge_dir → {spec_source}/specs/domain-knowledge
119
121
  # (You can still override these manually in paths: section below.)
120
122
  #
121
123
  # services: # domain → service submodule routing
122
124
  # {{DOMAIN_1}}: # must match @trace.domain in PRD files
123
- # path: "{{SERVICE_SUBMODULE_DIR}}" # relative path to service submodule
125
+ # path: "{{SERVICE_SUBMODULE_DIR}}" # relative path to service submodule (code + .trace/)
124
126
  # module: "{{STACK_MODULE}}" # e.g., java-spring, nextjs, flutter
125
- # specs_dir: "{{SERVICE_SUBMODULE_DIR}}/specs/bdd"
126
- # tech_docs_dir: "{{SERVICE_SUBMODULE_DIR}}/specs/tech-docs"
127
+ # # NOTE: with spec_source set, BDD + tech-docs are cross-team and live in the spec repo —
128
+ # # do NOT pin per-service specs_dir / tech_docs_dir here (they would be ignored).
129
+ # # Per-service specs_dir / tech_docs_dir apply ONLY when there is no spec_source.
127
130
  #
128
131
  # IMPORTANT — per-service CLAUDE.md:
129
132
  # Each service submodule should have its OWN CLAUDE.md ({path}/CLAUDE.md) defining its
@@ -51,11 +51,11 @@ Mỗi artifact link tới artifact khác qua `@trace.*` tags:
51
51
  ```
52
52
  product-definition.md
53
53
  └─► PRD.md (Service, Module trong metadata)
54
- └─► {UC-ID}.feature (@trace.service, @trace.module, @trace.prd_version)
55
- └─► tech-design.md (@trace.bdd_version)
56
- └─► src/ code (@trace.implements, @trace.prd_version, @trace.bdd_version)
57
- └─► src/test/ (@trace.verifies, @trace.service)
58
- └─► .trace/{UC-ID}.tsv (drift tracking)
54
+ └─► specs/bdd/{domain}/{web|app|system}/{UC-ID}.feature (@trace.prd_version)
55
+ └─► specs/tech-docs/{domain}/{UC-ID}-tech-design*.md (@trace.bdd_version)
56
+ └─► src/ code — service submodule (@trace.implements)
57
+ └─► src/test/ (@trace.verifies)
58
+ ════► {spec_source}/.trace/{UC-ID}.tsv — authoritative ở SPEC repo (drift tracking)
59
59
  ```
60
60
 
61
61
  `/validate-traces {domain}` đọc các `.trace/{UC-ID}.tsv` và báo cáo:
@@ -92,8 +92,8 @@ my-project-umbrella/ ← mở Claude Code ở đây
92
92
  └── web-app/ ← submodule: FE app
93
93
  ```
94
94
 
95
- - **Spec module** (`{spec_source}/`): chứa PRD, Design Spec, tech-docs (API contract) — shared để mọi umbrella đọc cùng contract. Report canonical của Living Docs cũng sinh tại `{spec_source}/.living-docs/`.
96
- - **Routing:** context-loader đọc `@trace.domain` từ PRD → tra trong `services` config → route BDD/code vào đúng service submodule. PRD phải có `@trace.domain` khớp một key trong `services`.
95
+ - **Spec module** (`{spec_source}/`): chứa PRD, Design Spec, **ALL BDD (web/app/system)**, tech-docs (BE API contract + FE tech-design), domain-knowledge, feedback — shared để mọi umbrella đọc cùng nguồn. Report canonical của Living Docs cũng sinh tại `{spec_source}/.living-docs/`.
96
+ - **Routing:** context-loader đọc `@trace.domain` từ PRD → tra trong `services` config → route **code** vào đúng service submodule; **BDD + tech-docs + specs + `.trace/` + feedback** đều ở spec module (cross-team, một chỗ cho PM). PRD phải có `@trace.domain` khớp một key trong `services`.
97
97
 
98
98
  Setup umbrella đầy đủ, file ownership, two-layer commit, multi-platform → [Operations › Sync & Update §4 Umbrella mode](../04-operations/sync-and-update.md#4-umbrella-mode--git-submodule).
99
99
 
@@ -90,7 +90,7 @@ git diff .agent/ && git add .agent/ && git commit -m "chore: upgrade framework"
90
90
 
91
91
  > Chỉ upgrade framework command files. `project-context.yaml`, `CLAUDE.md`, domain-knowledge, và `.trace/` không bao giờ bị ghi đè. Để sync *content* của project (submodule code/specs) dùng `/sync`.
92
92
  >
93
- > ⚠️ **QC skills & upgrade:** `--init` / `upgrade.sh` ghi đè **toàn bộ** `.agent/` — **gồm cả** `.agent/skills/qc/`. Nếu QC chỉnh skills trực tiếp trong `.agent/skills/qc/`, các thay đổi đó **mất** khi upgrade. Để giữ an toàn, trỏ `paths.qc_skills_dir` ra một repo/submodule QC **ngoài** `.agent/` (vd `qc-base/.claude/skills`) — upgrade không bao giờ chạm tới đó. Chi tiết: [../02-guides/qc-automation.md#skill-sourcing--upgrade-safety](../02-guides/qc-automation.md#skill-sourcing--upgrade-safety).
93
+ > ⚠️ **QC skills & upgrade:** `--init` / `upgrade.sh` ghi đè **toàn bộ** `.agent/` — **gồm cả** `.agent/skills/qc/`. Nếu QC chỉnh skills trực tiếp trong `.agent/skills/qc/`, các thay đổi đó **mất** khi upgrade. Để giữ an toàn, trỏ `paths.qc_skills_dir` ra một repo/submodule QC **ngoài** `.agent/` (vd `qc-base/.claude/skills`) — upgrade không bao giờ chạm tới đó. Chi tiết: [../02-guides/tester/qc-automation.md#skill-sourcing--upgrade-safety](../02-guides/tester/qc-automation.md#skill-sourcing--upgrade-safety).
94
94
 
95
95
  ## QC automation stack (tùy chọn)
96
96
 
@@ -104,7 +104,7 @@ pip install pytest-playwright
104
104
  python3 -m playwright install
105
105
  ```
106
106
 
107
- `qc-playwright` = Python + pytest-playwright + Page Object (output: Playwright Trace + pytest-html). Chi tiết pipeline: [../02-guides/qc-automation.md](../02-guides/qc-automation.md).
107
+ `qc-playwright` = Python + pytest-playwright + Page Object (output: Playwright Trace + pytest-html). Chi tiết pipeline: [../02-guides/tester/qc-automation.md](../02-guides/tester/qc-automation.md).
108
108
 
109
109
  ## VS Code extension (khuyến nghị)
110
110
 
@@ -80,6 +80,6 @@ Mỗi review command ghi findings vào `.agent/review/*-findings.yaml`. Mở **R
80
80
  ## Bước tiếp theo
81
81
 
82
82
  - Hiểu khái niệm phía sau pipeline → [core-concepts.md](core-concepts.md).
83
- - QC suite chính thức (`/qc-analyze → /qc-plan → /qc-design-test → /qc-review → /qc-run-test → /qc-report`) → [../02-guides/qc-automation.md](../02-guides/qc-automation.md).
83
+ - QC suite chính thức (`/qc-analyze → /qc-plan → /qc-design-test → /qc-review → /qc-run-test → /qc-report`) → [../02-guides/tester/qc-automation.md](../02-guides/tester/qc-automation.md).
84
84
  - Role guides, scenarios thực tế, multi-repo/umbrella → [../02-guides](../02-guides) và [../03-concepts](../03-concepts).
85
85
  - Full command reference → [../05-reference](../05-reference).
@@ -10,8 +10,7 @@ Mỗi role trong framework spec-driven-dev có một guide riêng: vai trò, com
10
10
  |---|---|---|
11
11
  | [Product Owner / BA](product-owner/README.md) | PO, BA | Viết PRD platform-agnostic, generate Design Spec + BDD, handoff cho dev team |
12
12
  | [Developer (FE / BE / App)](developer/README.md) | Dev | Đọc PRD + BDD từ spec submodule, generate tech-docs + code, dev self-check, trace system |
13
- | [Tester / QA](tester/README.md) | QA, Tester | Spec-manifest, đọc spec chain, viết test cases, `/report-bug` + `/propose-scenario` |
14
- | [QC Automation](qc-automation.md) | QC | Pipeline `/qc-*` 6 bước, `qc_status` chính thức, stack module `qc-playwright` |
13
+ | [Tester / QA](tester/README.md) | QA / Tester / QC | Spec-manifest, đọc spec chain, viết test cases, `/report-bug` + `/propose-scenario`, và chương **[QC Automation](tester/qc-automation.md)** (pipeline `/qc-*` 6 bước, `qc_status`, stack `qc-playwright`) — **một role duy nhất** |
15
14
  | Designer | Designer, UX | Tham gia giai đoạn Design Spec — sign-off màn hình + component trước khi PO gen BDD. Chưa có guide riêng; xem [Product Owner › Design Spec](product-owner/scenarios.md#tình-huống-3--tạo-design-spec-và-bdd-sau-khi-prd-approved) để biết điểm giao. |
16
15
 
17
16
  ## Phân biệt nhanh hai luồng test
@@ -43,4 +43,4 @@ PO/BA Dev
43
43
 
44
44
  ---
45
45
 
46
- *Xem thêm:* [Product Owner Guide](../product-owner/README.md) · [Tester Guide](../tester/README.md) · [QC Automation Guide](../qc-automation.md) · [Concepts › Traceability](../../03-concepts/traceability.md) · [Reference › Commands](../../05-reference/commands.md)
46
+ *Xem thêm:* [Product Owner Guide](../product-owner/README.md) · [Tester Guide](../tester/README.md) · [chương QC Automation](../tester/qc-automation.md) · [Concepts › Traceability](../../03-concepts/traceability.md) · [Reference › Commands](../../05-reference/commands.md)
@@ -70,11 +70,13 @@ Framework dùng metadata `@trace.*` để liên kết PRD → BDD → Code. (Chi
70
70
  ### Ví dụ trace chain hoàn chỉnh
71
71
 
72
72
  ```
73
- specs/prd/auth/FT-001-login.md ← @trace.domain: auth, @trace.status: approved
73
+ specs/prd/auth/FT-001-login.md ← @trace.domain: auth, @trace.status: approved
74
74
 
75
- specs/bdd/auth/FT-001-login.feature ← @trace.prd: FT-001, @trace.module: AuthService
75
+ specs/bdd/auth/system/FT-001-UC1-login.feature ← @trace.prd: FT-001 · web/app/system riêng (system tổng hợp từ web+app)
76
76
 
77
- src/auth/auth.service.ts ← // @trace.bdd: FT-001-UC1-SC1
77
+ src/auth/auth.service.ts ← // @trace.bdd: FT-001-UC1-SC1 (service submodule)
78
+
79
+ {spec_source}/.trace/FT-001.tsv ← coverage/drift — authoritative ở SPEC repo
78
80
  ```
79
81
 
80
82
  ### Khi nào chạy /validate-traces?
@@ -93,7 +95,7 @@ src/auth/auth.service.ts ← // @trace.bdd: FT-001-UC1-SC1
93
95
  **Lưu ý khi dùng umbrella (submodule):**
94
96
  ```
95
97
  Vấn đề: Living Docs panel mở ở umbrella root (hoặc một service submodule đơn lẻ) → nếu không có mirror local → TRỐNG.
96
- TSV authoritative nằm committed trong từng service submodule: user-service/.trace/, order-service/.trace/
98
+ TSV authoritative nằm committed MỘT chỗ spec repo: {spec_source}/.trace/
97
99
 
98
100
  Giải pháp: /validate-traces (hoặc /sync) regenerate canonical trace-report.json + TSV mirror
99
101
  trong SPEC MODULE tại {spec_source}/.living-docs/ (gitignored), đồng thời ghi
@@ -102,13 +104,13 @@ Giải pháp: /validate-traces (hoặc /sync) regenerate canonical trace-report.
102
104
 
103
105
  Lệnh chạy sau mỗi session:
104
106
  /validate-traces
105
- → Reads .trace/*.tsv authoritative (committed) trong từng service: user-service/.trace/, order-service/.trace/, ...
106
- → Writes canonical trace-report.json + TSV mirror → {spec_source}/.living-docs/ (gitignored, regenerated bởi /sync hoặc /validate-traces)
107
- → Writes panel mirror → ./.trace của workspace hiện tại (non-empty khi mở single service)
107
+ → Reads .trace/*.tsv authoritative (committed) MỘT chỗ: {spec_source}/.trace/ (mỗi row mang @trace.service)
108
+ → Writes trace-report.json → {spec_source}/.living-docs/ (gitignored, regenerated bởi /sync hoặc /validate-traces)
109
+ → Writes panel mirror → ./.trace của workspace hiện tại (non-empty khi mở repo lẻ)
108
110
  → Living Docs panel cập nhật ngay
109
111
  ```
110
112
 
111
- > **Authoritative vs mirror:** per-service `.trace/*.tsv` vẫn được **commit** trong từng service (nguồn sự thật). `{spec_source}/.living-docs/` và `./.trace` chỉ là mirror gitignored, regenerated bởi `/sync` hoặc `/validate-traces`.
113
+ > **Authoritative vs mirror:** `.trace/*.tsv` được **commit** spec repo `{spec_source}/.trace/` (nguồn sự thật, một chỗ). `{spec_source}/.living-docs/` và `./.trace` chỉ là mirror gitignored, regenerated bởi `/sync` hoặc `/validate-traces`.
112
114
 
113
115
  Thêm `.living-docs/` (spec module) và umbrella/workspace `.trace/` mirror vào `.gitignore`:
114
116
  ```
@@ -7,9 +7,9 @@
7
7
  | `/sync` `[spec-branch]` | **One-command setup hoặc update** — git pull + submodule sync + Living Docs refresh. Truyền branch để override branch spec submodule (vd `/sync develop`) | **Mỗi sáng trước khi bắt đầu work** |
8
8
  | `/update-framework` | Nâng cấp **bản thân framework** (`.agent/commands/`, steps/, modules/) từ npm | Khi có version framework mới — không đụng project-context/CLAUDE.md |
9
9
  | `/review-context {prd-file}` | Đọc + xác nhận PRD + BDD đủ rõ trước khi code — fan-out review dimension thành sub-agent song song + completeness-critic loop, findings file đầy đủ ngay trong 1 lần chạy | **Bước đầu tiên** khi nhận PRD mới |
10
- | `/generate-tech-docs {prd-file}` | Sinh Tech Docs (API, DB schema, sequence diagram) | Sau khi đọc BDD từ spec submodule |
10
+ | `/generate-tech-docs {feature-file}` | **Platform-aware.** BE (`system`): API contract (endpoints, DB, caching). FE/App (`web`/`app`): client design (components, state, API-integration map theo BE contract, routing) — **GATED**: cần System BDD + BE contract approved trước, nếu thiếu sẽ HALT | BE: sau khi đọc System BDD. FE: sau `--phase=ui`, khi BE contract đã approved |
11
11
  | `/generate-code {bdd-file}` | Sinh code — BE hoặc FE khi API đã sẵn sàng | Sau khi tech docs `approved` |
12
- | `/generate-code {bdd-file} --phase=ui` | FE: gen UI + mock adapter (BE chưa ready) | Ngay sau khi đọc BDD |
12
+ | `/generate-code {bdd-file} --phase=ui` | FE: gen UI + mock adapter. Mock **shape** từ BE contract nếu có (chuẩn) → else infer từ System BDD + warn (`mock_source=contract\|system-bdd`); fixture values luôn từ System BDD | Ngay sau khi đọc BDD (BE chưa cần deploy API) |
13
13
  | `/generate-code {bdd-file} --phase=integration` | FE: wire API thật thay mock | Sau khi sign-off gate `approved` |
14
14
  | `/dev-gen-test {bdd-file}` | **Dev self-check** — sinh test cases từ BDD để dev tự verify code mình vừa gen (KHÔNG phải bộ test chính thức của QC/dev-team) | Song song hoặc sau generate-code |
15
15
  | `/review-code {file}` | Review code theo 4 lens (Security/Perf/Arch/Test) | Trước khi tạo PR |
@@ -21,7 +21,7 @@
21
21
  | `/validate-traces` | Kiểm tra toàn bộ trace chain còn hợp lệ | Sau refactor hoặc khi PRD update |
22
22
  | `/learn {text}` | Ghi lại lỗi AI hay lặp thành guardrail | Khi AI lặp lại lỗi mà bạn không muốn nó tái diễn |
23
23
 
24
- > **Dev self-check vs QC chính thức:** `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` (ghi `dev_selftest`) chỉ là **smoke self-check của riêng dev**. Bộ QC chính thức giờ là native pipeline `/qc-analyze → /qc-plan → /qc-design-test → /qc-review → /qc-run-test → /qc-report` — **do QC chạy, không phải việc của dev** — và ghi `qc_status` riêng. Chi tiết: [QC Automation Guide](../qc-automation.md).
24
+ > **Dev self-check vs QC chính thức:** `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` (ghi `dev_selftest`) chỉ là **smoke self-check của riêng dev**. Bộ QC chính thức giờ là native pipeline `/qc-analyze → /qc-plan → /qc-design-test → /qc-review → /qc-run-test → /qc-report` — **do QC chạy, không phải việc của dev** — và ghi `qc_status` riêng. Chi tiết: [chương QC Automation](../tester/qc-automation.md).
25
25
 
26
26
  > Danh mục đầy đủ mọi command: [Reference › Commands](../../05-reference/commands.md).
27
27
 
@@ -67,6 +67,13 @@ Feature: User Authentication — System Contract
67
67
  ```
68
68
  BE dev dùng System BDD để: thiết kế API endpoint + response schema (`/generate-tech-docs`) · generate code skeleton (`/generate-code`) · viết integration tests (`/dev-gen-test`).
69
69
 
70
+ > **Đọc annotation `@system.resolution:` ở header (nếu có).** Khi web & app kỳ vọng response khác nhau, PO đã chốt cách giải quyết lúc gen System BDD — build contract đúng kiểu đó, **đừng tự đổi**:
71
+ > - `union` → trả tất cả field cho mọi client (`{ token, redirect_url, user_profile }`).
72
+ > - `platform-hint` → đọc header `X-Platform: web|app`, tailor response (System BDD dùng `Scenario Outline` + Examples).
73
+ > - `separate-endpoints` → mỗi platform một endpoint (`/auth/login/web` · `/auth/login/app`).
74
+ >
75
+ > Thấy resolution bất hợp lý, hoặc cần field chưa có trong contract → phản hồi PO (contract decision), đừng sửa System BDD trực tiếp. Bối cảnh: [PO › Tình huống 12](../product-owner/scenarios.md#tình-huống-12--system-bdd-synthesis-outside-in--xử-lý-cross-platform-conflict).
76
+
70
77
  ## Tình huống 3: Đọc Web/App BDD (FE/App dev)
71
78
 
72
79
  **Bối cảnh:** FE dev nhận thông báo BDD web đã sẵn sàng tại `specs/bdd/auth/web/`.
@@ -89,7 +96,7 @@ Scenario: Account locked — countdown shown
89
96
  ```
90
97
  FE dev dùng Web BDD để:
91
98
  1. Thiết kế component spec + API integration plan (`/generate-tech-docs`)
92
- 2. Gen UI + mock adapter từ System BDD contract (`/generate-code --phase=ui`) → Mock adapter trả về fixture data đúng với BDD `Then` clauses → Tester test toàn bộ FE flow ngay, không cần chờ BE
99
+ 2. Gen UI + mock adapter (`/generate-code --phase=ui`) — mock **shape** từ BE contract nếu có, else System BDD + warn → Mock adapter trả về fixture data đúng với BDD `Then` clauses → Tester test toàn bộ FE flow ngay, không cần chờ BE
93
100
  3. [Trong khi đó — tham gia review API contract, sign-off T7 gate]
94
101
  4. Khi sign-off done → wire real API (`/generate-code --phase=integration`)
95
102
  5. Viết E2E tests với Playwright/Cypress (`/dev-gen-test`)
@@ -179,7 +186,7 @@ Severity : Major
179
186
 
180
187
  Spec context:
181
188
  PRD : specs/prd/auth/FT-001-login.md (v1.0)
182
- BDD : free-trial-be/specs/bdd/auth/FT-001-login.feature
189
+ BDD : free-trial-specs/specs/bdd/auth/system/FT-001-login.feature
183
190
  → Scenario: "Lock account after 5 failed attempts"
184
191
  Tech Doc : free-trial-specs/specs/tech-docs/auth/FT-001-auth-api.md
185
192
 
@@ -206,7 +213,7 @@ Chạy:
206
213
  ```
207
214
  /fix-bug "BUG-20260605-003: FT-001-UC2-BR3 — account not locked after 5 failures
208
215
  PRD: specs/prd/auth/FT-001-login.md
209
- BDD: free-trial-be/specs/bdd/auth/FT-001-login.feature"
216
+ BDD: free-trial-specs/specs/bdd/auth/system/FT-001-login.feature"
210
217
  ```
211
218
  Agent sẽ: đọc BDD scenario được chỉ định · tìm code implement scenario đó (theo `@trace.bdd`) · so sánh logic thực tế vs spec · propose fix có giải thích.
212
219
 
@@ -337,7 +344,7 @@ code . ← hoặc claude .
337
344
 
338
345
  # 4. Framework tự detect umbrella mode từ project-context.yaml
339
346
  # Khi chạy /review-context với PRD có @trace.domain: be
340
- # → tự động route tới mass-product-be/specs/bdd/
347
+ # → CODE route tới mass-product-be/ · BDD đọc từ spec repo mass-product-spec/specs/bdd/ (spec_source set)
341
348
  ```
342
349
 
343
350
  **Update hằng ngày — cũng chỉ 1 lệnh:**
@@ -356,13 +363,14 @@ services:
356
363
  be:
357
364
  path: "mass-product-be"
358
365
  module: "NestJS"
359
- specs_dir: "mass-product-be/specs/bdd"
366
+ # specs_dir KHÔNG khai khi spec_source set — BDD đọc từ spec repo, không per-service
360
367
  web:
361
368
  path: "mass-product-web"
362
369
  module: "NextJS"
363
- specs_dir: "mass-product-web/specs/bdd"
364
370
  ```
365
371
 
372
+ > **BDD (specs_dir):** không khai trong `services` khi có `spec_source`. Tất cả BDD (web/app/system) nằm ở `{spec_source}/specs/bdd` (vd `mass-product-spec/specs/bdd`) — context-loader tự route `specs_dir` về đó; mọi `specs_dir` per-service đều bị **bỏ qua**. Per-service `specs_dir` **chỉ** dùng khi KHÔNG có `spec_source`.
373
+ >
366
374
  > **Tech-docs (API contract):** không khai trong `services`. Khi `setup.spec_source` được set, BE tech-design (API contract) **LUÔN** nằm tại `{spec_source}/specs/tech-docs` (vd `mass-product-spec/specs/tech-docs`) — context-loader tự route `tech_docs_dir` về đó. BE generate xong → commit + push lên spec repo; FE/App đọc qua `/sync` + `/generate-code --phase=integration`. Per-service tech-docs **chỉ** khi KHÔNG có `spec_source`.
367
375
  >
368
376
  > **Bắt buộc:** Mỗi service submodule cũng cần file `.agent/project-context.yaml` riêng. Framework đọc file này (context-loader Step 1.6) để lấy đúng `test_command` và `build_command` khi `/dev-run-test` hoặc `/dev-gen-test` chạy từ umbrella root.
@@ -402,21 +410,25 @@ Khi `/dev-run-test` chạy từ umbrella root cho một UC thuộc domain `be`:
402
410
  2. Step 1.6 load `mass-product-be/.agent/project-context.yaml` → `test_command = "npm test"`
403
411
  3. Lệnh test chạy: `cd mass-product-be && npm test`
404
412
 
405
- **Commit 2 lớp (bắt buộc):**
413
+ **BDD + trace ở spec repo (1 tầng); code ở service (2 tầng):**
406
414
  ```bash
407
- # Lớp 1: Commit trong service submodule
408
- cd mass-product-be
409
- git add specs/bdd/auth/FT-001-login.feature
415
+ # BDD (.feature) + trace (.tsv) → SPEC repo (1 tầng khi spec_source set)
416
+ cd mass-product-specs
417
+ git add specs/bdd/auth/FT-001-login.feature .trace/FT-001.tsv
410
418
  git commit -m "feat(bdd): add login BDD scenarios — FT-001"
411
- git push origin feature/ft-001-login
419
+ git push
412
420
 
413
- # Lớp 2: Update pointer tại umbrella
421
+ # Code service submodule (commit 2 lớp)
422
+ cd ../mass-product-be
423
+ git add src/
424
+ git commit -m "feat(FT-001): login implementation"
425
+ git push origin feature/ft-001-login
414
426
  cd .. ← về umbrella root
415
427
  git add mass-product-be
416
- git commit -m "chore: update mass-product-be submodule pointer — FT-001 BDD"
428
+ git commit -m "chore: update mass-product-be submodule pointer — FT-001"
417
429
  git push
418
430
  ```
419
- **Không commit lớp 2 → umbrella repo vẫn trỏ về commit cũ của service.**
431
+ **Không commit lớp 2 (pointer) → umbrella repo vẫn trỏ về commit cũ của service.**
420
432
 
421
433
  ## Tình huống 8: Validate traces trước khi tạo PR lớn
422
434
 
@@ -2,12 +2,46 @@
2
2
 
3
3
  # Workflow Cơ Bản
4
4
 
5
+ > Sơ đồ render thành flowchart trên GitHub (Mermaid). Bản text ASCII (mở mục bên dưới) là fallback cho viewer không hỗ trợ Mermaid.
6
+
7
+ ```mermaid
8
+ flowchart TD
9
+ A([Nhận PRD + BDD mới từ PO]) --> B["/sync<br/>kéo specs + services · refresh Living Docs"]
10
+ B --> C["/review-context {prd}<br/>kiểm tra domain · status=approved<br/>đọc AC / UC / BR + BDD"]
11
+ C --> D["Đọc BDD web/app/system từ spec repo<br/>(dev KHÔNG tự generate BDD)"]
12
+ D --> TD
13
+
14
+ subgraph TD["TECH DESIGN + CODE — BE và FE làm SONG SONG"]
15
+ direction LR
16
+ subgraph BE["BE track (system) — làm trước để có contract"]
17
+ direction TB
18
+ BE1["/generate-tech-docs {system}<br/>API contract ← System BDD<br/>endpoint · data model · DB"] --> BE2["/review-tech-docs → approved<br/>chốt = BE contract<br/>(FE chờ cái này)"] --> BE3["/generate-code {system}<br/>code BE ← System BDD + contract"]
19
+ end
20
+ subgraph FE["FE/App track (web · app) — không chờ BE deploy"]
21
+ direction TB
22
+ FE1["① /generate-code {bdd} --phase=ui<br/>UI ← Web/App BDD + Design Spec<br/>mock ← BE contract (nếu có) · else System BDD<br/>emit test-id · Tester test ngay"] --> GATE{{"GATE — chỉ làm tiếp khi ĐÃ CÓ:<br/>System BDD + BE contract (approved)"}}
23
+ GATE --> FE2["② /generate-tech-docs {web|app}<br/>FE design ← Web/App BDD + BE contract<br/>§4 map API · §2b test-id"] --> FE2b["/review-tech-docs → approved<br/>(bump revision)"] --> FE3["③ /generate-code --phase=integration<br/>thay mock bằng API thật theo §4"]
24
+ end
25
+ BE2 -. "cấp BE contract" .-> GATE
26
+ end
27
+
28
+ TD --> E["/dev-gen-test → /dev-run-test<br/>dev tự kiểm (dev_selftest)<br/>ghi vào spec .trace"]
29
+ E --> F["/validate-traces<br/>cập nhật Living Docs (.living-docs)"]
30
+ F --> G["/review-code — 4 lens:<br/>Security · Performance · Architecture · Test"]
31
+ G --> H([Tạo PR → notify PO/SA review])
32
+ ```
33
+
34
+ > **Full-stack / không tách mock:** chỉ cần BE track — chạy `/generate-code {bdd}` một lần (bỏ qua FE 2-phase).
35
+
36
+ <details>
37
+ <summary>Bản text (ASCII fallback — cho viewer không render Mermaid)</summary>
38
+
5
39
  ```
6
40
  Nhận thông báo PRD + BDD mới từ PO
7
41
 
8
42
 
9
- git submodule update --remote my-project-specs
10
- (lấy spec mới nhất, bao gồm cả BDD đã được PO gen)
43
+ /sync # pull specs + services + refresh Living Docs (1 lệnh, preferred)
44
+ (tương đương raw: git submodule update --remote my-project-specs — lấy spec mới nhất, gồm BDD PO đã gen)
11
45
 
12
46
 
13
47
  /review-context {prd-file}
@@ -23,27 +57,44 @@ App: my-project-specs/specs/bdd/{domain}/app/{TICKET-ID}-UC*.feature
23
57
  BE: my-project-specs/specs/bdd/{domain}/system/{TICKET-ID}-UC*.feature
24
58
 
25
59
 
26
- /generate-tech-docs {prd-file}
27
- Gen API spec, DB schema, sequence diagram dựa trên BDD
28
- → /review-tech-docs để verify chất lượng
29
-
30
-
31
- # BE (hoặc full-stack không cần mock split):
32
- /generate-code {bdd-file}
33
- Gen code skeleton theo BDD + tech docs
34
- → Đảm bảo @trace.bdd comment trong code
35
-
36
- # FE/App (2 phases không cần chờ BE):
37
- /generate-code {bdd-file} --phase=ui # Phase 1: UI + mock adapter
38
- Tester test FE ngay (không cần BE ready)
39
- /generate-code {bdd-file} --phase=integration # Phase 2: sau khi sign-off done
40
- Wire real API thay thế mock
60
+ ══════════ TECH DESIGN + CODE — BE track & FE track CHẠY SONG SONG ══════════
61
+ (/generate-tech-docs là platform-aware: đọc @trace.platform BE = API contract · FE/App = client design)
62
+
63
+ BE track (system) ── làm trước, sinh ra "BE contract" ──
64
+ /generate-tech-docs {system} → API contract: endpoints · data model · DB · caching
65
+ /review-tech-docs APPROVED → đây CHÍNH "BE contract" mà FE chờ
66
+ /generate-code {system} → code theo BDD (@trace.bdd)
67
+ (full-stack / không tách mock: chỉ cần track này — /generate-code {bdd} một lần)
68
+
69
+
70
+ FE/App track (web|app) ── KHÔNG chặn chờ BE ──
71
+
72
+ BẮT ĐẦU NGAY (song song với BE):
73
+ /generate-code {bdd} --phase=ui → UI + mock adapter
74
+ UI Web/App BDD + Design Spec
75
+ • mock shape = BE contract nếu có, else System BDD (+warn)
76
+ • fixture values: LUÔN từ System BDD
77
+ • emit test-id (convention {uc}-{screen}-{element}-{type})
78
+ • Tester test FE NGAY (không cần BE deploy API)
79
+
80
+ ╔═══════════════════▼═══════════ GATE ═══════════════════
81
+ ║ Chỉ mở khi CÓ: System BDD + BE contract (approved, từ track BE)
82
+ ╚═══════════════════╤════════════════════════════════════
83
+
84
+ ② /generate-tech-docs {web|app} → FE client design (GATED)
85
+ • components · state
86
+ • §4 API-integration map THEO BE contract
87
+ • §2b Test Selectors (test-id cho element có action)
88
+ /review-tech-docs → approved (bump revision)
89
+
90
+ ③ /generate-code {bdd} --phase=integration
91
+ → wire real API theo §4 FE tech-design (thay mock)
41
92
 
42
93
 
43
94
  /dev-gen-test {bdd-file}
44
95
  → Gen unit test (dev self-check, không phải coverage chính thức)
45
- → /dev-run-test để verify → ghi dev_selftest (pass/fail) + dev_selftest_at vào trace TSV
46
- → /validate-traces (hoặc /sync) để push trace lên spec-module Living Docs ({spec_source}/.living-docs/)
96
+ → /dev-run-test để verify → ghi dev_selftest (pass/fail) + dev_selftest_at vào TSV authoritative {spec_source}/.trace (commit 1 tầng ở spec repo)
97
+ → /validate-traces (hoặc /sync) regenerate report Living Docs {spec_source}/.living-docs/ (gitignored)
47
98
 
48
99
 
49
100
  /review-code {files}
@@ -54,7 +105,16 @@ BE: my-project-specs/specs/bdd/{domain}/system/{TICKET-ID}-UC*.feature
54
105
  Tạo PR → notify PO/SA review
55
106
  ```
56
107
 
57
- > **Commit ở đâu, push mấy tầng?** Code + `.trace/` nằm trong service submodule → **commit 2 tầng** (service rồi umbrella pointer); tech-docs đẩy lên spec repo. Sơ đồ git đầy đủ theo từng role: [Sync & Update — Git flow theo role](../../04-operations/sync-and-update.md#ai-commit-vào-repo-nào-git-flow-theo-role).
108
+ </details>
109
+
110
+ > **Vì sao đúng thứ tự này? — Chuỗi outside-in.** Toàn bộ pipeline đi từ ngoài (client) vào trong (hệ thống):
111
+ > 1. **PO gen BDD: web → app → System** — System BDD (BE) được **tổng hợp từ web+app BDD** (hành vi client định nghĩa trước, BE/system suy ra để phục vụ các flow đó). *(Project chỉ-BE: System BDD gen thẳng từ PRD.)*
112
+ > 2. **BE tech-docs trước** — API contract dẫn xuất từ **System BDD**.
113
+ > 3. **FE/App tech-docs sau (GATED)** — cần **System BDD + BE contract approved**; §4 map theo BE contract.
114
+ >
115
+ > FE **không** bị chặn chờ BE nhờ `--phase=ui` (mock shape: BE contract nếu có, else System BDD), rồi `--phase=integration` wire API thật khi contract đã có. Chi tiết flow: [Concepts › Pipeline](../../03-concepts/pipeline.md).
116
+
117
+ > **Commit ở đâu, push mấy tầng?** Code nằm trong service submodule → **commit 2 tầng** (service rồi umbrella pointer). Tech-docs + `.trace/` (dev_selftest/qc_status) đẩy lên **spec repo** (1 tầng, cross-repo). Sơ đồ git đầy đủ theo từng role: [Sync & Update — Git flow theo role](../../04-operations/sync-and-update.md#ai-commit-vào-repo-nào-git-flow-theo-role).
58
118
 
59
119
  ---
60
120
 
@@ -9,7 +9,7 @@ Tài liệu dành cho **Product Owner (PO)** và **Business Analyst (BA)** — v
9
9
  | Trang | Nội dung |
10
10
  |---|---|
11
11
  | [Commands](commands.md) | Bảng lệnh cho PO/BA · project lessons · xử lý feedback tester |
12
- | [Tình huống thực tế](scenarios.md) | 11 scenario: tính năng mới, design spec, BDD, PRD thay đổi, conflict, brownfield, ... |
12
+ | [Tình huống thực tế](scenarios.md) | 12 scenario: tính năng mới, design spec, BDD, PRD thay đổi, brownfield, **System BDD synthesis & cross-platform conflict**, ... |
13
13
  | [Quy tắc viết PRD](prd-writing-rules.md) | Platform-agnostic · testable AC · negative path · BR numbering |
14
14
  | [Checklist handoff](handoff-checklist.md) | Checklist verify trước khi thông báo dev team bắt đầu |
15
15
 
@@ -34,7 +34,7 @@ PO/BA Dev team
34
34
  - Đảm bảo PRD platform-agnostic (không chứa UI details hay API specs)
35
35
  - Đặt `@trace.domain` đúng để dev team routing hoạt động
36
36
  - Cập nhật `@trace.status: approved` trước khi handoff
37
- - **Generate BDD cho tất cả platforms** (web, app, system) trong spec repo
37
+ - **Generate BDD cho tất cả platforms** theo thứ tự **outside-in: web app system** — System BDD được **tổng hợp từ web+app BDD** (project chỉ-BE thì system gen thẳng từ PRD). Xem [scenarios](scenarios.md).
38
38
  - Thông báo dev team khi có PRD hoặc BDD mới/update
39
39
 
40
40
  **PO/BA KHÔNG cần quan tâm:**
@@ -51,7 +51,7 @@ PRD (WHAT + WHY) → BDD (HOW verified) → Code (HOW built)
51
51
  spec repo spec repo dev repo
52
52
  ```
53
53
 
54
- > **Sau khi BDD approved → QC chạy pipeline tự động:** Khi BDD của một UC được approve, QC team chạy bộ lệnh native `/qc-analyze → /qc-plan → /qc-design-test → /qc-review → /qc-run-test → /qc-report` — đọc official `.feature`, generate + run Playwright/pytest, rồi ghi `qc_status` (official QC coverage) vào Living Docs. PO không chạy QC, nhưng nên biết bước này tồn tại ở downstream. Chi tiết: [QC Automation Guide](../qc-automation.md).
54
+ > **Sau khi BDD approved → QC chạy pipeline tự động:** Khi BDD của một UC được approve, QC team chạy bộ lệnh native `/qc-analyze → /qc-plan → /qc-design-test → /qc-review → /qc-run-test → /qc-report` — đọc official `.feature`, generate + run Playwright/pytest, rồi ghi `qc_status` (official QC coverage) vào Living Docs. PO không chạy QC, nhưng nên biết bước này tồn tại ở downstream. Chi tiết: [chương QC Automation](../tester/qc-automation.md).
55
55
 
56
56
  **3 lý do chính BDD thuộc PO:**
57
57
 
@@ -70,8 +70,10 @@ PRD (WHAT + WHY) → BDD (HOW verified) → Code (HOW built)
70
70
  - App BDD: "App expects user profile sau khi đăng nhập"
71
71
  - System BDD: "BE phải trả `{ token, user_profile }` để thỏa mãn cả 2 platform"
72
72
 
73
+ > Khi web & app **kỳ vọng response khác nhau**, `/generate-bdd → system` dừng tại **CHECKPOINT** để PO chốt cách giải quyết (union / platform-hint / separate-endpoints) — quyết định ghi vào `@system.resolution:`. Quy trình + ví dụ đầy đủ: [scenarios › Tình huống 12](scenarios.md#tình-huống-12--system-bdd-synthesis-outside-in--xử-lý-cross-platform-conflict).
74
+
73
75
  > Xem [Concepts › Traceability](../../03-concepts/traceability.md) để hiểu trace chain PRD → BDD → Code.
74
76
 
75
77
  ---
76
78
 
77
- *Xem thêm:* [Developer Guide](../developer/README.md) · [Tester Guide](../tester/README.md) · [QC Automation Guide](../qc-automation.md) · [Reference › Commands](../../05-reference/commands.md)
79
+ *Xem thêm:* [Developer Guide](../developer/README.md) · [Tester Guide](../tester/README.md) · [chương QC Automation](../tester/qc-automation.md) · [Reference › Commands](../../05-reference/commands.md)
@@ -12,7 +12,7 @@
12
12
  | `/review-context --fix` | Auto-fix các lỗi nhỏ trong PRD | Khi có nhiều lỗi minor tự sửa được |
13
13
  | `/review-context --resume` | Apply các fix sau Review Board | Sau khi review findings |
14
14
  | `/generate-design-spec` | Tạo Design Spec cho FE/App (cần Figma link node-level `?node-id=` cho từng screen) | Sau khi PRD approved, trước khi generate BDD |
15
- | `/generate-bdd` | Tạo BDD cho web / app / system | Sau khi PRD + Design Spec approved |
15
+ | `/generate-bdd` | Tạo BDD theo thứ tự **outside-in: web app system** (System BDD tổng hợp từ web+app; chỉ-BE → system gen thẳng từ PRD) | Sau khi PRD + Design Spec approved |
16
16
  | `/learn {text}` | Ghi lại lỗi AI hay lặp khi gen PRD/BDD thành guardrail | Khi AI lặp lại cùng kiểu sai trong PRD/BDD |
17
17
 
18
18
  > Danh mục đầy đủ mọi command: [Reference › Commands](../../05-reference/commands.md).
@@ -29,6 +29,9 @@ Output: `specs/prd/auth/FEAT-01-login-prd.md`
29
29
  Agent fan-out 4 lens (QA/DEV/SA/PO) chạy song song, rồi chạy completeness-critic loop cho đến khi một vòng không tìm ra finding mới, cuối cùng dedup + resolve conflict. Findings đầy đủ trong 1 lần chạy.
30
30
 
31
31
  Mở findings file, xem xét từng finding: `accepted` → apply · `modified` → viết note · `rejected` → bỏ qua.
32
+
33
+ > **Finding khó hiểu? Bấm 💬 Giải thích.** Nếu một finding mô tả nặng tính kỹ thuật, dùng nút **💬 Giải thích** trên Review Board (extension Spec Driven Dev). Claude sẽ giải thích lại bằng ngôn ngữ no-tech + đề xuất phương án cụ thể (cover cả edge case) ngay trong terminal, và **chờ bạn confirm trước khi apply** vào PRD — tránh refine nhiều vòng. Prompt sửa được qua setting `reviewBoard.clarifyPrompt` (không cần cài lại extension).
34
+
32
35
  ```
33
36
  /review-context --resume specs/prd/auth/FEAT-01-login-prd.md
34
37
  ```
@@ -63,7 +66,7 @@ Agent hỏi: **"Platform? (1) web (2) app (3) system"**
63
66
  - Chạy lại, chọn `app` → `specs/bdd/auth/app/FEAT-01-UC1-login-app.feature`
64
67
  - Chạy lại, chọn `system` → Agent tổng hợp từ web+app BDDs → `specs/bdd/auth/system/FEAT-01-UC1-login-system.feature`
65
68
 
66
- > Nếu project chỉ có web → chỉ cần gen `web` rồi `system`.
69
+ > Nếu project chỉ có web → chỉ cần gen `web` rồi `system`. Nếu web & app kỳ vọng response khác nhau → agent dừng tại CHECKPOINT để PO chốt resolution (xem [Tình huống 12](#tình-huống-12--system-bdd-synthesis-outside-in--xử-lý-cross-platform-conflict)).
67
70
 
68
71
  **Bước 8 — Push và thông báo:**
69
72
  ```bash
@@ -354,4 +357,80 @@ Chạy ở mode **Reverse-document**: mô tả lại API đã tồn tại, ghi c
354
357
 
355
358
  ---
356
359
 
360
+ ## Tình huống 12 — System BDD synthesis: outside-in & xử lý cross-platform conflict
361
+
362
+ **Bối cảnh:** Đã có Web BDD + App BDD cho FEAT-01. Khi gen System BDD, `/generate-bdd → system` **không viết mới từ PRD** mà **tổng hợp ngược** từ Web + App BDD (outside-in) — vì BE/system tồn tại để phục vụ các flow client.
363
+
364
+ **4 mode tự nhận diện** (theo BDD client đang có):
365
+
366
+ | Có sẵn | Mode | System BDD lấy từ |
367
+ |---|---|---|
368
+ | web + app | **Multi-platform** | tổng hợp cả hai (+ conflict check) |
369
+ | chỉ web | **Web-only** | chỉ web |
370
+ | chỉ app | **App-only** | chỉ app |
371
+ | không có web/app | **Backend-only** | gen thẳng từ PRD (business-event language) |
372
+ | PRD có `API Source: existing` | **Brownfield** | dùng contract có sẵn trong PRD (xem [Tình huống 11](#tình-huống-11--brownfield-api-đã-tồn-tại-trên-hệ-thống-cũ)) |
373
+
374
+ ### Ví dụ multi-platform CÓ conflict
375
+
376
+ Web và App kỳ vọng response **khác nhau**:
377
+ ```gherkin
378
+ # web/FEAT-01-UC1-login-web.feature
379
+ Then user sees dashboard # → cần { token, redirect_url }
380
+
381
+ # app/FEAT-01-UC1-login-app.feature
382
+ Then app navigates to HomeScreen # → cần { token, user_profile }
383
+ ```
384
+
385
+ Chạy `/generate-bdd → system` → agent phát hiện **response shape mismatch** → dừng tại CHECKPOINT (bắt buộc, không skip được):
386
+
387
+ ```
388
+ ⚠️ CROSS-PLATFORM CONTRACT CONFLICT
389
+ Conflict 1: Response shape mismatch
390
+ Web (Then sees dashboard) → { token, redirect_url }
391
+ App (Then navigates HomeScreen) → { token, user_profile }
392
+
393
+ Resolution:
394
+ A — Union: BE trả { token, redirect_url, user_profile }; client bỏ field không dùng (đơn giản, hơi thừa)
395
+ B — Platform hint: client gửi header X-Platform: web|app, BE tailor response (gọn, BE phức tạp hơn)
396
+ C — Separate endpoints: POST /auth/login/web · /auth/login/app (linh hoạt nhất, nhiều endpoint)
397
+ D — Custom: tự mô tả
398
+ ```
399
+
400
+ **4 loại conflict agent bắt:**
401
+
402
+ | Loại | Ví dụ |
403
+ |---|---|
404
+ | Response shape mismatch | web `{ token, redirect_url }` vs app `{ token, user_profile }` |
405
+ | Error semantics mismatch | web HTTP 423 vs app error code `ACC_LOCKED` |
406
+ | Business rule contradiction | web "khoá sau 5 lần" vs app "khoá sau 3 lần" |
407
+ | Data field conflict | web `expires_in: seconds` vs app `expires_at: ISO timestamp` |
408
+
409
+ ### PO chọn resolution → ghi vào System BDD
410
+
411
+ Chọn **A (Union)** → System BDD được gen kèm annotation:
412
+ ```gherkin
413
+ # system/FEAT-01-UC1-login-system.feature
414
+ # @trace.platform: system
415
+ # @system.resolution: union — clients receive all fields
416
+ Scenario: Successful login returns token, redirect and profile
417
+ When the system receives a login request
418
+ Then the system returns { token, redirect_url, user_profile }
419
+ And the session is valid for 3600 seconds
420
+ ```
421
+ - **B (platform-hint)** → `Scenario Outline` + Examples cho web/app variant; annotation `platform-hint`.
422
+ - **C (separate endpoints)** → Scenario riêng mỗi endpoint; annotation ghi rõ split.
423
+
424
+ Mỗi quyết định được lưu thành `# @system.resolution:` trong file system BDD — để BE dev build contract đúng kiểu đã chốt.
425
+
426
+ ### Bàn giao xuống BE & xử lý thay đổi
427
+
428
+ - BE dev đọc `@system.resolution:` → build API contract theo đúng kiểu (union / platform-hint / separate-endpoints) trong `/generate-tech-docs`. **Không tự đổi** — nếu thấy bất hợp lý → phản hồi PO (đây là quyết định contract, không phải implementation).
429
+ - **Web/App BDD đổi về sau** → re-gen System BDD (`/generate-bdd → system`) để tổng hợp lại; phát sinh conflict mới → CHECKPOINT lại.
430
+ - **FE cần field mà BE contract chưa có** → là **contract gap**: QC/Dev `/report-bug` hoặc `/propose-scenario` → PO bổ sung vào Web/App BDD → re-synthesize System BDD → BE cập nhật contract. Vòng feedback: [Bug Flow](../../04-operations/bug-flow.md).
431
+
432
+ > **Tóm tắt outside-in:** Web/App BDD (client trước) → System BDD (tổng hợp, chốt conflict) → BE tech-docs (contract) → FE/App tech-docs (GATED: cần System BDD + BE contract). Chuỗi đầy đủ: [Developer › Workflow](../developer/workflow.md) · [Concepts › Pipeline](../../03-concepts/pipeline.md).
433
+
434
+ ---
435
+
357
436
  ← [Commands](commands.md) · Tiếp theo: [Quy tắc viết PRD](prd-writing-rules.md)