@qijenchen/design-system 0.1.0-beta.72 → 0.1.0-beta.74

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 (43) hide show
  1. package/dist/components/AppShell/_demo-helpers.d.ts.map +1 -1
  2. package/ds-canonical/fork/governance.lock +106 -2
  3. package/ds-canonical/fork/launchers/inject_fork_governance_preamble.sh +8 -0
  4. package/ds-canonical/fork/manifest.json +15 -1
  5. package/ds-canonical/fork/skills/bug-fix-rhythm/SKILL.md +183 -0
  6. package/ds-canonical/fork/skills/code-quality-audit/SKILL.md +65 -0
  7. package/ds-canonical/fork/skills/delivery-handoff/SKILL.md +229 -0
  8. package/ds-canonical/fork/skills/delivery-handoff/references/flow-diagram.md +180 -0
  9. package/ds-canonical/fork/skills/delivery-handoff/references/handoff-template.md +177 -0
  10. package/ds-canonical/fork/skills/delivery-handoff/references/inventory-checklist.md +196 -0
  11. package/ds-canonical/fork/skills/performance-audit/SKILL.md +107 -0
  12. package/ds-canonical/fork/skills/product-ui-audit/SKILL.md +232 -0
  13. package/ds-canonical/fork/skills/product-ui-audit/references/audit-checks.md +246 -0
  14. package/ds-canonical/fork/skills/product-ui-audit/references/common-misuses.md +329 -0
  15. package/ds-canonical/fork/skills/product-ui-audit/references/report-template.md +159 -0
  16. package/ds-canonical/fork/skills/propose-options/SKILL.md +177 -0
  17. package/ds-canonical/fork/skills/prototype/SKILL.md +244 -0
  18. package/ds-canonical/fork/skills/prototype/references/audit-checks.md +38 -0
  19. package/ds-canonical/fork/skills/prototype/references/benchmark-sources.md +94 -0
  20. package/ds-canonical/fork/skills/prototype/references/checkpoints.md +191 -0
  21. package/ds-canonical/fork/skills/prototype/references/evaluation-matrix.md +141 -0
  22. package/ds-canonical/fork/skills/prototype/references/ooux-template.md +198 -0
  23. package/ds-canonical/fork/skills/prototype/references/proposal-template.md +229 -0
  24. package/ds-canonical/fork/skills/scan-similar-bugs/SKILL.md +200 -0
  25. package/ds-canonical/fork/skills/ux-audit/SKILL.md +130 -0
  26. package/ds-canonical/fork/skills/visual-audit/SKILL.md +247 -0
  27. package/ds-canonical/fork/skills/visual-audit/output/.gitkeep +0 -0
  28. package/ds-canonical/fork/skills/visual-audit/references/audit-architecture.md +101 -0
  29. package/ds-canonical/fork/skills/visual-audit/references/visual-checklist.md +297 -0
  30. package/ds-canonical/fork/skills/visual-audit/references/world-class-benchmarks.md +198 -0
  31. package/ds-canonical/hooks/check_plugin_fork_health.sh +2 -2
  32. package/ds-canonical/hooks/lib/_app_shell_primary_header_consistency.sh +36 -6
  33. package/ds-canonical/hooks/session_start_governance_check.sh +1 -1
  34. package/ds-canonical/hooks/tests/test_check_app_shell_primary_header_consistency.sh +58 -2
  35. package/ds-canonical/skills/design-system-audit/SKILL.md +2 -2
  36. package/llms-full.txt +1 -1
  37. package/llms.txt +1 -1
  38. package/package.json +1 -1
  39. package/src/components/AppShell/_demo-helpers.tsx +25 -1
  40. package/src/components/AppShell/app-shell.principles.stories.tsx +3 -2
  41. package/src/components/AppShell/app-shell.spec.md +12 -7
  42. package/src/components/AppShell/app-shell.stories.tsx +6 -0
  43. package/src/components/Sidebar/sidebar.spec.md +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"_demo-helpers.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/_demo-helpers.tsx"],"names":[],"mappings":"AAiDA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;EAOX,CAAA;AAqBV,eAAO,MAAM,cAAc,+CAM1B,CAAA;AAID,eAAO,MAAM,UAAU,+CAuBtB,CAAA;AAQD,wBAAgB,WAAW,CAAC,EAC1B,gBAAgB,EAChB,qBAA4B,EAC5B,iBAAwB,GACzB,GAAE;IACD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,iBAAiB,CAAC,EAAE,OAAO,CAAA;CACvB,2CAkCL;AAWD,wBAAgB,WAAW,4CAyB1B;AAQD,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,GAAE;IAAE,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAO,2CAY/E;AASD,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,qBAA4B,GAC7B,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,2CAOA"}
1
+ {"version":3,"file":"_demo-helpers.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/_demo-helpers.tsx"],"names":[],"mappings":"AAmDA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;EAOX,CAAA;AAqBV,eAAO,MAAM,cAAc,+CAM1B,CAAA;AAID,eAAO,MAAM,UAAU,+CAuBtB,CAAA;AAQD,wBAAgB,WAAW,CAAC,EAC1B,gBAAgB,EAChB,qBAA4B,EAC5B,iBAAwB,GACzB,GAAE;IACD,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,iBAAiB,CAAC,EAAE,OAAO,CAAA;CACvB,2CAwDL;AAWD,wBAAgB,WAAW,4CAyB1B;AAQD,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,GAAE;IAAE,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAO,2CAY/E;AASD,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,qBAA4B,GAC7B,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,2CAOA"}
@@ -92,7 +92,7 @@
92
92
  },
93
93
  {
94
94
  "file": "launchers/inject_fork_governance_preamble.sh",
95
- "sha256": "eccf9dbb5ccd3a2e0bea6e3e225de2eb0f1634a6c12c349aab89439cf6e1fb89",
95
+ "sha256": "06bc80989782d15704a562cd9a7b2c13c063c89f1ee3a6bbfc807056825b20c7",
96
96
  "source": "template/.claude/hooks"
97
97
  },
98
98
  {
@@ -102,11 +102,115 @@
102
102
  },
103
103
  {
104
104
  "file": "manifest.json",
105
- "sha256": "ee4f619b722c7d3a4f80dddb52dcee4bf900c7e6923945cd59d290d4a8236e5a"
105
+ "sha256": "627ff28351c0af0baca271bbcfa9812389979218ffa64c4d23b4abee7606429a"
106
106
  },
107
107
  {
108
108
  "file": "preamble.md",
109
109
  "sha256": "394299047d01f60bf1d9fd14a41e173b31d649068c62bd47352556beab9683e1"
110
+ },
111
+ {
112
+ "file": "skills/bug-fix-rhythm/SKILL.md",
113
+ "sha256": "4bca87df4f2777fe76f8e302698d373fb0ba60699922fb8b35c8aefae1c51ae0"
114
+ },
115
+ {
116
+ "file": "skills/code-quality-audit/SKILL.md",
117
+ "sha256": "fb65ebf0c72f7b475640f4861a1bfa2e9140727e2ff051fbd58f8348c0dc187d"
118
+ },
119
+ {
120
+ "file": "skills/delivery-handoff/references/flow-diagram.md",
121
+ "sha256": "b750d5117c92a1d0cde53283951a6848a1d3baa69ef6253cdc308a49720281df"
122
+ },
123
+ {
124
+ "file": "skills/delivery-handoff/references/handoff-template.md",
125
+ "sha256": "7985469e96766da72032c7aad84e00efbbe0223dcaf7eb6df680b2f31c4d6a6e"
126
+ },
127
+ {
128
+ "file": "skills/delivery-handoff/references/inventory-checklist.md",
129
+ "sha256": "7be9cbe37788183aad8032373e22f5ca63e05f94f4232784a79f20bc3d122b75"
130
+ },
131
+ {
132
+ "file": "skills/delivery-handoff/SKILL.md",
133
+ "sha256": "b3ba781857bed71c1bff537519b1e3858e5f115f25fb7c55967e5b147d360f79"
134
+ },
135
+ {
136
+ "file": "skills/performance-audit/SKILL.md",
137
+ "sha256": "7a77f4999b8d4bb6875c105050196fc3d7b451713da791531d186c37e593020b"
138
+ },
139
+ {
140
+ "file": "skills/product-ui-audit/references/audit-checks.md",
141
+ "sha256": "4dd879a1c983dedc29520762313b22e3b4d38cb395afe8ca1ecb43eb5e52ef83"
142
+ },
143
+ {
144
+ "file": "skills/product-ui-audit/references/common-misuses.md",
145
+ "sha256": "5afa85d18b559d1ccb182b50489bd1744968d07203558f8efbccf4444b46b942"
146
+ },
147
+ {
148
+ "file": "skills/product-ui-audit/references/report-template.md",
149
+ "sha256": "a847aba70e7c8f8cd620420f8d34d7f818070253ece5cdb1010bec16f71f5f57"
150
+ },
151
+ {
152
+ "file": "skills/product-ui-audit/SKILL.md",
153
+ "sha256": "cef077d82f906fd26d1507bbab00f5215a75583780aa893805d3018eef000a05"
154
+ },
155
+ {
156
+ "file": "skills/propose-options/SKILL.md",
157
+ "sha256": "3c0f8a8cef70506802ad67350ecde1ff5f633ddab21c22f3a4f91d923b9b9151"
158
+ },
159
+ {
160
+ "file": "skills/prototype/references/audit-checks.md",
161
+ "sha256": "6f17d6b4bc6ae94eedef8c39b68d4ab1baec92ef1035eeab462e17239c2803e3"
162
+ },
163
+ {
164
+ "file": "skills/prototype/references/benchmark-sources.md",
165
+ "sha256": "5bf8b038d2476c38c72cbb808f75e023655eaa7735d72c3e6071e199307e594b"
166
+ },
167
+ {
168
+ "file": "skills/prototype/references/checkpoints.md",
169
+ "sha256": "b37d72ad57392a6dbc75398bd9f9b92868346245530b8bddfbda4729744def33"
170
+ },
171
+ {
172
+ "file": "skills/prototype/references/evaluation-matrix.md",
173
+ "sha256": "575385e5250ecbe96068a94f71521e5d0bf9a1a33873c79500708ab620067be8"
174
+ },
175
+ {
176
+ "file": "skills/prototype/references/ooux-template.md",
177
+ "sha256": "7fda191d66844a765a67c4eae6c5c5cd54c45a2b40feff68fa54d33e24639486"
178
+ },
179
+ {
180
+ "file": "skills/prototype/references/proposal-template.md",
181
+ "sha256": "ec54bb412c255be03dd0269b708be8e8d4797f8bd58f4954a6dc52f955a9a8c6"
182
+ },
183
+ {
184
+ "file": "skills/prototype/SKILL.md",
185
+ "sha256": "21b6c91550233609274e772f245afa25bbc1aa338cc2a7a135a3577e3b16da77"
186
+ },
187
+ {
188
+ "file": "skills/scan-similar-bugs/SKILL.md",
189
+ "sha256": "79c5125f6d65d9d530c09ba2f19afe60174278448b122f4d4a66f9280c1312ca"
190
+ },
191
+ {
192
+ "file": "skills/ux-audit/SKILL.md",
193
+ "sha256": "28673c2f0207a0fa37f262ae8276d2b120b61c3329ada4d900fd6cdca42e35ed"
194
+ },
195
+ {
196
+ "file": "skills/visual-audit/output/.gitkeep",
197
+ "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
198
+ },
199
+ {
200
+ "file": "skills/visual-audit/references/audit-architecture.md",
201
+ "sha256": "48c931ad559c1e37ecebd08d289509692c79d9c92d2574f65e89bf286b7c95cf"
202
+ },
203
+ {
204
+ "file": "skills/visual-audit/references/visual-checklist.md",
205
+ "sha256": "1d2d366122227b0665135c9a9f3138385d369996ad870ffa1c58402753b22bd0"
206
+ },
207
+ {
208
+ "file": "skills/visual-audit/references/world-class-benchmarks.md",
209
+ "sha256": "bdb46cb8d1f164c141e0e7092932a787674fe5bd4defe88ad2ca91d2cfb76bdf"
210
+ },
211
+ {
212
+ "file": "skills/visual-audit/SKILL.md",
213
+ "sha256": "0af4957c5ab08f8c04bbc944900ae45b719eed879e667de1fd139392e57c4525"
110
214
  }
111
215
  ]
112
216
  }
@@ -24,6 +24,14 @@ if [ ! -f "$PREAMBLE" ] && [ -f "$PD/package.json" ]; then
24
24
  ( cd "$PD" && npm install @qijenchen/design-system@beta @qijenchen/storybook-config@beta --legacy-peer-deps --no-audit --no-fund >/dev/null 2>&1 ) || true
25
25
  fi
26
26
 
27
+ # (1b) 自我修復 skills/commands/agents:本體在但 .claude/skills 尚未送達(C-prime 之前的舊 fork / 尚未 sync-all)→ 從 npm 補。
28
+ # ⚠️ Claude Code 在 SessionStart hook 跑「之前」就掃過 .claude/skills → 補的 skill「下個 session」才可叫用(self-heal,非當場;
29
+ # 全新 use-template/fork 因 committed scaffold 不走此路、session-1 即有)。fail-open:任何錯都不阻擋。
30
+ if [ -f "$PREAMBLE" ] && [ ! -e "$PD/.claude/skills/prototype" ] && [ -f "$PD/scripts/refresh-fork-launchers.mjs" ]; then
31
+ echo "💡 偵測 .claude/skills 尚未送達 → 從 npm 自我修復(下個 session 可叫用 /prototype 等 skill)…" >&2
32
+ ( cd "$PD" && node scripts/refresh-fork-launchers.mjs >/dev/null 2>&1 ) || true
33
+ fi
34
+
27
35
  # (2) 本體在(本機持久 / 剛裝完)→ 讀 + 經 additionalContext 注入設計紀律
28
36
  if [ -f "$PREAMBLE" ]; then
29
37
  CONTENT=$(cat "$PREAMBLE" 2>/dev/null)
@@ -75,5 +75,19 @@
75
75
  "bucket": "REPLACE"
76
76
  }
77
77
  ]
78
- }
78
+ },
79
+ "skills": [
80
+ "bug-fix-rhythm",
81
+ "code-quality-audit",
82
+ "delivery-handoff",
83
+ "performance-audit",
84
+ "product-ui-audit",
85
+ "propose-options",
86
+ "prototype",
87
+ "scan-similar-bugs",
88
+ "ux-audit",
89
+ "visual-audit"
90
+ ],
91
+ "commands": [],
92
+ "agents": []
79
93
  }
@@ -0,0 +1,183 @@
1
+ ---
2
+ name: bug-fix-rhythm
3
+ description: Batch-end-verify rhythm + parallel tool batch + user-listed N-rule MUST-ALL + claim runtime verify. Invoke when entering multi-fix session 或 user 列 numbered rules. Replaces M32(c)(d)(h1)(h2) sub-invariants(2026-05-12 split per Knowledge-Prune Checkpoint 2)。
4
+ ---
5
+
6
+ > **⚠️ Fork 工具註記(build 自動加)**:本 skill 提到的 `scripts/*.mjs` 或非標準 `npm run <audit>` 是 **DS-author repo 的機械工具,未隨 fork 套件附帶**(Claude Code 不掃 node_modules,fork 也無這些 executor + dep)。你的 product fork 用本 skill 的**方法論**(human / AI judgment)+ 既有 committed governance hook 的機械強制即可;要 mechanical 腳本層(截圖 / CI gate)請自行設置對應工具,或把該檢查 PR 回 DS repo 跑。
7
+
8
+ # /bug-fix-rhythm — 多 fix session 的 rhythm canonical
9
+
10
+ **目的**:當 session 有 ≥ 2 fixes(常見 visual bug session / user 列 N 條 numbered 規則),走 batch-end-verify rhythm,而非 per-fix verify cycle waste。**M32 split 後 (c)(d)(h1)(h2) 的 home**。
11
+
12
+ **對齊**:
13
+ - CLAUDE.md mindset #6「大原則吸收瑣碎」+ M14「對話結論 AUTO integrate」
14
+ - Bazel incremental-build / GitHub Actions matrix-batch idiom(per-step incremental = waste,batch-end = canonical)
15
+ - Anthropic Claude Code prompt engineering「single-message multi-tool-call」canonical
16
+ - Toyota TPS jidoka(per-station per-item verify,不可 skip 任何 item)
17
+
18
+ ## When to invoke
19
+
20
+ **強制 auto-chain**:
21
+ - multi-issue session 內 ≥ 2 fix 待處理(visual / behavior / code 任 mix)
22
+ - user 列 numbered N 條規則(「規則 1...規則 N」/「Q1...QN」/ image 標 1234)→ 視作 **MUST-ALL checklist**
23
+
24
+ **手動 invoke**:user 明言「批 fix」「一次做完」「跑完再驗」「列規則」
25
+
26
+ **不 invoke**(對齊 Anthropic Best Practice 小修 skip):
27
+ - 單一 surgical fix(無 numbered rule + 無 cross-component)— per-fix verify 即可
28
+ - pure refactor / typo / import cleanup
29
+ - spec.md docs only
30
+
31
+ ## Non-goals
32
+
33
+ - 不擴展到「audit full-dim」(那是 `/design-system-audit`)
34
+ - 不取代 `/scan-similar-bugs`(那是 fix 後 root-pattern scan;本 skill 是 fix-過程 rhythm)
35
+ - 不動 canonical 語意(走 audit-vs-execute STOP 提議)
36
+
37
+ ---
38
+
39
+ ## Workflow(4 phases)
40
+
41
+ ### Phase 0 — Intake & MUST-ALL checklist 化(原 M32(h1))
42
+
43
+ 讀 user message:
44
+
45
+ **If user 列 numbered rules**(「規則 1: X / 規則 2: Y / ...」/「Q1 / Q2 / ...」/ image 標號 / bulleted list)→ 抽出 **MUST-ALL checklist**:
46
+
47
+ ```markdown
48
+ ## MUST-ALL checklist(per-rule 不可下放)
49
+ - [ ] 規則 1: <verbatim user wording> — 對應 fix: <target>
50
+ - [ ] 規則 2: <verbatim user wording> — 對應 fix: <target>
51
+ - ...
52
+ - [ ] 規則 N: <verbatim user wording> — 對應 fix: <target>
53
+ ```
54
+
55
+ **禁止**:
56
+ - 把 N 條視作 ranked-priority(「先修 1-3,4 之後再說」)
57
+ - 漏 N 條中第 K 條當「做完」report
58
+ - 改寫 user wording 為自己 paraphrase(verbatim 保留)
59
+
60
+ ### Phase 1 — Parallel tool batch(原 M32(d))
61
+
62
+ Read / Grep / Glob 多檔需求 → **single message multi-tool-call**:
63
+
64
+ ```
65
+ ✓ Good: 1 message with [Read A, Read B, Read C, Grep D, Grep E] (~2s)
66
+ ✗ Bad : 5 messages sequential (~10s)
67
+ ```
68
+
69
+ **Heuristic**:任何 tool call 之間**無 dependency**(後一個不需前一個結果) → 必 parallel。
70
+
71
+ 對齊 Anthropic Claude Code best practice:「Maximize use of parallel tool calls where possible」。
72
+
73
+ ### Phase 2 — Batch fix(原 M32(c))
74
+
75
+ 每 fix 用 Edit(不 Write,降風險)。**禁止 per-fix tsc / audit cycle**:
76
+
77
+ ```
78
+ ✓ Good: [Edit A] [Edit B] [Edit C] [Edit D] → final tsc + audit + visual (once)
79
+ ✗ Bad : [Edit A → tsc → audit → visual] [Edit B → tsc → audit → visual] ... (5× waste)
80
+ ```
81
+
82
+ 例外:某 fix 確實依賴前一 fix 的 type 結果 → sequential 必要時可,但 verify cycle 仍 batch-end-only。
83
+
84
+ ### ⚠️ Checkpoint 1 — Substantive vs surgical 分流
85
+
86
+ 每 fix 落地前 inline 判斷:
87
+
88
+ - **Surgical**(CLAUDE.md「Scope classifier — Surgical visual bug」):pixel / token / class adjustment, no new SSOT / API / cross-component → AUTO ship 此 fix
89
+ - **Substantive**(audit-vs-execute 分權):新 SSOT / 新 prop / 新 canonical meaning / cross-component semantic → **STOP propose**,等 user verbatim 拍板才 ship
90
+
91
+ 混合 batch:surgical 部分 ship,substantive 部分 propose。**禁止**:substantive 偷渡進 surgical batch。
92
+
93
+ ### Phase 3 — Final batch-end verify(原 M32(c)(h2))
94
+
95
+ 全 fix 完成後**一次性**驗證:
96
+
97
+ ```bash
98
+ npx tsc -b # type
99
+ npm run hooks:test # invariant
100
+ node scripts/visual-audit-<target>.mjs # pixel-quantified per M32(a)
101
+ ```
102
+
103
+ **MUST-ALL re-check**(per Phase 0 checklist):
104
+
105
+ ```markdown
106
+ ## MUST-ALL verify report
107
+ - [x] 規則 1: ✓ verified via <tsc | audit script | pixel measurement | playwright>
108
+ - [x] 規則 2: ✓ verified via ...
109
+ - ...
110
+ - [x] 規則 N: ✓ verified via ...
111
+ ```
112
+
113
+ **禁止**(原 M32(h2) claim runtime verify):
114
+ - 寫「不會有問題」「無 side-effect」「verified」「都實作完了」**沒**對應 verify trace
115
+ - code-reading 推論當「verified」
116
+ - ranked-priority 漏 N 條中第 K 條當「做完」
117
+
118
+ 若某條無法 runtime verify → 明撤回 **「規則 K:未驗證,推論而已,user 真機 verify needed」**,不可假宣告。
119
+
120
+ 對齊 M20 claim-verify gap(M20 是 stop-hook 機制;本 skill Phase 3 是 active workflow side)。
121
+
122
+ ---
123
+
124
+ ## ⚠️ Checkpoints(禁止跳)
125
+
126
+ ### Checkpoint 1 — Phase 2 surgical vs substantive(見上)
127
+
128
+ ### Checkpoint 2 — Phase 3 verify trace 缺漏
129
+ 若 MUST-ALL N 條有 K 條無 verify trace → STOP report,先補 verify 再報 user。
130
+
131
+ ### Checkpoint 3 — User-listed rule wording 改寫
132
+ 若 Phase 0 抽 checklist 時改了 user wording → STOP,重抓 verbatim。
133
+
134
+ ---
135
+
136
+ ## 與其他 skill / hook 的關係
137
+
138
+ | Tool | Scope | 跟本 skill 關係 |
139
+ |---|---|---|
140
+ | `/scan-similar-bugs` | fix 後 DS-wide root-pattern scan | 本 skill batch-end-verify 後**才** chain `/scan-similar-bugs` |
141
+ | `/visual-audit` | 單次視覺對齊 | Phase 3 sub-step,本 skill 包它 |
142
+ | `/component-quality-gate` | stakeholder gate | 不重疊(stakeholder vs daily bug fix) |
143
+ | `stop_self_audit.sh`(hook) | claim-verify gap 攔 | 本 skill Phase 3 是 active side;hook 是 passive trip-wire |
144
+ | `check_pixel_quantified_audit.sh`(hook) | M32(a) audit script 必 pixel | 本 skill Phase 3 跑該 audit |
145
+
146
+ **3 層 防線**:
147
+ - **本 skill**(active workflow):MUST-ALL checklist + batch-end-verify rhythm
148
+ - **stop_self_audit.sh / check_codex_collab_5step.sh**(passive hook):claim-verify gap 攔
149
+ - **M20 / M32(a)**(meta-rule):上游 invariant
150
+
151
+ ---
152
+
153
+ ## 世界級對照
154
+
155
+ - **Bazel `bazel test //...`**:全 target 並行 + final report,而非 per-target sequential
156
+ - **GitHub Actions matrix**:N 個 job 並行,final aggregate verdict
157
+ - **Toyota TPS jidoka**:每 station per-item verify,**但** verify 是 station-end 而非 in-progress checkpoint
158
+ - **Anthropic Claude Code prompt eng**:「Maximize use of parallel tool calls」
159
+ - **Stripe / Linear engineering blog**:「batch deploy + single canary verify」over「per-PR canary」
160
+
161
+ ---
162
+
163
+ ## Self-improvement capture
164
+
165
+ 每次 invoke 完寫:
166
+ - (a) Phase 0 抽 MUST-ALL 時 user wording 是否變形?
167
+ - (b) Phase 2 surgical/substantive 分流是否準確?(false-positive 偷渡記錄)
168
+ - (c) Phase 3 verify trace 有沒有「runtime verify needed」的條目漏標?
169
+ - (d) 新發現 numbered-rule pattern → 加進 Phase 0 抽取 heuristic
170
+
171
+ 回填本 SKILL.md 或 references/。
172
+
173
+ ---
174
+
175
+ ## 歷史 absorbed failures(M32 split 來源)
176
+
177
+ 2026-05-12 4 prior failures absorbed by M32 → split 後本 skill 承接 (c)(d)(h1)(h2):
178
+ 1. cell-align audit「Δ=0 ALL PASS」但 user 抓 SKU/Qty 視覺垂直置中於 88px 高 row(audit 沒驗 Field collapse)
179
+ 2. divider 2px audit「ALL PASS」但 pinned panel 邊仍 2px(audit 沒驗 pixel overlap)
180
+ 3. breadcrumb tooltip audit「ALL PASS」但 user 連抓 hover 不 fire(audit 沒驗 Portal DOM bounding rect)
181
+ 4. row-alignment audit「Δ=0 ALL PASS」(attr 對齊,Field collapse 沒抓)
182
+
183
+ 具體 M32(a) pixel-quantified rule 仍在 meta-patterns.md,本 skill 是其 workflow side。
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: code-quality-audit
3
+ description: Clean code 量化稽核 — `any` 使用 / dead export / file size / long function / circular dep / magic number。補 `/design-system-audit` 只管「design canonical」的缺口。Invoke via /code-quality-audit scope=all(release / 季度)OR scope=changed(daily)OR scope=component:X(focused)。Auto-chain by `/design-system-audit --deep` Dim 27 + `/component-quality-gate` Ship phase + `/new-component` Phase 4.5。
4
+ ---
5
+
6
+ > **⚠️ Fork 工具註記(build 自動加)**:本 skill 提到的 `scripts/*.mjs` 或非標準 `npm run <audit>` 是 **DS-author repo 的機械工具,未隨 fork 套件附帶**(Claude Code 不掃 node_modules,fork 也無這些 executor + dep)。你的 product fork 用本 skill 的**方法論**(human / AI judgment)+ 既有 committed governance hook 的機械強制即可;要 mechanical 腳本層(截圖 / CI gate)請自行設置對應工具,或把該檢查 PR 回 DS repo 跑。
7
+
8
+ # Code Quality Audit — Clean Code 量化稽核
9
+
10
+ Scope:**tsx / ts code hygiene**,跟 design canonical 正交。
11
+
12
+ ## 為什麼要這 skill
13
+
14
+ `/design-system-audit`(全 dim per design-system-audit SSOT)管 design / spec / canonical correctness。但 **clean code 面向**(`any` 濫用 / dead export / 函式爆長 / circular dep / 檔案超標)**無任何 dim 覆蓋**。每次建元件 / audit / ship 都該跑這層。
15
+
16
+ ## 6 個 check
17
+
18
+ | # | Check | Severity | 如何判定 |
19
+ |---|-------|---------|---------|
20
+ | 1 | `any` 使用 | P0 | grep `: any` / `as any` / `<any>` / `any[]` / `Record<X, any>`;支援 `// any-allow: {rationale}` 逃生口(同行或上一行) |
21
+ | 2 | File size(.tsx)| P0 > 800 / P1 > 500 | `wc -l`;budget 500 / transition cap 800;spec 同 `check_file_size_budget.sh` policy |
22
+ | 3 | Long function | P1 > 80 行 | naive:`function`/`const` 宣告到 matching `}` indent 行距 |
23
+ | 4 | Dead export | P1 | `export` 名稱在其他 src/ 檔無出現;exempt `*Props/Options/Config/Args/Context/Variants/Value` 型別 API 慣例 |
24
+ | 5 | Circular dep | P0 | DFS import graph,找 cycle |
25
+ | 6 | Magic number | P1 | 覆蓋不完整 → 由 token 防線(`lib/_token_hygiene.sh` + `check_opacity_token_usage.sh`)層負責(primitive color / shadow / Tailwind v4 `[--foo]`);本 skill 不重複 |
26
+
27
+ ## When to run
28
+
29
+ - **Daily**:`/code-quality-audit --scope=changed`(git diff)
30
+ - **Component ship**:`/component-quality-gate` Ship phase auto-chain
31
+ - **New component**:`/new-component` Phase 4.5 auto-chain
32
+ - **Release / 季度**:`/code-quality-audit --scope=all`
33
+ - **Focus one component**:`/code-quality-audit --scope=component:<Name>`
34
+ - **CI gate**:`node scripts/code-quality-audit.mjs --check`(P0 violation → exit 1)
35
+
36
+ ## Workflow
37
+
38
+ 1. Run `node scripts/code-quality-audit.mjs [--scope=<scope>]`
39
+ 2. Triage findings into P0 / P1 / P2
40
+ 3. Auto-fix trivial(unused imports,trivial `any` casts with obvious type)
41
+ 4. STOP for user decision on:
42
+ - File-size P0(大 component architectural split)
43
+ - Circular dep(需設計層面重組)
44
+ - 無法 auto-type 的 `any`(需 design judgment 訂 proper type)
45
+
46
+ ## 禁止
47
+
48
+ - 禁 silent 吞 `any`(必加 `// any-allow: {rationale}`)
49
+ - 禁把 dead export 直接刪(可能是 planned API surface);flag → user 決策
50
+ - 禁把 long function 硬拆(拆錯比爆長還糟);只提議,user sign-off
51
+
52
+ ## Integration points
53
+
54
+ | Skill / Hook | How |
55
+ |---|---|
56
+ | `/design-system-audit` Dim 27 | `--deep` 必 chain 本 skill scope=all |
57
+ | `/component-quality-gate` Ship | chain 本 skill scope=component:{Name} |
58
+ | `/new-component` Phase 4.5 | 元件建完必跑 scope=component:{Name} |
59
+ | Hook `check_code_quality.sh` | PostToolUse Edit/Write on src/ — 只跑 any + file-size(quick) |
60
+
61
+ ## References
62
+
63
+ - `scripts/code-quality-audit.mjs` — 實作
64
+ - `.claude/hooks/check_code_quality.sh` — per-edit lite check
65
+ - 相關:token 防線 `lib/_token_hygiene.sh` + `check_opacity_token_usage.sh`(正交 — token 紀律 vs code 紀律)
@@ -0,0 +1,229 @@
1
+ ---
2
+ name: delivery-handoff
3
+ description: Generate stakeholder-ready handoff documentation when a product / feature is confirmed final. Produces Storybook handoff page + UI flow diagram + component usage inventory + token consumption report + a11y checklist + per-screen spec — a Figma-like inspectable delivery package. Invoke via /delivery-handoff when user says「要交付」「handoff」「交付文件」「給 X 團隊的文件」「產品確認要上線了」. **只在產品確認 final 後才 invoke**,非 prototype 階段。
4
+ ---
5
+
6
+ # Delivery Handoff Workflow
7
+
8
+ Purpose: 產品 / feature 通過 prototype → audit → stakeholder 決策後確認 final,需要產 **Figma-like inspectable handoff documentation** 給工程 / PM / QA / 其他 stakeholder。
9
+
10
+ 本 skill **不是** prototype 階段文件(那是 `/prototype` 的 notes.md),而是**正式交付包**。
11
+
12
+ ## When to run
13
+
14
+ **明確觸發**:
15
+ - User 說「要交付」「handoff」「交付文件」「給 X 團隊的文件」
16
+ - User 說「產品確認要上線了」「final 了做 handoff」「給工程交接」
17
+ - Final decision 已下 + product-ui-audit P0 都修完
18
+
19
+ **不觸發**:
20
+ - Prototype 階段(走 `/prototype`,產 exploration notes)
21
+ - Audit 階段(走 `/product-ui-audit`)
22
+ - DS 本身的 spec 維護(不走任何 skill,直接在 `.spec.md` 編)
23
+ - 要跑 audit 檢查 DS 用對不對 → `/product-ui-audit`
24
+
25
+ ## 生態位
26
+
27
+ ```
28
+ /prototype → exploration + shortlist
29
+ /product-ui-audit → QA gate
30
+ [stakeholder decides final]
31
+ [P0 fixed, P1 resolved]
32
+ /delivery-handoff ← 本 skill,只在 final confirmed 後
33
+ ```
34
+
35
+ ## Preconditions
36
+
37
+ - 產品 / feature 已 final(stakeholder 書面或對話確認)
38
+ - `/product-ui-audit` Zero P0(必要)/ P1 有計畫 resolve(建議)
39
+ - 代碼已 merge 或即將 merge 到 main branch
40
+ - 有明確 **target audience**(給工程? 給 PM? 給設計 review? 給跨團隊交接?)— AI 在 Phase 0 clarify
41
+
42
+ ---
43
+
44
+ ## 5-Phase Workflow
45
+
46
+ ### Phase 0 — Scope & audience
47
+
48
+ **clarify with user**:
49
+ 1. 交付**哪個 feature**?(single screen? full flow? 整個 module?)
50
+ 2. **給誰**?
51
+ - 工程團隊(實作參考 / QA test case)
52
+ - PM / BA(業務理解 / 邊界 case)
53
+ - 設計 review(世界級評估)
54
+ - 跨團隊(onboarding 他們使用)
55
+ 3. **format 需求**:
56
+ - Storybook 原生頁(最推薦)
57
+ - Markdown 可 export PDF
58
+ - Mermaid diagram(UI flow)
59
+ - Screenshot / mockup 用 Storybook render
60
+
61
+ ### Phase 1 — Inventory 生成
62
+
63
+ scan 目標 feature 的 code,自動 inventory:
64
+
65
+ 1. **Component 清單**(哪些 DS 元件被此 feature 消費):
66
+ ```
67
+ | Component | Count | Consumer files |
68
+ |-----------|-------|----------------|
69
+ | Button | 12 | Checkout.tsx, Summary.tsx, ... |
70
+ | Dialog | 2 | Confirm.tsx, Edit.tsx |
71
+ | Empty | 1 | NoItems.tsx |
72
+ ```
73
+
74
+ 2. **Token 使用報告**:
75
+ ```
76
+ | Token | Usage | Files |
77
+ |-------|-------|-------|
78
+ | --primary | 8 hits | ... |
79
+ | --fg-secondary | 14 hits | ... |
80
+ | --error | 3 hits | ... |
81
+ ```
82
+
83
+ 3. **Layout primitives 消費**: Empty / item-layout / overlay-surface / ScrollArea / AspectRatio 各幾次。
84
+
85
+ 4. **A11y checklist**(先掃再人工 review):
86
+ - aria-label 齊全
87
+ - role / keyboard
88
+ - Dialog title
89
+ - color contrast(此層 AI 報 visible,人工 review 判 final)
90
+
91
+ ### Phase 2 — UI flow 圖生成
92
+
93
+ 用 **Mermaid** 產 flow(Storybook 支援 render,也可 export PDF)。
94
+
95
+ 範本:
96
+
97
+ ```mermaid
98
+ flowchart TD
99
+ Start([進入 Checkout]) --> Review[結帳 Review]
100
+ Review -->|修改| Edit[編輯 Cart Dialog]
101
+ Edit --> Review
102
+ Review -->|確認| Payment[付款方式 Step]
103
+ Payment -->|信用卡| Card[Card Form]
104
+ Payment -->|轉帳| Bank[Bank Instructions]
105
+ Card --> Confirm[確認 Dialog]
106
+ Bank --> Confirm
107
+ Confirm -->|確定| Success([訂單成立])
108
+ Confirm -->|取消| Review
109
+ ```
110
+
111
+ AI 根據 code(route / onClick / navigation)auto-generate,user review 後微調。
112
+
113
+ ### Phase 3 — Per-screen spec sheet
114
+
115
+ 每個 screen / modal / flow step 一頁 spec(Storybook 的 Handoff story,或 Markdown 章節):
116
+
117
+ ```markdown
118
+ ## Screen: Checkout Review
119
+
120
+ **Storybook**: `Features/Checkout/Review`
121
+ **File**: `src/app/features/checkout/Review.tsx`
122
+
123
+ ### 用途
124
+ 使用者進入結帳後,第一屏預覽購物車 + 小計 + 折扣碼輸入。
125
+
126
+ ### 主要元件
127
+ - DataTable(訂單 items)
128
+ - Input(折扣碼)
129
+ - Button(套用)
130
+ - Dialog(編輯 item 彈出)
131
+ - Empty(購物車空狀態)
132
+
133
+ ### States
134
+ - **default**: 載入後正常顯示(≥1 item)
135
+ - **empty**: 購物車無 item — 顯示 Empty 元件 + 「回去繼續購物」CTA
136
+ - **error**: 折扣碼無效 — Input error state + Alert 說明
137
+
138
+ ### Interactions
139
+ - 點擊 item → open Edit Dialog
140
+ - 輸入 discount → debounce 500ms → auto-validate
141
+ - 按 Apply → post /discount API
142
+
143
+ ### A11y
144
+ - ✓ 所有 icon-only 有 aria-label
145
+ - ✓ Dialog 有 title + description
146
+ - ✓ keyboard 可 tab 所有互動
147
+ - ✓ color contrast 通過 WCAG AA
148
+
149
+ ### 邊界 case
150
+ - 折扣碼已套用:顯示 "已套用 {code}",Apply Button 變 Clear
151
+ - 網路錯誤:顯示 Alert + retry button
152
+ - 折扣超過總額:capped 折扣 = 總額,顯示說明
153
+ ```
154
+
155
+ ### Phase 4 — Handoff Storybook page
156
+
157
+ 在 Storybook 建立 `Features/{Feature}/Handoff` page,內含:
158
+
159
+ - **Overview**: feature 一句話重述
160
+ - **UI Flow**: Mermaid diagram(Storybook 支援 render)
161
+ - **Inventory**: 元件 / token / a11y 報告
162
+ - **Screens**: 每個 screen 可點進去的 story link + inline preview
163
+ - **Spec table**: per-screen spec 嵌入
164
+
165
+ Storybook title: `Features/{FeatureName}/Handoff`
166
+
167
+ 此 page 就是「Figma-like 的 inspectable 交付」— stakeholder 打開就看到全景。
168
+
169
+ ### ⚠️ Checkpoint — User review handoff package
170
+
171
+ Phase 4 產出後 pause,讓 user review:
172
+
173
+ ```
174
+ 📦 Handoff Package Ready
175
+
176
+ Scope: {feature}
177
+ Audience: {engineering / PM / designer / cross-team}
178
+ Package:
179
+ - Storybook page: Features/{Feature}/Handoff
180
+ - Inventory: {N components / M tokens}
181
+ - UI Flow: Mermaid diagram ({N nodes})
182
+ - Spec sheets: {N screens}
183
+ - A11y checklist: {N passed / M needs review}
184
+
185
+ Export formats:
186
+ - Storybook URL: {link}
187
+ - Markdown(可 export PDF): {path}
188
+
189
+ 請 review:
190
+ (a) 通過,準備 share 給 {audience}
191
+ (b) 需要修改: ...
192
+ (c) 還缺 ... 補齊
193
+ (d) Audience 換人,調整語氣 / 深度
194
+ ```
195
+
196
+ ---
197
+
198
+ ## 世界級 handoff 標準(reference)
199
+
200
+ 本 skill 對標:
201
+ - **Figma Dev Mode** — inspectable 元件 + token + spacing
202
+ - **Zeplin** — per-screen spec + asset export
203
+ - **Shopify Polaris Pattern pages** — 完整 flow + usage + edge cases
204
+ - **Material Design Showcase** — UI + spec + code sample 三欄
205
+
206
+ 我們的 Storybook handoff page 整合上述 3 個 tool 的優勢到一頁。
207
+
208
+ ---
209
+
210
+ ## Non-goals
211
+
212
+ - 不替代工程 code review(本 skill 是 **設計 handoff**,不是 code 品質審核)
213
+ - 不寫實作 / fix bug(已經 audit 過,final 了才 invoke 本 skill)
214
+ - 不生成業務需求文件(那是 PM 職責)
215
+ - 不管 release scheduling / branching strategy(那是 DevOps)
216
+
217
+ ## Common failure modes
218
+
219
+ - **Audience 不清**: user 說「要 handoff」但沒說給誰 → Phase 0 必 clarify,否則 format 錯
220
+ - **UI flow 過度簡化**: flow 圖少 error path / loading / edge case → 讓 handoff 失真
221
+ - **Component inventory 漏掉 hidden consumption**:e.g., 內部某 function 呼叫 Toast → 需 grep 所有 imports
222
+ - **A11y checklist 自動判 pass**:checklist 只能「visible hits」,color contrast / keyboard 實測需人工
223
+ - **Spec sheet 寫成 code comment 複製**:spec 應該是 design 語言而非 code 描述,翻譯為 UX 詞彙
224
+
225
+ ## References
226
+
227
+ - [references/handoff-template.md](references/handoff-template.md) — Storybook Handoff page 結構 + Markdown spec 範本
228
+ - [references/flow-diagram.md](references/flow-diagram.md) — Mermaid UI flow 指引 + 世界級 reference
229
+ - [references/inventory-checklist.md](references/inventory-checklist.md) — 元件 / token / a11y 清單 + grep pattern