/design-system:product-ui-auditfrom design-system
Audits consumer UI code against design system discipline across 7 dimensions: token hygiene, element misuse, design principle violations, geometry bugs, and a11y gaps. Invoked via /product-ui-audit or auto-triggered by /prototype Phase 3.5 gate.
Ships in design-system. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Purpose: design-system-audit audits the DS itself(spec / cva / SSOT 三方漂移);product-ui-audit audits consumer UI code(不是 DS 本身,是 app / exploration / feature code — 即「consumer 用 DS 的地方」)。防止:
明確觸發(直接 invoke):
/prototype Phase 3.5 自動 invoke(audit src/explorations/{topic-slug}/)不觸發:
/design-system-audit(不同 scope)design-system-audit /design-system-audit audit DS 本身(設計系統內部)
/product-ui-audit audit consumer UI code(本 skill)
/prototype 呼叫本 skill 作 Phase 3.5 gate
/delivery-handoff 只在產品交付前執行(產 handoff 文件)
src/app/** / src/explorations/** / src/pages/** / src/features/** / apps/**(含 DS repo 自家 apps/template + create-app 產物)等 — 不掃 packages/design-system/src/)Feature-scoped UI audit 不擴張到無關檔案;但 release、full-repo 或 deep audit 必先依
node_modules/@qijenchen/design-system/ds-canonical/references/repository-hygiene.md 完成一次
Git-index + nonignored worktree inventory。若 authority repo 的 portable gate 可用,執行
node scripts/repository-hygiene-invariant.mjs --profile=product-consumer --check;否則依同一
canonical 手動分類。未掛載的 registered repo 是 unobserved,不可寫成 PASS。
每個 dimension 獨立檢查,產出 findings。詳細 grep pattern + rule 見 references/audit-checks.md。
packages/design-system/src/tokens/utility-registry.json;此處 inline 為 grep 便利,新增 alias 改 registry)[--foo] shorthand 靜默失效w-[48px] 應改 token)此維對齊既有 token 防線(lib/_token_hygiene.sh 5-check:shadcn alias / v4 shorthand / hardcoded shadow / primitive-color-as-utility / native overflow,由 post_edit_dispatcher.sh source;+ check_opacity_token_usage.sh 對齊 utility-registry.json 類別 — pattern hardcode 於 hook,registry 僅存在性 fallback gate)+ 擴充硬色值 / 硬 px 檢查。
掃是否正確消費既有 layout primitives(非自 roll):
| 視覺 pattern | 應消費 | 違規 signal |
|---|---|---|
| icon+title+desc 垂直居中 | <Empty> | 自己寫 flex flex-col items-center 3-layer text |
| row prefix+content+suffix | item-layout | 自己寫 flex items-center gap-2 3-slot |
| overlay Header/Body/Footer | overlay-surface | 自己寫 border-b/border-t padding loose/tight |
| 橫向按鈕列 | action-bar pattern | 自己 flex gap-2 按鈕組 |
| 水平溢出 + fade mask | horizontal-overflow | 自己 overflow-x-auto + mask |
| 跨 OS 一致捲軸 | ScrollArea | native overflow-(auto|scroll) |
| 圖像 / media 容器 | AspectRatio | 硬寫 aspect-video / aspect-square class |
| Field wrapper | Field + fieldWrapperStyles | 自己 border + padding + startIcon + endAction |
aria-labelpopover.spec.md「禁止事項」)對齊 shared governance 6 條 mindset(逐條檢查 #1-#5;#6「大原則吸收瑣碎」屬 governance meta 層,不在 consumer code audit scope。編號用 mindset #N,避免撞 meta-patterns M-rules 編號):
Option A/B/C / 按鈕一 / Rule A?packages/design-system/ds-canonical/references/ui-dev-rules.md「同 flex 列互動 slot 幾何鐵律」)text-[13px])aria-labelrole 正確詳見 references/audit-checks.md。
chain packages/design-system/ds-canonical/skills/design-system-audit/references/principle-audit-protocol.md 做 4 子維 scoped 對 consumer code:
判斷 auto vs STOP 依 protocol 的 authority classifier。修 consumer code 一致化、工程 bug、 a11y、performance 與治理修復 = AUTO;只有建議會改變產品/UI/UX SSOT 且存在真實取捨時 才 STOP 提議。修改 DS canonical 本身不自動等於 human gate。
從 explicit request、目前 frozen scope、changed paths 與 registered feature owner 解析 audit target(file / folder / feature area)。工程範圍模糊時選最小完整 affected scope 並記錄 rationale; 只有不同 scope 會導致真正產品/UI/UX SSOT 取捨時才提問 user。禁止無 evidence 掃整個 repo (失焦),也禁止把可由 repository evidence 解出的 scope 轉交 user。
7 個維度各自獨立 grep + code review。可 parallelize。
產出 report 表格:
| Dim | File:Line | Finding | Severity | Fix suggestion |
|-----|-----------|---------|----------|----------------|
| 1 Token | src/app/foo.tsx:42 | 硬寫 `#3b82f6` | P0 | 改 var(--primary) |
| 2 Layout | src/app/bar.tsx:87 | 自己寫 icon+title+desc 垂直堆疊 | P1 | 改用 `<Empty>` |
| 3 Component | src/app/baz.tsx:12 | icon-only Button 無 aria-label | P0 | 加 aria-label |
| ... |
類似 design-system-audit 的 triage checkpoint:
🔍 Audit 結果
P0(必修,無爭議):N 項
P1(批次修 + review):M 項
P2E(工程/治理,自主修):K 項
P2H(產品/UI/UX SSOT 真取捨):J 項
P0/P1/P2E 依 frozen scope 自主修;只有 P2H 要 exact target-bound user decision。
詳見 references/report-template.md。
P0/P1/P2E 依 Standing Authorization surgical 修復;每批(Dim 1 / Dim 2 / ...)一個 可驗證 change set。P2H 在 exact decision 前保持 proposal-only。
npm run build:lib 無錯(型別證明;設計系統本庫的 tsc -b 只看根目錄 src/、不檢查 DS 原始碼,不算 —— 對齊 component-quality-gate + self-verify.md)對齊 shared governance 稽核 canonical Tier 1 stakeholder-gate:產品 UI 要給 stakeholder / end-user 看之前,code + visual 雙層都要過。Phase 1-4 是 code 層;本 Phase 補視覺層。
Input:Phase 4 verify 過關的產品 UI(screens / routes / embedded widgets)
Process:
npm run visual-audit -- --urls=<csv>(例:--urls=http://localhost:3000/inbox,http://localhost:3000/settings)npm run visual-audit -- --scope=component:<topic>--retina opt-in)→ snapshots//visual-audit skill):讀 snapshots/*.png,判斷設計合理性(視覺對齊 / 覆蓋限制 / 世界級對照 / typography hierarchy)Gate 規則:P0 有 → 停下修,不放給 stakeholder;P1/P2E 自主修復與驗證;只有 P2H 產品/UI/UX SSOT 真取捨走 exact target-bound user-decision 流程。
何時可縮窄:內部 UI(只給 engineer / admin 看,非 stakeholder / end-user)可依 canonical scope evidence 縮窄 Layer B,但 Layer A a11y P0 不得省略;這是工程判斷, 不是 user approval gate。
為什麼 mandatory:code audit 對 + spec 對,視覺仍可能錯(對比不夠、overlay 疊到文字、跨 OS 捲軸跑版)——這類 bug 只有視覺層抓得到。產品給 stakeholder / user 看時 = stakeholder-visible artifact,必過 Tier 1 gate。
audit 完畢報告應含:
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub ajenchen/design-system --plugin design-system27 skills in this plugin
/bug-fix-rhythmBatch-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)。/canonical-reviewerReview governance changes in an isolated read-only context with explicit author identity, complete canonical evidence, and mutation detection./code-quality-auditClean 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。Other plugins' skills for the same job