spec-lite 1.5.0 → 1.5.2

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.
package/README.md CHANGED
@@ -151,13 +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
- 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.
154
+ Mỗi **main** template mang `template_version` (số nguyên) trong frontmatter; main artifact copy nó lúc được tạo. Khi template đổi structure, main artifact cũ thành "lỗi thời" — hai skill dưới phát hiện và migrate. **Chỉ áp dụng cho main artifacts** (integration artifacts ephemeral nên không versioned). Quy ước đầy đủ: [conventions.md](conventions.md) §7.
155
155
 
156
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ộ.
157
+ Phát hiện **main 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 main type / list) hoặc mọi main type.
158
158
 
159
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.
160
+ Migrate **main artifact** lỗi thời lên structure mới (mọi main 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.
161
161
 
162
162
  ---
163
163
 
@@ -172,8 +172,8 @@ Migrate artifact lỗi thời lên structure mới (generic mọi type). Tự ch
172
172
  | `/spec-brownfield-component` | `.specs/main/component/{C-XXX}-*/crd.md + cdd.md` |
173
173
  | `/spec-brownfield-feature` | `.specs/main/feature/{F-XXX}-*/frd.md + fdd.md` |
174
174
  | `/spec-tsd` | `.specs/main/feature/{F-XXX}-*/tsd.md` |
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`)* |
175
+ | `/artifact-audit` | *(báo cáo out-dated; + stamp `template_version` cho main artifact legacy conform)* |
176
+ | `/artifact-migrate` | *(modify in-place main artifact lỗi thời lên structure mới + set `template_version`)* |
177
177
  | `/spec-new` | `.specs/integrations/{slug}/spec.md` |
178
178
  | `/spec-tech` | `.specs/integrations/{slug}/tech.md` |
179
179
  | `/spec-test` | `.specs/integrations/{slug}/test.md`, cascade: `feature/{F-XXX}/tsd.md` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-lite",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "Spec-driven development kit for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,26 +1,28 @@
1
1
  ---
2
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.
3
+ description: Audit MAIN artifacts trong .specs/main/ xem có lỗi thời so với template không (chỉ main artifacts — prd/domain/sad/frd/fdd/tsd/crd/cdd; integration artifacts ngoài scope). 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 main type làm scope (vd `frd`, `frd,crd`); không có arg → audit mọi main type.
4
4
  ---
5
5
 
6
6
  # artifact-audit
7
7
 
8
8
  ## Overview
9
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?**
10
+ Trả lời một câu hỏi: **main artifact nào trong `.specs/main/` đã lỗi thời so với template mới nhất?**
11
+
12
+ > **Scope = chỉ main artifacts** (`prd`, `domain`, `sad`, `frd`, `fdd`, `tsd`, `crd`, `cdd` — đều nằm dưới `.specs/main/`). Integration artifacts (`spec`, `tech`, `test`, `plan`, `todo`, `techdebt` dưới `.specs/integrations/`) **không** thuộc scope của skill này — chúng là ephemeral và immutable sau khi `done`, không audit/migrate theo version.
11
13
 
12
14
  Cơ chế (xem `conventions.md` §7 Template Versioning):
13
15
  - **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
16
  - Mỗi artifact mang `template_version` (copy lúc CREATE bởi skill sinh nó). Audit so số artifact với số template.
15
17
 
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).
18
+ 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` (cho mọi main type).
17
19
 
18
20
  ## When to Use
19
21
 
20
22
  - 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.
23
+ - Audit định kỳ một main type cụ thể (`/artifact-audit frd`) hoặc mọi main type (`/artifact-audit`).
24
+ - Sau khi bump `template_version` của một template → tìm mọi main artifact giờ thành `out-dated`.
25
+ - Onboarding repo cũ → stamp version cho main artifact legacy khớp structure, lọc ra cái cần migrate.
24
26
 
25
27
  ## When NOT to Use
26
28
 
@@ -32,7 +34,7 @@ Skill này **chỉ phát hiện + stamp legacy**, **KHÔNG migrate**. Việc đ
32
34
 
33
35
  ## Type → template map
34
36
 
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:
37
+ Type của main artifact resolve theo **filename**. Mỗi type map tới đúng một template:
36
38
 
37
39
  | Filename | type | Template (`.claude/templates/...`) |
38
40
  | --- | --- | --- |
@@ -44,14 +46,8 @@ Type của artifact resolve theo **filename** (integration artifact không có f
44
46
  | `tsd.md` | tsd | `main/feature/tsd-template.md` |
45
47
  | `crd.md` | crd | `main/component/crd-template.md` |
46
48
  | `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
49
 
54
- File không khớp bảng (vd `notes.md`, `*.bak`) → bỏ qua, không phải artifact có template.
50
+ **Chỉ main artifacts.** Integration artifacts (`spec`, `tech`, `test`, `plan`, `todo`, `techdebt`) **không** thuộc scope — gặp file integration thì bỏ qua. File không khớp bảng (vd `notes.md`, `*.bak`) → cũng bỏ qua.
55
51
 
56
52
  ---
57
53
 
@@ -59,8 +55,8 @@ File không khớp bảng (vd `notes.md`, `*.bak`) → bỏ qua, không phải a
59
55
 
60
56
  ### Bước 0: Resolve scope
61
57
 
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.
58
+ - **ARGUMENT là 1 main type hoặc list** (vd `frd`, `frd,crd`) → chỉ audit các type đó. Type lạ hoặc type integration (`spec`/`tech`/`test`/`plan`/`todo`/`techdebt`, không có trong map) → cảnh báo và bỏ qua type đó.
59
+ - **Không có ARGUMENT** → audit **mọi** main type trong map.
64
60
 
65
61
  ### Bước 1: Đọc current version của template
66
62
 
@@ -73,13 +69,11 @@ Lưu bảng `currentVersion[type]`.
73
69
 
74
70
  ### Bước 2: Discover artifacts
75
71
 
76
- Quét artifacts trong:
77
- - `.specs/main/**` (prd, domain, sad, và feature/component artifacts)
78
- - `.specs/integrations/**` (spec, tech, test, plan, todo, techdebt)
72
+ Quét **chỉ** main artifacts trong `.specs/main/**` (prd, domain, sad, và feature/component artifacts).
79
73
 
80
- **Bỏ qua** (đã đóng băng — không audit/migrate):
74
+ **Bỏ qua:**
75
+ - Toàn bộ `.specs/integrations/**` — integration artifacts ngoài scope skill này (ephemeral + immutable sau `done`; không audit/migrate theo version).
81
76
  - `.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
77
 
84
78
  Với mỗi file khớp: resolve type theo filename, đọc frontmatter để lấy `template_version` (có thể thiếu).
85
79
 
@@ -140,8 +134,8 @@ In bảng phân nhóm (xem Output Format). Skill **không** migrate, **không**
140
134
  ## Output Format
141
135
 
142
136
  ```
143
- ARTIFACT AUDIT — scope: {all | frd, spec}
144
- Current template versions: prd v1 · domain v1 · sad v1 · frd v2 · spec v1 · ...
137
+ ARTIFACT AUDIT — scope: {all main | frd, crd}
138
+ Current template versions: prd v1 · domain v1 · sad v1 · frd v2 · crd v1 · ...
145
139
 
146
140
  OUT-DATED ({n}) — cần migrate:
147
141
  feature/F-002-payment/frd.md frd v1 → v2 → /artifact-migrate
@@ -149,7 +143,7 @@ OUT-DATED ({n}) — cần migrate:
149
143
 
150
144
  STAMPED ({n}) — legacy khớp structure, vừa ghi template_version:
151
145
  feature/F-001-auth/frd.md frd → v2
152
- integrations/001-checkout/spec.md spec → v1
146
+ component/C-001-core/crd.md crd → v1
153
147
 
154
148
  UP-TO-DATE ({n}): {đếm, liệt kê path ngắn gọn hoặc gập lại nếu nhiều}
155
149
 
@@ -173,14 +167,14 @@ Bước tiếp theo (nếu có out-dated):
173
167
  - Stamp `template_version` cho artifact mà chưa đối chiếu structure với template.
174
168
  - Tự sửa structure / nội dung artifact (vượt phạm vi — đó là migration skill).
175
169
  - 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 spec.md `status: done` (immutable record — bỏ qua).
170
+ - Audit/stamp artifact ngoài scope: bất kỳ file nào trong `.specs/integrations/` (integration artifacts ngoài scope), `.specs/archive/`, `.specs/removed/` — bỏ qua hết.
177
171
  - Đọc version từ một manifest/cache thay vì đọc thẳng frontmatter template.
178
172
 
179
173
  ## Verification
180
174
 
181
- - [ ] Scope resolve đúng từ argument (1 type / list / mọi type)
175
+ - [ ] Scope = **chỉ main artifacts** (`.specs/main/**`); resolve đúng từ argument (1 main type / list / mọi main type)
182
176
  - [ ] 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`
177
+ - [ ] Bỏ qua toàn bộ `.specs/integrations/`, `.specs/archive/`, `.specs/removed/`, `*.bak.*`, file không khớp type map
184
178
  - [ ] Versioned: `==` → up-to-date; `!=` → out-dated `(vX → vY)` → migrate
185
179
  - [ ] 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
180
  - [ ] 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)
@@ -1,13 +1,15 @@
1
1
  ---
2
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.
3
+ description: Migrate MAIN artifact trong .specs/main/ lên structure template mới nhất (chỉ main artifacts — prd/domain/sad/frd/fdd/tsd/crd/cdd; integration artifacts ngoài scope). 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 main artifact (path); không có arg → quét mọi main artifact, migrate từng cái có confirm + skip.
4
4
  ---
5
5
 
6
6
  # artifact-migrate
7
7
 
8
8
  ## Overview
9
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**).
10
+ Đưa một main artifact (hoặc toàn bộ main artifacts) **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
+ > **Scope = chỉ main artifacts** (`prd`, `domain`, `sad`, `frd`, `fdd`, `tsd`, `crd`, `cdd` — đều dưới `.specs/main/`). Integration artifacts (`spec`, `tech`, `test`, `plan`, `todo`, `techdebt`) **không** thuộc scope — ephemeral + immutable sau `done`, không migrate theo version.
11
13
 
12
14
  Cơ chế (xem `conventions.md` §7 Template Versioning):
13
15
  - **Required section hiện tại** = body `##` headings của template (deterministic theo level; `###` = instance).
@@ -30,11 +32,11 @@ Cơ chế (xem `conventions.md` §7 Template Versioning):
30
32
 
31
33
  ## Type → template map
32
34
 
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/...`:
35
+ Resolve type của main artifact theo **filename** (giống `/artifact-audit`). Mỗi type map tới đúng một template tại `.claude/templates/...`:
34
36
 
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`
37
+ `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`
36
38
 
37
- File không khớp map → bỏ qua.
39
+ **Chỉ main artifacts.** Integration artifacts (`spec`/`tech`/`test`/`plan`/`todo`/`techdebt`) ngoài scope → bỏ qua. File không khớp map → cũng bỏ qua.
38
40
 
39
41
  ---
40
42
 
@@ -42,8 +44,8 @@ File không khớp map → bỏ qua.
42
44
 
43
45
  ### Bước 0: Resolve scope
44
46
 
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
+ - **ARGUMENT là path tới 1 main artifact** → migrate riêng nó. Nếu path là integration artifact (`.specs/integrations/...`) → **DỪNG**, báo "integration artifact ngoài scope chỉ migrate main artifacts". Nếu nằm trong `.specs/archive`/`.specs/removed` → **DỪNG**, báo "artifact đóng băng (immutable record) — không migrate".
48
+ - **Không có ARGUMENT** → quét **chỉ** `.specs/main/**`, áp **đúng skip list của `/artifact-audit`** (bỏ toàn bộ `.specs/integrations/`, archive/removed, `*.bak.*`).
47
49
 
48
50
  ### Bước 1: Pre-flight — working tree clean
49
51
 
@@ -94,7 +96,7 @@ User confirm (toàn bộ / từng item / skip artifact). **Section nội dung m
94
96
  - Áp UPDATE format: thay nội dung section bằng bản chuyển format đã confirm (giữ section + ngữ nghĩa).
95
97
  - **Giữ nguyên** mọi sub-section / content tác giả **không nằm trong `remove`/`update`** (superset rule).
96
98
  - Set frontmatter `template_version` = current.
97
- - Nếu template có `## Change History` (main artifact) → append entry, operation = `manual`:
99
+ - Main artifact có `## Change History` cuối → append entry, operation = `manual`:
98
100
  ```markdown
99
101
  ### {YYYY-MM-DD} — manual — migrate
100
102
 
@@ -138,12 +140,13 @@ SKIPPED / up-to-date ({n})
138
140
  - Xóa section không nằm trong `migrations.remove` (vi phạm superset).
139
141
  - Tự remap ID / đụng tới artifact khác (migrate là single-artifact, không cascade).
140
142
  - 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).
143
+ - Migrate artifact ngoài scope: bất kỳ file nào trong `.specs/integrations/` (integration artifacts ngoài scope), `.specs/archive`, `.specs/removed` (phải skip / DỪNG).
142
144
  - Migrate artifact đã up-to-date (phải no-op sớm).
143
145
  - Tự cài lại logic detect thay vì dùng audit classify-only.
144
146
 
145
147
  ## Verification
146
148
 
149
+ - [ ] Scope = **chỉ main artifacts** (`.specs/main/**`); arg là integration artifact → DỪNG, no-arg chỉ quét `.specs/main/**`
147
150
  - [ ] Pre-flight: working tree clean (hoặc user confirm khi không phải git repo)
148
151
  - [ ] Detect bằng `/artifact-audit` classify-only, scoped theo target; version `==` → up-to-date → no-op sớm; `!=` → migrate
149
152
  - [ ] Required `##` thiếu → ADD (skeleton từ body template); section `migrations.remove` còn sót → REMOVE (confirm)
@@ -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. Frontmatter lấy `template_version` từ template (xem `conventions.md` §7).
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 copy từ template (plan.md là integration artifact — **không** mang `template_version`; versioning chỉ áp dụng cho main artifacts, 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. Frontmatter lấy `template_version` từ template.
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 copy từ template (todo.md là integration artifact — không mang `template_version`).
132
132
 
133
133
  ---
134
134
 
@@ -146,4 +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 `template_version` copy từ template tương ứng
149
+ - [ ] plan.md + todo.md (integration) KHÔNG mang `template_version` (versioning chỉ cho main artifacts)
@@ -43,6 +43,31 @@ Skill này là cặp greenfield đối xứng với `/spec-brownfield-feature` (
43
43
 
44
44
  ## Process
45
45
 
46
+ ### Pre-flight: chuẩn bị nhánh Git (chạy TRƯỚC Bước 0)
47
+
48
+ Mục tiêu: không bao giờ author frd ngay trên nhánh hiện tại của user (có thể là một nhánh đang làm dở) — luôn bắt đầu từ **nhánh chính mới nhất** rồi tách một **nhánh làm việc riêng**.
49
+
50
+ **Trước tiên, thông báo cho user toàn bộ việc Git skill sẽ làm** (để user biết trước, đúng tinh thần "agent làm các việc này"):
51
+
52
+ > Trước khi author frd, mình sẽ:
53
+ > 1. Pull code mới nhất từ nhánh chính (`{main}`).
54
+ > 2. Tạo & checkout một nhánh mới tách từ `{main}` để làm việc.
55
+ >
56
+ > (Bạn đang ở nhánh `{current}`.)
57
+
58
+ **1. Xác định nhánh chính (`{main}`).**
59
+ - Không phải git repo → bỏ qua toàn bộ pre-flight, note cho user rồi tiếp Bước 0.
60
+ - Có nhánh `develop` → mặc định `{main}` = `develop`. Không có `develop` nhưng có `main`/`master` → dùng nó.
61
+ - Mơ hồ (tồn tại cả `develop` lẫn `main`, hoặc remote default khác) → **hỏi user** nhánh nào là nhánh chính. KHÔNG đoán.
62
+
63
+ **2. Kiểm tra working tree sạch.** `git status` còn thay đổi chưa commit → **DỪNG**, báo user commit/stash trước. KHÔNG tự ý stash/discard.
64
+
65
+ **3. Checkout + pull nhánh chính:** `git checkout {main}` rồi `git pull`. Pull fail (conflict, không có upstream…) → **DỪNG**, surface lỗi cụ thể, để user xử lý.
66
+
67
+ **4. Tạo nhánh làm việc mới off `{main}`.** Cần slug để đặt tên → thực hiện **ngay sau khi xác định feature mục tiêu ở Bước 1c** (xem nhắc ở đó): đề xuất `git checkout -b spec/{F-XXX}-{slug}`, cho user sửa tên rồi tạo. Mọi việc author/cascade từ Bước 2 trở đi diễn ra trên nhánh này.
68
+
69
+ ---
70
+
46
71
  ### Bước 0: Nạp nguồn yêu cầu (tùy chọn)
47
72
 
48
73
  Giống `/spec-prd` Bước 0. Xác định có nguồn baseline cho feature không (proposal, mô tả feature, ghi chú họp, wireframe note):
@@ -106,7 +131,7 @@ Chọn feature để author frd:
106
131
 
107
132
  Kiểm tra `.specs/main/feature/{F-XXX}-*/frd.md`.
108
133
 
109
- - **Chưa tồn tại** → tiếp Bước 2 (author mới).
134
+ - **Chưa tồn tại** → **tạo nhánh làm việc** (Pre-flight bước 4): `git checkout -b spec/{F-XXX}-{slug}` off `{main}` (đề xuất tên, cho user sửa), rồi tiếp Bước 2 (author mới).
110
135
  - **Đã tồn tại** → **DỪNG**, redirect `/spec-new`:
111
136
  > frd.md cho {F-XXX} đã tồn tại. Mọi thay đổi feature đã được spec phải đi qua `/spec-new` — skill đó phân tích delta, cascade lên frd/crd/prd/domain, và kéo theo việc kỹ thuật/test (`/spec-tech`, `/spec-test`).
112
137
  > Chạy: `/spec-new {F-XXX}` (hoặc `/spec-new <mô tả thay đổi>`).
@@ -355,6 +380,7 @@ Bước tiếp theo:
355
380
 
356
381
  ## Verification
357
382
 
383
+ - [ ] **Pre-flight Git**: đã thông báo plan cho user; xác định đúng nhánh chính (hỏi nếu mơ hồ); working tree sạch; đã `checkout {main}` + `pull`; tạo nhánh làm việc mới off `{main}` trước khi author
358
384
  - [ ] `prd.md` tồn tại
359
385
  - [ ] **Single-feature gate**: nguồn liên quan đúng 1 feature; nếu >1 đã DỪNG và mô tả rõ lý do tách + redirect `/spec-prd`
360
386
  - [ ] **Create-only gate**: frd.md của feature mục tiêu CHƯA tồn tại; nếu đã có đã redirect `/spec-new`
@@ -27,6 +27,31 @@ Tạo `spec.md` cho một integration mới trong `.specs/integrations/{NNN}-{sl
27
27
 
28
28
  ## Process
29
29
 
30
+ ### Bước 0 · Pre-flight: chuẩn bị nhánh Git (chạy TRƯỚC Bước 1)
31
+
32
+ Mục tiêu: không bao giờ tạo spec/cascade ngay trên nhánh hiện tại của user (có thể là một nhánh đang làm dở) — luôn bắt đầu từ **nhánh chính mới nhất** rồi tách một **nhánh làm việc riêng** cho integration.
33
+
34
+ **Trước tiên, thông báo cho user toàn bộ việc Git skill sẽ làm** (để user biết trước, đúng tinh thần "agent làm các việc này"):
35
+
36
+ > Trước khi tạo spec, mình sẽ:
37
+ > 1. Pull code mới nhất từ nhánh chính (`{main}`).
38
+ > 2. Tạo & checkout một nhánh mới tách từ `{main}` để làm integration này.
39
+ >
40
+ > (Bạn đang ở nhánh `{current}`.)
41
+
42
+ **1. Xác định nhánh chính (`{main}`).**
43
+ - Không phải git repo → bỏ qua toàn bộ pre-flight, note cho user rồi tiếp Bước 1.
44
+ - Có nhánh `develop` → mặc định `{main}` = `develop`. Không có `develop` nhưng có `main`/`master` → dùng nó.
45
+ - Mơ hồ (tồn tại cả `develop` lẫn `main`, hoặc remote default khác) → **hỏi user** nhánh nào là nhánh chính. KHÔNG đoán.
46
+
47
+ **2. Kiểm tra working tree sạch.** `git status` còn thay đổi chưa commit → **DỪNG**, báo user commit/stash trước. KHÔNG tự ý stash/discard.
48
+
49
+ **3. Checkout + pull nhánh chính:** `git checkout {main}` rồi `git pull`. Pull fail (conflict, không có upstream…) → **DỪNG**, surface lỗi cụ thể, để user xử lý.
50
+
51
+ **4. Tạo nhánh làm việc mới off `{main}`.** Cần `{NNN}-{slug}` để đặt tên → thực hiện **ngay sau khi xác định slug + số thứ tự ở Bước 4** (xem nhắc ở đó): đề xuất `git checkout -b feat/{NNN}-{slug}`, cho user sửa tên rồi tạo. Mọi việc ghi spec + auto-cascade từ Bước 5/7 diễn ra trên nhánh này.
52
+
53
+ ---
54
+
30
55
  ### Bước 1: Xác định input
31
56
 
32
57
  **Nếu có ARGUMENT** → đây là raw requirement, chuyển sang Bước 2.
@@ -156,6 +181,8 @@ Xác định số thứ tự (`NNN`):
156
181
 
157
182
  Output path: `.specs/integrations/{NNN}-{slug}/spec.md`
158
183
 
184
+ **Tạo nhánh làm việc** (Pre-flight bước 4) — giờ đã có `{NNN}-{slug}`: `git checkout -b feat/{NNN}-{slug}` off `{main}` (đề xuất tên, cho user sửa). Bỏ qua nếu không phải git repo (pre-flight đã note).
185
+
159
186
  ---
160
187
 
161
188
  ### Bước 5: Write — sinh draft
@@ -343,7 +370,7 @@ Chỉ tiến hành Bước 7 sau khi user confirm. Nếu user yêu cầu chỉnh
343
370
 
344
371
  Tạo thư mục `.specs/integrations/{NNN}-{slug}/` nếu chưa có.
345
372
 
346
- **[7.1] Ghi spec.md** với status `approved` (không phải `draft` — human đã confirm ở Bước 6 chính là approval). Frontmatter `features` và `components` phải được điền theo những gì đã nhận diện ở Bước 2; `template_version` lấy từ `spec-template.md` (xem `conventions.md` §7).
373
+ **[7.1] Ghi spec.md** với status `approved` (không phải `draft` — human đã confirm ở Bước 6 chính là approval). Frontmatter `features` và `components` phải được điền theo những gì đã nhận diện ở Bước 2. (spec.md là integration artifact — **không** mang `template_version`; versioning chỉ áp dụng cho main artifacts, xem `conventions.md` §7.)
347
374
 
348
375
  **[7.2] Auto-apply mỗi Changes block** vào main artifact tương ứng. Thứ tự apply (để tránh forward reference): `prd.md` → `domain.md` → `sad.md` → `component/*/crd.md` → `feature/*/frd.md`.
349
376
 
@@ -429,6 +456,7 @@ Bước tiếp theo:
429
456
 
430
457
  Trước khi user confirm (Bước 6), kiểm tra:
431
458
 
459
+ - [ ] **Pre-flight Git**: đã thông báo plan cho user; xác định đúng nhánh chính (hỏi nếu mơ hồ); working tree sạch; đã `checkout {main}` + `pull`; tạo nhánh làm việc mới off `{main}` trước khi cascade
432
460
  - [ ] Problem Statement từ góc nhìn user/business, không mention tech
433
461
  - [ ] Mỗi Acceptance Criterion dùng cú pháp GIVEN / WHEN / THEN, có thể test được
434
462
  - [ ] Out of Scope có ít nhất 1 item
@@ -443,4 +471,4 @@ Sau khi user confirm (Bước 7):
443
471
  - [ ] Auto-apply chạy theo thứ tự prd → domain → sad → crd → frd
444
472
  - [ ] Mỗi artifact bị touched có entry mới được append vào `## Change History` (xem `conventions.md` §5.5)
445
473
  - [ ] Fail-safe: nếu apply fail thì không ghi spec.md (rollback luôn Change History entries)
446
- - [ ] Artifact create (spec.md + frd/crd mới) có `template_version` copy từ template; artifact update giữ nguyên version
474
+ - [ ] Main artifact create (frd/crd mới) có `template_version` copy từ template; artifact update giữ nguyên version cũ. spec.md (integration) KHÔNG mang `template_version`
@@ -216,7 +216,7 @@ Chỉ ghi file sau khi user confirm. Nếu user yêu cầu chỉnh sửa → c
216
216
 
217
217
  ### Bước 6: Save + Auto-cascade
218
218
 
219
- **[6.1] Ghi `.specs/integrations/{slug}/tech.md`** với status `approved` (không phải `draft` — human đã confirm ở Bước 5 chính là approval). Frontmatter `features` và `components` mirror từ `spec.md`; `template_version` lấy từ `tech-template.md` (xem `conventions.md` §7).
219
+ **[6.1] Ghi `.specs/integrations/{slug}/tech.md`** với status `approved` (không phải `draft` — human đã confirm ở Bước 5 chính là approval). Frontmatter `features` và `components` mirror từ `spec.md`. (tech.md là integration artifact — **không** mang `template_version`; versioning chỉ áp dụng cho main artifacts, xem `conventions.md` §7.)
220
220
 
221
221
  **[6.2] Auto-apply mỗi Changes block** vào main artifact tương ứng. Thứ tự apply (để tránh forward reference): `sad.md` → `domain.md` → `component/*/cdd.md` → `feature/*/fdd.md`.
222
222
 
@@ -315,4 +315,4 @@ Sau khi user confirm (Bước 6):
315
315
  - [ ] Auto-apply chạy theo thứ tự sad → domain → cdd → fdd
316
316
  - [ ] Mỗi artifact bị touched có entry mới được append vào `## Change History` (conventions §5.5)
317
317
  - [ ] Fail-safe: nếu apply fail thì không ghi tech.md (rollback luôn Change History entries)
318
- - [ ] Artifact create (tech.md + cdd/fdd mới) có `template_version` copy từ template; artifact update giữ nguyên version
318
+ - [ ] Main artifact create (cdd/fdd mới) có `template_version` copy từ template; artifact update giữ nguyên version cũ. tech.md (integration) KHÔNG mang `template_version`
@@ -284,7 +284,7 @@ Chỉ tiến hành Bước 6 sau khi QC confirm.
284
284
 
285
285
  ### Bước 6: Save + Auto-cascade
286
286
 
287
- **[6.1] Ghi `.specs/integrations/{slug}/test.md`** với status `approved` (không phải `draft` — human đã confirm ở Bước 5 chính là approval). Frontmatter `features` mirror từ `spec.md`; `template_version` lấy từ `test-template.md` (xem `conventions.md` §7).
287
+ **[6.1] Ghi `.specs/integrations/{slug}/test.md`** với status `approved` (không phải `draft` — human đã confirm ở Bước 5 chính là approval). Frontmatter `features` mirror từ `spec.md`. (test.md là integration artifact — **không** mang `template_version`; versioning chỉ áp dụng cho main artifacts, xem `conventions.md` §7.)
288
288
 
289
289
  **[6.2] Auto-apply mỗi Changes block** vào `feature/{F-XXX}/tsd.md` tương ứng. Thứ tự apply: theo thứ tự xuất hiện trong frontmatter `features` (deterministic, không có forward reference giữa các feature tsd.md). Bỏ qua feature có operation `no-op` trong Cascade Summary.
290
290
 
@@ -381,4 +381,4 @@ Sau khi QC confirm (Bước 6):
381
381
  - [ ] Mỗi tsd.md bị touched có entry mới trong `## Change History` (conventions §5.5)
382
382
  - [ ] Fail-safe: nếu apply fail thì không ghi integration test.md (rollback luôn Change History entries)
383
383
  - [ ] Mỗi feature tsd.md mới có status `draft` (separate lifecycle)
384
- - [ ] test.md + tsd.md create có `template_version` copy từ template; tsd.md update giữ nguyên version
384
+ - [ ] Main artifact tsd.md create có `template_version` copy từ template; tsd.md update giữ nguyên version cũ. test.md (integration) KHÔNG mang `template_version`
@@ -220,26 +220,26 @@ Nhóm skill dọn dẹp / migrate artifacts hiện có sau khi template được
220
220
 
221
221
  | Command | Reads | Writes |
222
222
  | --- | --- | --- |
223
- | `/artifact-audit [type]` | `.specs/**` artifacts, `.claude/templates/*-template.md` | *(báo cáo; + stamp `template_version` cho artifact legacy conform)* |
224
- | `/artifact-migrate [path]` | `.specs/**` artifacts, `.claude/templates/*-template.md` (block `migrations`) | artifact được migrate (structure + `template_version`) |
223
+ | `/artifact-audit [type]` | `.specs/main/**` artifacts, `.claude/templates/main/*-template.md` | *(báo cáo; + stamp `template_version` cho main artifact legacy conform)* |
224
+ | `/artifact-migrate [path]` | `.specs/main/**` artifacts, `.claude/templates/main/*-template.md` (block `migrations`) | main artifact được migrate (structure + `template_version`) |
225
225
 
226
226
  ### `/artifact-audit [type]`
227
227
 
228
- Phát hiện 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/` — không manifest, không cache.
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.
229
229
 
230
- **Scope:** argument là 1 type (`/artifact-audit frd`) hoặc list (`frd,spec`); không có arg → audit mọi type. Type resolve theo **filename** (integration artifact không có field `type`).
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
 
232
232
  **Phân loại mỗi artifact:**
233
233
  - Có `template_version` → `==`: **up-to-date**; `!=`: **out-dated** `(vX → vY)` → migrate.
234
234
  - Thiếu version (legacy) → presence-check (đủ required `##` + không còn section `migrations.remove`): conform → **stamp** `template_version` (có confirm); lệch → **out-dated** + tóm tắt phần thiếu.
235
235
 
236
- **Ranh giới:** chỉ phát hiện + stamp legacy conform. **KHÔNG migrate** — đổi structure là việc của `/artifact-migrate`. Bỏ qua `.specs/archive/` `.specs/removed/`.
236
+ **Ranh giới:** chỉ phát hiện + stamp legacy conform. **KHÔNG migrate** — đổi structure là việc của `/artifact-migrate`. Bỏ qua toàn bộ `.specs/integrations/`, `.specs/archive/`, `.specs/removed/`.
237
237
 
238
238
  ### `/artifact-migrate [path]`
239
239
 
240
- Migrate artifact lỗi thời lên structure template mới nhất, generic cho mọi type (vế **fix** đối xứng với `/artifact-audit` vế **detect**).
240
+ Migrate **main artifact** lỗi thời lên structure template mới nhất, cho mọi main type (vế **fix** đối xứng với `/artifact-audit` vế **detect**). Integration artifacts ngoài scope.
241
241
 
242
- **Scope:** arg = 1 artifact (path) → migrate riêng nó; không arg → quét toàn bộ, migrate từng cái có confirm + skip.
242
+ **Scope:** arg = 1 main artifact (path) → migrate riêng nó; không arg → quét mọi main artifact trong `.specs/main/`, migrate từng cái có confirm + skip.
243
243
 
244
244
  **Quy trình:** pre-flight git clean → **tự chạy `/artifact-audit` classify-only (scoped)** để phát hiện out-dated (up-to-date → no-op sớm) → đọc block `migrations` của template lấy delta `add`/`remove`/`update` → dry-run + confirm → apply (set `template_version` = current; main artifact thêm Change History `manual`/migrate).
245
245
 
@@ -6,10 +6,6 @@ features: []
6
6
  components: []
7
7
  status: draft
8
8
  created: {YYYY-MM-DD}
9
- template_version: 1
10
- migrations:
11
- - to: 1
12
- note: "baseline"
13
9
  referenced_by:
14
10
  - conventions.md > 4. Integration Artifacts > 4.5 plan.md > Cấu trúc
15
11
  - skills/plan/SKILL.md > Output Format > plan.md
@@ -6,10 +6,6 @@ features: []
6
6
  components: []
7
7
  status: draft
8
8
  created: {YYYY-MM-DD}
9
- template_version: 1
10
- migrations:
11
- - to: 1
12
- note: "baseline"
13
9
  referenced_by:
14
10
  - conventions.md > 4. Integration Artifacts > 4.3 spec.md > Cấu trúc
15
11
  - skills/spec-new/SKILL.md > Process > Bước 5: Write — sinh draft
@@ -6,10 +6,6 @@ features: []
6
6
  components: []
7
7
  status: draft
8
8
  created: {YYYY-MM-DD}
9
- template_version: 1
10
- migrations:
11
- - to: 1
12
- note: "baseline"
13
9
  referenced_by:
14
10
  - conventions.md > 4. Integration Artifacts > 4.4 tech.md > Cấu trúc
15
11
  - skills/spec-tech/SKILL.md > Process > Bước 4: Write — sinh draft
@@ -1,10 +1,6 @@
1
1
  ---
2
2
  slug: "{slug}"
3
3
  created: {YYYY-MM-DD}
4
- template_version: 1
5
- migrations:
6
- - to: 1
7
- note: "baseline"
8
4
  referenced_by:
9
5
  - skills/review-integration/SKILL.md > Bước 2 — Luôn ghi findings vào techdebt.md
10
6
  ---
@@ -5,10 +5,6 @@ title: "{title}"
5
5
  features: []
6
6
  status: draft
7
7
  created: {YYYY-MM-DD}
8
- template_version: 1
9
- migrations:
10
- - to: 1
11
- note: "baseline"
12
8
  referenced_by:
13
9
  - conventions.md > 4. Integration Artifacts > 4.7 test.md > Cấu trúc
14
10
  - skills/spec-test/SKILL.md > Process > Bước 4: Write — sinh draft
@@ -5,10 +5,6 @@ title: "{title}"
5
5
  features: []
6
6
  components: []
7
7
  created: {YYYY-MM-DD}
8
- template_version: 1
9
- migrations:
10
- - to: 1
11
- note: "baseline"
12
8
  referenced_by:
13
9
  - conventions.md > 4. Integration Artifacts > 4.6 todo.md > Cấu trúc
14
10
  - skills/plan/SKILL.md > Output Format > todo.md