/design-system:code-quality-auditfrom design-system
Runs quantitative clean-code audits on tsx/ts code: `any` usage, dead exports, file size, long functions, circular deps, magic numbers. Supports scope=all/changed/component:X and CI gate via scripts/code-quality-audit.mjs.
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.
None: SKILL.md is the whole skill.
Scope:tsx / ts code hygiene,跟 design canonical 正交。
/design-system-audit(全 dim per design-system-audit SSOT)管 design / spec / canonical correctness。但 clean code 面向(any 濫用 / dead export / 函式爆長 / circular dep / 檔案超標)無任何 dim 覆蓋。每次建元件 / audit / ship 都該跑這層。
| # | Check | Severity | 如何判定 |
|---|---|---|---|
| 1 | any 使用 | P0 | grep : any / as any / <any> / any[] / Record<X, any>;支援 // any-allow: {rationale} 逃生口(同行或上一行) |
| 2 | File size(.tsx) | P0 > 800 / P1 > 500 | wc -l;budget 500 / transition cap 800(tsx SSOT = scripts/code-quality-audit.mjs:36-37 + lib/_code_quality.sh;check_file_size_budget.sh 僅管治理 md,數字精神一致非同一 policy) |
| 3 | Long function | P1 > 80 行 | naive:function/const 宣告到 matching } indent 行距 |
| 4 | Dead export | P1 | export 名稱在其他 src/ 檔無出現;exempt *Props/Options/Config/Args/Context/Variants/Value 型別 API 慣例 |
| 5 | Circular dep | P0 | DFS import graph,找 cycle |
| 6 | Magic number | P1 | 覆蓋不完整 → 由 token 防線(lib/_token_hygiene.sh + check_opacity_token_usage.sh)層負責(primitive color / shadow / Tailwind v4 [--foo]);本 skill 不重複 |
/code-quality-audit --scope=changed(git diff)/component-quality-gate Ship phase auto-chain/new-component Phase 4.5 auto-chain/code-quality-audit --scope=all/code-quality-audit --scope=component:<Name>node scripts/code-quality-audit.mjs --check(P0 violation → exit 1)node scripts/code-quality-audit.mjs [--scope=<scope>]any casts with obvious type)any(必加 // any-allow: {rationale})| Skill / Hook | How |
|---|---|
/design-system-audit Dim 27 | --deep 必 chain 本 skill scope=all |
/component-quality-gate Ship | chain 本 skill scope=component:{Name} |
/new-component Phase 4.5 | 元件建完必跑 scope=component:{Name} |
Hook post_edit_dispatcher.sh → lib/_code_quality.sh | PostToolUse Edit/Write on src/ — 只跑 any + file-size(quick);原 check_code_quality.sh folded(2026-05-13 dispatcher consolidation) |
scripts/code-quality-audit.mjs — 實作packages/design-system/ds-canonical/hooks/lib/_code_quality.sh(經 canonical post-edit dispatcher chain)— per-edit lite checklib/_token_hygiene.sh + check_opacity_token_usage.sh(正交 — token 紀律 vs code 紀律)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
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./codex-collabCoordinate an evidence-complete primary analysis with a genuinely independent peer provider, then verify and synthesize both results./codify-correctionsProcess $GOVERNANCE_STATE_DIR/user-corrections.jsonl — the Stop-hook-harvested signals of user corrections ("不是" / "不對" / "應該" / "糾正" etc.). Dedup by session + keyword, cluster by topic, and apply edits to the canonical owner(ds-canonical rule / repository memory / canonical skill reference / spec.md rationale) under the shared authority classifier. After codification archive processed entries in the same Git-owned runtime state root. Invoke when user-corrections.jsonl exceeds 40 entries(session_start hard blocker; there is no soft reminder), when the user asks, OR quarterly./codify-principleUser 提出新設計原則 → auto 5-layer artifact generation pipeline。將原則文字自動轉化為 SSOT canonical text + hook scaffold + audit dim + scaffold update + memory entry,依 rule-placement Level 1–9 taxonomy 放入正確 home。對齊 M14 + M19。Invoke when user says「我想加一條設計原則 X」「新原則 Y」「ensure X always」OR auto-recognize trigger phrase。本 skill 把 reactive markdown rule 升級成 proactive principle-to-artifact generator。/component-quality-gatePre-merge quality gate for new or significantly refactored design-system components. Walks through Spec / Code / Stories / Ship checklist (35 items) to ensure world-class discipline before a component enters `packages/design-system/src/components/`. Invoke when user says「元件做完了」「這元件可以收工了嗎」「元件 ready 嗎」「check 這個 element」「要 merge 進 DS 了」or before closing a component PR.