Design system in code: from Figma, from scratch or off the shelf
The agent builds the interface from what it sees in the repository. If there’s no design system there, it pulls one from the model’s memory: the same spacing, the same gradients and the same components as thousands of other projects. In zeroheight’s 2026 survey, 59% of teams see interfaces built around their design system instead of with it. This topic is about where to get a system in code that the agent will use to build your product.
There are three paths. First: you have a library in Figma, and it needs to become code. Second: there’s nothing, and you build the system from scratch with the agent. Third: you take an open-source system and restyle it as your own. In practice the paths mix: teams most often bring tokens over from Figma and take components off the shelf. How to make a system that already lives in code readable for an agent is the next topic, “AI-first design systems”.
The word “token” here means a named design value, a color or a spacing step, not a unit of text for the model. The difference is explained in the glossary.
What changed: code became the source of truth
While people built interfaces, the design system lived in Figma and the code caught up with it. An agent reads code, not mockups. So teams that work with agents move the source of truth into the repository: tokens live in JSON, components in code with all their states, rules in a file for the agent. Luke Wroblewski, who built a system like this for agents, writes that they started from mockups, moved the system into code through Figma MCP, and code became the source of truth: in practice they never needed to write changes back into Figma.
Figma isn’t going anywhere, though. It stays the input when the agent reads the library through MCP, and the output when a mockup is generated from code to discuss with the team. It just stops being the place where the rules are stored.

Path 1. From a Figma library to code
Step 1. Clean up the library before you connect the agent. Figma gives a short list: anything that repeats is a component; names describe purpose (color/surface/primary, not blue-500); colors, spacing, radii and fonts are set as variables; auto layout instead of coordinates; the library is published. A layer called Frame 427 tells the agent nothing, so it will make up a value. Absolute coordinates in a mockup turn into absolute positioning in code.
Step 2. Move the tokens into JSON. The format is DTCG, a specification from the W3C Design Tokens Community Group (not a W3C standard); the first stable version came out on October 28, 2025. There are two ways: Figma’s native variable export to JSON, announced in October 2025 and rolled out by December, or the Tokens Studio plugin, whose free plan syncs one file with Git. According to user reports, the native export doesn’t yet output composite tokens like typography and shadows, so you’ll have to add those by hand. This JSON is the system’s canonical file: Terrazzo builds CSS variables and the @theme block for Tailwind v4 from it; Style Dictionary reads DTCG too, but doesn’t fully support the 2025.10 format yet. When variables change in Figma, the JSON changes, not the code.
Step 3. Connect Figma MCP and write the rules. The remote server is available on all plans, the desktop one on Dev and Full seats of paid plans. Figma has a create_design_system_rules prompt: the agent reads the codebase and writes a rules file into CLAUDE.md or AGENTS.md: where the tokens live, what must not be hardcoded, how to reuse a component from the project instead of making a new one. Without this file, the agent gets React and Tailwind code with hex values from MCP and builds a new button for every screen.
Step 4. Components one at a time. Start with the three to five most common: button, input field, card. For each one, the agent gets the node structure through get_design_context, the variables through get_variable_defs and a screenshot, writes the component on tokens, and you compare it with the mockup. There should be no gaps in the variant matrix: the agent assumes a component has exactly as many states as it saw. Asking for a whole screen doesn’t work: a response over 25,000 tokens doesn’t fit in the client, and instead of a system you get one big file.
![The code of a PrimaryButton from a Figma MCP response. Hardcoded values in the classes are highlighted in red: gap-[8px], h-[44px], px-[20px], rounded-[10px], bg-[#5B4CF0], text-[#FFFFFF], text-[15px], font-[600], w-[16px] and the icon address http://localhost:3845/assets/plus.svg.](/images/topics/en/31-ds-code-before.webp)
Without a rules file: the agent takes the code from MCP as is, with hex and pixels. The next screen will get another button just like it.

With a rules file: the same button is built from the project’s component, and the values come from tokens.
Step 5. Link the mockup to the code. Code Connect shows the agent the real name and import of a component when it appears in a mockup; it’s available on the Organization and Enterprise plans. If your plan doesn’t include it, the substitute is a “Figma component → file in the repository” table in the rules file. Check after every component: the get_screenshot screenshot next to the render, then Storybook with visual regression testing.
Path 2. A system from scratch
Don’t start with Figma. Start with an audit of what already exists in the product or prototype. Then pick a base: shadcn/ui if the project is on React and the agent already knows it; Base UI or React Aria if you need your own components without someone else’s styles. The agent doesn’t have to write accessibility from scratch; you get it from the base.
Tokens first, and only a few. Teddy Ni from Magic Patterns advises starting with 20–30 tokens, not 200: colors, a type scale of five to seven levels, spacing, two or three radii, shadows. For colors, it helps to set background and text pairs right away: for the surface, the primary and secondary actions and for errors. Names by purpose, not by appearance. Tokens go straight into JSON and CSS, and Figma gets connected later if you need it.
One component first. The most common one, usually the button, with all its variants and states, in Storybook with a story for each state. The agent learns to write the rest from this file. Then the rules file: short, always in context, written as prohibitions — don’t invent tokens, don’t use hex, don’t create a component if a similar one exists. Dianne Alter puts it this way: the strongest instruction you can give an agent is to tell it what not to do.
Checks live where the agent works. A script that searches the code for hex and pixels outside tokens; Playwright MCP so the agent looks at its own result; accessibility tests. If nothing fails when a rule is broken, the agent will break it confidently and often. Figma from code comes last, if the team needs it: the use_figma tool builds a mockup from components and variables.
Path 3. An off-the-shelf open-source system
| System | What it’s for | MCP | Skills | Figma kit | License |
|---|---|---|---|---|---|
| shadcn/ui | React and Tailwind, your own look through tokens | Yes | Yes, from the author | Community only | MIT |
| Chakra UI v3 | React, a full library with themes | Yes | Yes | Official, free, with variable modes | MIT |
| Mantine | React, lots of components out of the box | Yes | Yes | No official one, community only | MIT |
| MUI | Material Design | Yes | Yes | Official, the free version is cut down | MIT |
| Nuxt UI v4 | Vue and Nuxt | Yes | Yes | Official, free, with variables | MIT |
| Astryx | React, Meta’s system in beta | Announced | No | No | MIT |

There are four criteria for choosing: the project’s framework; whether there are official MCP and skills; whether you need a Figma kit with variables; the license. Some systems you shouldn’t pick. Polaris React was archived in September 2026. PrimeVue from version 5 and PrimeReact from version 11 are distributed under the PrimeUI license, which is free only for small companies with revenue under a million dollars. Material Web has had no active development since 2024.
shadcn/ui: why it’s the default choice and what you pay for it
shadcn/ui isn’t a library but a way of distributing code: the shadcn add command copies a component’s source into the project, and from then on it’s yours. The author gave it everything an agent needs: an MCP server, an official skill, an llms.txt file, an info --json command with the project configuration, and registries from which other authors’ components install with the same command. Since July 2026 the default accessibility base is Base UI; Radix is still available with a flag.
Pros. The code belongs to the project, and the agent edits it as its own. Agents know it without hints, because it shows up in training data more often than the others. Accessibility comes from the base. The tokens are already semantic, and the background and foreground pairs can be recolored for a brand; there’s the tweakcn editor for that. Everything is free under MIT.
Cons. Components don’t update themselves; the --diff flag on the add command only shows the differences. Interfaces on untouched tokens all look alike: in a study of 500 Show HN sites, 23.5% used the components unchanged. There’s no official Figma kit. The most complete kit, shadcndesign, is paid and independent of shadcn/ui, although the library’s author publicly endorsed it; free kits exist in Figma Community, but no one vouches for how complete they are. React and Tailwind only. There’s more code in the project, and you’re responsible for it.
The rule is simple. shadcn/ui fits if the project is on React and you’ll override the tokens for your brand before the first screen. If the Figma library is large and the team expects an official kit, look at Chakra or MUI.
Example: a 30-component library
A designer has a 30-component library on the Professional plan and a side project on React; the example is hypothetical. The audit took a day: 12 components had no variants, 40 colors had no variables. After the fixes, the variables got names by purpose, and the library was published. Exporting to JSON and building with Terrazzo produced tokens.css and the @theme block.
Next, the agent installed shadcn/ui with a preset, rewrote the variables to match tokens.css and wrote a table into the rules file: 22 components from the library map to shadcn/ui components, 8 are custom. The agent moved the eight custom ones over one at a time through get_design_context, with stories in Storybook. Code Connect isn’t available on Professional, so the same table replaced it. At the end, the check script found zero hex values in the code outside tokens.css, and with that the system was ready for the first screen.
Here’s what the start of that table looks like in CLAUDE.md:
| Component in Figma | File in the repository | Source |
|---|---|---|
| Button | src/components/ui/button.tsx |
shadcn/ui |
| Text field | src/components/ui/input.tsx |
shadcn/ui |
| Card | src/components/ui/card.tsx |
shadcn/ui |
| Modal | src/components/ui/dialog.tsx |
shadcn/ui |
| Price tag | src/components/price-tag.tsx |
custom |
Where AI does harm in this work
AI does harm when the agent gets a whole screen instead of a component. When tokens are carried over from the mockup as hex. When a component in code has one variant because Storybook has one story. When the rules file is written once and never updated as the system grows. When checks happen by eye afterward instead of by a script along the way. And when a system is chosen for its popularity instead of its fit with the project’s framework.
Command examples for practice
Read the node [link to the component in Figma with node-id] through get_design_context and get_variable_defs. Write the [name] component in src/components/ui using the tokens from src/styles/tokens.css. There must be no hex values or pixels outside the tokens. Build every variant and state from the mockup, with a Storybook story for each. Show the get_screenshot screenshot next to your render and list the differences
Go through the published library [link] and make a table: Figma component → the file in the repository that matches it. For components with no match, write ‘none’. Put the table in CLAUDE.md under a ‘Mockup-to-code mapping’ section
Here’s tokens.json in DTCG format. Set up Terrazzo so it builds tokens.css with CSS variables and an @theme block for Tailwind v4 from it. Keep the semantic names, and split composite typography tokens into font, size and line height. Add a tokens:build npm script and a check that src has no hex values outside tokens.css
Create a design system rules file in CLAUDE.md: where the tokens and components live; what must not be hardcoded; how to check whether a similar component exists before creating a new one; what to do if the needed token doesn’t exist — stop and ask, don’t invent one. Write the rules as prohibitions, no longer than 60 lines
We’re on shadcn/ui. Rewrite the variables in globals.css for this palette: [brand colors]. Keep the background and foreground pairs, check text contrast against the background to WCAG AA, write the values in OKLCH. Then build a page with a button, an input field and a card in all variants so I can look at the result
My project is on [framework], the team is [number] people, the Figma plan is [plan], the library has [number] components. Compare shadcn/ui, Chakra UI and Mantine on five criteria: framework, official MCP and skills, a Figma kit with variables, license, updates. Give a recommendation and separate what follows from my constraints from what follows from the general properties of the systemsTake the library from your side project or any library published in Figma Community. Audit it against the five points from step 1 and write down what needs fixing. Export the variables to JSON and build CSS variables from them with the third prompt. Write the rules file with the fourth prompt. Move one component over with the first prompt and compare the result with the screenshot.
Sources
- Structure your Figma file for better code — Figmadevelopers.figma.com
- Refine your components and variables for the Figma agent — Figma Helphelp.figma.com
- Figma MCP server: tools and promptsdevelopers.figma.com
the create_design_system_rules prompt in the Prompts section
- Rate limits and accessdevelopers.figma.com
20 calls a month on Starter and on a View or Collab seat of any plan; 200 a day on Dev and Full seats of Professional and Organization; 600 a day on Enterprise
- Guide to the Figma MCP server — Figma Helphelp.figma.com
the remote server on all plans, the desktop server on Dev and Full seats of paid plans
- Code Connect — Figma Helphelp.figma.com
Organization and Enterprise, Full or Dev seat
- Design Tokens Format Module 2025.10 — W3C Design Tokens Community Groupdesigntokens.org
October 28, 2025
- Schema 2025 recap — Figmafigma.com
October 28, 2025; variable export and import promised for November
- DTCG composite token export support — Figma forumforum.figma.com
February 26, 2026; user reports about composite tokens
- Tokens Studio: pricingtokens.studio
Starter is free, multi-file sync is on paid plans
- Multi-file syncdocs.tokens.studio
- Style Dictionary and DTCGstyledictionary.com
- Terrazzo: Tailwind pluginterrazzo.app
- Theme variables — Tailwind CSS v4tailwindcss.com
- Theming — shadcn/uiui.shadcn.com
- shadcn/ui: MCPui.shadcn.com
- shadcn/ui: Skillsui.shadcn.com
- shadcn/ui: Figmaui.shadcn.com
- shadcn/ui: Changelogui.shadcn.com
CLI 4.21.4 from October 7, 2026
- Design Systems for AI Agents — Luke Wroblewskilukew.com
October 1, 2026
- State of AI in Design Systems 2026 — zeroheightzeroheight.com
123 respondents; 82% use AI, 48% have launched an MCP server, 17% rate their documentation as “very AI-ready”
- Building a Design System Faster with AI — Teddy Ni, Magic Patternsmagicpatterns.com
May 3, 2026; “Start with 20 to 30 tokens, not 200”
- Agentic design system — Dianne Alter, The Design Projectdesignproject.io
May 7, 2026
- Agentic design system: Context edition — Dianne Alter, The Design Projectdesignproject.io
August 28, 2026
- Agentic AI, design systems and Figma — Christine Vallaurechristinevallaure.substack.com
March 31, 2026; the full variant matrix and stories in Storybook
- Design systems for AI agents — Headwayheadway.io
July 28, 2026; checks where the agent works
- Codex CLI + Figma MCP — Daniel Vaughancodex.danielvaughan.com
April 18, 2026, updated October 10, 2026; responses over 25,000 tokens, hex without a token name, a new button without Code Connect
- Why your design system needs its own Figma → Code MCP — Malaka Venugopal Reddymalakavenu.com
May 5, 2026; about 3,400 hardcoded values in a repository with 600 components
- GIGAZINE on Adrian Krebs’s study: 500 Show HN sites and the typical AI designgigazine.net
April 23, 2026
- Storybook 10.3: MCP, a11y improvements, & workflow upgradesstorybook.js.org
April 6, 2026
- Storybook MCP for React, benchmarkstorybook.js.org
March 23, 2026; with MCP, 12.8% better use of the library’s code (improved code usage) and 2.76x faster, measured by the vendor
- Agent Skillsagentskills.io
- vercel-labs/skillsgithub.com
- vercel-labs/agent-skillsgithub.com
- Chakra UI: MCPchakra-ui.com
- Mantine: LLMs and MCPmantine.dev
- MUI: MCPmui.com
- Nuxt UI: MCPui.nuxt.com
- Astryxastryx.atmeta.com
- Shopify/polaris — GitHubgithub.com
archived since September 11, 2026
- PrimeUI Licensecdn.jsdelivr.net
- material-web: maintenance modegithub.com
June 10, 2024
Found a mistake or an outdated fact? Write to hey@iskra.guide