UI/UX Design Skill for AI Coding Agents: Type Scales, Color, Spacing and a Design Review Checklist
An open-source UI/UX design skill (in the Agent Skills SKILL.md format) that gives AI coding agents real design sense. With it installed, agents such as Claude Code build interfaces from design tokens instead of random values, pick type scales and color ramps that work, keep spacing on a grid, design every state (loading, empty, error, focus), meet WCAG contrast, and review their own UI against a checklist before calling it done.
It ships with four small Python scripts the agent (or you) can run: a WCAG contrast checker that suggests a passing color, a modular and fluid type scale generator, an OKLCH palette generator, and a CSS audit that finds off-system colors, font sizes, spacing and z-index values. It is for developers who build front ends with AI assistance and are tired of UI that “works but looks off”.
Last reviewed: December 2026. Accessibility figures follow WCAG 2.2; skill and plugin formats were checked against the Agent Skills specification and Claude Code docs at that date.
Contents
- What the skill changes
- Install
- How agents use it
- The design rules
- Design tokens: the three layers
- Dark mode done properly
- The scripts
- Before and after
- The review checklist
- Adapting it to your brand or design system
- Learn from established design systems
- FAQ
- Where to go next
- Repository layout
- Contributing
- License
- More free resources
What the skill changes
Without guidance, coding agents tend to produce UI with familiar problems:
| Typical agent output | With the skill |
|---|---|
| A dozen font sizes (13px, 15px, 17px, 22px…) | Four to six sizes from one modular scale |
| Hex colors sprinkled through components | Semantic tokens (--color-text, --color-primary) backed by ramps |
| Light grey text that fails contrast | Every text pair checked against 4.5:1 |
| Padding of 10px here, 18px there | A 4px grid: 4, 8, 12, 16, 24, 32, 48… |
| Only the happy path designed | Loading, empty, error, disabled and focus states |
outline: none on focus |
A visible :focus-visible ring |
| Three equally loud buttons | One primary action per section |
| Dark mode by inverting colors | Swapped semantic tokens with re-checked contrast |
The skill is deliberately opinionated but small: the main SKILL.md is under 100 lines, and detailed guidance lives in reference files the agent reads only when needed, so it costs little context.
Install
Claude Code (plugin)
/plugin marketplace add Ralpberry-Labs/ui-ux-design-skill
/plugin install ui-ux-design-skill@ralpberry-design
Claude Code (copy the skill folder)
git clone https://github.com/Ralpberry-Labs/ui-ux-design-skill.git
# For one project (commit it so your team gets it too)
mkdir -p .claude/skills && cp -r ui-ux-design-skill/skills/design-system .claude/skills/
# Or for all your projects
mkdir -p ~/.claude/skills && cp -r ui-ux-design-skill/skills/design-system ~/.claude/skills/
Other agents
The skill follows the open Agent Skills format: a folder with a SKILL.md (YAML frontmatter with name and description) plus scripts/, references/ and assets/. Copy skills/design-system/ into whatever skills folder your agent reads. If your tool does not support skills, paste the body of SKILL.md into its instruction file (AGENTS.md, rules file, custom instructions) and keep the references/ folder in the repository.
Requirements for the scripts: Python 3.10 or newer, standard library only.
How agents use it
The description tells the agent to load the skill whenever it builds or restyles UI, chooses colors or fonts, creates tokens, or reviews a page. Once loaded, the skill gives the agent a five-step workflow:
- Find the existing system first: tokens, theme files, Tailwind config, component library, existing components. Reuse beats invention.
- If there is none, start from the starter tokens in
assets/tokens.css, generating a brand ramp and type scale with the scripts. - Build with the rules: every color, size, space, radius, shadow and z-index from a token.
- Design every state, not just the happy path.
- Review: run the checklist,
audit_css.pyon changed files andcontrast.pyon new color pairs, and report what was checked.
You can also invoke it directly: “Use the design-system skill to review the settings page.”
The design rules
These are the rules in the skill, with the reasoning behind them.
Typography
- One or two families. The system UI stack is a strong default for apps: no loading, native feel. Add a brand font only where it earns its keep (headings, marketing).
- A modular scale. Multiply a base size by a ratio: about 1.125 to 1.2 for dense apps, 1.2 to 1.25 for general UI, up to 1.333 for marketing. Four to six sizes cover nearly everything.
- 16px body text minimum on the web, in
remso user settings apply. Nothing below 12px. - Line height about 1.5 for body, 1.1 to 1.3 for headings; larger text needs tighter leading.
- Line length 45 to 75 characters.
max-width: 65chon prose fixes most “wall of text” pages. - Two weights (400 and 600) are enough for most UI. Hierarchy comes from size, weight and color together.
- Tabular figures for numbers in tables and dashboards:
font-variant-numeric: tabular-nums.
Common ratios:
| Name | Ratio | Feel |
|---|---|---|
| Major second | 1.125 | Very compact, data-heavy UI |
| Minor third | 1.2 | Balanced apps and docs |
| Major third | 1.25 | Clear hierarchy, general purpose |
| Perfect fourth | 1.333 | Editorial, landing pages |
| Perfect fifth | 1.5 | Dramatic display headings |
Color and contrast
- Neutrals do most of the work. Roughly 60 to 70 percent of a screen is background and surface, 20 to 30 percent text and borders, under 10 percent brand and status color.
- One brand color for primary actions, links and focus. Semantic colors (red, green, amber, blue) only carry meaning.
- Ramps, not one-offs. Each hue gets steps 50 to 950. Components never use a raw hex.
- Contrast minimums (WCAG 2.2 AA): 4.5:1 for normal text; 3:1 for large text (24px, or about 18.66px bold) and for meaningful icons, input borders, focus indicators and chart lines.
- Never color alone. Errors get text, status gets an icon or label, chart series get direct labels or patterns.
- Watch the usual traps: muted grey text, placeholder text, white text on mid-tone (500-step) buttons, text over photos.
Spacing
- 4px base grid with a scale: 4, 8, 12, 16, 24, 32, 48, 64, 96.
- Proximity communicates grouping: space inside a group is smaller than space between groups. This single rule fixes most cluttered layouts.
- Use
gapon flex and grid containers instead of margins on children. - Pick a density per surface (compact for tables, roomy for marketing) and do not mix densities inside one component.
Layout
- Mobile first from 320px wide; add breakpoints where the content breaks.
- Constrain content width: about 1200 to 1280px for apps, about 65ch for reading, with at least 16px side padding on phones.
- Few alignment edges. Labels and inputs share a left edge; numbers right-align; center only short standalone content.
- Layering scale for z-index (dropdown 10, sticky 20, overlay 30, modal 40, toast 50) instead of
z-index: 99999. - Touch targets: WCAG 2.2 AA requires at least 24 by 24 CSS pixels (criterion 2.5.8); 44 by 44 is a comfortable target on touch screens.
Components and states
- Buttons: primary, secondary, tertiary and destructive only. One primary per section. Verb labels (“Save changes”). Loading state that blocks double submits.
- Forms: visible labels above inputs (placeholders are not labels), errors under the field in words, the right
typeandautocomplete, related fields grouped. - Tables: clear headers with units, right-aligned tabular numbers, row height 40 to 48px, a plan for small screens.
- Feedback: inline errors for content problems; toasts only for brief confirmations, never for errors that need action.
- Every data view has five states: loading (skeletons matching the layout), empty (what will appear and the next action), error (what happened, keep input, retry), partial, and success.
- Focus is visible on every interactive element with
:focus-visible.
Depth, radius and motion
- Two or three radii (for example 4, 8 and 12px) assigned by component type, plus a full radius for pills and avatars.
- Two or three shadow levels, soft and low-contrast. In dark mode, show elevation with lighter surfaces instead.
- Motion: short (about 150 to 250ms for UI transitions), ease-out, meaningful, and disabled under
prefers-reduced-motion.
Design tokens: the three layers
The starter file assets/tokens.css uses a structure that scales from a side project to a large design system:
/* 1. Ramps: raw values, never used directly by components */
--color-brand-600: #2361e9;
--color-neutral-900: #0f172a;
/* 2. Semantic tokens: what components use */
--color-primary: var(--color-brand-600);
--color-text: var(--color-neutral-900);
/* 3. Component tokens (optional, for large systems) */
--button-primary-bg: var(--color-primary);
Why it matters: rebranding means regenerating one ramp, and dark mode means remapping the semantic layer. No component changes.
The starter tokens include neutral, brand and status colors; a type scale; a 4px spacing scale; radii; shadows; a z-index scale; durations and easing; light and dark semantic mappings; a reduced-motion rule; and a default focus ring. The test suite checks that every main text pair in both themes meets WCAG AA.
Dark mode done properly
- Use dark greys (not pure black) for backgrounds, and lighter greys for raised surfaces.
- Use lighter, slightly less saturated brand steps (for example 400 instead of 600).
- Swap semantic tokens, both for the system preference and for an explicit user choice:
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) { --color-bg: var(--color-neutral-950); /* ... */ }
}
:root[data-theme="dark"] { --color-bg: var(--color-neutral-950); /* ... */ }
- Add
color-scheme: light dark;so form controls and scrollbars match. - Re-check contrast for every pair. A color that passes on white can fail on dark grey.
The scripts
All four live in skills/design-system/scripts/ and use only the Python standard library.
contrast.py: WCAG contrast with a fix
python3 contrast.py "#9ca3af" "#ffffff"
#9ca3af on #ffffff: 2.54:1
FAIL AA normal text (4.5)
FAIL AA large text (3.0)
FAIL AA UI components (3.0)
FAIL AAA normal text (7.0)
FAIL AAA large text (4.5)
Suggestion: #6f7681 gives 4.58:1 (same hue, adjusted lightness)
The suggestion keeps the hue and adjusts OKLCH lightness to the nearest value that passes. Use --target 3 for large text or UI components. Exit code is 1 when the pair fails, so it works in scripts.
type_scale.py: modular or fluid type scale
python3 type_scale.py --ratio major-third --down 1 --up 4
:root {
--font-size-sm: 0.8rem; /* 12.8px */
--line-height-sm: 1.5;
--font-size-base: 1rem; /* 16px */
--line-height-base: 1.5;
--font-size-lg: 1.25rem; /* 20px */
--line-height-lg: 1.4;
--font-size-xl: 1.562rem; /* 25px */
...
}
With --fluid, it emits clamp() values that grow smoothly between two viewport widths (defaults 360px and 1280px), with separate minimum and maximum ratios so headings get more dramatic on large screens while body text barely moves.
palette.py: an even 50 to 950 ramp from one color
python3 palette.py "#2563eb"
step hex on white on dark
50 #f0f5ff 1.09 17.97
100 #dce8ff 1.23 15.93
...
600 #2361e9 5.31 3.70
700 #134ac4 7.49 2.62
...
Steps are spaced evenly in OKLCH lightness, with chroma tapered toward the light and dark ends so tints are not neon and shades are not muddy. Colors outside the sRGB gamut are brought in by reducing chroma, not by clipping. The contrast columns show at a glance which steps can carry text on light and dark backgrounds. Add --css --name brand to print custom properties.
audit_css.py: find design-system drift
python3 audit_css.py src/ --grid 4 --font-sizes 12,14,16,18,20,24,30,36,48
card.css:1: [font-size] 15px is not on the type scale
card.css:1: [spacing] 18px is not a multiple of 4px
card.css:2: [raw-color] use a color token instead of a literal
card.css:4: [z-index] z-index 99999 is not in the layering scale
card.css:3: [focus] focus outline removed without a visible replacement
Summary: focus=1, font-size=1, raw-color=1, spacing=1, z-index=1
It scans .css, .scss, .less, .jsx, .tsx, .vue, .svelte and .html files, skipping node_modules. Color literals inside custom property definitions (--x: #fff) are allowed, since that is where tokens live. Exit code 1 when anything is found, so you can gate CI on it. It is a heuristic line-based scanner, not a CSS parser: treat its output as a review list.
Before and after
A card an agent might write without guidance:
.card { background: #fff; padding: 18px; border-radius: 7px; box-shadow: 0 2px 9px rgba(0,0,0,.3); }
.card h3 { font-size: 22px; color: #333; margin-bottom: 6px; }
.card p { font-size: 15px; color: #999; }
.card button { background: #3b82f6; color: #fff; padding: 10px 14px; }
.card button:focus { outline: none; }
Problems: five one-off values, #999 body text at about 2.8:1 on white, a heavy shadow, white on a mid-tone blue that falls short of 4.5:1, and no focus indicator.
The same card with the skill:
.card {
background: var(--color-surface-raised);
padding: var(--space-6);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-sm);
display: grid;
gap: var(--space-2);
}
.card h3 { font-size: var(--font-size-xl); line-height: var(--line-height-snug); color: var(--color-text); }
.card p { font-size: var(--font-size-base); color: var(--color-text-muted); max-width: 65ch; }
.card button {
justify-self: start;
background: var(--color-primary);
color: var(--color-on-primary);
padding: var(--space-2) var(--space-4);
border-radius: var(--radius-md);
}
.card button:hover { background: var(--color-primary-hover); }
.card button:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
Every value is a token, contrast is verified by the token tests, spacing comes from gap, and the button has hover and focus states. Dark mode works with no extra code.
The review checklist
The full checklist is in references/review-checklist.md. The agent runs it at the end of UI work. Highlights:
- No raw colors, off-scale font sizes or off-grid spacing in components (
audit_css.pyis clean) - The most important element is obvious within a second; one primary action per section
- Related items closer together than unrelated ones; few alignment edges
- Works at 320px wide without horizontal scrolling
- Loading, empty, error and success states for every data view; hover, active, focus-visible and disabled for every control
- Long text, big numbers, missing images and zero/one/many items do not break the layout
- Every text pair passes contrast; focus indicators are visible; meaning never depends on color alone
- Keyboard-only walkthrough works, including Escape to close overlays
- Buttons say what they do; error messages say how to fix the problem
- Motion respects
prefers-reduced-motion; no layout shift when content loads
Adapting it to your brand or design system
- Brand color:
python3 scripts/palette.py "#yourcolor" --name brand --css, paste the result over the brand ramp in your copy oftokens.css, then re-run the tests orcontrast.pyon your semantic pairs. - Existing design system: edit
SKILL.mdstep 1 to name your token file and component library explicitly (“Use components from@acme/ui; tokens live inpackages/tokens/src/”). The skill will then enforce your system instead of the starter one. - Tailwind projects: map the semantic tokens into your Tailwind theme (as CSS variables) and tell the skill to prefer theme classes over arbitrary values like
p-[18px]. - Different grid or scale: pass
--grid 8or your own--font-sizeslist toaudit_css.py, and update the numbers inSKILL.mdso the agent’s rules and the audit agree.
Learn from established design systems
Public design systems are free, well-documented references for decisions this skill makes. What each is especially useful for (our summary):
| System | Worth studying for |
|---|---|
| Material Design 3 | Color roles and tonal palettes, dynamic color, component states |
| Apple Human Interface Guidelines | Platform conventions, typography, touch targets, accessibility |
| Carbon | Dense enterprise UI, data tables, a rigorous spacing and type system |
| Polaris | Content and copy guidelines, admin layouts |
| Primer | Developer-tool UI, color modes and accessibility |
| Fluent 2 | Cross-platform tokens and theming |
| Atlassian Design System | Tokens naming, collaboration product patterns |
| GOV.UK Design System | Accessible forms, error messages, plain-language patterns |
Picks: GOV.UK for forms and errors, Carbon for dense data UI, Material 3 for color roles, and the platform guidelines (Apple HIG) whenever you build native-feeling mobile UI.
FAQ
Does this replace a designer? No. It raises the floor: consistent, accessible, unsurprising UI. A designer still decides what the product should feel like, and the skill is a good way to encode those decisions for agents.
Will it fight my existing styles? Step 1 of the workflow tells the agent to find and use your existing system first. It only introduces the starter tokens when nothing exists.
Why OKLCH for palettes? Equal steps in OKLCH lightness look equally spaced to people, unlike HSL, where “50 percent lightness” yellow and blue look very different. That makes ramps predictable and contrast easier to reason about.
Is passing contrast.py enough for accessibility? No. Contrast is one criterion. See references/accessibility.md for the other checks, and test with a keyboard and a screen reader.
What contrast ratio do I need? WCAG 2.2 AA: 4.5:1 for normal text, 3:1 for large text and for UI components and focus indicators.
What is a good base font size for web apps? 16px for body text, with a modular scale for headings and a 1.4 to 1.6 line height.
4px or 8px grid? Both work; a 4px base with mostly 8px multiples gives enough fine control for dense UI. Pick one and enforce it with audit_css.py --grid.
Why Python scripts? Python 3 is available on most developer machines and in most agent sandboxes, and the standard library is enough for color math. No install step means agents can run them immediately.
Where to go next
- Standards: WCAG 2.2 and its quick reference; WebAIM contrast checker
- Color: OKLCH in CSS explainer, the oklch.com picker, Radix Colors
- Type and layout: Utopia for fluid type and space scales, Every Layout for robust CSS layout primitives
- Tokens: Open Props as a ready-made set of CSS custom properties
- Practical design for developers: Refactoring UI
- Companion repos: Claude Code Agents (includes
ui-reviewerandaccessibility-auditorsubagents)
Repository layout
ui-ux-design-skill/
├── .claude-plugin/
│ ├── plugin.json # plugin: ui-ux-design-skill
│ └── marketplace.json # marketplace: ralpberry-design
├── skills/design-system/
│ ├── SKILL.md # the skill (workflow + core rules)
│ ├── references/ # typography, color, spacing-layout, components,
│ │ # accessibility, review-checklist
│ ├── scripts/ # contrast, type_scale, palette, audit_css (+ colorlib)
│ └── assets/tokens.css # starter tokens, light and dark
├── tests/test_design_scripts.py
├── LICENSE
└── README.md
Run the tests:
python3 -m unittest discover -s tests -v
Contributing
Pull requests are welcome: sharper rules, more component guidance, better scripts, and examples from real projects. Please keep SKILL.md short (detail goes in references/), keep scripts dependency-free with tests, and back any numeric rule with a source or a clear rationale. Accessibility figures must match the current WCAG version.
License
MIT.
If this skill made your agent’s UI look better, a star helps others find it.
More free resources
Part of the Ralpberry Labs open-source collection. See also Top 100 Open Source.