技能 编程开发 设计系统采用率审计

设计系统采用率审计

v20261122
design-system-adoption
量化代码库对设计系统的真实采用率:统计令牌覆盖率与硬编码颜色、间距、字号的对比,设计系统组件与本地重复实现、分叉组件的对比。定位问题热点,识别应抽取为组件的重复模式,并制定带 lint 规则与安全代码迁移脚本、可防回退的迁移计划。
获取技能
346 次下载
概览

Design System Adoption

A design system only helps where the code uses it. Teams know their design system exists; few know that a third of their colors are still hardcoded or that the product has six button implementations. This skill measures adoption the way you measure test coverage — reproducibly and per area — and turns the result into a migration plan that can't regress.

Phase 1: Locate the system

Find the tokens (CSS custom properties, Tailwind theme, theme object, DTCG files) and the component library: an internal package or folder, or an external one (MUI, Chakra, Mantine, Radix, shadcn/ui, Ant Design, Polaris…). Note which components it provides and how they're imported. If there are no tokens yet, run design-system-extract first.

Scope the measurement to application source. Exclude the design system's own code, generated files, vendored code, tests, stories and fixtures.

Phase 2: Measure token adoption

For each category, count token usages against hardcoded values in the scoped files, using commands someone else can re-run. Example patterns to adapt to the stack (use ripgrep when available):

CategoryHardcodedToken usage
Color#[0-9a-fA-F]{3,8}\b, rgba?\(, hsla?\(, oklch\( in styles; Tailwind arbitrary values like bg-[#…]var(--color-…), theme references, Tailwind classes from the theme palette
Spacingmargin, padding, gap with px values off the scale; Tailwind p-[13px]scale classes, var(--space-…)
Font sizefont-size: literals, Tailwind text-[15px]type-scale classes or tokens
Radius, shadow, z-indexliterals in those propertiestokens

Report adoption = token usages ÷ (token usages + hardcoded values) per category and per top-level area (feature folder, package or route). Count separately the literals that exactly equal a token value: they're the easy wins.

Expect noise. SVG fills, third-party overrides and one-off illustrations are legitimate. Review a sample of matches for each pattern and state the estimated false-positive rate instead of presenting the number as exact.

Phase 3: Measure component adoption

For each design-system component, count:

  • DS usages — imports from the design system.
  • Native re-implementations — raw <button>, <input>, <select>, <dialog> and similar elements styled locally where a DS component exists.
  • Local look-alikes — components outside the system whose name or markup duplicates one (PrimaryButton, MyModal, CardV2).
  • Forks — copies of a DS component modified locally.

Report component adoption = DS usages ÷ (DS usages + re-implementations + look-alikes) per component.

Phase 4: Find candidates for new components

Look for UI patterns that appear at least three times without a DS component: cards, list rows, empty states, page headers, stat tiles, form sections. For each candidate, list the variants and states actually used (default, hover, focus, disabled, loading, error), the tokens it should use, and its accessibility requirements — enough for someone to build it once.

Phase 5: Plan the migration

Prioritize by frequency × visibility ÷ effort: a hardcoded color on every screen of the main flow beats 30 occurrences in an admin page.

  1. Safe codemods — literals that exactly equal a token value can be replaced automatically. Propose the script and apply it only if asked, in its own commit.
  2. Manual replacements — near-values and local components, grouped into PR-sized batches by area, in priority order.
  3. New components from Phase 4.
  4. Stop the regression. Add a lint rule that forbids new hardcoded values in the scoped files — stylelint (color-no-hex, declaration-property-value-disallowed-list), an ESLint rule on Tailwind arbitrary values, or restricted imports for deprecated components — with a baseline of existing violations or warnings-only on old code, so the rule can land today. Ratchet: the count can go down, never up.

Output

Write docs/product/design-system-adoption.md (or the project's docs location) with: the commands used, adoption per category and per area, the component adoption table, hotspots (top files and areas), candidate components with their inventory, and the migration plan. Summarize the headline numbers and the three changes with the best impact-to-effort ratio. Re-running the same commands later shows the trend.

信息
分类 编程开发
名称 design-system-adoption
版本 v20261122
大小 4.9KB
更新时间 2026-11-25
语言