spec-lite 1.4.0 → 1.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-lite",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Spec-driven development kit for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,588 @@
1
+ ---
2
+ name: spec-remove
3
+ description: Remove một feature toàn diện — tạo removal integration với Code Inventory, Reverse Dependency Audit, reverse-TDD test strategy, và Finalize Plan (move feature artifacts sang specs/removed/ + đóng ADO tickets) như task cuối trong todo.md. Nhận F-XXX làm argument.
4
+ ---
5
+
6
+ # spec-remove
7
+
8
+ ## Overview
9
+
10
+ Tạo removal integration cho 1 feature đã tồn tại. Output là `spec.md` với đầy đủ:
11
+
12
+ - **Code Inventory** — code, route, DB, feature flag, config liên quan
13
+ - **Reverse Dependency Audit** — ai còn reference, an toàn xoá hay không
14
+ - **Test Strategy** — reverse-TDD (regression test "thing is gone")
15
+ - **Finalize Plan** — move feature artifacts sang `specs/removed/` + đóng ADO tickets, được DEV chạy như task cuối trong `todo.md`
16
+ - **Changes blocks** — `[REMOVE]` markers cho mọi artifact bị touched
17
+
18
+ Skill **không** sinh `tech.md` / `plan.md` / `todo.md`. Sau khi `spec.md` được approve, chạy `/spec-tech` → `/plan` → `/build` như flow thường. `spec.md` đủ giàu để 3 skill đó hoạt động không cần modification.
19
+
20
+ ## When to Use
21
+
22
+ - Một feature đã ship và cần decommission (deprecated, business pivot, replaced by feature khác)
23
+ - Cần xoá toàn bộ code + spec + ADO state một cách an toàn, có audit trail
24
+ - Có nhiều reverse-dep cần được liệt kê và quyết định rõ ràng trước khi xoá
25
+
26
+ ## When NOT to Use
27
+
28
+ - Chỉ muốn xoá 1 US / 1 AC / 1 VR khỏi feature → dùng `/spec-new` với marker `[REMOVE]` cho item đó. Feature vẫn sống.
29
+ - Feature chưa từng được implement (chỉ có frd.md, chưa có code) → dùng `/spec-new` với block `[REMOVE]` cho frd.md, không cần workflow này.
30
+ - Muốn pause / disable tạm thời mà giữ code → đây không phải removal, dùng feature flag thay vì skill này.
31
+
32
+ ---
33
+
34
+ ## Prerequisites
35
+
36
+ - `specs/main/feature/{F-XXX}-*/frd.md` tồn tại
37
+ - `specs/main/prd.md` có row của feature trong Feature Index
38
+ - (Optional) `.claude/ado.yaml` cấu hình nếu muốn đóng ADO tickets ở finalize step
39
+
40
+ ---
41
+
42
+ ## Process
43
+
44
+ ### Bước 1: Validate argument
45
+
46
+ Argument BẮT BUỘC là Feature ID dạng `F-XXX` (3 chữ số). Nếu argument thiếu hoặc sai format → dừng:
47
+
48
+ ```
49
+ spec-remove cần Feature ID. Ví dụ: /spec-remove F-001
50
+ ```
51
+
52
+ Tìm thư mục `specs/main/feature/F-XXX-*/`:
53
+ - 0 matches → báo lỗi feature không tồn tại, dừng.
54
+ - ≥ 2 matches → báo lỗi data inconsistency (nhiều thư mục cùng prefix), dừng.
55
+ - 1 match → tiếp.
56
+
57
+ Đọc `frd.md` frontmatter:
58
+ - Nếu `status: removed` → hỏi:
59
+
60
+ ```
61
+ F-XXX đã có status `removed`. Bạn muốn:
62
+ [1] Re-finalize (move artifacts + close ADO lại, idempotent)
63
+ [2] Tạo removal integration mới (có thể bạn chưa cleanup code lần trước)
64
+ [3] Hủy
65
+ ```
66
+
67
+ ---
68
+
69
+ ### Bước 2: Load context
70
+
71
+ Đọc các file sau:
72
+
73
+ **Bắt buộc:**
74
+ - `specs/main/feature/{F-XXX}-*/frd.md` — full content
75
+ - `specs/main/feature/{F-XXX}-*/fdd.md` — nếu tồn tại
76
+ - `specs/main/prd.md` — Feature Index (capture ADO ticket ID cho F-XXX), Component Index, NFR
77
+ - `specs/main/domain.md` — Glossary + Shared Entities (xác định entity nào owned bởi component thuộc F-XXX)
78
+
79
+ **Components used by F-XXX:**
80
+
81
+ Trích từ `frd.md` section `Components Used` + `fdd.md` section `Components Touched`. Với mỗi C-YYY:
82
+ - `specs/main/component/{C-YYY}-*/crd.md`
83
+ - `specs/main/component/{C-YYY}-*/cdd.md` — nếu tồn tại
84
+
85
+ **Reverse dependency scan:**
86
+
87
+ Với mỗi C-YYY mà F-XXX sử dụng, grep `specs/main/feature/F-*/frd.md` (trừ F-XXX) tìm references tới C-YYY. Mọi feature khác có reference → load `frd.md` của feature đó để hiểu nó dùng C-YYY làm gì.
88
+
89
+ Output context summary cho user:
90
+
91
+ ```
92
+ F-XXX — {feature title}
93
+ Status: {Done/In Progress/...}
94
+ ADO: #{ticket_id} ({current state}) {nếu prd.md có cột ADO}
95
+
96
+ Components dùng bởi F-XXX:
97
+ - C-YYY-{slug} — {role} ({exclusive | shared with F-AAA, F-BBB})
98
+ - ...
99
+
100
+ Reverse-dep features (dùng chung component với F-XXX):
101
+ ⚠ F-AAA {title} — dùng C-YYY {interface_name}
102
+ ⚠ F-BBB {title} — dùng C-ZZZ {interface_name}
103
+ {hoặc} ✓ Không có reverse-dep — F-XXX hoàn toàn cô lập
104
+
105
+ Glossary terms từ domain.md tham chiếu trong F-XXX:
106
+ - {term} {(unique to F-XXX | shared)}
107
+ - ...
108
+
109
+ Shared entities owned bởi components của F-XXX:
110
+ - {Entity} (Owner: C-YYY) — {used by F-XXX only | also F-AAA}
111
+ - ...
112
+ ```
113
+
114
+ ---
115
+
116
+ ### Bước 3: Interview ngắn
117
+
118
+ Hỏi 2 câu, tuần tự:
119
+
120
+ **3.1 — Lý do remove:**
121
+
122
+ ```
123
+ Lý do remove F-XXX? (sẽ ghi vào Change History + ADO closure comment)
124
+ > ___
125
+ ```
126
+
127
+ **3.2 — Removal strategy:**
128
+
129
+ Dùng `AskUserQuestion`:
130
+
131
+ ```
132
+ Removal strategy:
133
+ [1] Single-shot — xoá hết trong 1 deploy. Phù hợp khi feature off-traffic, internal-only, không có DB schema lớn.
134
+ [2] Phased — disable trước (feature flag off + deprecation banner), soak period, sau đó xoá code. Phù hợp khi có DB / external API / traffic gradual.
135
+ [3] Phased + drop schema riêng — như Phased nhưng tách thêm 1 integration cho DROP TABLE/COLUMN sau khi code đã xoá và observed.
136
+ ```
137
+
138
+ Nếu chọn `[2]` hoặc `[3]` → hỏi soak period (1-2 tuần là baseline):
139
+
140
+ ```
141
+ Soak period giữa các phase (ngày)?
142
+ > ___
143
+ ```
144
+
145
+ Phased và Phased+drop schema → ghi nhận để Bước 6 (sinh draft) có Removal Phases section.
146
+
147
+ ---
148
+
149
+ ### Bước 4: Code Discovery
150
+
151
+ Mục tiêu: build **Code Inventory** — danh sách code cụ thể sẽ bị xoá.
152
+
153
+ **Nguồn discovery (kết hợp):**
154
+
155
+ 1. **fdd.md / cdd.md** — nếu artifact có ghi file path / module path cụ thể trong section như "Implementation Notes" → dùng làm seed trực tiếp.
156
+ 2. **Component slug** — search filesystem cho directory matching `{C-YYY}-{slug}` (kebab) hoặc camelCase variant.
157
+ 3. **Public Interface signatures** — từ `crd.md` Public Interface, lấy function/class/endpoint name → grep codebase.
158
+ 4. **Route paths** — từ `frd.md` User Flows / `fdd.md` sequence diagrams, extract API path patterns (`/api/...`) → grep route registrations.
159
+ 5. **Owned Entities** — từ `domain.md` Shared Entities (owned bởi component của F-XXX), table name → grep migrations + queries.
160
+ 6. **Feature flag names** — nếu được nhắc trong artifact → grep config files.
161
+ 7. **Test files** — sau khi xác định module paths, grep `tests/` cho cùng prefix / cùng tên.
162
+
163
+ **Tools:** `Grep`, `Glob`, `Bash` (`rg`, `find`). Khi không chắc filesystem layout, hỏi user 1 câu: "Codebase root ở `src/` hay project có monorepo structure khác?"
164
+
165
+ **Output Code Inventory** dạng table, group theo category:
166
+
167
+ ```
168
+ Code Inventory for F-XXX:
169
+
170
+ ROUTES / API ENDPOINTS:
171
+ [1] POST /api/auth/login → src/routes/auth.ts:12-50
172
+ [2] POST /api/auth/logout → src/routes/auth.ts:52-80
173
+ [3] POST /api/auth/refresh → src/routes/auth.ts:82-115
174
+
175
+ SOURCE MODULES:
176
+ [4] src/services/auth/ → entire directory (8 files)
177
+ [5] src/middleware/auth-token.ts
178
+ [6] src/utils/jwt.ts → ⚠ also used by F-007 (reverse-dep)
179
+
180
+ TESTS:
181
+ [7] tests/auth/ → 12 files
182
+ [8] tests/integration/auth-flow.test.ts
183
+
184
+ DATABASE:
185
+ [9] table `sessions` → migration drop_sessions.sql cần tạo
186
+ [10] table `refresh_tokens` → migration cần tạo
187
+ [11] users.last_login_at column → ⚠ used by F-007 analytics
188
+
189
+ FEATURE FLAGS:
190
+ [12] ff_new_auth → src/config/flags.ts:12
191
+
192
+ CONFIG / ENV:
193
+ [13] AUTH_SECRET, AUTH_TTL → .env.example, src/config/index.ts
194
+
195
+ OTHER (best-effort, manual verify):
196
+ - Grafana dashboard "Auth metrics" — không scan được tự động, BA verify tay
197
+ - Docs site có section /docs/auth/ — verify tay
198
+ ```
199
+
200
+ Mỗi item có thể là `safe` (xanh) hoặc `⚠ has external ref` (cần quyết định ở Bước 5).
201
+
202
+ ---
203
+
204
+ ### Bước 5: Reverse Dependency Audit
205
+
206
+ Với mỗi item trong Code Inventory, grep external references (ngoài thư mục chính của F-XXX). Mọi reference `⚠` cần user quyết định.
207
+
208
+ ```
209
+ Reverse-dep audit:
210
+
211
+ [6] src/utils/jwt.ts
212
+ External refs found:
213
+ - src/services/admin/sessions.ts:34 — imports `verifyJWT`
214
+ - src/services/api-gateway/auth-check.ts:12 — imports `signJWT`
215
+
216
+ Quyết định:
217
+ [a] Keep file — không xoá src/utils/jwt.ts (chỉ xoá phần exclusive của F-XXX bên trong nếu có)
218
+ [b] Migrate consumer first — abort removal, tạo integration migration F-007 + api-gateway sang alternative trước
219
+ [c] Remove anyway — xoá luôn, downstream tự fix (rủi ro cao, cần justify)
220
+ Chọn: ___
221
+
222
+ [11] users.last_login_at column
223
+ External refs found:
224
+ - src/analytics/login-tracking.ts:88 — SELECT this column
225
+ Quyết định: ___
226
+ ```
227
+
228
+ Mọi item `⚠` đều phải có quyết định trước khi sang Bước 6. Nếu user chọn `[b]` cho bất kỳ item nào → dừng skill, instruct:
229
+
230
+ ```
231
+ F-XXX chưa thể remove vì có reverse-dep chưa migrate:
232
+ - {item} blocked by {consumer}
233
+
234
+ Tạo integration migration trước:
235
+ /spec-new "Migrate {consumer} away from {item}"
236
+
237
+ Sau khi migration deploy xong, chạy lại /spec-remove F-XXX.
238
+ ```
239
+
240
+ ---
241
+
242
+ ### Bước 6: Sinh draft spec.md
243
+
244
+ Xác định slug và NNN giống `/spec-new`:
245
+ - Slug: `remove-{f-xxx-slug}` (ví dụ `remove-f001-authentication`)
246
+ - NNN: max của thư mục hiện có trong `specs/integrations/` + 1, format 3 chữ số.
247
+
248
+ Output path: `specs/integrations/{NNN}-remove-{f-xxx-slug}/spec.md`
249
+
250
+ Cấu trúc spec.md:
251
+
252
+ ```markdown
253
+ ---
254
+ id: "{NNN}"
255
+ slug: "remove-{f-xxx-slug}"
256
+ title: "Remove {F-XXX} {feature title}"
257
+ features: [{F-XXX}]
258
+ components: [{C-YYY list những component bị touched}]
259
+ status: approved
260
+ removal: true
261
+ created: {YYYY-MM-DD}
262
+ ---
263
+
264
+ ## Context
265
+ {tóm tắt frd/fdd/components/reverse-deps đã load ở Bước 2}
266
+
267
+ ## Problem Statement
268
+ {lý do remove từ Bước 3.1 — ghi từ góc nhìn business/product, không phải tech}
269
+
270
+ ## Removal Strategy
271
+ {Single-shot | Phased | Phased + schema drop} — chi tiết theo lựa chọn:
272
+
273
+ ### Phase 1: Disable (chỉ khi Phased)
274
+ - Tắt feature flag `ff_xxx`
275
+ - Deprecation banner trên UI (nếu user-facing)
276
+ - Telemetry warning log mỗi lần feature được hit
277
+ - Soak: {N} ngày, monitor traffic = 0
278
+
279
+ ### Phase 2: Remove code
280
+ - Xoá code per Code Inventory dưới
281
+ - Regression tests (xem Test Strategy)
282
+
283
+ ### Phase 3: Drop schema (chỉ khi Phased + schema drop)
284
+ - Tạo integration riêng sau {N} ngày Phase 2 deployed
285
+ - Migration DROP TABLE / DROP COLUMN
286
+
287
+ ## Code Inventory
288
+ {copy table từ Bước 4, đã loại bỏ các item user quyết định `[a] Keep`}
289
+
290
+ ## Reverse Dependency Audit
291
+ {liệt kê mỗi item ⚠ + quyết định user đã chọn, kèm lý do/justify}
292
+
293
+ ## Test Strategy (Reverse-TDD)
294
+
295
+ Pattern cho mỗi target:
296
+
297
+ 1. **Baseline check (trước khi xoá):** ghi nhận test hiện có hoặc viết quick smoke test xác nhận thing exists và functional. Mục đích: confirm mental model trước khi xoá.
298
+
299
+ 2. **Delete trong 1 commit:**
300
+ - Xoá source code
301
+ - Xoá test files cũ tương ứng
302
+ - Update import statements
303
+
304
+ 3. **Regression assertion (sau khi xoá):** thêm test khẳng định thing is gone:
305
+ - Route → assert GET/POST trả 404 (hoặc proper error code)
306
+ - Exported function/class → assert import fails (compile-time check, không cần runtime test)
307
+ - DB table/column → migration test confirm DROP applied, query trả error
308
+ - Feature flag → assert flag key không tồn tại trong config
309
+
310
+ 4. **Full suite run:** mọi test khác phải pass. Nếu có test fail → reverse-dep chưa detect đủ, rollback commit, audit lại.
311
+
312
+ Regression tests **được giữ lại** trong codebase như guardrail — future-self không vô tình re-add feature đã removed.
313
+
314
+ ## Finalize Plan
315
+
316
+ Đây là **task cuối** trong todo.md (sẽ được /plan tự nhặt). DEV thực thi sau khi mọi removal task khác xong và đã deploy verify.
317
+
318
+ ### Actions:
319
+
320
+ 1. **Move feature artifacts:**
321
+ ```bash
322
+ mkdir -p specs/removed
323
+ mv specs/main/feature/{F-XXX}-{slug}/ specs/removed/{F-XXX}-{slug}/
324
+ ```
325
+
326
+ 2. **Append Change History** vào `specs/removed/{F-XXX}-{slug}/frd.md` (nếu file còn tồn tại sau move):
327
+ ```markdown
328
+ ### {YYYY-MM-DD} — [{NNN}-remove-{slug}](../../integrations/{NNN}-remove-{slug}/spec.md) — removed
329
+ - **Feature decommissioned**: moved from specs/main/feature/ to specs/removed/
330
+ - Reason: {lý do từ Problem Statement}
331
+ ```
332
+
333
+ 3. **Update prd.md Feature Index:**
334
+ - Row F-XXX: status → `Removed`
335
+ - Add note column hoặc inline: `(see specs/removed/{F-XXX}-{slug}/)`
336
+
337
+ 4. **Close ADO tickets** (nếu prd.md có ADO ticket ID cho F-XXX):
338
+ - Feature ticket → state `Removed`
339
+ - Tất cả User Story tickets thuộc F-XXX → state `Removed`
340
+ - Comment trên mỗi ticket: "Decommissioned per integration {NNN}-remove-{slug}. Reason: {lý do}"
341
+ - Dùng `mcp__azure-devops__wit_update_work_item` (state) + `mcp__azure-devops__wit_add_work_item_comment` (comment)
342
+ - Nếu ADO state name khác (vd "Closed") → xem `.claude/ado.yaml` hoặc fetch từ `wit_get_work_item_type`
343
+
344
+ 5. **Verify finalize:**
345
+ - `ls specs/main/feature/ | grep {F-XXX}` → không còn match
346
+ - `ls specs/removed/{F-XXX}-{slug}/` → tồn tại
347
+ - prd.md grep `F-XXX` → status `Removed`
348
+ - ADO ticket fetch → state khớp
349
+
350
+ ## Changes
351
+ <!-- Changes blocks theo format chuẩn của spec-template.md, áp dụng cho mọi artifact bị touched. Xem markers [NEW]/[MODIFY {field}]/[REMOVE] theo conventions §5.5. -->
352
+
353
+ ### prd.md
354
+ **Operation:** update
355
+ **Format reference:** [prd-template.md](../../templates/main/prd-template.md)
356
+
357
+ #### Features (Feature Index)
358
+ - Row [MODIFY status]: `F-XXX` {current status} → `Removed`
359
+ - {nếu có note column} Row [MODIFY note]: `F-XXX` add note "see specs/removed/"
360
+
361
+ #### Components (Component Index) — chỉ component exclusive với F-XXX
362
+ - Row [MODIFY status]: `C-YYY` {current status} → `Removed`
363
+ - ... (component shared thì KHÔNG đổi status)
364
+
365
+ ### feature/{F-XXX}-{slug}/frd.md
366
+ **Operation:** update
367
+ **Format reference:** [frd-template.md](../../templates/main/feature/frd-template.md)
368
+
369
+ <!--
370
+ Đánh dấu mọi item bằng [REMOVE]. File sẽ bị move sang specs/removed/ ở Finalize step
371
+ nhưng cascade content vẫn ghi vào file gốc trước (để Change History entry được apply).
372
+ -->
373
+
374
+ #### User Stories
375
+ - US-FXXX-001 [REMOVE] — feature decommissioned
376
+ - US-FXXX-002 [REMOVE] — feature decommissioned
377
+ - ... (mọi US)
378
+
379
+ #### Acceptance Criteria
380
+ - AC-FXXX-* [REMOVE] — feature decommissioned
381
+
382
+ #### Verification Rules
383
+ - VR-FXXX-* [REMOVE] — feature decommissioned
384
+
385
+ #### Frontmatter
386
+ - [MODIFY status]: `draft|approved|...` → `removed`
387
+
388
+ ### feature/{F-XXX}-{slug}/fdd.md *(nếu tồn tại)*
389
+ **Operation:** update
390
+ **Format reference:** [fdd-template.md](../../templates/main/feature/fdd-template.md)
391
+
392
+ #### Flow Sequences
393
+ - [REMOVE] FS-FXXX-* — feature decommissioned
394
+
395
+ #### Data Models
396
+ - [REMOVE] {model} — feature decommissioned
397
+
398
+ #### Frontmatter
399
+ - [MODIFY status]: → `removed`
400
+
401
+ ### component/{C-YYY}-{slug}/crd.md *(lặp cho mỗi component bị touched)*
402
+ **Operation:** update
403
+ **Format reference:** [crd-template.md](../../templates/main/component/crd-template.md)
404
+
405
+ <!--
406
+ Component exclusive với F-XXX:
407
+ - Toàn bộ sections [REMOVE]
408
+ - Frontmatter status → removed
409
+
410
+ Component shared (vẫn còn feature khác dùng):
411
+ - Chỉ [REMOVE] những Public Interface / Responsibility / Owned Entity
412
+ chỉ phục vụ F-XXX (đã audit ở Bước 5)
413
+ - Giữ nguyên phần còn lại
414
+ - Frontmatter status KHÔNG đổi
415
+ -->
416
+
417
+ #### Public Interface
418
+ - {interface} [REMOVE] — only used by F-XXX, no other consumer
419
+
420
+ #### Owned Entities
421
+ - {Entity} [REMOVE] — exclusive to F-XXX
422
+
423
+ ### domain.md
424
+ **Operation:** update
425
+ **Format reference:** [domain-template.md](../../templates/main/domain-template.md)
426
+
427
+ #### Glossary
428
+ - {term} [REMOVE] — unique to F-XXX, no other reference
429
+
430
+ #### Shared Entities
431
+ - {Entity} [REMOVE] — orphan after F-XXX removal, no other component owns
432
+
433
+ ## Out of Scope
434
+ - {Migration của reverse-dep features tới alternative — separate integration nếu có}
435
+ - {Documentation site cleanup — manual task ngoài integration}
436
+ - {Grafana dashboard cleanup — manual task}
437
+
438
+ ## Cascade Summary
439
+
440
+ | Artifact | Operation | Summary |
441
+ | --- | --- | --- |
442
+ | `prd.md` | update | F-XXX status → Removed; {N} components status → Removed |
443
+ | `feature/F-XXX-*/frd.md` | update | All items [REMOVE]; status → removed; folder move tại Finalize |
444
+ | `feature/F-XXX-*/fdd.md` | update | All items [REMOVE]; status → removed |
445
+ | `component/C-YYY-*/crd.md` | update | All [REMOVE] (exclusive) / {N} items [REMOVE] (shared) |
446
+ | `domain.md` | update | {N} glossary [REMOVE], {N} entity [REMOVE] |
447
+ ```
448
+
449
+ ---
450
+
451
+ ### Bước 7: Review — xác nhận với user
452
+
453
+ Hiển thị toàn bộ draft. Hỏi:
454
+
455
+ ```
456
+ Draft trên đã đúng chưa?
457
+ - Code Inventory đầy đủ và chính xác?
458
+ - Reverse-dep audit đã quyết định hết các ⚠?
459
+ - Removal Strategy phù hợp (single-shot vs phased)?
460
+ - Finalize Plan đủ steps?
461
+ - Changes blocks dùng [REMOVE] đúng chỗ (exclusive vs shared)?
462
+
463
+ Sau khi confirm, agent sẽ auto-apply Changes blocks lên main artifacts.
464
+ File feature artifacts (frd/fdd) KHÔNG bị move ngay — chỉ apply [REMOVE] markers
465
+ + Change History entry. Move sang specs/removed/ là task cuối trong todo.md,
466
+ do /build chạy sau khi mọi deletion task khác xong.
467
+ ```
468
+
469
+ Chỉ tiến hành Bước 8 sau khi user confirm.
470
+
471
+ ---
472
+
473
+ ### Bước 8: Save + Auto-cascade
474
+
475
+ Giống `/spec-new` Bước 7, nhưng với removal-specific extensions.
476
+
477
+ **[8.1] Ghi spec.md** với status `approved`, `removal: true` trong frontmatter. Frontmatter `features` chứa F-XXX, `components` chứa list components touched.
478
+
479
+ **[8.2] Auto-apply Changes blocks** vào main artifacts. Thứ tự: `prd.md` → `domain.md` → `sad.md` → `component/*/crd.md` → `component/*/cdd.md` → `feature/F-XXX-*/frd.md` → `feature/F-XXX-*/fdd.md`.
480
+
481
+ Áp dụng marker [REMOVE] theo conventions §5.5:
482
+ - Xoá item khỏi artifact, ID không tái sử dụng, không renumber.
483
+ - Khi toàn bộ items trong frd/fdd của F-XXX bị [REMOVE] → đổi frontmatter `status: removed`.
484
+
485
+ **[8.3] Append Change History entry** vào mọi artifact bị touched (conventions §5.5). Entry format chuẩn:
486
+
487
+ ```markdown
488
+ ### {YYYY-MM-DD} — [{NNN}-remove-{slug}](../../integrations/{NNN}-remove-{slug}/spec.md) — update
489
+
490
+ - **{Section name}**:
491
+ - [REMOVE] {ID/item} — feature decommissioned ({lý do ngắn})
492
+ ```
493
+
494
+ **[8.4] Side-effects:**
495
+
496
+ - Trong prd.md: row F-XXX status đổi `Removed` ngay (không chờ finalize). Lý do: spec.md đã approved tức là quyết định removal đã được ký, status reflect quyết định ngay.
497
+ - ADO tickets KHÔNG transition ngay. Chỉ transition khi DEV chạy task Finalize ở `/build`. Lý do: tránh case rollback removal sau khi spec approve nhưng chưa deploy.
498
+ - File feature/F-XXX-*/ KHÔNG move ngay. Lý do giống ADO — chỉ move sau khi code thật đã xoá và verified.
499
+
500
+ **[8.5] Thông báo kết quả:**
501
+
502
+ ```
503
+ ✓ specs/integrations/{NNN}-remove-{f-xxx-slug}/spec.md đã được tạo (status: approved, removal: true)
504
+
505
+ Auto-cascade applied:
506
+ ✓ prd.md — F-XXX status → Removed; {N} components status → Removed
507
+ ✓ domain.md — {N} glossary/entity [REMOVE]
508
+ ✓ component/C-YYY-*/crd.md — {summary}
509
+ ✓ feature/F-XXX-*/frd.md — all items [REMOVE], status → removed
510
+ ✓ feature/F-XXX-*/fdd.md — all items [REMOVE], status → removed
511
+
512
+ ⚠ File feature/F-XXX-*/ vẫn ở specs/main/feature/. Sẽ được move sang specs/removed/ ở task cuối todo.md.
513
+ ⚠ ADO tickets giữ nguyên state. Sẽ được close ở task cuối todo.md (cần .claude/ado.yaml).
514
+
515
+ Bước tiếp theo:
516
+ /spec-tech → thiết kế delete order, migration SQL, regression test cases
517
+ /plan → break down deletion tasks + finalize task cuối
518
+ /build → execute deletion + finalize
519
+ ```
520
+
521
+ **Nếu apply fail** (markers reference ID không tồn tại, reverse-dep audit chưa hoàn tất, file không ghi được) → dừng, báo lỗi cụ thể, **không** ghi spec.md. Yêu cầu user fix draft.
522
+
523
+ ---
524
+
525
+ ## Downstream Integration (informational)
526
+
527
+ Skill này chỉ sinh `spec.md`. Để biết các skill sau xử lý removal flavor như nào:
528
+
529
+ - **`/spec-tech`** đọc `spec.md`, thấy `removal: true` + Code Inventory + Test Strategy + Finalize Plan → sinh `tech.md` với:
530
+ - Section "Delete Order" liệt kê file paths theo Code Inventory
531
+ - Section "Migration SQL" nếu có DB target (DROP + rollback)
532
+ - Section "Regression Tests" theo Test Strategy pattern
533
+ - Section "Finalize Task" passthrough nguyên xi từ spec.md Finalize Plan
534
+
535
+ - **`/plan`** đọc cả spec.md + tech.md → sinh `plan.md` + `todo.md`. Task cuối todo.md = Finalize task với 5 sub-actions như Finalize Plan của spec.md.
536
+
537
+ - **`/build`** chạy tuần tự todo.md. Khi tới Finalize task:
538
+ - Move folder bằng shell mv
539
+ - Edit prd.md
540
+ - Append Change History
541
+ - Gọi ADO API để transition tickets (cần `.claude/ado.yaml` configured)
542
+ - Verify outputs
543
+
544
+ Nếu `/spec-tech` hoặc `/plan` hiện tại chưa nhặt được removal flavor → có thể cần update sau (separate work). Trong v1, spec.md đủ rõ ràng để 2 skill đó produce reasonable output kể cả không có removal-awareness explicit.
545
+
546
+ ---
547
+
548
+ ## Common Rationalizations
549
+
550
+ | Rationalization | Reality |
551
+ | --- | --- |
552
+ | "Grep nhanh, không cần Code Inventory chi tiết" | Inventory sót item = code chết nằm trong repo vô thời hạn. Audit trail mất. |
553
+ | "Reverse-dep nhỏ thôi, xoá luôn rồi fix sau" | Một import dangling phá CI cả team. Audit trước rẻ hơn rollback. |
554
+ | "Feature flag off là xong, không cần xoá code" | Code dead vẫn phải maintain (security patch, dependency upgrade). Xoá hẳn mới sạch. |
555
+ | "Single-shot cho nhanh, soak period làm gì" | Có DB / external traffic mà single-shot = rollback đắt khi phát hiện consumer chưa migrate. |
556
+ | "Skip Finalize, để folder ở main feature là được" | Active dir bị noise. Sau 5 features removed, không phân biệt được active vs dead. |
557
+
558
+ ## Red Flags
559
+
560
+ - Code Inventory empty hoặc chỉ có 1-2 file cho 1 feature đã ship → discovery chưa đủ rộng, xem lại sources
561
+ - Reverse-dep audit không có ⚠ nào cho component shared → grep chưa đủ kỹ
562
+ - Removal Strategy single-shot nhưng có DB schema lớn hoặc external traffic > 0 → cân nhắc Phased
563
+ - Test Strategy chỉ có "delete code" mà không có regression test → future re-add risk
564
+ - Finalize Plan thiếu ADO closure mà prd.md có ticket ID → audit trail không đầy đủ
565
+ - Changes block frd.md mark [REMOVE] nhưng không đổi `status: removed` trong frontmatter → inconsistent state
566
+
567
+ ## Verification
568
+
569
+ Trước khi user confirm (Bước 7):
570
+
571
+ - [ ] Code Inventory liệt kê đủ 7 category (route / module / test / DB / flag / config / other)
572
+ - [ ] Mỗi item ⚠ trong Reverse-dep audit đã có quyết định rõ ràng (a/b/c)
573
+ - [ ] Nếu có item chọn `[b] Migrate first` → skill đã dừng, không tạo spec
574
+ - [ ] Removal Strategy match scale: single-shot cho nhỏ, phased cho lớn
575
+ - [ ] Test Strategy có 4 sub-step: baseline / delete / regression / full-suite
576
+ - [ ] Finalize Plan có 5 actions: move folder / change history / prd update / ADO close / verify
577
+ - [ ] Changes blocks: exclusive component → all [REMOVE]; shared component → chỉ items của F-XXX [REMOVE]
578
+ - [ ] frd.md / fdd.md frontmatter có [MODIFY status] → removed
579
+
580
+ Sau khi user confirm (Bước 8):
581
+
582
+ - [ ] spec.md frontmatter `removal: true`
583
+ - [ ] Auto-cascade chạy đúng thứ tự prd → domain → sad → crd → cdd → frd → fdd
584
+ - [ ] Mọi artifact bị touched có Change History entry
585
+ - [ ] prd.md row F-XXX status = Removed (đổi ngay sau approve)
586
+ - [ ] File feature/F-XXX-*/ VẪN ở specs/main/feature/ (chưa move — chỉ move ở Finalize task)
587
+ - [ ] ADO tickets KHÔNG bị transition (chưa close — chỉ close ở Finalize task)
588
+ - [ ] Notification cuối ghi rõ 2 ⚠ về việc folder + ADO chưa được động vào