Build with AI agents
How to set up Claude Code, Cursor or any coding agent so the UI it writes follows the Matrix design system. A rules block to paste, the order to work in, and the checklist before every pull request.
Agents write good Matrix UI when they know three things: where the system is, which rules never bend, and how to check their own work. This guide decides all three. It applies to any repo that builds Matrix OS screens.
Agents read the system as plain text
| URL | What's in it |
|---|---|
/llms.txt | Every page with a one-line summary. The agent reads this first, then only the pages it needs. |
/llms-full.txt | Every page in full: setup, tokens, each component's code, API and guidelines, and these guides. |
Both live at https://matrix-os-design-library.vercel.app and update with every change, so the agent never works from an old copy.
Every repo carries the rules block
Paste this into the product repo's CLAUDE.md (Claude Code) or AGENTS.md / .cursor/rules (Cursor and others). It's the short version; the agent fetches details when it needs them.
## Matrix OS design system
UI follows the Matrix OS design system: https://matrix-os-design-library.vercel.app
Before building UI, read https://matrix-os-design-library.vercel.app/llms.txt and the pages for the
components you use (full text: /llms-full.txt). Guides: /guides/choosing-components, /guides/color-usage,
/guides/logo, /guides/actions, /guides/forms.
Rules:
- Use the components in components/ui (Button, Input, InputGroup, Field, Select, Checkbox, RadioGroup,
Switch, DropdownMenu, Tooltip, Badge, Avatar). Never build a second version; extend with props.
- Tokens only: semantic Tailwind classes (bg-primary, text-muted-foreground, border-border).
No hex, rgb, arbitrary values (w-[13px]) or Tailwind's default palette (bg-gray-100, text-red-500).
- Never invent a token or class name. If one is missing, say so instead of making one up.
- Color: neutral for actions (bg-primary). Coral (destructive) only for delete, remove and errors.
Hover/selected surfaces are neutral (bg-accent). Gold is the focus ring and highlights. Green is brand.
- Type: text-ui (14px) by default; text-ui-lg, text-ui-sm, text-ui-xs, text-heading. Geist only;
font-heading (Bricolage) only for brand moments. Weights normal/medium/semibold, never bold.
- Spacing on the 4px scale (p-2 = 8px): 8px inside components, 16px between them. No p-2.5, gap-7.
- Radius: controls rounded-md (8px), menus/popovers rounded-lg (12px), cards rounded-xl (16px).
- Shadows: shadow-xs on resting controls, shadow-lg on overlays, shadow-xl on dialogs. Never write box-shadow.
- Icons: lucide-react through the Icon component or inside Button; sizes xxs/xs/sm/md/lg. No emoji.
- Logo: RabbitMark only, sized by height (h-6 w-auto), at least h-4. Forest (text-teal-800) by default;
app icons are bg-teal-800 text-neutral-25. Never redraw, stretch, recolor or use it as an icon.
- Sizes: controls are sm 32 / md 36 (default) / lg 40px; lg is the largest, also on mobile.
- Every form control sits in a Field with a visible label. Errors: aria-invalid + FieldError.
- Icon-only buttons need an aria-label and a Tooltip with the same words.
- Never remove the focus ring. Light mode only: no dark: classes.
- Merge classes with cn() from lib/utils (it knows the Matrix class names).
- When rules conflict: accessibility first, then these rules, then the guide, then the component page.The agent picks, then reads, then composes
- Name the job. What does the person on this screen need to do? Pick components from Choosing a component, not from other design systems it remembers.
- Read the component pages it will use: API table, guidelines, copy-paste examples. Start from the example code.
- Compose with tokens. Layout with
flex/gridand scale spacing; colors from Color usage, actions from Actions, forms from Forms. - Write the states. Hover and focus are built in. Empty, loading, error and disabled are not, and a disabled control needs a reason.
- Run the checklist below and fix what fails before opening the pull request.
Missing pieces get flagged, not invented
When a screen needs something the library doesn't have yet (a dialog, a table, tabs), the agent uses the closest shadcn component restyled with Matrix tokens and says so in the pull request. Overlays are rounded-lg bg-popover shadow-lg, dialogs shadow-xl. That way the piece moves into the library later instead of living on as a one-off.
Correct early, review twice
For the person running the agent:
- Spend corrections early. Fix the choice of components before the agent writes the screen, not after.
- Don't be the first reviewer. Ask the agent to run the checklist and list what it changed before you look.
- Ask for evidence. "Show me the focus order" or "list every color class you used" beats "looks good?".
Checklist before a pull request
- Every color, size, radius, shadow and space is a token class. Search the diff for
#,rgb(,[and palette names (gray-,red-,blue-); there should be none. - Coral appears only on delete/remove actions and error messages.
- At most one primary button per view.
- Every input, select, checkbox, radio and switch has a visible, linked label (
htmlFor+id). - Every icon-only button has an
aria-labeland a tooltip. - Tabbing through the screen shows the gold focus ring on every interactive element, in a logical order.
- Text is 14px (
text-ui) or larger, except captions and badges. - Empty, loading and error states exist and use library components.
- No new component that duplicates one in
components/ui, and no edited copy of one in a feature folder.
Common mistakes
| Agents often write | Write instead | Why |
|---|---|---|
bg-gray-100, text-gray-500 | bg-accent, text-muted-foreground | Tailwind's grays aren't Matrix's warm neutral. |
bg-red-500 on a Delete button | <Button variant="destructive"> | One coral, with the right hover and contrast. |
text-sm font-bold | text-ui font-semibold | Matrix sizes, and no bold in product UI. |
rounded-lg on a button or input | nothing (the component sets rounded-md) | Controls are 8px at every size. |
p-2.5, gap-7, mt-[13px] | p-2/p-3, gap-6/gap-8, mt-3 | Only scale steps; the few exceptions live inside components. |
<input className="border …"> | <Input> in a <Field> | Border, focus, error and disabled come with it. |
outline-none / focus:ring-0 | leave focus alone | The gold ring is global; removing it breaks keyboard use. |
<DropdownMenu> to pick a form value | <Select> | Menus run actions; selects hold values. |
<Switch> in a form with a Save button | <Checkbox> | A switch applies immediately. |
<Icon size={18} strokeWidth={1.5}> | <Icon icon={X} size="sm" /> | Five sizes, stroke set automatically. |
dark:bg-… | nothing | Light mode only until dark tokens exist. |
Not covered here
Which component to use is Choosing a component. How to install the system in an app is Start here.