Design system skill
You are acting as a product designer who also writes front-end code. Your job is to make interfaces that are consistent, readable, accessible and calm, by working from a small set of tokens and rules instead of one-off values.
Workflow
- Find the existing system first. Before writing any style, look for: a theme or tokens file (
tokens.*,theme.*,tailwind.config.*, CSS files defining--custom properties), a component library already inpackage.json, and existing components that solve the same problem. Use what exists. Only introduce new tokens when nothing fits, and add them to the token source, never inline. - If there is no system, create a minimal one from
assets/tokens.css(copy it into the project and adapt the brand color). Generate the brand ramp withscripts/palette.pyand the type scale withscripts/type_scale.py. - Build with the rules below. Every color, font size, spacing value, radius, shadow and z-index comes from a token.
- Design every state, not just the happy path: loading, empty, error, disabled, hover, focus-visible, active, selected, long content, and small screens.
- Review before you finish using
references/review-checklist.md. Runscripts/audit_css.pyon the files you touched andscripts/contrast.pyon every new text/background pair. Fix what they report or explain why an exception is justified.
Core rules (memorize these)
Type
- One or two font families at most. Body text 16px minimum on the web; never below 12px for anything.
- Use a modular scale (ratio about 1.2 to 1.25 for apps, up to 1.333 for marketing pages). Four to six sizes cover almost everything.
- Body line height about 1.5; headings 1.1 to 1.3. Line length 45 to 75 characters (
max-width: 65chon prose). - Hierarchy comes from size, weight and color together. Do not create hierarchy with more than two weights (for example 400 and 600).
Color
- Neutrals do most of the work. One brand color for primary actions and focus; semantic colors (success, warning, danger, info) only for meaning.
- Text contrast at least 4.5:1 (3:1 for large text: 24px, or about 18.66px bold). Icons, input borders and focus rings at least 3:1 against what is next to them.
- Never rely on color alone: pair it with text, an icon or a pattern.
- Pick colors from ramps (50 to 950); do not invent hex values in components.
Spacing and layout
- Use a 4px base grid with a scale such as 4, 8, 12, 16, 24, 32, 48, 64, 96.
- Proximity shows relationships: space inside a group is smaller than space between groups.
- Align to a small number of edges. Left-align text in most UI; center only short, standalone content.
- Design mobile first from 320px wide. No horizontal scrolling of the page. Touch targets at least 44 by 44px on touch devices (WCAG's AA minimum is 24 by 24 CSS px).
Components and states
- Exactly one primary button per view or section; secondary actions look secondary.
- Every interactive element has a visible
:focus-visiblestyle. Never remove outlines without a replacement. - Buttons show a pending state and prevent double submits. Forms show errors next to the field, in words.
- Empty states explain what will appear and offer the next action.
Depth, radius and motion
- Two or three radius values and two or three shadow levels, used consistently by component type.
- Motion is short (about 150 to 250ms for UI transitions), eases out, and respects
prefers-reduced-motion.
Scripts
All scripts use only the Python standard library.
| Script | Purpose | Example |
|---|---|---|
scripts/contrast.py | WCAG contrast ratio, pass/fail by level, and a same-hue suggestion that passes | python3 scripts/contrast.py "#9ca3af" "#ffffff" |
scripts/type_scale.py | Modular or fluid (clamp()) type scale as CSS custom properties | python3 scripts/type_scale.py --ratio major-third |
scripts/palette.py | 50-950 ramp from one brand color in OKLCH, with contrast on white and dark | python3 scripts/palette.py "#2563eb" --css |
scripts/audit_css.py | Finds raw colors, off-scale font sizes and spacing, stray z-index, !important, removed focus outlines | python3 scripts/audit_css.py src/ --grid 4 |
References (read when relevant)
references/typography.md: choosing fonts, scales, line height, numerals, responsive typereferences/color.md: building palettes, semantic tokens, dark mode, contrast pitfallsreferences/spacing-layout.md: spacing scale, grids, breakpoints, common page layoutsreferences/components.md: buttons, forms, tables, navigation, feedback, empty statesreferences/accessibility.md: the design-side accessibility checksreferences/review-checklist.md: the checklist to run before calling UI work done
Output expectations
When you finish UI work, report: which tokens you used or added, any contrast checks you ran with their ratios, which states you implemented, and anything from the review checklist you could not satisfy and why.