/design-system:component-quality-gatefrom design-system
Pre-merge quality gate for design-system components. Walks through a 35-item Spec/Code/Stories/Ship checklist to ensure discipline before merging into packages/design-system/src/components/.
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: 元件進 packages/design-system/src/components/ 前的最終 checklist。防止「code 寫完但 spec / stories / token 消費紀律有漂移」的半成品進入系統。
/design-system-audit 發現某元件偏離 checklist 後的修復驗證不 invoke 的情境:小改(typo / 單 bug fix),走 spec 本身的 sync hook 即可。
packages/design-system/src/components/{Name}/.spec.md / .tsx / .stories.tsx / .anatomy.stories.tsx / .principles.stories.tsx 已完成初稿packages/design-system/ds-canonical/rules/spec-rules.md / packages/design-system/ds-canonical/rules/ui-development.md(含 Tailwind / Token 命名 / Props 命名 / shadcn 元件規範) / packages/design-system/ds-canonical/rules/story-rules.md)逐條走 references/checklist.md 的 Spec section(12 項):定位明確 / 實作基礎宣告 / 每個 prop/variant 有何時用何時不用 / 互斥規則 / 為什麼不只是什麼 / 術語一致 / 無視覺描述 / 禁止事項列出 / 邊界案例覆蓋 / 近親 SSOT pointer / 對標世界級 7 維度。
任一不過 → 停下補 spec。不往下跑 Phase 2。
走 Code section(13 項):shadcn 基底完整 / cva() 不條件字串 / data-* selector / 無硬寫 token / Tailwind v4 var() 正確 / 無自包 Provider / Props 命名按「是什麼」/ ARIA 齊 / defaultVariants size=md 若屬 field-height family。
cva defaultVariants 異動 → 強制 grep 該元件所有檔案確認三方同步(見 packages/design-system/ds-canonical/skills/story-writing/references/anatomy-standard.md → 高風險漂移點)。
走 Stories section(6 項):展示 / 設計規格 5-story 齊全 / TOKEN_MAP 對得上 cva / Rule note 傳達原則 / title 命名對齊 / Internal vs Components 判斷正確。
範例品質問題 → invoke /story-writing skill 做深度審。
走 Ship section(checklist 4 項 = 35 項總數的 Ship 份額;下列 5-7 為 checklist 外加掛的 mechanical gate,不計入 35):
npm run storybook 本地渲染正常npm run build:lib 無錯(型別證明;設計系統本庫的 tsc -b 只看根目錄 src/、不檢查 DS 原始碼,不算)@/design-system/...componentMeta export + spec frontmatter)→ 跑 node scripts/compile-stories.mjs {Name} --check 必 exit 0;migration 未做 → skip 此項(另 new-component skill 推動逐步 migration)node scripts/code-quality-audit.mjs --scope=component:{Name} --check 必 exit 0(無 P0 clean-code violation)。P1 flag 但不 block;P0(any 無 escape / file-size > 800 / circular dep)必修才 ship# 稽核 canonical M6)這是 stakeholder-gate,不能跳。元件 merge = stakeholder-visible 產出,必過進階模式 6 維(非高效)。
| 維度 | 做法 | Chain 的 skill / tool |
|---|---|---|
| D1 設計語言一致 | Phase 1-3 已覆蓋 | — |
| D2 程式語言一致 | Phase 2 + tsc + lint | — |
| D3 元件效能 | 檢查 render / memo / bundle | chain /performance-audit |
| D4 UX 行為 | keyboard / focus / ARIA / animation / interaction canonical | chain /ux-audit |
| D5 視覺品質 | Layer A mechanical + Layer B AI judgement | Auto npm run visual-audit -- --scope=component:{Name} + chain /visual-audit |
| D6 設計原則自檢(4 子維) | chain principle-audit-protocol.md 對該元件 scope scan | 合理 / 一致 / 無矛盾 / 完整;auto vs STOP 依判斷公式 |
執行步驟:
npm run visual-audit -- --scope=component:{Name}(D5 Layer A:WCAG / 幾何 assertion / 1x snapshot,--retina opt-in debug)/visual-audit(D5 Layer B):讀 snapshots/{Name}-*.png 做 AI judgement/performance-audit --scope=component:{Name}(D3)/ux-audit --scope=component:{Name}(D4)packages/design-system/ds-canonical/skills/design-system-audit/references/principle-audit-protocol.md 對該元件 + 其 spec 跨指的 kin specs 跑 4 子維(合理 / 一致 / 無矛盾 / 完整);先讀「常見 FP 記憶」節避免誤報# 治理 canonical → Audit skill Phase F 節為什麼 mandatory:code / spec 對不夠;效能 / UX / 視覺三維各有歷史 bug(DatePicker 四邊不對稱、DropdownMenu 鍵盤不通、Badge 位置離譜、Rating 邊框、Carousel 箭頭壓文字、inline 物件 prop 造成 render 爆)。merge 前沒過 6 維 = 把 bug 帶進 DS。
合理跳過情境(極少):純 spec.md 文字修正(無 tsx 改動)→ 視覺 / 效能 / UX 無變,可跳 Phase 4.5;但 tsx / token / cva / style 任一動 → 必跑全 6 維。
全部打勾後,回報 user:
<absolute-git-dir>/governance-runtime/evidence/visual/visual-audit/report.json 摘要(contrast / geometry violation 數 = 0)Fail-closed 路由:任一項不過都不得默默放行。純工程/治理失敗依 Engineering Decision Policy、tests 與 hard gates 自行釐清並 remediation;依既定重試仍無法收斂則回報 technical blocker,不把工程選擇轉問 user。只有改變產品/UI/UX SSOT 且仍有真實選擇或取捨才 P2H/STOP。Phase 4.5 Layer A 有 violation 絕不放行。
references/checklist.md — 完整 35 項 checklist(Spec 12 / Code 13 / Stories 6 / Ship 4 + 各項的 shared-governance pointer)packages/design-system/ds-canonical/skills/design-system-audit/ — 本 skill focus 在單元件進 DS 的 gate;design-system-audit 是系統級 full-dim sweep(per design-system-audit SSOT),兩者互補packages/design-system/ds-canonical/skills/story-writing/ — Phase 3 story 深審可 chain 進去pre_edit_spec_check.sh(改靠 M3 mindset #3「改一處看三處」)— 編輯 tsx 前提醒讀 spec(session 級)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
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