spec-lite 1.4.6 → 1.5.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 (34) hide show
  1. package/README.md +8 -4
  2. package/bin/cli.js +22 -1
  3. package/package.json +1 -1
  4. package/skills/ado-config/SKILL.md +52 -9
  5. package/skills/ado-create/SKILL.md +6 -0
  6. package/skills/artifact-audit/SKILL.md +189 -0
  7. package/skills/artifact-migrate/SKILL.md +156 -0
  8. package/skills/plan/SKILL.md +3 -2
  9. package/skills/spec-brownfield-component/SKILL.md +3 -0
  10. package/skills/spec-brownfield-feature/SKILL.md +3 -0
  11. package/skills/spec-brownfield-init/SKILL.md +2 -1
  12. package/skills/spec-frd/SKILL.md +8 -3
  13. package/skills/spec-new/SKILL.md +3 -2
  14. package/skills/spec-prd/SKILL.md +3 -1
  15. package/skills/spec-sad/SKILL.md +2 -2
  16. package/skills/spec-tech/SKILL.md +3 -2
  17. package/skills/spec-test/SKILL.md +3 -2
  18. package/skills/spec-tsd/SKILL.md +2 -1
  19. package/skills-overview.md +27 -23
  20. package/templates/integrations/plan-template.md +4 -0
  21. package/templates/integrations/spec-template.md +4 -0
  22. package/templates/integrations/tech-template.md +4 -0
  23. package/templates/integrations/techdebt-template.md +4 -0
  24. package/templates/integrations/test-template.md +4 -0
  25. package/templates/integrations/todo-template.md +4 -0
  26. package/templates/main/component/cdd-template.md +4 -0
  27. package/templates/main/component/crd-template.md +4 -0
  28. package/templates/main/domain-template.md +4 -0
  29. package/templates/main/feature/fdd-template.md +4 -0
  30. package/templates/main/feature/frd-template.md +12 -0
  31. package/templates/main/feature/tsd-template.md +4 -0
  32. package/templates/main/prd-template.md +4 -0
  33. package/templates/main/sad-template.md +4 -0
  34. package/skills/spec-frd-update/SKILL.md +0 -398
package/README.md CHANGED
@@ -151,10 +151,13 @@ Sau khi có findings, hỏi user severity tier muốn xử lý (Critical / Criti
151
151
 
152
152
  Skill ad-hoc dùng khi template đã được update và artifacts hiện có cần migrate. Không phải pipeline — chạy khi cần.
153
153
 
154
- #### `/spec-frd-update`
155
- Migrate `feature/*/frd.md` hiện có sang format mới nhất của [frd-template.md](.claude/templates/main/feature/frd-template.md). Detect 8 migration vectors: fix Mermaid syntax `[{...}]` → `["..."]`, rename `Feature-level AC` → `Feature AC` với 4 nhóm chuẩn, rename `AC-F{NNN}-*` (Feature AC) → `FAC-F{NNN}-*` + cascade ID remap qua `fdd.md`/`tsd.md`/`integrations/*/{spec,tech,test}.md`, insert US/AC stability notes + Verification Rules, derive Mermaid User Flows từ User Stories, v.v.
154
+ Mỗi template mang `template_version` (số nguyên) trong frontmatter; artifact copy nó lúc được tạo. Khi template đổi structure, artifact cũ thành "lỗi thời" — hai skill dưới phát hiện và migrate. Quy ước đầy đủ: [conventions.md](conventions.md) §7.
156
155
 
157
- Pre-flight yêu cầu git working tree clean — rollback dùng `git checkout -- {file}`, **không** tạo file `.bak`. V4 (FAC remap), V6 (Verification Rules propose), V8 (User Flows propose) đều có confirm step trước khi ghi. No-op safe: nếu mọi FRD đã clean, skill dừng mà không ghi gì.
156
+ #### `/artifact-audit [type]`
157
+ Phát hiện artifact lỗi thời. So `template_version` của artifact với version đọc thẳng từ template. Versioned: `==` → up-to-date; `!=` → out-dated `(vX → vY)` → migrate. Legacy thiếu version → presence-check (đủ required `##` headings + không còn section đã `migrations.remove`): conform → stamp version; lệch → out-dated. Chỉ phát hiện + stamp, KHÔNG migrate. Scope theo arg (1 type / list) hoặc toàn bộ.
158
+
159
+ #### `/artifact-migrate [path]`
160
+ Migrate artifact lỗi thời lên structure mới (generic mọi type). Tự chạy `/artifact-audit` (classify-only) để phát hiện, rồi áp delta từ block `migrations` của template: **add** required section thiếu (skeleton từ template; nội dung mới → interview hoặc `NEEDS_CLARIFY`, không bịa), **remove** section đã `migrations.remove` (có confirm; giữ content tác giả khác), **update** section đổi format (giữ section + ngữ nghĩa, vd ASCII → Mermaid; show cũ + đề xuất mới, không bịa). Rename = remove+add → hỏi carry-over. Single-artifact, không cascade. Pre-flight git clean — rollback dùng git, không `.bak`. No-op nếu đã up-to-date.
158
161
 
159
162
  ---
160
163
 
@@ -169,7 +172,8 @@ Pre-flight yêu cầu git working tree clean — rollback dùng `git checkout --
169
172
  | `/spec-brownfield-component` | `.specs/main/component/{C-XXX}-*/crd.md + cdd.md` |
170
173
  | `/spec-brownfield-feature` | `.specs/main/feature/{F-XXX}-*/frd.md + fdd.md` |
171
174
  | `/spec-tsd` | `.specs/main/feature/{F-XXX}-*/tsd.md` |
172
- | `/spec-frd-update` | *(modify in-place `feature/*/frd.md` + cascade refs)* |
175
+ | `/artifact-audit` | *(báo cáo out-dated; + stamp `template_version` cho artifact legacy conform)* |
176
+ | `/artifact-migrate` | *(modify in-place artifact lỗi thời lên structure mới + set `template_version`)* |
173
177
  | `/spec-new` | `.specs/integrations/{slug}/spec.md` |
174
178
  | `/spec-tech` | `.specs/integrations/{slug}/tech.md` |
175
179
  | `/spec-test` | `.specs/integrations/{slug}/test.md`, cascade: `feature/{F-XXX}/tsd.md` |
package/bin/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { cpSync, mkdirSync, existsSync } from 'fs'
2
+ import { cpSync, mkdirSync, existsSync, readFileSync, writeFileSync } from 'fs'
3
3
  import { join, dirname } from 'path'
4
4
  import { fileURLToPath } from 'url'
5
5
 
@@ -11,6 +11,8 @@ if (command === 'install') {
11
11
  const pkgRoot = join(__dirname, '..')
12
12
  const claudeDir = join(cwd, '.claude')
13
13
 
14
+ const pkg = JSON.parse(readFileSync(join(pkgRoot, 'package.json'), 'utf8'))
15
+
14
16
  mkdirSync(claudeDir, { recursive: true })
15
17
 
16
18
  // Copy skills → .claude/skills/
@@ -28,6 +30,25 @@ if (command === 'install') {
28
30
  // Copy references → .claude/references/
29
31
  cpSync(join(pkgRoot, 'references'), join(claudeDir, 'references'), { recursive: true })
30
32
  console.log('✓ references → .claude/references/')
33
+
34
+ // Write install metadata → .claude/spec-lite.json
35
+ const metaPath = join(claudeDir, 'spec-lite.json')
36
+ const prev = existsSync(metaPath)
37
+ ? JSON.parse(readFileSync(metaPath, 'utf8'))
38
+ : null
39
+ const now = new Date().toISOString()
40
+ const meta = {
41
+ name: pkg.name,
42
+ version: pkg.version,
43
+ installedAt: prev?.installedAt ?? now,
44
+ updatedAt: now,
45
+ contents: ['skills', 'templates', 'references'],
46
+ }
47
+ writeFileSync(metaPath, JSON.stringify(meta, null, 2) + '\n')
48
+ const action = prev
49
+ ? `updated ${prev.version} → ${pkg.version}`
50
+ : `installed ${pkg.version}`
51
+ console.log(`✓ spec-lite.json → .claude/spec-lite.json (${action})`)
31
52
  } else {
32
53
  console.log('Usage: npx spec-lite install')
33
54
  process.exit(1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-lite",
3
- "version": "1.4.6",
3
+ "version": "1.5.0",
4
4
  "description": "Spec-driven development kit for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {
@@ -53,16 +53,19 @@ options:
53
53
  description: "Cập nhật danh sách PE / SE / DE"
54
54
  - label: "Epic ticket"
55
55
  description: "Tạo mới hoặc thay Epic ticket đang được lưu"
56
+ - label: "Area / Iteration path"
57
+ description: "Cập nhật area_path và iteration_path mặc định cho ticket"
56
58
  - label: "Môi trường"
57
59
  description: "Cập nhật danh sách environments (dev / stag / prod)"
58
60
  ```
59
61
 
60
62
  Tuỳ theo lựa chọn:
61
- - **"Toàn bộ từ đầu"** → chạy Bước 2 → 3 → 4 → 5 → 6 → 7
62
- - **"Thông tin project"** → chỉ chạy Bước 2, bỏ qua Bước 3, 4, 5, nhảy thẳng đến Bước 67 (giữ nguyên `team`, `epic`, `environments` từ file cũ)
63
- - **"Team members"** → chỉ chạy Bước 3, bỏ qua Bước 2, 4, 5, nhảy thẳng đến Bước 67 (giữ nguyên `organization/project`, `epic`, `environments` từ file cũ)
64
- - **"Epic ticket"** → chỉ chạy Bước 4, bỏ qua Bước 2, 3, 5, nhảy thẳng đến Bước 67 (giữ nguyên `organization/project`, `team`, `environments` từ file cũ)
65
- - **"Môi trường"** → chỉ chạy Bước 5, bỏ qua Bước 2, 3, 4, nhảy thẳng đến Bước 67 (giữ nguyên tất cả từ file cũ)
63
+ - **"Toàn bộ từ đầu"** → chạy Bước 2 → 3 → 4 → 5 → 6 → 7 → 8
64
+ - **"Thông tin project"** → chỉ chạy Bước 2, bỏ qua Bước 3, 4, 5, 6, nhảy thẳng đến Bước 78 (giữ nguyên `team`, `epic`, `area_path/iteration_path`, `environments` từ file cũ)
65
+ - **"Team members"** → chỉ chạy Bước 3, bỏ qua Bước 2, 4, 5, 6, nhảy thẳng đến Bước 78 (giữ nguyên `organization/project`, `epic`, `area_path/iteration_path`, `environments` từ file cũ)
66
+ - **"Epic ticket"** → chỉ chạy Bước 4, bỏ qua Bước 2, 3, 5, 6, nhảy thẳng đến Bước 78 (giữ nguyên `organization/project`, `team`, `area_path/iteration_path`, `environments` từ file cũ)
67
+ - **"Area / Iteration path"** → chỉ chạy Bước 5, bỏ qua Bước 2, 3, 4, 6, nhảy thẳng đến Bước 78 (giữ nguyên tất cả còn lại từ file cũ)
68
+ - **"Môi trường"** → chỉ chạy Bước 6, bỏ qua Bước 2, 3, 4, 5, nhảy thẳng đến Bước 7 → 8 (giữ nguyên tất cả từ file cũ)
66
69
 
67
70
  ---
68
71
 
@@ -238,7 +241,41 @@ https://dev.azure.com/{organization}/{project_name}/_workitems/edit/{id}
238
241
 
239
242
  ---
240
243
 
241
- ### Bước 5: Cấu hình môi trường
244
+ ### Bước 5: Cấu hình Area & Iteration Path
245
+
246
+ Area Path và Iteration Path mặc định sẽ được gán cho mọi Feature/User Story khi `/ado-create` tạo ticket. Cả hai đều **tùy chọn** — nếu bỏ trống, ADO dùng giá trị mặc định của team.
247
+
248
+ Hỏi user bằng `AskUserQuestion`:
249
+
250
+ ```
251
+ question: "Cấu hình Area / Iteration path mặc định cho ticket?"
252
+ options:
253
+ - label: "Nhập area & iteration path"
254
+ description: "Gán area_path và iteration_path mặc định cho mọi ticket tạo qua /ado-create"
255
+ - label: "Bỏ qua"
256
+ description: "Không set — ADO dùng giá trị mặc định của team"
257
+ ```
258
+
259
+ Nếu user chọn **"Nhập area & iteration path"** → hỏi lần lượt (cho phép Enter trống để bỏ từng field):
260
+
261
+ ```
262
+ Area Path (ví dụ: Tickets\Clients\C-GAL\P-GCC):
263
+ > Tickets\Clients\C-GAL\P-GCC
264
+
265
+ Iteration Path (ví dụ: Tickets\Weekly Sprint):
266
+ > Tickets\Weekly Sprint
267
+ ```
268
+
269
+ Lưu ý khi thu thập:
270
+ - Path dùng dấu backslash `\` phân cách như trên ADO. Chấp nhận cả khi user paste có khoảng trắng ở đầu/cuối → trim.
271
+ - Nếu user nhập area path nhưng không chắc đúng → vẫn lưu nguyên văn, không tự validate qua MCP (tránh fail khi node chưa tồn tại). Validation thực tế sẽ xảy ra lúc `/ado-create` tạo ticket.
272
+ - Field nào để trống → bỏ key tương ứng trong YAML, không ghi `area_path: null`.
273
+
274
+ Nếu user chọn **"Bỏ qua"** → không thêm `area_path`/`iteration_path` vào config.
275
+
276
+ ---
277
+
278
+ ### Bước 6: Cấu hình môi trường
242
279
 
243
280
  **Bắt buộc** hỏi user bằng `AskUserQuestion` — không cho phép bỏ qua:
244
281
 
@@ -265,7 +302,7 @@ Nếu user chọn "Other" (nhập tay) → parse chuỗi nhập vào (phân các
265
302
 
266
303
  ---
267
304
 
268
- ### Bước 6: Preview và xác nhận
305
+ ### Bước 7: Preview và xác nhận
269
306
 
270
307
  Hiển thị preview YAML sẽ được ghi — **chưa ghi file**:
271
308
 
@@ -287,6 +324,9 @@ team:
287
324
  DE:
288
325
  - d@atstechnology.vn
289
326
 
327
+ area_path: 'Tickets\Clients\C-GAL\P-GCC'
328
+ iteration_path: 'Tickets\Weekly Sprint'
329
+
290
330
  epic:
291
331
  id: 42
292
332
  title: "[GAL-GCC] Spec Lite Kit"
@@ -304,11 +344,13 @@ Nếu user yêu cầu chỉnh sửa → cập nhật preview → hỏi lại.
304
344
 
305
345
  Nếu user bỏ qua bước Epic (không muốn cấu hình ngay) → bỏ qua key `epic` trong YAML, không ghi `epic: null`.
306
346
 
307
- **Bước 5 (môi trường) bắt buộc** không cho phép bỏ qua. Nếu user chưa chọn, nhắc lại trước khi tiếp tục.
347
+ Nếu user bỏ qua Area/Iteration (Bước 5) bỏ qua key `area_path`/`iteration_path` tương ứng, không ghi giá trị `null`.
348
+
349
+ **Bước 6 (môi trường) là bắt buộc** — không cho phép bỏ qua. Nếu user chưa chọn, nhắc lại trước khi tiếp tục.
308
350
 
309
351
  ---
310
352
 
311
- ### Bước 7: Ghi file
353
+ ### Bước 8: Ghi file
312
354
 
313
355
  Ghi nội dung đã confirm vào `.claude/ado.yaml`.
314
356
 
@@ -345,5 +387,6 @@ Trước khi ghi file, kiểm tra:
345
387
  - [ ] `team.PE` có ít nhất 1 email — không được để trống
346
388
  - [ ] SE và DE có thể là array rỗng `[]`
347
389
  - [ ] Nếu có Epic: `epic.id` là số nguyên, `epic.title` có prefix `[{project_code}]`, `epic.url` là full URL dạng `https://dev.azure.com/{org}/{project_name}/_workitems/edit/{id}`
390
+ - [ ] Nếu có `area_path` / `iteration_path`: là chuỗi đã trim, giữ nguyên dấu `\` (dùng YAML single-quote để tránh escape); bỏ qua key nếu user không nhập — không ghi `null`
348
391
  - [ ] `environments` là array ít nhất 1 phần tử (bắt buộc), mỗi phần tử là lowercase string không có khoảng trắng, luôn có `prod` ở cuối
349
392
  - [ ] User đã confirm preview trước khi ghi file
@@ -14,6 +14,8 @@ description: Tạo Feature và User Story tickets trên ADO từ spec.md của m
14
14
  - `.claude/ado.yaml` phải tồn tại và có `epic.id` (chạy `/ado-config` nếu chưa có)
15
15
  - `frd.md` tương ứng phải tồn tại trong `.specs/main/features/` cho mỗi feature
16
16
 
17
+ **Area / Iteration (tùy chọn):** Nếu `.claude/ado.yaml` có `area_path` và/hoặc `iteration_path`, mọi ticket (Feature + User Story) tạo ở Bước 5 và Bước 6 phải set `areaPath` / `iterationPath` tương ứng. Nếu không khai báo → để ADO dùng giá trị mặc định của team.
18
+
17
19
  ---
18
20
 
19
21
  ## Process
@@ -131,6 +133,8 @@ Gọi `mcp__azure-devops__wit_create_work_item` với:
131
133
  - `title`: `[{project_code}] [{feature_id}] {feature_name}` — ví dụ: `[SDLC-TEST] [F-001] Đăng ký / Đăng nhập`
132
134
  - `description`: toàn bộ nội dung `frd.md` (giữ nguyên format Markdown)
133
135
  - `assignedTo`: ADO identity ID của current user (nếu resolve thành công)
136
+ - `areaPath`: giá trị `area_path` từ ado.yaml (nếu có)
137
+ - `iterationPath`: giá trị `iteration_path` từ ado.yaml (nếu có)
134
138
 
135
139
  Sau khi tạo thành công → **ngay lập tức** link parent. Ưu tiên dùng `mcp__azure-devops__wit_add_child_work_items` (parent = Epic ID, child = Feature ticket ID). Nếu tool này không khả dụng, fallback sang `mcp__azure-devops__wit_work_items_link` với:
136
140
  - `sourceId`: Feature ticket ID vừa tạo
@@ -186,6 +190,8 @@ Gọi `mcp__azure-devops__wit_create_work_item` với:
186
190
  - `title`: `[{project_code}] [{feature_name}] - {US-code} — {story_title}` — ví dụ: `[SDLC-TEST] [Đăng ký / Đăng nhập] - US-F001-001 — Đăng ký`
187
191
  - `description`: description đã build ở 6.2
188
192
  - `assignedTo`: ADO identity ID của current user
193
+ - `areaPath`: giá trị `area_path` từ ado.yaml (nếu có)
194
+ - `iterationPath`: giá trị `iteration_path` từ ado.yaml (nếu có)
189
195
 
190
196
  Sau khi tạo thành công → **ngay lập tức** link parent. Ưu tiên dùng `mcp__azure-devops__wit_add_child_work_items` (parent = Feature ticket ID, child = User Story ticket ID). Nếu không khả dụng, fallback sang `mcp__azure-devops__wit_work_items_link` với:
191
197
  - `sourceId`: User Story ticket ID vừa tạo
@@ -0,0 +1,189 @@
1
+ ---
2
+ name: artifact-audit
3
+ description: Audit artifacts trong .specs/ xem có lỗi thời so với template không. So `template_version` của artifact với `template_version` hiện tại đọc thẳng từ template (.claude/templates/). Versioned khớp → up-to-date, lệch → out-dated (in vX → vY). Artifact thiếu version (sinh trước versioning) → đối chiếu structure với template: khớp thì stamp version, lệch thì flag out-dated. KHÔNG tự migrate — chỉ stamp khi chắc chắn khớp + báo cáo. Nhận tùy chọn 1 hay nhiều type làm scope (vd `frd`, `frd,spec`); không có arg → audit mọi type.
4
+ ---
5
+
6
+ # artifact-audit
7
+
8
+ ## Overview
9
+
10
+ Trả lời một câu hỏi: **artifact nào trong `.specs/` đã lỗi thời so với template mới nhất?**
11
+
12
+ Cơ chế (xem `conventions.md` §7 Template Versioning):
13
+ - **Nguồn sự thật** = `template_version` trong frontmatter template đang cài (`.claude/templates/...`). Đọc thẳng lúc chạy — không manifest, không cache.
14
+ - Mỗi artifact mang `template_version` (copy lúc CREATE bởi skill sinh nó). Audit so số artifact với số template.
15
+
16
+ Skill này **chỉ phát hiện + stamp legacy**, **KHÔNG migrate**. Việc đưa structure artifact lên format mới là của `/artifact-migrate` (generic cho mọi type).
17
+
18
+ ## When to Use
19
+
20
+ - Sau khi `git pull` kit mới (template có thể đã bump version) → xem artifact nào cần migrate.
21
+ - Audit định kỳ một type cụ thể (`/artifact-audit frd`) hoặc toàn repo (`/artifact-audit`).
22
+ - Sau khi bump `template_version` của một template → tìm mọi artifact giờ thành `out-dated`.
23
+ - Onboarding repo cũ → stamp version cho artifact legacy khớp structure, lọc ra cái cần migrate.
24
+
25
+ ## When NOT to Use
26
+
27
+ - Muốn **migrate** artifact lên format mới → `/artifact-migrate` (skill này chỉ flag, không sửa structure).
28
+ - Muốn đổi **nội dung** artifact → integration changeset (`/spec-new`) hoặc edit tay.
29
+ - Chưa cài template vào `.claude/templates/` → skill không có nguồn version để so; dừng.
30
+
31
+ ---
32
+
33
+ ## Type → template map
34
+
35
+ Type của artifact resolve theo **filename** (integration artifact không có field `type` trong frontmatter). Mỗi type map tới đúng một template:
36
+
37
+ | Filename | type | Template (`.claude/templates/...`) |
38
+ | --- | --- | --- |
39
+ | `prd.md` | prd | `main/prd-template.md` |
40
+ | `domain.md` | domain | `main/domain-template.md` |
41
+ | `sad.md` | sad | `main/sad-template.md` |
42
+ | `frd.md` | frd | `main/feature/frd-template.md` |
43
+ | `fdd.md` | fdd | `main/feature/fdd-template.md` |
44
+ | `tsd.md` | tsd | `main/feature/tsd-template.md` |
45
+ | `crd.md` | crd | `main/component/crd-template.md` |
46
+ | `cdd.md` | cdd | `main/component/cdd-template.md` |
47
+ | `spec.md` | spec | `integrations/spec-template.md` |
48
+ | `tech.md` | tech | `integrations/tech-template.md` |
49
+ | `test.md` | test | `integrations/test-template.md` |
50
+ | `plan.md` | plan | `integrations/plan-template.md` |
51
+ | `todo.md` | todo | `integrations/todo-template.md` |
52
+ | `techdebt.md` | techdebt | `integrations/techdebt-template.md` |
53
+
54
+ File không khớp bảng (vd `notes.md`, `*.bak`) → bỏ qua, không phải artifact có template.
55
+
56
+ ---
57
+
58
+ ## Process
59
+
60
+ ### Bước 0: Resolve scope
61
+
62
+ - **ARGUMENT là 1 type hoặc list** (vd `frd`, `frd,spec,tech`) → chỉ audit các type đó. Type lạ (không có trong map) → cảnh báo và bỏ qua type đó.
63
+ - **Không có ARGUMENT** → audit **mọi** type trong map.
64
+
65
+ ### Bước 1: Đọc current version của template
66
+
67
+ Cho mỗi type trong scope, đọc frontmatter template tương ứng tại `.claude/templates/...` → lấy `template_version`.
68
+
69
+ - Template thiếu field `template_version` → không audit được type đó (chưa versioned ở phía template); cảnh báo, skip type.
70
+ - Template không tồn tại tại `.claude/templates/` → báo kit chưa cài đủ; dừng.
71
+
72
+ Lưu bảng `currentVersion[type]`.
73
+
74
+ ### Bước 2: Discover artifacts
75
+
76
+ Quét artifacts trong:
77
+ - `.specs/main/**` (prd, domain, sad, và feature/component artifacts)
78
+ - `.specs/integrations/**` (spec, tech, test, plan, todo, techdebt)
79
+
80
+ **Bỏ qua** (đã đóng băng — không audit/migrate):
81
+ - `.specs/archive/**`, `.specs/removed/**`, file `*.bak.*`, file không khớp type map.
82
+ - **Integration folder đã `done`**: nếu `.specs/integrations/{X}/spec.md` có `status: done` → bỏ qua **toàn bộ folder đó** (spec/tech/test/plan/todo/techdebt). Integration artifacts là **immutable sau khi done** (conventions §7 Versioning) — không migrate record bất biến. Folder integration đang active (spec chưa `done`) và mọi **main artifact** thì vẫn audit/migrate bình thường.
83
+
84
+ Với mỗi file khớp: resolve type theo filename, đọc frontmatter để lấy `template_version` (có thể thiếu).
85
+
86
+ ### Bước 3: Classify
87
+
88
+ Cho mỗi artifact:
89
+
90
+ **3a. Có `template_version`** → so với `currentVersion[type]`:
91
+ - `==` → **up-to-date**.
92
+ - `!=` → **out-dated** → cần migrate. Ghi `(vX → vY)`.
93
+
94
+ Version compare bắt **mọi** loại delta của các bump ở giữa — `add` / `remove` / **`update` (format)** — kể cả thay đổi format mà presence-check không thấy được. Số version là tín hiệu tổng.
95
+
96
+ **3b. Thiếu `template_version`** (unversioned — sinh trước versioning) → chưa kết luận được bằng số. Áp **conformance check** (xem `conventions.md` §7 "Conformance model — required-emptyable").
97
+
98
+ > **Điểm mù:** presence-check chỉ thấy heading có/không → **KHÔNG phát hiện được format-update** (vd section vẫn đó nhưng dùng ASCII diagram thay vì Mermaid). Artifact unversioned đủ heading sẽ bị stamp thành conform dù format cũ. Đây là giới hạn cố hữu của nhánh unversioned (format-update chỉ bắt được qua version compare ở 3a). Chấp nhận vì là edge-case pre-versioning.
99
+
100
+ **Presence-check, quan hệ BAO HÀM (superset).** Conformance = artifact **chứa đủ mọi heading required** của template (body rỗng OK). Template là skeleton tối thiểu; artifact đã điền luôn chứa nhiều hơn. KHÔNG đòi giống hệt template.
101
+ - **Required heading** = các heading **`##`** của template body, TRỪ cái đánh dấu `*(nếu có)*` (conditional). Heading `###` là instance/sub (vd `### US-F{NNN}-001`, `### Flow 1`) → KHÔNG tính. Phân biệt bằng level nên deterministic.
102
+
103
+ **Hai dấu hiệu out-dated** (artifact tụt sau template) — đọc `remove` từ block `migrations` của template để biết tên section deprecated cần dò:
104
+ 1. **Thiếu** một required heading mà template hiện tại có.
105
+ 2. **Còn chứa** một section mà `migrations.remove` ghi đã bỏ (deprecated còn sót).
106
+
107
+ (Đổi tên section được biểu diễn bằng remove + add ở block `migrations`, nên rơi vào cả 2 dấu hiệu: tên cũ nằm trong `remove` → dấu hiệu 2; tên mới là required heading bị thiếu → dấu hiệu 1.)
108
+
109
+ **KHÔNG phải out-dated** (authoring bình thường, vẫn **stamp**):
110
+ - Artifact **thêm** sub-section / heading con không có trong template (vd dưới `### Feature Acceptance Criteria` có thêm `#### NFR AC`). Required heading vẫn có mặt → conform.
111
+ - Body rỗng của một required-emptyable section.
112
+ - Thêm nội dung/bảng/ghi chú riêng **không nằm trong `migrations.remove`**; khác thứ tự; số item nhiều/ít hơn ví dụ.
113
+
114
+ > **Quan trọng — phân biệt dấu hiệu 2 với superset:** section "thừa" (có trong artifact, không trong template) chỉ là out-dated khi tên nó **nằm trong `migrations.remove`** (đã khai báo deprecated). Section thừa **không** được khai báo remove → là content tác giả → **giữ, conform** (superset). Đây là cách removal vẫn detect được bằng presence-check mà không xóa nhầm content.
115
+
116
+ Kết luận:
117
+ - **Conform** (đủ required heading, không dính 1–2) → **stamp** `template_version: <currentVersion>`. Lần audit sau so bằng số.
118
+ - **Out-dated** (dính ≥1 trong 1–2) → KHÔNG stamp. Tóm tắt đúng dấu hiệu (thiếu required heading gì / section deprecated nào còn sót) để `/artifact-migrate` xử lý.
119
+
120
+ > Nguyên tắc thận trọng — chỉ về việc **có stamp hay không**: nếu nghi ngờ một required heading có thực sự thiếu hay không (diễn đạt khác) → flag out-dated thay vì stamp (thà flag thừa còn hơn giấu artifact lỗi thời). **Nội dung thừa không khai báo remove KHÔNG bao giờ là lý do nghi ngờ** — chỉ thiếu-required / deprecated-còn-sót mới tính.
121
+
122
+ ### Bước 4: Confirm trước khi stamp
123
+
124
+ > **Chế độ classify-only** (khi `/artifact-migrate` gọi audit làm bước phát hiện): **bỏ qua Bước 4–5** — KHÔNG stamp, KHÔNG confirm, chỉ trả phân loại (up-to-date / legacy-conformant / out-dated) cho caller. Mọi ghi (stamp + migrate) do `/artifact-migrate` điều phối trong một luồng confirm duy nhất. Phần dưới chỉ áp dụng khi audit chạy **standalone**.
125
+
126
+ Nếu Bước 3b có artifact cần stamp → hiển thị danh sách **sẽ stamp** + danh sách **out-dated** trước, xin confirm:
127
+
128
+ > Sẽ ghi `template_version` vào {N} artifact legacy khớp structure (additive frontmatter change). {M} artifact out-dated sẽ KHÔNG bị đụng. Tiếp tục? [y/n]
129
+
130
+ `y` → ghi stamp (chỉ thêm field `template_version` vào frontmatter, không đụng nội dung khác). `n` → bỏ qua stamp, vẫn in báo cáo.
131
+
132
+ Stamp là thay đổi additive an toàn; khuyến nghị commit riêng để diff sạch.
133
+
134
+ ### Bước 5: Report
135
+
136
+ In bảng phân nhóm (xem Output Format). Skill **không** migrate, **không** đổi nội dung artifact ngoài việc stamp ở Bước 4.
137
+
138
+ ---
139
+
140
+ ## Output Format
141
+
142
+ ```
143
+ ARTIFACT AUDIT — scope: {all | frd, spec}
144
+ Current template versions: prd v1 · domain v1 · sad v1 · frd v2 · spec v1 · ...
145
+
146
+ OUT-DATED ({n}) — cần migrate:
147
+ feature/F-002-payment/frd.md frd v1 → v2 → /artifact-migrate
148
+ feature/F-003-x/frd.md frd unversioned, lệch structure (thiếu: Verification Rules) → migrate
149
+
150
+ STAMPED ({n}) — legacy khớp structure, vừa ghi template_version:
151
+ feature/F-001-auth/frd.md frd → v2
152
+ integrations/001-checkout/spec.md spec → v1
153
+
154
+ UP-TO-DATE ({n}): {đếm, liệt kê path ngắn gọn hoặc gập lại nếu nhiều}
155
+
156
+ Bước tiếp theo (nếu có out-dated):
157
+ - /artifact-migrate [path]
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Common Rationalizations
163
+
164
+ | Rationalization | Reality |
165
+ | --- | --- |
166
+ | "Cứ stamp hết cho gọn rồi tính sau" | Stamp nhầm artifact lệch structure = giấu luôn nó khỏi audit lần sau. Chỉ stamp khi structure khớp chắc chắn. |
167
+ | "Audit luôn tiện migrate luôn" | Hai trách nhiệm khác nhau. Audit chỉ phát hiện; migrate (đổi structure) là `/artifact-migrate` với dry-run + confirm. |
168
+ | "Thiếu version thì coi như out-dated hết" | Sai — legacy khớp structure chỉ là chưa stamp, không phải lỗi thời. Phải đối chiếu structure trước khi kết luận. |
169
+ | "Artifact có thêm `#### NFR AC` mà template không có → lệch → out-dated" | Sai — template là skeleton tối thiểu; thừa sub-section/nội dung là authoring bình thường. Conformance là quan hệ bao hàm: section bắt buộc còn đó → conform. Chỉ thiếu/đổi-tên/đổi-format mới là out-dated. |
170
+
171
+ ## Red Flags
172
+
173
+ - Stamp `template_version` cho artifact mà chưa đối chiếu structure với template.
174
+ - Tự sửa structure / nội dung artifact (vượt phạm vi — đó là migration skill).
175
+ - Flag out-dated chỉ vì artifact có thêm sub-section / nội dung ngoài template (thừa ≠ lỗi thời; chỉ thiếu/đổi-tên/đổi-format mới tính).
176
+ - Audit/stamp artifact đóng băng: `.specs/archive/`, `.specs/removed/`, hoặc integration folder có spec.md `status: done` (immutable record — bỏ qua).
177
+ - Đọc version từ một manifest/cache thay vì đọc thẳng frontmatter template.
178
+
179
+ ## Verification
180
+
181
+ - [ ] Scope resolve đúng từ argument (1 type / list / mọi type)
182
+ - [ ] Current version đọc thẳng từ frontmatter template tại `.claude/templates/...` (không manifest)
183
+ - [ ] Bỏ qua `.specs/archive/`, `.specs/removed/`, `*.bak.*`, file không khớp type map, và integration folder có spec.md `status: done`
184
+ - [ ] Versioned: `==` → up-to-date; `!=` → out-dated `(vX → vY)` → migrate
185
+ - [ ] Unversioned: conformance là quan hệ bao hàm (artifact chứa đủ structure bắt buộc; thừa sub-section/nội dung không khai báo remove KHÔNG phải lỗi thời); 2 dấu hiệu out-dated = thiếu required heading / section `migrations.remove` còn sót
186
+ - [ ] Conform → stamp; out-dated → tóm tắt đúng dấu hiệu (thiếu required heading gì / section deprecated nào còn sót). Lưu ý: presence-check KHÔNG bắt format-update (blind spot unversioned)
187
+ - [ ] Có confirm trước khi ghi stamp; stamp chỉ thêm field `template_version`, không đụng nội dung khác
188
+ - [ ] KHÔNG migrate / không sửa structure artifact
189
+ - [ ] Report phân nhóm out-dated / stamped / up-to-date + bước tiếp theo
@@ -0,0 +1,156 @@
1
+ ---
2
+ name: artifact-migrate
3
+ description: Migrate artifact trong .specs/ lên structure template mới nhất. Generic cho mọi type. Tự chạy /artifact-audit (classify-only, scoped) để phát hiện out-dated, rồi áp delta từ block `migrations` của template — add section thiếu, remove section deprecated, update format section (vd ASCII→Mermaid) — set template_version = current. Tương tác: confirm add/remove/update, hỏi carry-over khi rename, section nội dung mới thì interview hoặc NEEDS_CLARIFY (không bịa). Single-artifact, KHÔNG cascade. Nhận tùy chọn 1 artifact (path); không có arg → quét toàn bộ, migrate từng cái có confirm + skip.
4
+ ---
5
+
6
+ # artifact-migrate
7
+
8
+ ## Overview
9
+
10
+ Đưa một artifact (hoặc toàn bộ) **lỗi thời** lên đúng structure của template mới nhất, rồi cập nhật `template_version`. Đây là vế **fix** đối xứng với `/artifact-audit` (vế **detect**).
11
+
12
+ Cơ chế (xem `conventions.md` §7 Template Versioning):
13
+ - **Required section hiện tại** = body `##` headings của template (deterministic theo level; `###` = instance).
14
+ - **Delta giữa các version** = đọc từ block `migrations` của template: mỗi entry `to: N` ghi `add` (section thêm) + `remove` (section bỏ) + `update` (section giữ nhưng đổi format/cách thể hiện, vd ASCII → Mermaid). `remove` và `update` không suy lại được từ body → block `migrations` là nguồn duy nhất.
15
+ - Migrate **single-artifact, KHÔNG cascade**. ID format đổi (hiếm, cross-artifact) → xử lý tay theo `note`.
16
+
17
+ ## When to Use
18
+
19
+ - Sau `git pull` kit mới, `/artifact-audit` báo có artifact out-dated → migrate chúng lên template mới.
20
+ - Onboarding repo cũ: artifact legacy thiếu version / lệch structure.
21
+ - Sau khi bump `template_version` một template → migrate các artifact cùng type.
22
+
23
+ ## When NOT to Use
24
+
25
+ - Chỉ muốn **biết** artifact nào lỗi thời (không sửa) → `/artifact-audit`.
26
+ - Muốn đổi **nội dung** artifact (thêm US, đổi AC) → integration changeset (`/spec-new`) hoặc edit tay.
27
+ - Working tree đang dirty → commit/stash trước (skill rollback dựa git, không tạo `.bak`).
28
+
29
+ ---
30
+
31
+ ## Type → template map
32
+
33
+ Resolve type theo **filename** (giống `/artifact-audit` — integration artifact không có field `type`). Mỗi type map tới đúng một template tại `.claude/templates/...`:
34
+
35
+ `prd.md`→`main/prd-template.md` · `domain.md`→`main/domain-template.md` · `sad.md`→`main/sad-template.md` · `frd.md`→`main/feature/frd-template.md` · `fdd.md`→`main/feature/fdd-template.md` · `tsd.md`→`main/feature/tsd-template.md` · `crd.md`→`main/component/crd-template.md` · `cdd.md`→`main/component/cdd-template.md` · `spec.md`→`integrations/spec-template.md` · `tech.md`→`integrations/tech-template.md` · `test.md`→`integrations/test-template.md` · `plan.md`→`integrations/plan-template.md` · `todo.md`→`integrations/todo-template.md` · `techdebt.md`→`integrations/techdebt-template.md`
36
+
37
+ File không khớp map → bỏ qua.
38
+
39
+ ---
40
+
41
+ ## Process
42
+
43
+ ### Bước 0: Resolve scope
44
+
45
+ - **ARGUMENT là path tới 1 artifact** → migrate riêng nó. Nếu artifact thuộc integration folder đã `done` (spec.md `status: done`) hoặc nằm trong `.specs/archive`/`.specs/removed` → **DỪNG**, báo "artifact đóng băng (immutable record) — không migrate".
46
+ - **Không có ARGUMENT** → quét `.specs/main/**` + `.specs/integrations/**`, áp **đúng skip list của `/artifact-audit`** (bỏ archive/removed, `*.bak.*`, và **integration folder có spec.md `status: done`**).
47
+
48
+ ### Bước 1: Pre-flight — working tree clean
49
+
50
+ Chạy `git status --porcelain`. Output không rỗng → **DỪNG**:
51
+ > ⛔ Working tree không clean. Skill không tạo `.bak` — rollback dựa git. Hãy commit/stash trước rồi chạy lại.
52
+
53
+ Không phải git repo → cảnh báo, yêu cầu confirm (default no) vì không rollback được.
54
+
55
+ ### Bước 2: Detect — tự chạy `/artifact-audit` (classify-only, scoped)
56
+
57
+ Dùng **chính conformance check của `/artifact-audit`** (presence-check, conventions §7) làm bước phát hiện — một nguồn phán đoán duy nhất, không tự cài lại logic. Scoped theo Bước 0:
58
+ - Có arg → audit đúng artifact/type đó.
59
+ - Không arg → audit toàn bộ scope.
60
+
61
+ Audit chạy **classify-only** ở đây: chỉ phân loại, **không tự stamp/confirm** (migrate sẽ điều phối mọi ghi vào một luồng confirm). Kết quả mỗi artifact:
62
+ - **up-to-date** (versioned, version `==` template) → bỏ qua. Target đơn lẻ → **no-op sớm**, thoát.
63
+ - **legacy-conformant** (thiếu version nhưng đủ required `##`, không dính `migrations.remove`) → chỉ cần **stamp** version (không đổi structure).
64
+ - **out-dated** (versioned `!=` template, HOẶC unversioned thiếu required `##`, HOẶC còn section trong `migrations.remove`) → cần migrate structure.
65
+
66
+ Không arg → in danh sách phân nhóm trước, rồi xử lý **từng artifact một, có confirm + cho skip** (không bulk-auto).
67
+
68
+ ### Bước 3: Lập transform plan cho từng artifact
69
+
70
+ Resolve type→template, đọc template: `template_version` hiện tại + block `migrations` + body `##` headings.
71
+
72
+ Gộp delta các entry `to:` > version artifact (hoặc tất cả nếu artifact unversioned):
73
+
74
+ 1. **Sections cần ADD** = required `##` của template mà artifact **thiếu**. (Phát hiện bằng so `##` body, deterministic; `migrations.add` để tham khảo delta.)
75
+ 2. **Sections cần REMOVE** = section trong **`migrations.remove`** mà artifact **còn chứa**.
76
+ 3. **Sections cần UPDATE format** = section trong **`migrations.update`** (giữ section, đổi cách thể hiện — vd ASCII → Mermaid). Section vẫn còn → không add/remove; chỉ transform format theo mô tả `change`. (Không suy được từ presence-check → bắt buộc dựa `migrations.update`.)
77
+ 4. **Rename phát hiện được** khi một `remove` (tên cũ) đi kèm một `add` (tên mới) trong cùng entry — đánh dấu để hỏi carry-over content.
78
+ 5. **ID format** (nếu `note` đề cập, cross-artifact) → liệt kê để người dùng sửa tay; skill không tự remap.
79
+
80
+ ### Bước 4: Dry-run + confirm (một luồng)
81
+
82
+ Trình bày cho user **trước khi ghi**:
83
+ - sections sẽ ADD (kèm skeleton lấy từ body template) + sections sẽ REMOVE (kèm reason).
84
+ - sections sẽ UPDATE format → show **nội dung hiện tại** + **đề xuất bản chuyển format** (vd ASCII diagram → Mermaid tương ứng), giữ nguyên ngữ nghĩa.
85
+ - cặp rename phát hiện được → hỏi: "carry-over nội dung từ {cũ} sang {mới}?".
86
+ - artifact legacy-conformant trong scope → sẽ stamp version (gộp vào cùng confirm).
87
+
88
+ User confirm (toàn bộ / từng item / skip artifact). **Section nội dung mới** (vd Verification Rules) → **interview user điền** hoặc chèn `**[NEEDS_CLARIFY]**` — **KHÔNG tự bịa nội dung**. Với UPDATE format: chuyển *cách thể hiện*, **không bịa thêm/bớt thông tin** so với bản cũ; phần không chắc → giữ + `[NEEDS_CLARIFY]`.
89
+
90
+ ### Bước 5: Apply (atomic mỗi artifact)
91
+
92
+ - Chèn section ADD theo đúng thứ tự body template; nếu là rename + user đồng ý carry-over → move nội dung từ section cũ sang.
93
+ - Xóa section REMOVE (đã confirm).
94
+ - Áp UPDATE format: thay nội dung section bằng bản chuyển format đã confirm (giữ section + ngữ nghĩa).
95
+ - **Giữ nguyên** mọi sub-section / content tác giả **không nằm trong `remove`/`update`** (superset rule).
96
+ - Set frontmatter `template_version` = current.
97
+ - Nếu template có `## Change History` (main artifact) → append entry, operation = `manual`:
98
+ ```markdown
99
+ ### {YYYY-MM-DD} — manual — migrate
100
+
101
+ - **Migration**: v{cũ} → v{current} qua /artifact-migrate (add: {...}; remove: {...}; update: {...})
102
+ ```
103
+ - **Single-artifact, KHÔNG cascade.** Apply fail → rollback bằng git (`git checkout -- {file}`); báo user.
104
+
105
+ ### Bước 6: Report
106
+
107
+ ```
108
+ ARTIFACT MIGRATE — scope: {file | all}
109
+
110
+ MIGRATED ({n}):
111
+ feature/F-002-payment/frd.md v0 → v1 +User Flows, −Components Consumed, ~System Overview (ASCII→Mermaid)
112
+ STAMPED ({n}) — legacy conform, chỉ set version:
113
+ feature/F-001-auth/frd.md → v1
114
+ SKIPPED / up-to-date ({n})
115
+
116
+ {nếu có} NEEDS_CLARIFY còn lại:
117
+ feature/F-002-payment/frd.md → Verification Rules (chờ điền)
118
+ {nếu có} Cần sửa tay (ID remap theo note):
119
+ ...
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Common Rationalizations
125
+
126
+ | Rationalization | Reality |
127
+ | --- | --- |
128
+ | "Tự đoán nội dung cho section mới cho nhanh" | Section nội dung mới = quyết định của BA/owner. Bịa = sai mà không ai review. Interview hoặc NEEDS_CLARIFY. |
129
+ | "Section thừa chắc là rác, xóa luôn" | Chỉ xóa section nằm trong `migrations.remove`. Thừa khác là content tác giả → giữ (superset). |
130
+ | "Format đổi thì xóa section rồi thêm lại" | remove+add làm **mất nội dung**. Format-update giữ section + ngữ nghĩa, chỉ chuyển cách thể hiện (dùng op `update`). |
131
+ | "Chuyển format thì tiện viết lại nội dung cho đẹp" | UPDATE chỉ đổi *cách thể hiện*, KHÔNG thêm/bớt thông tin. Phần không chắc → giữ + NEEDS_CLARIFY. |
132
+ | "Migrate tiện remap ID luôn" | Không có op remap; cascade đã bỏ. ID đổi (hiếm) ghi ở `note`, người dùng sửa tay. |
133
+ | "Khỏi chạy audit, tự check structure cho nhanh" | Phải dùng audit classify-only → một nguồn phán đoán duy nhất, không lệch giữa hai skill. |
134
+
135
+ ## Red Flags
136
+
137
+ - Bịa nội dung cho section ADD thay vì interview / NEEDS_CLARIFY.
138
+ - Xóa section không nằm trong `migrations.remove` (vi phạm superset).
139
+ - Tự remap ID / đụng tới artifact khác (migrate là single-artifact, không cascade).
140
+ - Chạy khi working tree dirty (mất đường rollback).
141
+ - Migrate artifact đóng băng: integration folder đã `done`, `.specs/archive`, `.specs/removed` (immutable record — phải skip).
142
+ - Migrate artifact đã up-to-date (phải no-op sớm).
143
+ - Tự cài lại logic detect thay vì dùng audit classify-only.
144
+
145
+ ## Verification
146
+
147
+ - [ ] Pre-flight: working tree clean (hoặc user confirm khi không phải git repo)
148
+ - [ ] Detect bằng `/artifact-audit` classify-only, scoped theo target; version `==` → up-to-date → no-op sớm; `!=` → migrate
149
+ - [ ] Required `##` thiếu → ADD (skeleton từ body template); section `migrations.remove` còn sót → REMOVE (confirm)
150
+ - [ ] Section `migrations.update` → chuyển format (giữ section + ngữ nghĩa); show cũ + đề xuất mới, confirm; KHÔNG thêm/bớt thông tin
151
+ - [ ] Rename (remove+add) → hỏi carry-over content; section nội dung mới → interview / NEEDS_CLARIFY (KHÔNG bịa)
152
+ - [ ] Giữ content tác giả không nằm trong `remove`/`update` (superset)
153
+ - [ ] Set `template_version` = current; main artifact có Change History entry operation `manual`/migrate
154
+ - [ ] Single-artifact, KHÔNG cascade; ID remap (nếu có) chỉ báo để sửa tay
155
+ - [ ] Không arg → liệt kê trước, migrate từng cái có confirm + skip
156
+ - [ ] Apply fail → rollback git; user được thông báo
@@ -118,7 +118,7 @@ Invoke `planning-and-task-breakdown` với context đã load. Skill đó sẽ th
118
118
 
119
119
  ### plan.md
120
120
 
121
- Dùng `.claude/templates/integrations/plan-template.md` làm skeleton, điền nội dung từ breakdown vào từng section.
121
+ Dùng `.claude/templates/integrations/plan-template.md` làm skeleton, điền nội dung từ breakdown vào từng section. Frontmatter lấy `template_version` từ template (xem `conventions.md` §7).
122
122
 
123
123
  **Lưu ý format:**
124
124
  - Task ID dùng `·` (middle dot), không dùng `—`
@@ -128,7 +128,7 @@ Dùng `.claude/templates/integrations/plan-template.md` làm skeleton, điền n
128
128
 
129
129
  ### todo.md
130
130
 
131
- Dùng `.claude/templates/integrations/todo-template.md` làm skeleton, điền nội dung từ breakdown vào từng section.
131
+ Dùng `.claude/templates/integrations/todo-template.md` làm skeleton, điền nội dung từ breakdown vào từng section. Frontmatter lấy `template_version` từ template.
132
132
 
133
133
  ---
134
134
 
@@ -146,3 +146,4 @@ Nếu trong quá trình breakdown phát hiện delta cần cập nhật `sad.md`
146
146
  - [ ] plan.md có section **Dependency Graph**
147
147
  - [ ] Mỗi task có đủ: Mục tiêu / depends / Các bước / Verification
148
148
  - [ ] Không viết code trong suốt quá trình
149
+ - [ ] plan.md + todo.md có `template_version` copy từ template tương ứng
@@ -221,6 +221,8 @@ Ghi tất cả? [y] hoặc review từng file trước [r]:
221
221
  - `y` → ghi tất cả
222
222
  - `r` → hiển thị lần lượt từng file, user confirm / skip / edit từng cái
223
223
 
224
+ **Stamp `template_version`:** frontmatter mỗi `crd.md`/`cdd.md` lấy `template_version` từ template tương ứng (xem `conventions.md` §7).
225
+
224
226
  **Change History:** Append entry vào section `## Change History` cuối mỗi `crd.md`/`cdd.md` vừa ghi (theo `conventions.md` §5.5):
225
227
 
226
228
  ```markdown
@@ -304,4 +306,5 @@ Bước tiếp theo:
304
306
  - [ ] prd.md Component Index đã được update
305
307
  - [ ] sad.md Components table đã được update — danh sách C-XXX khớp với prd.md
306
308
  - [ ] Shared Entities đã được cascade vào domain.md (nếu có)
309
+ - [ ] Mỗi crd.md/cdd.md có `template_version` copy từ template tương ứng
307
310
  - [ ] NEEDS_CLARIFY items được list đầy đủ trong summary
@@ -225,6 +225,8 @@ Sẽ tạo {N} features ({2N} files):
225
225
  Ghi tất cả? [y] hoặc review từng file trước [r]:
226
226
  ```
227
227
 
228
+ **Stamp `template_version`:** frontmatter mỗi `frd.md`/`fdd.md` lấy `template_version` từ template tương ứng (xem `conventions.md` §7).
229
+
228
230
  **Change History:** Append entry vào section `## Change History` cuối mỗi `frd.md`/`fdd.md` vừa ghi (theo `conventions.md` §5.5):
229
231
 
230
232
  ```markdown
@@ -307,4 +309,5 @@ grep "NEEDS_CLARIFY" để tìm và fill in khi có thêm context.
307
309
  - [ ] Feature không có tests → AC section có NEEDS_CLARIFY rõ ràng
308
310
  - [ ] Verification Rules: rule reverse-engineer từ code đã đánh dấu source; field thiếu validation đã NEEDS_CLARIFY; không chứa regex/code/error message
309
311
  - [ ] prd.md Feature Index đã được update
312
+ - [ ] Mỗi frd.md/fdd.md có `template_version` copy từ template tương ứng
310
313
  - [ ] NEEDS_CLARIFY items được list đầy đủ trong summary
@@ -272,7 +272,7 @@ Confirm? [y] Bỏ qua [n] Chỉnh sửa [e]:
272
272
 
273
273
  ### Bước 9: Save
274
274
 
275
- Tạo `.specs/main/` nếu chưa có. Ghi các files đã được confirm.
275
+ Tạo `.specs/main/` nếu chưa có. Ghi các files đã được confirm. Frontmatter mỗi file (`prd.md`/`domain.md`/`sad.md`) lấy `template_version` từ template tương ứng (xem `conventions.md` §7).
276
276
 
277
277
  **Change History:** Append entry vào section `## Change History` cuối mỗi file vừa ghi (`prd.md`, `domain.md`, `sad.md`) theo `conventions.md` §5.5:
278
278
 
@@ -320,3 +320,4 @@ Format chuẩn — dùng nhất quán trong tất cả artifacts:
320
320
  - [ ] sad.md có Architectural Guardrails section
321
321
  - [ ] NEEDS_CLARIFY items được list đầy đủ trong summary cuối
322
322
  - [ ] User đã confirm từng file trước khi ghi
323
+ - [ ] Mỗi file (prd/domain/sad) có `template_version` copy từ template tương ứng