Spark
Vibe coding: from idea to production

Design system in code: from Figma, from scratch or off the shelf

Topic 3211 min read + 1 hour for the taskRevised October 11, 2026

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.

A two-row diagram. The top row, left to right: a Figma library with variables and variants, tokens.json in DTCG format, Terrazzo or Style Dictionary, tokens.css and an @theme block. An arrow down to components in code with all variants and Storybook; this block is highlighted in orange. The bottom row, right to left: a rules file for the agent, CLAUDE.md or AGENTS.md, and an agent that builds screens with checks by a script and tests. A dashed arrow from the agent back to the Figma library is labeled “mockup from code: use_figma”.
Code becomes the source of truth: Figma hands over the tokens once. · diagram made for this guide

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.

BeforeThe 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.

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.

AfterThe code of a CreateProjectButton. The import of Button from @/components/ui/button and the Plus icon from lucide-react is highlighted in green; inside is a Button with size="lg", the icon and the label “Create project”. A comment says color, radius and padding come from tokens.css through the Button variant.

With a rules file: the same button is built from the project’s component, and the values come from tokens.

code written for this guide

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
A terminal in the my-app project. The command npx shadcn@latest add button creates the file src/components/ui/button.tsx. The command npx skills add shadcn-ui/ui installs two skills, shadcn and migrate-radix-to-base, into the .claude/skills folder. The ls command shows that button.tsx and both skill folders have appeared in the project.
The component and the skill install with two commands, and both end up in the repository: you can edit the button’s code, and the agent will read the skill on its own. The flags -a claude-code -y --copy install the skill only for Claude Code without questions; without them, the command asks which agents to install it for. Output shortened. · shadcn CLI 4.21.4, skills CLI

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

Where to pasteTerminal agent with Figma MCP connected
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
Where to pasteTerminal agent in the repository
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
Where to pasteAny chat assistant
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 systems
Mini-task

Take 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.

Time: 1 hour
Done when: you have a list of library fixes, a tokens.css file built from JSON, a rules file written as prohibitions and one component in code with all its variants and a Storybook story

Sources

  1. Structure your Figma file for better code — Figmadevelopers.figma.com
  2. Refine your components and variables for the Figma agent — Figma Helphelp.figma.com
  3. Figma MCP server: tools and promptsdevelopers.figma.com

    the create_design_system_rules prompt in the Prompts section

  4. 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

  5. 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

  6. Code Connect — Figma Helphelp.figma.com

    Organization and Enterprise, Full or Dev seat

  7. Design Tokens Format Module 2025.10 — W3C Design Tokens Community Groupdesigntokens.org

    October 28, 2025

  8. Schema 2025 recap — Figmafigma.com

    October 28, 2025; variable export and import promised for November

  9. DTCG composite token export support — Figma forumforum.figma.com

    February 26, 2026; user reports about composite tokens

  10. Tokens Studio: pricingtokens.studio

    Starter is free, multi-file sync is on paid plans

  11. Multi-file syncdocs.tokens.studio
  12. Style Dictionary and DTCGstyledictionary.com
  13. Terrazzo: Tailwind pluginterrazzo.app
  14. Theme variables — Tailwind CSS v4tailwindcss.com
  15. Theming — shadcn/uiui.shadcn.com
  16. shadcn/ui: MCPui.shadcn.com
  17. shadcn/ui: Skillsui.shadcn.com
  18. shadcn/ui: Figmaui.shadcn.com
  19. shadcn/ui: Changelogui.shadcn.com

    CLI 4.21.4 from October 7, 2026

  20. Design Systems for AI Agents — Luke Wroblewskilukew.com

    October 1, 2026

  21. 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”

  22. Building a Design System Faster with AI — Teddy Ni, Magic Patternsmagicpatterns.com

    May 3, 2026; “Start with 20 to 30 tokens, not 200”

  23. Agentic design system — Dianne Alter, The Design Projectdesignproject.io

    May 7, 2026

  24. Agentic design system: Context edition — Dianne Alter, The Design Projectdesignproject.io

    August 28, 2026

  25. Agentic AI, design systems and Figma — Christine Vallaurechristinevallaure.substack.com

    March 31, 2026; the full variant matrix and stories in Storybook

  26. Design systems for AI agents — Headwayheadway.io

    July 28, 2026; checks where the agent works

  27. 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

  28. 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

  29. GIGAZINE on Adrian Krebs’s study: 500 Show HN sites and the typical AI designgigazine.net

    April 23, 2026

  30. Storybook 10.3: MCP, a11y improvements, & workflow upgradesstorybook.js.org

    April 6, 2026

  31. 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

  32. Agent Skillsagentskills.io
  33. vercel-labs/skillsgithub.com
  34. vercel-labs/agent-skillsgithub.com
  35. Chakra UI: MCPchakra-ui.com
  36. Mantine: LLMs and MCPmantine.dev
  37. MUI: MCPmui.com
  38. Nuxt UI: MCPui.nuxt.com
  39. Astryxastryx.atmeta.com
  40. Shopify/polaris — GitHubgithub.com

    archived since September 11, 2026

  41. PrimeUI Licensecdn.jsdelivr.net
  42. material-web: maintenance modegithub.com

    June 10, 2024

Found a mistake or an outdated fact? Write to hey@iskra.guide