designspec

Keep AI-written UI on your design system.
designspec reads your design system from code into a design/ spec (tokens, component contracts, rules).
AI coding agents use that spec before they write UI, and a GitHub Action blocks pull requests that drift
from it.
$ npx designspec-kit init
✔ Next.js + Tailwind v4
✔ shadcn/ui (src/components/ui): 3 components, 18 variant values
✔ Headless: base-ui, radix (allowed only inside src/components/ui)
✔ 9 tokens from src/app/globals.css
✔ AI agents: AGENTS.md, skills designspec-ui + designspec-propose and an MCP server in .mcp.json
✔ Baseline: 12 existing violations recorded in design/baseline.json (they won't fail checks)
$ npx designspec-kit check --no-baseline
src/app/page.tsx
9:22 error Hardcoded color "text-[#1a1a1a]". no-hardcoded-color
↳ Closest token: text-foreground (--foreground).
10:67 error Raw palette color "bg-red-500". no-palette-color
↳ Closest token: bg-destructive.
15:7 error Native <button> used; the design system provides <Button>. prefer-ds-component
↳ import { Button } from "@/components/ui/button"
16:24 error "ghost2" is not a variant of Button. no-unknown-variant
↳ Allowed: default, destructive, outline, ghost, link. Need a new one? Run `designspec propose`.
24:36 error "h-12" overrides the height that Button's size variant controls. no-variant-override
↳ Pick a size instead (default, sm, lg, icon), or propose a new one with `designspec propose`.
Why
AI agents write UI fast, but they don't know your design system. They hardcode hex values, invent
variant="ghost2", resize a <Button> with classes and reach for <button>. Linters catch some of this.
Nothing tells the agent what to use instead, and nothing governs how the design system itself changes.
designspec does three things:
- Spec.
design/ holds tokens (W3C DTCG), component contracts and rules. It is extracted from your code, so there is nothing to write by hand.
- Agents. An
AGENTS.md section, two skills and an MCP server make Claude Code, Cursor, Codex and others look things up in the spec and open a proposal instead of inventing values.
- Enforcement.
designspec check runs as a GitHub Action on your own runner, with no server and no API key. It only reports problems on changed lines, so adopting it doesn't mean fixing everything first.
Supported stacks
| |
|---|
| Frameworks | React, Next.js, Vite, Remix, React Native / Expo, Vue and Svelte single-file components |
| Styling | Tailwind CSS v4 and v3, CSS, SCSS and Less files, styled-components and Emotion (templates, object styles, css prop), inline styles, StyleSheet.create, MUI sx |
| Components | shadcn/ui and any cva() or tailwind-variants tv() components; others through string-literal union props (variant?: "primary" | "ghost"); workspace UI packages (@acme/ui) and design systems from npm, read from their type declarations |
| Headless | Base UI, Radix |
| Component libraries | Chakra UI, Mantine, MUI: theme tokens (createSystem, createTheme) and style props (bg="brand.500") |
| Tokens | CSS variables (incl. .dark and [data-*] theme modes, @theme, @imports), SCSS $ and Less @ variables, W3C DTCG and Tokens Studio JSON, Tailwind v3 config, JS/TS theme modules |
Quick start
npm install --save-dev designspec-kit
npx designspec-kit init # detect the stack, extract the spec, set up agents, record a baseline
npx designspec-kit check # check the project
npx designspec-kit fix # apply the fixes that are safe to apply automatically
Then add the GitHub Action (.github/workflows/design-system.yml):
name: Design system
on: pull_request
permissions:
contents: read
pull-requests: write # for the PR comment
jobs:
designspec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: Eronred/designspec@v0
Problems show up as annotations on the PR diff, in the job summary and in a PR comment that is kept up to
date. Monorepos, AI review and the other inputs are covered in docs/github-action.md.
Commands