一键导入
design-system
Expert reference for building, scaling, and governing design systems — tokens, component APIs, documentation, adoption, and contribution governance
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Expert reference for building, scaling, and governing design systems — tokens, component APIs, documentation, adoption, and contribution governance
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Expert reference for application security — OWASP Top 10 mitigations, auth/authz, secrets management, cryptography, input validation, dependency hygiene, and secure-by-default code patterns
Expert reference for token counting, prompt compression, cost estimation, and quality preservation when optimizing prompts for Claude models
Experimentation design and A/B testing standards for product teams
Expert reference for digital accessibility — WCAG conformance, ARIA, and inclusive design patterns
Authoritative reference for agent architecture selection, multi-agent orchestration, tool design, memory systems, and failure mode prevention
Expert reference for evaluating LLM systems, RAG pipelines, and AI features in production
| name | design-system |
| description | Expert reference for building, scaling, and governing design systems — tokens, component APIs, documentation, adoption, and contribution governance |
| version | 2 |
variant prop.If all of the following are true → adopt an existing system (MUI, Radix, Paste, etc.) rather than build:
If any of the following are true → build (or heavily customize an existing system):
Never build a custom system to avoid learning an existing one. Adoption friction is a docs problem, not an architecture problem.
Token Architecture
color.text.primary) → it maps to a primitive (e.g., color.gray.900). Never skip the semantic layer.category-role-variant. Examples: --color-action-default, --color-action-hover, --space-inset-md, --text-body-size.--brand-blue or --primary-color. Always use --color-interactive-default or --color-feedback-error.Token Naming Conventions (specific)
| Category | Primitive format | Semantic format | Bad name |
|---|---|---|---|
| Color | --color-blue-500 | --color-action-default | --brand-blue, --primary |
| Spacing | --space-4 (= 16px) | --space-inset-md | --padding-medium |
| Typography | --font-size-14 | --text-body-size | --normal-text |
| Radius | --radius-4 | --radius-md | --rounded |
| Shadow | --shadow-2 | --shadow-overlay | --card-shadow |
Use Style Dictionary to define primitives in JSON and generate CSS custom properties, JS constants, iOS/Android outputs from one source. Figma Tokens plugin (or Tokens Studio) keeps Figma variables in sync with the same source.
Component API Design
...rest.className prop or CSS custom properties on the token layer.<Tab> that only works inside <TabGroup> is fine; <TabGroup> that crashes without a <Tab> child is not).Versioning and Breaking Changes
console.warn in development mode.Adoption
A component is not shippable until all five criteria are met. No exceptions.
| Criterion | Minimum bar |
|---|---|
| Design | Figma spec covers all states: default, hover, focus, active, disabled, loading, error |
| Code | TypeScript types exported, all props documented, ...rest forwarded, no any |
| Storybook | Stories for every prop combination that changes visual output; interactive controls; accessibility add-on enabled |
| Tests | Unit tests for logic/state; visual regression snapshot (Chromatic or Percy) for each story |
| Accessibility | Keyboard navigation tested; screen reader tested (VoiceOver + NVDA); color contrast verified; focus management correct |
Every component story must:
intent/variant/size permutations as named storiesPlayground story with all props exposed via controls@storybook/addon-a11y with zero violations at the AA levelautodocsNever hand-write prop tables in MDX. They drift. TypeScript is the source of truth.
Who can contribute:
Contribution process:
What does not belong in the system:
<LeadScoreCard> is a product component, not a system component)Mistake: Primitive token names used in components
--color-blue-600 used directly in 40 components. Changing the brand color requires a global search-replace across 40 files.
Fix: Semantic layer. --color-interactive-default: var(--color-blue-600). Update one token, retheming is instant.
Mistake: Monolithic variant prop
// Bad — one prop encoding three orthogonal decisions
<Button variant="primary-large-destructive-loading" />
// Good — each prop controls one axis independently
<Button intent="destructive" size="lg" loading />
Mistake: Accessibility as afterthought
Building a custom dropdown, shipping it, then receiving a11y bug reports in production.
Fix: Write accessibility acceptance criteria before writing any code. Test with keyboard-only and VoiceOver in the PR checklist. The PR does not merge if addon-a11y reports violations.
Mistake: No component contract
Undocumented className overrides used by consumers to patch visual bugs. Internal markup changes; their overrides break silently with no warning.
Fix: Document the extension surface explicitly. If className is supported, document it. If it is not, enforce it via an ESLint rule that warns on direct class overrides.
Mistake: Documentation drift Storybook shows old API. README has a different API. Source has a third. Fix: Auto-generate prop tables from TypeScript types. Storybook is the source of truth. A documentation divergence is a failing CI check, not a manual review concern.
Mistake: Design-dev token divergence
Figma has Button/Primary/Default. Code has button-bg-primary. The mapping is tribal knowledge that leaves with the person who built it.
Fix: Tokens are defined once in a shared source (Style Dictionary JSON or Tokens Studio) and transformed into platform outputs (CSS vars, JS objects, Figma variables). One source, all platforms.
Bad: Hardcoded component
.button-primary {
background: #2563eb;
border-radius: 6px;
font-size: 14px;
padding: 8px 16px;
}
Good: Token-driven component
.button-primary {
background: var(--color-action-default);
border-radius: var(--radius-md);
font-size: var(--text-sm-size);
padding: var(--space-2) var(--space-4);
}
Bad: Prop explosion
<Modal
isLarge
hasCloseButton
closeButtonLabel="Close"
hasHeader
headerText="Title"
hasFooter
footerPrimaryText="Save"
footerSecondaryText="Cancel"
/>
Good: Composition
<Modal size="lg">
<Modal.Header onClose={handleClose}>Title</Modal.Header>
<Modal.Body>{children}</Modal.Body>
<Modal.Footer>
<Button intent="secondary" onClick={handleCancel}>Cancel</Button>
<Button onClick={handleSave}>Save</Button>
</Modal.Footer>
</Modal>
Bad: No migration path
Rename type prop to intent in a patch release. 400 consumer instances silently render wrong.
Good: Graceful deprecation
// v2.3.0 — deprecated prop preserved with runtime warning
interface ButtonProps {
intent?: 'primary' | 'secondary' | 'destructive'
/** @deprecated Use `intent` instead. Will be removed in v3.0. */
type?: string
}
// Runtime: if `type` is passed, map it to `intent` + console.warn in development
// Codemod: npx @design-system/codemod button-type-to-intent ./src
Design Token — A named design decision (color, spacing, typography, shadow) stored as a variable. Three tiers:
--color-blue-600: #2563eb (raw value, no semantic meaning)--color-action-default: var(--color-blue-600) (role in the UI)--button-background-default: var(--color-action-default) (scoped to one component)Headless Component — Logic and state without opinions about rendering. The consumer provides the markup. Enables full style control while sharing behavior. Reference implementations: Radix UI, Headless UI, React Aria.
Compound Component Pattern — A parent component manages shared state; children are named slots. <Select>, <Select.Option>, <Select.Trigger>. The pattern prevents prop-drilling and makes the consumer's code readable.
Escape Hatch — A deliberate, documented way to override the system for one-off needs (style, className, asChild). Without escape hatches, teams fork. With undocumented escape hatches, upgrades silently break consumers.
Style Dictionary — The industry-standard tool (by Amazon) for defining tokens in JSON/YAML and transforming them into CSS custom properties, JS constants, iOS/Android asset files. Single source of truth across platforms.
Breaking Change — Any change that requires consumer code to change to maintain previous behavior. Includes: renamed props, changed defaults, removed elements, altered DOM structure, changed CSS custom property names.
Adoption Funnel — Awareness → Discoverability → First Use → Habitual Use. Measure each stage. Documentation fixes awareness and discoverability. API quality fixes first use. Governance and migration tooling fix habitual use.
Contribution Model — Centralized (core team only) gives consistency but bottlenecks at scale. Federated (any team can build, core team reviews) scales but requires strong governance. Hybrid (federated build, centralized API approval) is the industry standard for systems with 5+ consuming teams.