spec-lite 1.5.2 → 1.6.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.
@@ -0,0 +1,243 @@
1
+ ---
2
+ name: spec-test-design
3
+ description: Tạo test-design.md (Test Design Document) trực tiếp tại feature level từ frd.md — mechanical derive Test Scenarios + Test Cases. KHÔNG cần integration, không cascade. Dùng cho brownfield onboarding (sau /spec-brownfield-feature) hoặc greenfield bootstrap khi feature đã có frd.md nhưng chưa có test-design.md.
4
+ ---
5
+
6
+ # spec-test-design
7
+
8
+ ## Overview
9
+
10
+ Tạo `.specs/main/feature/{F-XXX}-{slug}/test-design.md` trực tiếp từ frd.md của feature đó — **không qua integration**, không cascade.
11
+
12
+ Skill này song hành với `/spec-prd` và `/spec-sad`: skill có acronym suffix (`prd`/`sad`/`test-design`) → tạo main artifact trực tiếp. Phân biệt với `/spec-test` — skill đó tạo `test.md` integration-level và cascade qua Changes blocks.
13
+
14
+ ## When to Use
15
+
16
+ - **Brownfield onboarding** — sau `/spec-brownfield-feature` đã sinh frd.md, cần bootstrap test-design.md để có test coverage tracking ngay từ đầu.
17
+ - **Greenfield deferred** — feature có frd.md từ lâu nhưng test-design.md chưa được tạo (vd: test design bị defer).
18
+ - **Ad-hoc rebuild** — test-design.md drift quá xa khỏi frd.md, muốn regenerate fresh.
19
+
20
+ ## When NOT to Use
21
+
22
+ - Có integration mới và muốn cascade thay đổi frd lên test-design hiện tại → dùng `/spec-test` (changeset patch giữ ID stable)
23
+ - Chỉ muốn sửa vài TC → edit `test-design.md` trực tiếp
24
+ - Feature chưa có frd.md → chạy `/spec-brownfield-feature` (brownfield) hoặc `/spec-new` (greenfield) trước
25
+
26
+ ## Cảnh báo về ID stability
27
+
28
+ `/spec-test-design` **regenerate IDs từ 001** mỗi lần chạy. Nếu test-design.md đã tồn tại và đang được reference (vd: test code có `// covers TC-F001-005`), rebuild sẽ làm vỡ những reference đó.
29
+
30
+ Quy tắc:
31
+ - **test-design.md chưa tồn tại** → an toàn, không có reference, regenerate fresh.
32
+ - **test-design.md tồn tại** → skill hỏi confirm rõ ràng trước khi overwrite. Khuyến nghị: dùng `/spec-test` qua integration changeset để preserve ID stable.
33
+
34
+ ---
35
+
36
+ ## Process
37
+
38
+ ### Bước 1: Xác định feature
39
+
40
+ **Nếu có ARGUMENT:**
41
+ - Parse argument: có thể là feature ID (`F-001`, `001`) hoặc slug (`F-001-auth`, `auth`)
42
+ - Quét `.specs/main/feature/*/frd.md`, tìm feature khớp
43
+ - Nếu không tìm thấy → báo lỗi:
44
+ > Không tìm thấy feature khớp với "{argument}". Kiểm tra `.specs/main/feature/`.
45
+
46
+ **Nếu không có ARGUMENT:**
47
+
48
+ Quét `.specs/main/feature/`. Liệt kê **tất cả** features có `frd.md`, đánh dấu trạng thái test-design:
49
+
50
+ ```
51
+ Features có frd.md:
52
+
53
+ [1] F-001 — auth spec✓ test-design✓
54
+ [2] F-002 — checkout spec✓ test-design—
55
+ [3] F-003 — refund spec✓ test-design— (frd có 5 Flow, 12 US, 8 VR, 3 FAC)
56
+
57
+ Chọn số feature:
58
+ ```
59
+
60
+ Nếu không có feature nào có frd → thông báo:
61
+ > Chưa có feature nào có frd.md. Hãy chạy `/spec-brownfield-feature` hoặc `/spec-new` trước.
62
+
63
+ ---
64
+
65
+ ### Bước 2: Gate check — frd.md tồn tại + warn nếu test-design.md đã có
66
+
67
+ **Check 1 — frd.md tồn tại:**
68
+
69
+ Nếu `.specs/main/feature/{F-XXX}-{slug}/frd.md` không tồn tại → dừng:
70
+ > ⛔ `feature/{F-XXX}-{slug}/frd.md` không tồn tại. `/spec-test-design` cần frd làm input.
71
+
72
+ **Check 2 — test-design.md đã tồn tại:**
73
+
74
+ Nếu `.specs/main/feature/{F-XXX}-{slug}/test-design.md` đã tồn tại:
75
+
76
+ > ⚠ `test-design.md` đã tồn tại cho feature **{F-XXX} — {slug}**.
77
+ >
78
+ > `/spec-test-design` regenerate IDs từ 001 — nếu có test code đang reference TC-{F_ID}-NNN hoặc TS-{F_ID}-NNN, references sẽ bị vỡ.
79
+ >
80
+ > Khuyến nghị: dùng `/spec-test` qua integration changeset để giữ ID stable.
81
+ >
82
+ > Tiếp tục overwrite? (yes / no — default no)
83
+
84
+ Nếu user chọn no → dừng, suggest `/spec-test`.
85
+ Nếu user chọn yes → backup test-design.md cũ thành `test-design.md.bak.{timestamp}` rồi proceed.
86
+
87
+ ---
88
+
89
+ ### Bước 3: Load context
90
+
91
+ Load các file sau:
92
+
93
+ - `.specs/main/feature/{F-XXX}-{slug}/frd.md` — **bắt buộc**, source của TC
94
+ - `.specs/main/feature/{F-XXX}-{slug}/fdd.md` — optional, đọc nếu tồn tại để hint Components Used (cho Dependencies section của test-design)
95
+
96
+ Tóm tắt context:
97
+
98
+ ```
99
+ TÔI HIỂU:
100
+ - Feature: {F-XXX} — {slug}
101
+ - Trong frd.md:
102
+ - {N} Flows
103
+ - {M} User Stories ({K} Acceptance Criteria)
104
+ - {P} Verification Rules
105
+ - {Q} Feature Acceptance Criteria
106
+ - test-design.md hiện tại: {chưa có / sẽ overwrite — backup tại test-design.md.bak.{timestamp}}
107
+ - fdd.md: {tồn tại — Components Used: C-XXX, C-YYY / chưa có}
108
+ ```
109
+
110
+ ---
111
+
112
+ ### Bước 4: Auto-derive draft
113
+
114
+ **Nguyên tắc:** mechanical derive 1:1 từ frd.md — same algorithm như `/spec-test` (xem [skills/spec-test/SKILL.md](../spec-test/SKILL.md) Bước 3.1-3.3). Tóm lại:
115
+
116
+ #### 4.1 ID assignment
117
+
118
+ - IDs bắt đầu từ `001` (vì tạo mới hoặc regenerate). TS và TC cùng feature ID `F{NNN}`, TC dùng chung sequence cho Functional / Validation / E2E / Non-functional / Data & Migration — không đẻ prefix riêng.
119
+ - ID sẽ stable kể từ thời điểm này — lần edit tiếp theo qua `/spec-test` integration phải preserve.
120
+
121
+ #### 4.2 Derivation rules
122
+
123
+ | frd item | test-design output |
124
+ | --- | --- |
125
+ | Mỗi `Flow {N}` trong User Flows | 1 Test Scenario `TS-F{NNN}-{seq}` |
126
+ | Mỗi `AC-F{NNN}-{seq}` trong US | 1 Functional TC `TC-F{NNN}-{seq}` |
127
+ | Mỗi `VR-F{NNN}-{seq}` | 1 positive + 1+ negative Validation TC |
128
+ | Mỗi `FAC-F{NNN}-{seq}` (end-to-end) | 1 E2E TC (Type `E2E — journey`/`consistency`/`integrity`) |
129
+ | Mỗi `NFR-F{NNN}-{seq}` | 1 Non-functional TC (Type `performance`/`a11y`/`security`...) |
130
+ | Mỗi `DM-F{NNN}-{seq}` (section required-emptyable) | 1 Data & Migration TC (Type `data migration`) |
131
+
132
+ Detail dịch G/W/T → Preconditions/Steps/Expected, infer negative VR branches từ rule text — xem `/spec-test` Bước 3.2.
133
+
134
+ #### 4.3 Priority defaults
135
+
136
+ | Source | Priority |
137
+ | --- | --- |
138
+ | TC cover US Must | P0 |
139
+ | TC cover US Should | P1 |
140
+ | TC cover US Could | P2 |
141
+ | TC cover VR | inherit max priority của Refs (P1 default nếu Refs trống) |
142
+ | TC cover FAC e2e (journey) | P0 |
143
+ | TC cover FAC integrity | P0 |
144
+ | TC cover FAC consistency | P1 |
145
+ | TC cover NFR security | P0 |
146
+ | TC cover NFR perf/a11y/i18n/browser | P1 |
147
+ | TC cover DM (data & migration) | P0 |
148
+
149
+ #### 4.4 Traceability Matrix
150
+
151
+ Row per frd item — Flow / US / Story AC / VR / FAC / NFR / DM. Mọi item phải có cover ✅. Item không thể derive → ❌ + ghi lý do ở Gaps section.
152
+
153
+ #### 4.5 Placeholders cần QC fill
154
+
155
+ Agent **không suy đoán**:
156
+
157
+ | Field | Placeholder |
158
+ | --- | --- |
159
+ | Test Data Requirements | Row `{TBD — shape}` cho mỗi dataset test cần (yêu cầu data, không phải nguồn/refresh) |
160
+ | Out of Scope | Để trống với note `<!-- QC fill -->` |
161
+ | Test Strategy > Approach | Bullet generic theo template gốc |
162
+ | Overview | 2-3 câu mô tả feature scope từ frd Overview |
163
+
164
+ #### 4.6 Dependencies section
165
+
166
+ - **FRD reference**: path tới `frd.md` của feature này
167
+ - **Components Used**: copy từ `frd.md > Components Used`. Nếu fdd.md tồn tại → cross-reference C-XXX để đảm bảo đúng.
168
+
169
+ ---
170
+
171
+ ### Bước 5: Review — xác nhận với QC
172
+
173
+ Hiển thị draft đầy đủ — chưa ghi file.
174
+
175
+ > Draft test-design.md trên đã đúng chưa? Check:
176
+ >
177
+ > 1. **Coverage** — Traceability Matrix có đủ row cho mỗi Flow / US / AC / VR / FAC / NFR / DM trong frd?
178
+ > 2. **Priority** — defaults theo bảng 4.3, có TC nào cần override?
179
+ > 3. **Placeholders** — fill Test Data Requirements / Out of Scope / Strategy Approach.
180
+ > 4. **Extra edge cases** — ngoài AC/VR có scenario QC muốn thêm?
181
+ >
182
+ > Confirm để ghi file. Reject để revise.
183
+
184
+ ---
185
+
186
+ ### Bước 6: Save
187
+
188
+ Ghi `.specs/main/feature/{F-XXX}-{slug}/test-design.md` với status `draft` (feature-level artifact có lifecycle riêng, không phải `approved` — QC còn fill placeholders nên status `draft` cho đến khi đầy đủ). Frontmatter lấy `template_version` từ `test-design-template.md` (xem `conventions.md` §7).
189
+
190
+ Nếu overwrite — file backup `test-design.md.bak.{timestamp}` đã tạo ở Bước 2.
191
+
192
+ **Change History:** Append entry vào section `## Change History` cuối test-design.md (theo `conventions.md` §5.5):
193
+
194
+ ```markdown
195
+ ### {YYYY-MM-DD} — manual — create
196
+
197
+ - **All sections**: initial scaffold qua /spec-test-design (mechanical derive từ frd.md — N TS, M Functional TC, P Validation TC, Q E2E TC, R Non-functional TC, S Data & Migration TC)
198
+ ```
199
+
200
+ Nếu overwrite test-design.md cũ → entry vẫn dùng operation `create` (vì IDs regenerate fresh, không phải update), thêm note trong body: `- **Note**: overwrote previous test-design.md (backup tại test-design.md.bak.{timestamp}) — IDs regenerated từ 001`.
201
+
202
+ Thông báo kết quả:
203
+
204
+ ```
205
+ ✓ .specs/main/feature/{F-XXX}-{slug}/test-design.md đã được tạo (status: draft)
206
+ Coverage: N Flows → N TS, M US/AC → M Functional TC, P VR → ~2P Validation TC, Q FAC → Q E2E TC, R NFR → R Non-functional TC, S DM → S Data & Migration TC
207
+ {nếu overwrite: backup tại test-design.md.bak.{timestamp}}
208
+
209
+ Bước tiếp theo:
210
+ - QC: fill remaining placeholders (Test Data Requirements, Out of Scope, Strategy)
211
+ - Đổi status: draft → approved khi sẵn sàng
212
+ - Sau này: nếu frd thay đổi → dùng /spec-test qua integration changeset để giữ ID stable
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Common Rationalizations
218
+
219
+ | Rationalization | Reality |
220
+ | --- | --- |
221
+ | "Có frd rồi, viết test-design sau cũng được" | Test coverage không tracked = không biết feature đóng được chưa. test-design làm song song với frd, không sau. |
222
+ | "Rebuild test-design nhanh hơn cập nhật manual" | Đúng cho lần đầu. Lần sau khi đã có test code reference → rebuild sẽ break references. Lúc đó dùng `/spec-test`. |
223
+ | "Brownfield không cần test-design, đã có test code" | Test code là HOW. test-design là WHAT — declarative TC list để track coverage vs frd. Hai layer khác nhau. |
224
+
225
+ ## Red Flags
226
+
227
+ - Traceability Matrix có ❌ mà không có Gaps section giải thích
228
+ - Priority hàng loạt P1 — chưa override theo defaults
229
+ - Test Strategy / Test Data Requirements toàn `TBD` sau khi QC review xong
230
+ - Overwrite test-design.md hiện có mà không cảnh báo về ID break
231
+
232
+ ## Verification
233
+
234
+ Trước khi ghi file:
235
+
236
+ - [ ] Mỗi Flow trong frd có 1 TS
237
+ - [ ] Mỗi US AC có TC Functional cover
238
+ - [ ] Mỗi VR có ≥1 positive + ≥1 negative TC
239
+ - [ ] Mỗi FAC có TC E2E cover; mỗi NFR có TC Non-functional; mỗi DM có TC Data & Migration
240
+ - [ ] Priority deterministic theo bảng 4.3
241
+ - [ ] Nếu overwrite: test-design.md.bak.{timestamp} đã được tạo
242
+ - [ ] QC đã confirm draft
243
+ - [ ] Frontmatter có `template_version` copy từ `test-design-template.md`
@@ -62,14 +62,14 @@ Nhận F-XXX từ argument (hoặc chọn từ prd Feature Index) + tùy chọn
62
62
  - **Create-only**: frd.md của feature mục tiêu **chưa tồn tại**. Đã tồn tại → **dừng, redirect `/spec-new`** (thay đổi feature đã spec phải đi qua integration để delta cascade + kéo theo `/spec-tech`/`/spec-test`).
63
63
  - Feature mới **đơn lẻ** chưa có trong Index → offer **register một row vào `prd.md > Features`** rồi author.
64
64
 
65
- **Sections template** (7): Overview · User Flows · Feature Acceptance Criteria · User Stories · Verification Rules · Scope · Dependencies
65
+ **Sections template**: Overview · User Flows · Feature Acceptance Criteria (end-to-end) · Non-Functional Requirements · Data & Migration *(nếu có)* · User Stories · Verification Rules · Scope · Dependencies
66
66
 
67
67
  **Phạm vi hẹp — chủ yếu `frd.md`:**
68
68
  - Reference component frd phụ thuộc (Components Used → C-XXX có sẵn).
69
69
  - Component cần-nhưng-chưa-có → ghi *candidate* + Open Question cho `/spec-sad`/architect chốt boundary.
70
70
  - Có thể register **một** feature row vào prd (side-effect lên prd).
71
71
  - **Cascade vocabulary lên `domain.md`** (pha mô tả/WHAT): glossary term + **định nghĩa shared entity** (attributes), `Owner: TBD` để `/spec-sad` gán ở pha thiết kế (HOW). BA define entity, KHÔNG carve/gán Owner.
72
- - **KHÔNG** tạo `crd.md`/`cdd.md` (sinh ở integration time qua `/spec-new` cascade), không tạo `fdd.md`/`tsd.md`, không đổi status feature đã có, không đụng sad.
72
+ - **KHÔNG** tạo `crd.md`/`cdd.md` (sinh ở integration time qua `/spec-new` cascade), không tạo `fdd.md`/`test-design.md`, không đổi status feature đã có, không đụng sad.
73
73
  - Change History operation = `manual` (cả frd lẫn domain). Verification Rules dùng quy ước option-suggester của `/spec-new` (BA owns).
74
74
 
75
75
  Bỏ qua bước này cũng được — `/spec-new` sẽ tự tạo frd làm fallback khi integration đầu tiên chạm tới feature.
@@ -94,14 +94,14 @@ Bỏ qua bước này cũng được — `/spec-new` sẽ tự tạo frd làm fa
94
94
 
95
95
  Dùng khi onboarding một project đã có code vào SDD. Mục tiêu: extract main artifacts từ codebase hiện có, sau đó chuyển vào **Integration Pipeline** để implement.
96
96
 
97
- **Thứ tự bắt buộc:** `init` → `component` → `feature` → `tsd` *(tùy chọn — bootstrap test coverage tracking)*
97
+ **Thứ tự bắt buộc:** `init` → `component` → `feature` → `test-design` *(tùy chọn — bootstrap test coverage tracking)*
98
98
 
99
99
  | Command | Scan | Reads | Writes |
100
100
  | --- | --- | --- | --- |
101
101
  | `/spec-brownfield-init [path]` | tech stack, README, auth, infra | attachments | `prd.md` *(no indexes)*, `domain.md` *(glossary only)*, `sad.md` |
102
102
  | `/spec-brownfield-component [path]` | module dirs, service/controller/entity files | `prd.md`, `domain.md` | `component/{C-XXX}-*/crd.md + cdd.md`; update `prd.md` Component Index; cascade Shared Entities → `domain.md` |
103
103
  | `/spec-brownfield-feature [path]` | use cases, routes, test files | `prd.md`, `domain.md`, `component/*/crd.md` | `feature/{F-XXX}-*/frd.md + fdd.md`; update `prd.md` Feature Index |
104
- | `/spec-tsd [F-XXX]` | — *(không scan code, derive 100% từ frd)* | `feature/{F-XXX}-*/frd.md`, `fdd.md` *(optional)* | `feature/{F-XXX}-*/tsd.md` |
104
+ | `/spec-test-design [F-XXX]` | — *(không scan code, derive 100% từ frd)* | `feature/{F-XXX}-*/frd.md`, `fdd.md` *(optional)* | `feature/{F-XXX}-*/test-design.md` |
105
105
 
106
106
  ### Phân chia trách nhiệm
107
107
 
@@ -173,21 +173,21 @@ Component Index và Feature Index **để placeholder** — sẽ được điề
173
173
 
174
174
  ---
175
175
 
176
- ### `/spec-tsd [F-XXX]`
176
+ ### `/spec-test-design [F-XXX]`
177
177
 
178
- **Mục tiêu:** Bootstrap `tsd.md` (Test Spec Document) cho một feature trực tiếp từ frd.md — mechanical derive Test Scenarios + Test Cases. KHÔNG cần integration.
178
+ **Mục tiêu:** Bootstrap `test-design.md` (Test Design Document) cho một feature trực tiếp từ frd.md — mechanical derive Test Scenarios + Test Cases. KHÔNG cần integration.
179
179
 
180
180
  **Khi nào dùng:**
181
- - **Brownfield onboarding** — sau `/spec-brownfield-feature` đã sinh frd.md, chạy `/spec-tsd` cho từng feature để có test coverage tracking từ ngày 1.
182
- - **Greenfield deferred** — feature đã có frd.md từ lâu nhưng tsd.md chưa được tạo.
183
- - **Ad-hoc rebuild** — tsd drift khỏi frd, regenerate fresh.
181
+ - **Brownfield onboarding** — sau `/spec-brownfield-feature` đã sinh frd.md, chạy `/spec-test-design` cho từng feature để có test coverage tracking từ ngày 1.
182
+ - **Greenfield deferred** — feature đã có frd.md từ lâu nhưng test-design.md chưa được tạo.
183
+ - **Ad-hoc rebuild** — test-design drift khỏi frd, regenerate fresh.
184
184
 
185
185
  **Khi nào KHÔNG dùng:**
186
- - Có integration cascade từ spec.md → frd → muốn cập nhật tsd theo changeset → dùng `/spec-test` (preserve ID stable).
186
+ - Có integration cascade từ spec.md → frd → muốn cập nhật test-design theo changeset → dùng `/spec-test` (preserve ID stable).
187
187
 
188
- **Derivation:** mechanical 1:1 từ frd — mỗi Flow → TS, mỗi US/AC → Functional TC, mỗi VR → ≥1 positive + 1+ negative Validation TC, mỗi FAC → Feature AC TC. Priority deterministic theo US Priority + FAC group. KHÔNG interview.
188
+ **Derivation:** mechanical 1:1 từ frd — mỗi Flow → TS, mỗi US/AC → Functional TC, mỗi VR → ≥1 positive + 1+ negative Validation TC, mỗi FAC → E2E TC, mỗi NFR → Non-functional TC, mỗi DM → Data & Migration TC. Priority deterministic theo US Priority + loại requirement. KHÔNG interview.
189
189
 
190
- **Cảnh báo overwrite:** nếu tsd.md đã tồn tại, skill hỏi confirm rõ ràng — regenerate sẽ reassign IDs từ 001 và làm vỡ test code references nếu có.
190
+ **Cảnh báo overwrite:** nếu test-design.md đã tồn tại, skill hỏi confirm rõ ràng — regenerate sẽ reassign IDs từ 001 và làm vỡ test code references nếu có.
191
191
 
192
192
  ---
193
193
 
@@ -203,7 +203,7 @@ Component Index và Feature Index **để placeholder** — sẽ được điề
203
203
  /spec-brownfield-feature [path]
204
204
 
205
205
 
206
- /spec-tsd [F-XXX] (tùy chọn — chạy cho mỗi feature để bootstrap tsd.md)
206
+ /spec-test-design [F-XXX] (tùy chọn — chạy cho mỗi feature để bootstrap test-design.md)
207
207
 
208
208
 
209
209
  (fill in NEEDS_CLARIFY items khi có thêm context)
@@ -225,7 +225,7 @@ Nhóm skill dọn dẹp / migrate artifacts hiện có sau khi template được
225
225
 
226
226
  ### `/artifact-audit [type]`
227
227
 
228
- Phát hiện **main artifact** lỗi thời so với template (xem `conventions.md` §7 Template Versioning). So `template_version` của artifact với `template_version` đọc thẳng từ template tại `.claude/templates/main/` — không manifest, không cache. **Chỉ main artifacts** (`prd`/`domain`/`sad`/`frd`/`fdd`/`tsd`/`crd`/`cdd`); integration artifacts ngoài scope.
228
+ Phát hiện **main artifact** lỗi thời so với template (xem `conventions.md` §7 Template Versioning). So `template_version` của artifact với `template_version` đọc thẳng từ template tại `.claude/templates/main/` — không manifest, không cache. **Chỉ main artifacts** (`prd`/`domain`/`sad`/`frd`/`fdd`/`test-design`/`crd`/`cdd`); integration artifacts ngoài scope.
229
229
 
230
230
  **Scope:** argument là 1 main type (`/artifact-audit frd`) hoặc list (`frd,crd`); không có arg → audit mọi main type. Type resolve theo **filename**.
231
231
 
@@ -260,7 +260,7 @@ Sau khi main artifacts đã sẵn sàng (từ greenfield hoặc brownfield), m
260
260
  | --- | --- | --- |
261
261
  | `/spec-new [requirement]` | `prd.md`, `domain.md`, frd(s), crd(s) | `.specs/integrations/{slug}/spec.md` |
262
262
  | `/spec-tech [number]` | `sad.md`, `domain.md`, cdd(s), fdd(s), `spec.md` | `.specs/integrations/{slug}/tech.md` |
263
- | `/spec-test [number]` | `spec.md`, frd(s), tsd(s), `tech.md` *(optional)* | `.specs/integrations/{slug}/test.md`, `feature/{F-XXX}/tsd.md` |
263
+ | `/spec-test [number]` | `spec.md`, frd(s), test-design(s), `tech.md` *(optional)* | `.specs/integrations/{slug}/test.md`, `feature/{F-XXX}/test-design.md` |
264
264
  | `/plan` | `spec.md`, `tech.md`, `domain.md` | `plan.md`, `todo.md` |
265
265
  | `/build` | `plan.md`, `todo.md` | *(source code)* |
266
266
  | `/review-integration` | `spec.md`, `tech.md`, `plan.md`, `todo.md`, *(source code)* | *(findings report)* |
@@ -308,21 +308,22 @@ Tạo `.specs/integrations/{slug}/test.md` cho một integration. Chạy bởi *
308
308
 
309
309
  **Luôn hiển thị danh sách tất cả integrations** trong `.specs/integrations/`, đánh dấu `✓` những cái đã có `test.md`. Nếu có argument → chọn luôn không cần hiển thị.
310
310
 
311
- **Gate check:** spec.md phải `approved` + `features:` non-empty. Integration có `features: []` (thuần component) → dừng vì component-level `tsd` không tồn tại trong kit này.
311
+ **Gate check:** spec.md phải `approved` + `features:` non-empty. Integration có `features: []` (thuần component) → dừng vì component-level `test-design` không tồn tại trong kit này.
312
312
 
313
- Context load: `spec.md` + `frd.md` (cho mỗi feature — source của TC) + `tsd.md` (cho mỗi feature nếu tồn tại, để diff và assign next ID) + `tech.md` *(optional, hint env / data set / NFR threshold)*.
313
+ Context load: `spec.md` + `frd.md` (cho mỗi feature — source của TC) + `test-design.md` (cho mỗi feature nếu tồn tại, để diff và assign next ID) + `tech.md` *(optional, hint env / data set / NFR threshold)*.
314
314
 
315
315
  **KHÔNG interview** — agent **mechanical derive** TC từ frd.md:
316
316
  - mỗi Flow → 1 Test Scenario (`TS-F{NNN}-{seq}`)
317
317
  - mỗi US AC → 1 Functional TC
318
318
  - mỗi VR → 1 positive + 1+ negative Validation TC
319
- - mỗi FAC → 1 Feature AC TC (theo nhóm e2e / consistency / NFR / data & migration)
319
+ - mỗi FAC → 1 E2E TC (Type e2e / consistency)
320
+ - mỗi NFR → 1 Non-functional TC; mỗi DM → 1 Data & Migration TC
320
321
 
321
- Priority deterministic: US Priority Must/Should/Could → P0/P1/P2 (TC cover US/AC); VR → inherit max priority của Refs; FAC e2e/security/data → P0, consistency/perf/a11y → P1.
322
+ Priority deterministic: US Priority Must/Should/Could → P0/P1/P2 (TC cover US/AC); VR → inherit max priority của Refs; FAC e2e + NFR security + DM → P0, FAC consistency + NFR perf/a11y → P1.
322
323
 
323
- **Cascade Proposals** đề xuất delta cho mỗi `feature/{F-XXX}/tsd.md` qua Changes blocks với markers `[NEW]/[MODIFY {field}]/[REMOVE]`. Feature no-delta → **bỏ block hoàn toàn**, ghi `no-op` trong Cascade Summary.
324
+ **Cascade Proposals** đề xuất delta cho mỗi `feature/{F-XXX}/test-design.md` qua Changes blocks với markers `[NEW]/[MODIFY {field}]/[REMOVE]`. Feature no-delta → **bỏ block hoàn toàn**, ghi `no-op` trong Cascade Summary.
324
325
 
325
- QC review: override priority defaults, fill placeholders (env / data / OOS / strategy), add extra edge cases ngoài AC/VR nếu thấy cần. Sau confirm → auto-cascade ghi tsd.md.
326
+ QC review: override priority defaults, fill placeholders (env / data / OOS / strategy), add extra edge cases ngoài AC/VR nếu thấy cần. Sau confirm → auto-cascade ghi test-design.md.
326
327
 
327
328
  ---
328
329
 
@@ -410,7 +411,7 @@ Di chuyển integration đã hoàn thành hoặc không còn active từ `.specs
410
411
  ▼ ▼
411
412
  /spec-tech /spec-test
412
413
  (review + cascade (review + cascade
413
- → cdd / fdd / sad) → tsd)
414
+ → cdd / fdd / sad) → test-design)
414
415
  │ │
415
416
  └───────────┬───────────┘
416
417
  │ (tech.md approved — /plan KHÔNG đợi test.md)
@@ -12,15 +12,15 @@ referenced_by:
12
12
 
13
13
  ## Context
14
14
 
15
- <!-- Tóm tắt ngắn các thông tin quan trọng từ context đã load (spec.md, tech.md, frd.md, current tsd.md của các feature touched), để file self-contained. -->
15
+ <!-- Tóm tắt ngắn các thông tin quan trọng từ context đã load (spec.md, tech.md, frd.md, current test-design.md của các feature touched), để file self-contained. -->
16
16
 
17
17
  ## Test Strategy
18
18
 
19
19
  <!--
20
20
  Strategy cho integration này — KHÔNG lặp lại Strategy chung của feature.
21
21
  Chỉ ghi delta hoặc nhấn mạnh phần đặc thù integration:
22
- - Loại test ưu tiên (functional / validation / FAC / cross-story consistency / NFR).
23
- - Environments / data set / fixture đặc thù.
22
+ - Loại test ưu tiên (functional / validation / FAC e2e: journey / consistency / integrity / NFR / data & migration).
23
+ - Yêu cầu data đặc thù integration (shape) — nguồn/refresh/env assignment thuộc execution layer, KHÔNG ở đây.
24
24
  - Risk areas (vd: data migration cần backfill verify, integration đụng auth flow → security regression).
25
25
  -->
26
26
 
@@ -28,46 +28,40 @@ Chỉ ghi delta hoặc nhấn mạnh phần đặc thù integration:
28
28
 
29
29
  - {bullet ngắn}
30
30
 
31
- ### Environments
32
-
33
- | Env | Mục đích | Data set | Ghi chú |
34
- | --- | --- | --- | --- |
35
- | {dev / staging / prod-like} | {functional / E2E / load} | {seed / anonymized prod} | ... |
36
-
37
31
  ## Changes
38
32
 
39
33
  <!--
40
- test.md = changeset patch áp lên feature tsd.md(s). Mỗi block dưới đây tương ứng 1 feature bị touched.
34
+ test.md = changeset patch áp lên feature test-design.md(s). Mỗi block dưới đây tương ứng 1 feature bị touched.
41
35
  Lặp block cho mỗi feature trong `features:` frontmatter mà có delta TC.
42
36
 
43
37
  **Khi nào BỎ block của 1 feature:**
44
- - Diff giữa frd hiện tại và tsd.md hiện tại của feature đó = empty (frd không thêm/đổi item nào mà tsd chưa cover).
38
+ - Diff giữa frd hiện tại và test-design.md hiện tại của feature đó = empty (frd không thêm/đổi item nào mà test-design chưa cover).
45
39
  - Bỏ block hoàn toàn, ghi `no-op` cho feature đó trong Cascade Summary để minh bạch.
46
40
 
47
41
  **Operation:**
48
- - `create` — feature/{F-XXX}/tsd.md chưa tồn tại. Nội dung đầy đủ theo template gốc, mọi TS/TC implicit [NEW] (không cần marker).
49
- - `update` — feature/{F-XXX}/tsd.md đã tồn tại. Chỉ liệt kê TS/TC bị ảnh hưởng. Mỗi item có marker:
50
- - `[NEW]` — TS/TC chưa có trong tsd hiện tại
42
+ - `create` — feature/{F-XXX}/test-design.md chưa tồn tại. Nội dung đầy đủ theo template gốc, mọi TS/TC implicit [NEW] (không cần marker).
43
+ - `update` — feature/{F-XXX}/test-design.md đã tồn tại. Chỉ liệt kê TS/TC bị ảnh hưởng. Mỗi item có marker:
44
+ - `[NEW]` — TS/TC chưa có trong test-design hiện tại
51
45
  - `[MODIFY {field}]` — TS/TC đã có, đang đổi field cụ thể (ví dụ `[MODIFY steps]`, `[MODIFY expected]`, `[MODIFY priority]`, `[MODIFY covers]`)
52
46
  - `[REMOVE]` — TS/TC đã có, sẽ bị xóa (ID retire — không tái sử dụng)
53
47
 
54
- **Format reference:** dùng đúng format của template gốc — KHÔNG duplicate skeleton ở đây. `templates/main/feature/tsd-template.md` là single source of truth cho format.
48
+ **Format reference:** dùng đúng format của template gốc — KHÔNG duplicate skeleton ở đây. `templates/main/feature/test-design-template.md` là single source of truth cho format.
55
49
 
56
- **ID assignment:** agent đọc tsd.md hiện tại của feature để xác định next ID:
50
+ **ID assignment:** agent đọc test-design.md hiện tại của feature để xác định next ID:
57
51
  - `TS-F{NNN}-{seq}` cho Test Scenarios
58
- - `TC-F{NNN}-{seq}` cho Test Cases (Functional, Validation, Feature AC dùng chung sequence — không reset theo loại)
52
+ - `TC-F{NNN}-{seq}` cho Test Cases (Functional, Validation, E2E dùng chung sequence — không reset theo loại)
59
53
  - ID **stable** — không tái sử dụng khi [REMOVE], không renumber khi [MODIFY].
60
54
 
61
- **Auto-cascade:** sau khi human approve test.md, agent tự apply tất cả Changes blocks vào feature tsd.md. Integration test.md được giữ như PR record bất biến.
55
+ **Auto-cascade:** sau khi human approve test.md, agent tự apply tất cả Changes blocks vào feature test-design.md. Integration test.md được giữ như PR record bất biến.
62
56
  -->
63
57
 
64
- ### feature/{F-XXX}-{feature-slug}/tsd.md *(lặp block cho mỗi feature trong `features:` mà có delta TC; bỏ block nếu no-delta)*
58
+ ### feature/{F-XXX}-{feature-slug}/test-design.md *(lặp block cho mỗi feature trong `features:` mà có delta TC; bỏ block nếu no-delta)*
65
59
 
66
60
  **Operation:** create | update
67
- **Format reference:** [tsd-template.md](../../templates/main/feature/tsd-template.md)
61
+ **Format reference:** [test-design-template.md](../../templates/main/feature/test-design-template.md)
68
62
 
69
63
  <!--
70
- operation=create → nội dung đầy đủ theo tsd-template.md (Overview, Test Strategy, Test Scenarios, Functional TCs, Validation TCs, Feature AC TCs, Test Data, Traceability Matrix, Out of Scope, Dependencies).
64
+ operation=create → nội dung đầy đủ theo test-design-template.md (Overview, Test Strategy, Test Scenarios, Functional TCs, Validation TCs, E2E TCs, Non-Functional TCs, Data & Migration TCs, Test Data Requirements, Traceability Matrix, Out of Scope, Dependencies).
71
65
  operation=update → chỉ liệt kê TS/TC bị ảnh hưởng, mỗi item có marker, và **bắt buộc update Traceability Matrix** rows tương ứng.
72
66
 
73
67
  Ví dụ operation=update:
@@ -121,13 +115,13 @@ Ví dụ operation=update:
121
115
  | `TC-F001-030` | `VR-F001-008` | `refund_reason` | `"Customer changed mind"` | accept | positive | NEW |
122
116
  | `TC-F001-031` | `VR-F001-008` | `refund_reason` | `"abc"` | reject — min length | negative | NEW |
123
117
 
124
- #### Feature AC Test Cases
118
+ #### E2E Test Cases
125
119
 
126
120
  ##### TC-F001-040 [NEW]: E2E checkout + refund
127
121
 
128
122
  | Field | Value |
129
123
  | --- | --- |
130
- | **Type** | Feature AC e2e |
124
+ | **Type** | E2Ejourney |
131
125
  | **Priority** | P0 |
132
126
  | **Covers** | `FAC-F001-004` |
133
127
  | **Spans** | `US-F001-001`, `US-F001-005` |
@@ -135,6 +129,32 @@ Ví dụ operation=update:
135
129
  **Steps:** ...
136
130
  **Expected:** ...
137
131
 
132
+ #### Non-Functional Test Cases
133
+
134
+ ##### TC-F001-045 [NEW]: Refund endpoint chịu tải
135
+
136
+ | Field | Value |
137
+ | --- | --- |
138
+ | **Type** | Non-functional — performance |
139
+ | **Priority** | P1 |
140
+ | **Covers** | `NFR-F001-002` |
141
+
142
+ **Steps:** ...
143
+ **Expected:** ...
144
+
145
+ #### Data & Migration Test Cases
146
+
147
+ ##### TC-F001-048 [NEW]: Backfill refund_reason cho order cũ
148
+
149
+ | Field | Value |
150
+ | --- | --- |
151
+ | **Type** | Data migration |
152
+ | **Priority** | P0 |
153
+ | **Covers** | `DM-F001-001` |
154
+
155
+ **Steps:** ...
156
+ **Expected:** ...
157
+
138
158
  #### Traceability Matrix
139
159
 
140
160
  Bổ sung row cho mọi item mới + cập nhật row cho item bị [MODIFY]. KHÔNG xóa row của [REMOVE] — đánh dấu retire.
@@ -145,6 +165,8 @@ Bổ sung row cho mọi item mới + cập nhật row cho item bị [MODIFY]. KH
145
165
  | `AC-F001-012` | Story AC | `TC-F001-022` | ✅ | NEW |
146
166
  | `VR-F001-008` | VR | `TC-F001-030`, `TC-F001-031` | ✅ | NEW |
147
167
  | `FAC-F001-004` | Feature AC | `TC-F001-040` | ✅ | NEW |
168
+ | `NFR-F001-002` | NFR | `TC-F001-045` | ✅ | NEW |
169
+ | `DM-F001-001` | Data & Migration | `TC-F001-048` | ✅ | NEW |
148
170
  | Flow 3 | Flow | `TS-F001-003` | ✅ | NEW |
149
171
  -->
150
172
 
@@ -162,5 +184,5 @@ Bổ sung row cho mọi item mới + cập nhật row cho item bị [MODIFY]. KH
162
184
 
163
185
  | Artifact | Operation | Summary |
164
186
  | --- | --- | --- |
165
- | `feature/F-XXX-{slug}/tsd.md` | create / update | {ngắn: +N TS, +M TC, modify TC-F001-008, remove TC-F001-015} |
166
- | `feature/F-YYY-{slug}/tsd.md` | no-op | frd không đổi, tsd hiện tại đã cover full |
187
+ | `feature/F-XXX-{slug}/test-design.md` | create / update | {ngắn: +N TS, +M TC, modify TC-F001-008, remove TC-F001-015} |
188
+ | `feature/F-YYY-{slug}/test-design.md` | no-op | frd không đổi, test-design hiện tại đã cover full |
@@ -4,10 +4,15 @@ type: frd
4
4
  status: draft
5
5
  owner: "{BA}"
6
6
  feature_id: "{Feature ID từ PRD Feature Index}"
7
- template_version: 1
7
+ template_version: 2
8
8
  migrations:
9
9
  - to: 1
10
10
  note: "baseline"
11
+ - to: 2
12
+ note: "Tách FAC theo type/execution-mode: FAC rescope còn end-to-end (journey + consistency + integrity); tách entries loại NFR → section 'Non-Functional Requirements' và loại data/migration → section 'Data & Migration', cả hai required-emptyable (heading luôn hiện, để trống nếu không có). NFR-F* tham chiếu NFR-* của PRD nếu có thể. Test case downstream giữ prefix TC-F*."
13
+ add: ["Non-Functional Requirements", "Data & Migration"]
14
+ update:
15
+ - { section: "Feature Acceptance Criteria", change: "rescope còn end-to-end (e2e liên story + cross-story consistency + integrity); tách entries loại NFR → section 'Non-Functional Requirements' (required-emptyable), loại data/migration → section 'Data & Migration' (required-emptyable); relocate tương tác, e2e/consistency giữ nguyên" }
11
16
  referenced_by:
12
17
  - conventions.md > 3. Main Artifacts > 3.3 Feature level > frd.md > Cấu trúc
13
18
  - skills/spec-frd/SKILL.md > Process > Bước 5: Write — sinh draft
@@ -55,25 +60,55 @@ flowchart TD
55
60
 
56
61
  ## Feature Acceptance Criteria
57
62
 
58
- Criteria áp dụng cho **toàn bộ feature** phần Story AC không cover được. Mọi Feature AC phải test được pass/fail.
63
+ Criteria **end-to-end** áp cho toàn feature Story AC lẻ không cover được — verify sự **kết nối giữa các phần** (emergent), không phải behavior từng story. Mọi Feature AC phải test được pass/fail.
59
64
 
60
- Thường gồm 4 nhóm:
61
- - **End-to-end liên story** — full happy path đi qua nhiều story.
62
- - **Cross-story consistency** — UI/behavior đồng nhất giữa các màn trong feature.
63
- - **Non-functional** — performance, accessibility, browser support, i18n, security.
64
- - **Data & migration** — backfill, schema migration, không mất data cũ.
65
+ Gồm 3 shape (đều functional, scope rộng — trục phân chia + lý do xem `terms/001-frd-fac-pillars.md`; nền tảng type/scope xem `terms/002-functional-test-vs-e2e-test.md`):
66
+ - **Journey (liên story)** — full happy path đi *tuần tự* qua nhiều story trong 1 session; verify state persist + không đứt giữa các bước.
67
+ - **Consistency (đa màn)** — UI/behavior đồng nhất khi *so* nhiều màn trong feature với nhau.
68
+ - **Integrity (bất biến liên story)** — business invariant phải đúng khi *kết hợp* nhiều story, **không nhất thiết theo trình tự** (vd: xóa account → cascade xóa mọi order ở mọi module; tổng/đối soát khớp sau nhiều thao tác). Verify *trạng thái nhất quán cuối cùng*, không phải hành trình tuần tự — đây là nhà cho cross-story functional rule mà journey/consistency không ôm.
65
69
 
70
+ > NFR (performance, a11y, security, browser, i18n) và Data & Migration **KHÔNG** thuộc đây — chúng có section riêng bên dưới (khác type / execution-mode).
66
71
  > Out of scope: release readiness (runbook/rollout/legal sign-off) và success metric/KPI post-release — đặt ở artifact khác (`tech.md`, `sad.md`, hoặc PMO checklist).
67
72
 
68
73
  Feature AC ID format: `FAC-F{NNN}-{seq}` — counter **độc lập** với Story AC (`AC-F{NNN}-{seq}`). ID **stable** — không tái sử dụng seq khi xóa, không renumber.
69
74
 
70
- Format: **Given/When/Then bắt buộc** — kể cả NFR / consistency. **Then phải đo được**: ngưỡng cụ thể HOẶC danh sách item so sánh.
75
+ Format: **Given/When/Then bắt buộc** — kể cả consistency. **Then phải đo được**: ngưỡng cụ thể HOẶC danh sách item so sánh.
71
76
 
72
77
  - `FAC-{F_ID}-001`
73
78
  - **Given** {precondition đo được}
74
79
  - **When** {action}
75
80
  - **Then** {outcome có threshold hoặc danh sách cụ thể, không vague}
76
81
 
82
+ ## Non-Functional Requirements
83
+
84
+ <!-- Required-emptyable: GIỮ heading; để trống (không bullet) nếu feature không có NFR riêng ngoài bar chung của PRD. -->
85
+
86
+ NFR áp cho feature — **non-functional type** (performance, accessibility, security, browser support, i18n). Khác Feature AC ở chỗ verify *chất lượng dưới điều kiện*, không phải *làm đúng việc*.
87
+
88
+ > **Security — phân biệt rõ type:** access-control / authz rules ("role X không được thấy/làm Y") là **functional** → đặt ở Story AC hoặc Verification Rules, KHÔNG vào đây. Chỉ phần **non-functional** của security (pentest, vulnerability scan, security posture / hardening — verify bằng scanner, không phải walk UI) mới là NFR.
89
+
90
+ Quan hệ với PRD: mỗi NFR **tham chiếu `NFR-*` của PRD nếu có thể** (refine/siết bar chung cho feature này); nếu là yêu cầu **đặc thù-feature** mà PRD không có → đứng độc lập (không ref).
91
+
92
+ NFR ID format: `NFR-F{NNN}-{seq}` — counter độc lập. ID **stable** — không tái sử dụng seq khi xóa, không renumber. Format **Given/When/Then bắt buộc**, **Then đo được** (ngưỡng cụ thể).
93
+
94
+ - `NFR-{F_ID}-001` *(refines `NFR-P01` — nếu có)*
95
+ - **Given** {điều kiện đo được — vd: 100 RPS sustained 5 phút}
96
+ - **When** {action}
97
+ - **Then** {ngưỡng cụ thể — vd: p95 ≤ 500ms, error rate ≤ 0.1%}
98
+
99
+ ## Data & Migration
100
+
101
+ <!-- Required-emptyable: GIỮ heading; để trống (không bullet) nếu feature không đụng migration / backfill data cũ. -->
102
+
103
+ Yêu cầu về **dữ liệu cũ qua nâng cấp** — backfill, schema migration, không mất/hỏng data hiện hữu. Functional-type nhưng execution-mode riêng (chạy migration trên dataset, không phải UI flow).
104
+
105
+ DM ID format: `DM-F{NNN}-{seq}` — counter độc lập. ID **stable** — không tái sử dụng seq khi xóa, không renumber. Format **Given/When/Then bắt buộc**, **Then đo được** (đếm bản ghi / so khớp cụ thể).
106
+
107
+ - `DM-{F_ID}-001`
108
+ - **Given** {dataset cũ đo được — vd: 10.000 bản ghi địa chỉ format cũ}
109
+ - **When** {chạy migration}
110
+ - **Then** {kết quả đo được — vd: 10.000/10.000 đọc được, 0 bản ghi null, count khớp trước/sau}
111
+
77
112
  ## User Stories
78
113
 
79
114
  US ID format: `US-F{NNN}-{seq}` — đánh số tăng dần toàn feature. ID **stable** — không tái sử dụng seq khi xóa, không renumber.