spec-lite 1.5.1 → 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.
@@ -1,241 +0,0 @@
1
- ---
2
- name: spec-tsd
3
- description: Tạo tsd.md (Test Spec 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ó tsd.md.
4
- ---
5
-
6
- # spec-tsd
7
-
8
- ## Overview
9
-
10
- Tạo `.specs/main/feature/{F-XXX}-{slug}/tsd.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`/`tsd`) → 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 tsd.md để có test coverage tracking ngay từ đầu.
17
- - **Greenfield deferred** — feature có frd.md từ lâu nhưng tsd.md chưa được tạo (vd: test design bị defer).
18
- - **Ad-hoc rebuild** — tsd.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 tsd hiện tại → dùng `/spec-test` (changeset patch giữ ID stable)
23
- - Chỉ muốn sửa vài TC → edit `tsd.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-tsd` **regenerate IDs từ 001** mỗi lần chạy. Nếu tsd.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
- - **tsd.md chưa tồn tại** → an toàn, không có reference, regenerate fresh.
32
- - **tsd.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 tsd:
49
-
50
- ```
51
- Features có frd.md:
52
-
53
- [1] F-001 — auth spec✓ tsd✓
54
- [2] F-002 — checkout spec✓ tsd—
55
- [3] F-003 — refund spec✓ tsd— (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 tsd.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-tsd` cần frd làm input.
71
-
72
- **Check 2 — tsd.md đã tồn tại:**
73
-
74
- Nếu `.specs/main/feature/{F-XXX}-{slug}/tsd.md` đã tồn tại:
75
-
76
- > ⚠ `tsd.md` đã tồn tại cho feature **{F-XXX} — {slug}**.
77
- >
78
- > `/spec-tsd` 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 tsd.md cũ thành `tsd.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 tsd)
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
- - tsd.md hiện tại: {chưa có / sẽ overwrite — backup tại tsd.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 / Feature AC.
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 | tsd 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}` | 1 Feature AC TC |
129
-
130
- Detail dịch G/W/T → Preconditions/Steps/Expected, infer negative VR branches từ rule text — xem `/spec-test` Bước 3.2.
131
-
132
- #### 4.3 Priority defaults
133
-
134
- | Source | Priority |
135
- | --- | --- |
136
- | TC cover US Must | P0 |
137
- | TC cover US Should | P1 |
138
- | TC cover US Could | P2 |
139
- | TC cover VR | inherit max priority của Refs (P1 default nếu Refs trống) |
140
- | TC cover FAC e2e | P0 |
141
- | TC cover FAC consistency | P1 |
142
- | TC cover FAC NFR security/data | P0 |
143
- | TC cover FAC NFR perf/a11y/i18n/browser | P1 |
144
- | TC cover FAC data & migration | P0 |
145
-
146
- #### 4.4 Traceability Matrix
147
-
148
- Row per frd item — Flow / US / Story AC / VR / FAC. Mọi item phải có cover ✅. Item không thể derive → ❌ + ghi lý do ở Gaps section.
149
-
150
- #### 4.5 Placeholders cần QC fill
151
-
152
- Agent **không suy đoán**:
153
-
154
- | Field | Placeholder |
155
- | --- | --- |
156
- | Environments table | Row mặc định `dev / staging / prod-like` với data set `TBD`, mục đích `TBD` |
157
- | Test Data table | Row `{TBD — fixture}` cho mỗi dataset thấy cần |
158
- | Out of Scope | Để trống với note `<!-- QC fill -->` |
159
- | Test Strategy > Approach | Bullet generic theo template gốc |
160
- | Overview | 2-3 câu mô tả feature scope từ frd Overview |
161
-
162
- #### 4.6 Dependencies section
163
-
164
- - **FRD reference**: path tới `frd.md` của feature này
165
- - **Components Used**: copy từ `frd.md > Components Used`. Nếu fdd.md tồn tại → cross-reference C-XXX để đảm bảo đúng.
166
-
167
- ---
168
-
169
- ### Bước 5: Review — xác nhận với QC
170
-
171
- Hiển thị draft đầy đủ — chưa ghi file.
172
-
173
- > Draft tsd.md trên đã đúng chưa? Check:
174
- >
175
- > 1. **Coverage** — Traceability Matrix có đủ row cho mỗi Flow / US / AC / VR / FAC trong frd?
176
- > 2. **Priority** — defaults theo bảng 4.3, có TC nào cần override?
177
- > 3. **Placeholders** — fill Environments / Test Data / Out of Scope / Strategy Approach.
178
- > 4. **Extra edge cases** — ngoài AC/VR có scenario QC muốn thêm?
179
- >
180
- > Confirm để ghi file. Reject để revise.
181
-
182
- ---
183
-
184
- ### Bước 6: Save
185
-
186
- Ghi `.specs/main/feature/{F-XXX}-{slug}/tsd.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ừ `tsd-template.md` (xem `conventions.md` §7).
187
-
188
- Nếu overwrite — file backup `tsd.md.bak.{timestamp}` đã tạo ở Bước 2.
189
-
190
- **Change History:** Append entry vào section `## Change History` cuối tsd.md (theo `conventions.md` §5.5):
191
-
192
- ```markdown
193
- ### {YYYY-MM-DD} — manual — create
194
-
195
- - **All sections**: initial scaffold qua /spec-tsd (mechanical derive từ frd.md — N TS, M Functional TC, P Validation TC, Q Feature AC TC)
196
- ```
197
-
198
- Nếu overwrite tsd.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 tsd.md (backup tại tsd.md.bak.{timestamp}) — IDs regenerated từ 001`.
199
-
200
- Thông báo kết quả:
201
-
202
- ```
203
- ✓ .specs/main/feature/{F-XXX}-{slug}/tsd.md đã được tạo (status: draft)
204
- Coverage: N Flows → N TS, M US/AC → M Functional TC, P VR → ~2P Validation TC, Q FAC → Q Feature AC TC
205
- {nếu overwrite: backup tại tsd.md.bak.{timestamp}}
206
-
207
- Bước tiếp theo:
208
- - QC: fill remaining placeholders (Environments, Test Data, Out of Scope, Strategy)
209
- - Đổi status: draft → approved khi sẵn sàng
210
- - Sau này: nếu frd thay đổi → dùng /spec-test qua integration changeset để giữ ID stable
211
- ```
212
-
213
- ---
214
-
215
- ## Common Rationalizations
216
-
217
- | Rationalization | Reality |
218
- | --- | --- |
219
- | "Có frd rồi, viết tsd sau cũng được" | Test coverage không tracked = không biết feature đóng được chưa. tsd làm song song với frd, không sau. |
220
- | "Rebuild tsd 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`. |
221
- | "Brownfield không cần tsd, đã có test code" | Test code là HOW. tsd là WHAT — declarative TC list để track coverage vs frd. Hai layer khác nhau. |
222
-
223
- ## Red Flags
224
-
225
- - Traceability Matrix có ❌ mà không có Gaps section giải thích
226
- - Priority hàng loạt P1 — chưa override theo defaults
227
- - Test Strategy / Test Data toàn `TBD` sau khi QC review xong
228
- - Overwrite tsd.md hiện có mà không cảnh báo về ID break
229
-
230
- ## Verification
231
-
232
- Trước khi ghi file:
233
-
234
- - [ ] Mỗi Flow trong frd có 1 TS
235
- - [ ] Mỗi US AC có TC Functional cover
236
- - [ ] Mỗi VR có ≥1 positive + ≥1 negative TC
237
- - [ ] Mỗi FAC có TC Feature AC cover
238
- - [ ] Priority deterministic theo bảng 4.3
239
- - [ ] Nếu overwrite: tsd.md.bak.{timestamp} đã được tạo
240
- - [ ] QC đã confirm draft
241
- - [ ] Frontmatter có `template_version` copy từ `tsd-template.md`