/design-system:scan-similar-bugsfrom design-system
After bug fix commits, extracts the root-cause anti-pattern, greps the entire design system for matching patterns, runs visual verification, and batches related fixes. Invoke via /scan-similar-bugs.
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.
目的:任何 bug fix 提交後,機械化掃 DS-wide 找同 pattern,而非靠 model 記得 M10。
對齊:
packages/design-system/ds-canonical/rules/meta-patterns.md M10 「Proactive exhaustive scan」mechanical 落地對位其他 skill:
/design-system-audit 是定期 batch full-dim audit/visual-audit 是單次視覺對齊 check/bug-fix-rhythm Phase 2-3 batch fix + single end-verify canonical;M32 split 後 batch-end home 移至 bug-fix-rhythm skill)強制(auto-chain)— batch-end only(2026-05-12 重構,per independent review):
手動 invoke:
不 invoke(對齊 provider-neutral best practice 小修 skip plan):
/design-system-audit)/visual-audit)# 讀 last fix commit message + diff
git log -1 --format='%s%n%n%b'
git show HEAD --stat
從 commit message + diff 抽出 grep-able pattern。常見類型:
| Bug 類型 | Anti-pattern grep target |
|---|---|
| Padding / sizing 公式錯 | calc((var(--field-height-X) - <num>px) / 2) etc |
| Token leak / shadcn alias | bg-popover / text-muted-foreground / bg-accent |
| 硬寫 magic number | text-[14px] / shadow-[0_2px_8px_...] |
| API mis-use(prop combo) | iconOnly + endIcon / loading + disabled |
| a11y missing | <button> 無 aria-label 又無 children |
| Symbol mis-import | from 'shadcn/ui/X' |
| CSS w/h asymmetric | SVG 量測 width !== height |
Output: ANTI_PATTERN(grep regex / Playwright assertion)。
選最適合的 detection:
Static grep(快,適合 token / class / API mis-use):
grep -rnE "$ANTI_PATTERN" packages/design-system/src/ --include="*.tsx" \
| grep -v "test_\|stories\|node_modules"
Playwright visual scan(慢,適合 geometry / a11y / interaction):
node scripts/scan-asymmetric-icons.mjs # 已存在,iconOnly visual scan template
# 或 base 同 pattern 自寫 dim-specific scan
Output:候選清單(file:line + 樣本)。
產出:
Phase 1 found N candidates of same anti-pattern:
- packages/design-system/src/components/A/a.tsx:42 > grep match
- packages/design-system/src/components/B/b.tsx:18 > grep match
- packages/design-system/src/components/C/c.tsx:55 > 視覺 14×16
Execution:
- deterministic fix → Auto-fix all confirmed N
- engineering judgment → 依 owning spec + highest certified capability 逐檔收斂;task/deliverable 明確要求時才加 independent review
- 不屬 frozen scope → Backlog with evidence;不得用 defer 逃避 scope 內修復
- 會改產品/UI/UX SSOT 且仍有真取捨 → batch-at-end 交 user(類別照共同 bootstrap `canonical-decision-authority` 區塊)
不可 silent 跳過 confirmed scope;影響 N 檔是工程 blast radius,不是 user approval gate。必記錄 scope、evidence、tests 與 rollback。
按 Phase 1.5 authority classifier 執行。每修一檔:
npm run build:lib);根目錄 tsconfig 是 files: [] 時 npx tsc --noEmit 一個檔都不檢查,不算npm run icons:scan 或 dim-specific scannpm run hooks:testnpm run build:lib(設計系統本庫的 tsc -b 不檢查 DS 原始碼,不算)## Scan-similar-bugs report
### Root cause(來自 last fix commit `<hash>`)
- Pattern:{ANTI_PATTERN}
- Origin file:{first detected location}
### DS-wide impact
- {N} candidates found
- {M} fixed this run
- {K} deferred(spec rationale 已記)
### New defense layer(防 future regression)
- 加 canonical hook:`packages/design-system/ds-canonical/hooks/check_<pattern>.sh`(若 pattern 易 grep),再由 generator 投影到各 provider;禁止直接新增 provider-owned hook。
- 加 visual test:`scripts/scan-<pattern>.mjs`(若需 Playwright)
- 加 spec rule:{spec.md anchor}
## Self-improvement capture
- 新 anti-pattern 加進本 skill 的 Phase 0 「Bug 類型 → grep target」表
- M10 fire 紀錄(commit 後本 skill invoke vs not)
寫進:
memory/ 若是 cross-session patternreferences/ 若是 reusable detection 公式N 個 candidate 的修法 scope由 agent 依 frozen scope、canonical、tests 與 rollback 自行收斂;檔案數量不構成人類工程核准門檻。
若 N candidates 都 violate 同 canonical,但 canonical 本身可能 outdated → 走 audit 重訂。工程/治理決策 AUTO;只有重訂會改產品/UI/UX SSOT 且存在真取捨才停。
只有不屬 frozen scope 的 improvement 才放 Backlog,必寫 memory + evidence + reason;Scope 內可修復項不得因 milestone 或工程偏好 defer。
| Tool | scope | 跟本 skill 關係 |
|---|---|---|
/design-system-audit | full-dim batch audit | 本 skill 抓不到的 architectural pattern audit 補位 |
/visual-audit | 單次視覺對齊 | Phase 3 verify 用 |
/scan-similar-bugs(本) | immediate-after-fix grep + verify | M10 mechanical 落地 |
/knowledge-prune | 季度 governance prune | 不重複 |
check_canonical_propagation.sh E.2(hook;原 check_l3_primitive_import.sh folded 折入,P0 BLOCK) | L3 primitive import 違規 | 即時 detect,本 skill 是 batch retro scan |
pre_write_subsumption_check.sh(retired 2026-06 → canonical hooks/retired/;新 file / M-row 治理由 session_start_governance_check.sh + enforce_home_charter.sh 現役防線接手) | 新 file / M-row | 不重複 |
3 層 防線:
/design-system-audit(periodic):季度 full-dim sweep我們對齊 4 家但加 DS-domain-specific anti-pattern table(Phase 0 列表),是 generic IDE 沒做到的。
每次 invoke 完寫:
回填 SKILL.md 或 references/ 形成累積資產。
What SKILL.md sets; muted values are Claude Code's defaults
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./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。/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。