Workflow recipe
Turn a Figma design into code with an agent
Connect the Figma MCP server, map the design's variables to your tokens first, build one frame, then run a visual diff and an axe check.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
To turn Figma into code with AI, tidy the frame in Figma, connect Figma’s MCP server to your coding agent with Figma’s skills, and ask for a table that maps every Figma variable the frame uses to a token in your code before any component is written. Then have the agent build the one frame with your existing components and tokens, compare a screenshot of the result with the Figma render side by side, run an automated accessibility check, and review the diff for hard-coded values.
The Figma MCP server gives an agent the design’s structure, variables, a screenshot and reference code, which is far better than pasting an image. Its reference code is still a prototype: absolute positions, raw colour values and new copies of components you already have. Without rules, the agent ships that as is, and you end up with a second design system inside your first. Mapping tokens first and reviewing for hard-coded values is what keeps the output in your codebase’s own terms; the screenshot and accessibility checks catch what looks right in Figma and fails in a browser.
FigmaAbout 15 min
1. Prepare one frame so the agent reads it correctly
Pick one screen or one component, not a whole page; Figma’s own guidance warns that large selections slow the tools down or return incomplete results. Then make the frame easy to read:
- Make repeated elements (buttons, inputs, cards) components.
- Use variables for colour, spacing, radius and type, not raw values.
- Rename layers like
Frame 1268to what they are (PriceCard,PrimaryButton). - Use auto layout rather than absolute positions, and resize the frame once to check it behaves.
- Add annotations for behaviour the picture cannot show: hover and focus states, what happens on narrow screens, which text is dynamic.
Copy the link to the frame (right-click, Copy link to selection). Each link points at one node, which keeps the agent’s context small.
TerminalAbout 10 min
2. Connect the Figma MCP server and its skills
Figma recommends its plugin where one exists, because it installs the MCP server settings and Figma’s skills together. The remote server is at https://mcp.figma.com/mcp and signs you in with OAuth.
claude plugin install figma@claude-plugins-officialThen run /plugin, open the Installed tab, select figma and allow access in the browser. Without the plugin, claude mcp add --transport http figma https://mcp.figma.com/mcp adds the server only (no skills); authenticate from /mcp.
In the Codex app, open Plugins and install Figma. From the CLI, this adds the server only, without Figma’s skills:
codex mcp add figma --url https://mcp.figma.com/mcpSign in to Figma and allow access when prompted.
Open the agent chat and run /add-plugin figma, click Add Plugin, then open Tools & MCP in Cursor Settings and click Connect next to Figma to sign in.
The skill that matters here is Figma’s figma-design-to-code, which tells the agent to request a screenshot with the design context, reuse the project’s components and tokens, translate absolute positioning into normal layout, and never leave temporary Figma asset URLs in code. Our directory lists the older Figma to code skill from OpenAI’s catalogue, which does the same job if you install skills by hand.
Check the connection with a cheap call: ask the agent “Use the Figma MCP whoami tool and tell me my plan and seat.” On a View or Collab seat you get up to 20 tool calls a month, which this recipe can use up in one run.
Your agentAbout 20 min
3. Map the design’s variables to your tokens before building
This step decides whether the result uses your design system or invents a new one. Ask for a mapping, read it, and fix the gaps before any code exists.
Read the table with the designer if you can. For each MISSING row, decide: add a token (a design decision, not the agent’s), or use the nearest one and tell the designer. Raw values in the frame usually mean the design is not using its own library there; ask before you copy them into code. Save the final table to a file in the repository so step 4 can use it.
Your agentAbout 30 min
4. Build the frame with your components and tokens
Now ask for the component, with the mapping as the rulebook.
Treat the agent’s “could not build” list as the start of a conversation with the designer, not as a to-do list for the agent. Interactions and states that the frame does not show (loading, error, empty) are still undecided.
Terminal and browserAbout 20 min
5. Compare a screenshot of the build with the Figma render
Put the component on a page at the frame’s width and take a screenshot. A short Playwright script does it repeatably:
// scripts/shot.spec.ts
import { test } from "@playwright/test";
test("price card screenshot", async ({ page }) => {
await page.setViewportSize({ width: 1440, height: 900 }); // the Figma frame width
await page.goto("http://localhost:5173/preview/price-card");
await page.locator("[data-testid=price-card]").screenshot({ path: "shots/price-card.png" });
});npx playwright test scripts/shot.spec.tsOpen the screenshot next to the Figma frame (or ask the agent to fetch the frame with get_screenshot and compare the two images) and look for: spacing that is a few pixels off everywhere (a wrong spacing token), the wrong font weight or line height, text that wraps differently, icons swapped for look-alikes, and colours one shade away. Fix by correcting the mapping, not by adding one-off values. Once the component matches, keep the screenshot as a baseline with Playwright’s toHaveScreenshot so later changes show up as a diff.
TerminalAbout 15 min
6. Run an accessibility check the design cannot show
A frame can look perfect and still fail keyboard and screen reader users. Add an axe scan to the same test file:
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
test("price card has no serious accessibility violations", async ({ page }) => {
await page.goto("http://localhost:5173/preview/price-card");
const results = await new AxeBuilder({ page })
.include("[data-testid=price-card]")
.withTags(["wcag2a", "wcag2aa"])
.analyze();
expect(results.violations.filter((v) => ["serious", "critical"].includes(v.impact ?? ""))).toEqual([]);
});Then check by hand what axe cannot: tab through the component and confirm every control is reachable with a visible focus ring, the order makes sense, and nothing is announced twice. Colour contrast failures usually trace back to the design, so take them to the designer with the token names. For a fuller pass, the Accessibility review skill or the accessibility audit with an agent recipe goes further.
TerminalAbout 15 min
7. Review the diff for hard-coded values and duplicates
git diff main --stat
git diff main | grep -nE "#[0-9a-fA-F]{3,8}\b|rgb\(|[0-9]+px|position: ?absolute|figma\.com"Red flags: raw colours or pixel values outside the token files, absolute positioning, a new component that duplicates one you have, edited token files you did not approve, and Figma URLs left in code. Each needs a reason or a fix. Then ask the designer to look at the screenshot from step 5 before you merge.
Check it worked
Verification checklist
0 of 6 done
When it goes wrong
If the tools are slow, time out or return partial results, the selection is too big. Link a smaller node, or ask the agent to call get_metadata first for an outline and then fetch design context only for the parts it needs, which is what Figma’s documentation recommends.
If the agent stops working after a few calls, check your seat. View and Collab seats are limited to 20 tool calls a month on every plan; Dev and Full seats on paid plans get a daily allowance (200 a day on Professional). The whoami tool tells you which seat the server sees.
If the code is full of absolute positions and fixed widths, the frame probably was not using auto layout, so the design context could only describe positions. Fix the frame in Figma and fetch again; it is quicker than fixing the layout by hand.
If colours or spacing are slightly off everywhere, a mapping row is wrong, usually a CLOSE match that should have been MISSING. Correct the mapping file and ask the agent to re-apply it, rather than patching values one by one.
Variations
If your design system is not in the repository yet, write it down first as an Agent Skill, as in the design system skill recipe; the agent then knows your tokens and do and don’t rules in every session, not only when the mapping file is open.
With Figma’s Code Connect set up, the design context names your real components for each Figma component, which makes step 3 shorter. For a quick prototype rather than production code, an app builder is faster; see prototype an internal tool with an app builder.
If your agent cannot reach the Figma MCP server, Figma’s desktop app also runs a local server for Dev and Full seats on paid plans. Connect MCP servers to your agent covers adding servers in each client.
Related guides
Web design guidelines reviews the finished component against a public checklist of interface rules. The glossary entry for an MCP server explains what the Figma server is doing for the agent.
Outcome and tools
- Outcome
- One Figma frame built as a component in your codebase with your existing tokens and components, a side-by-side screenshot comparison and an accessibility check with no serious violations.
- For
- Developers
- Variants for
- Claude Code, Codex, Cursor
Related
- Skill recipe: your design system
A worked skill that teaches coding agents your tokens, components and do and don't rules, with detail in reference files so it loads only when needed.
- Run an accessibility audit with an agent
Run an AI accessibility audit against WCAG 2.2 AA with Playwright, axe-core and an agent, add the manual checks scanners miss, and rank fixes by user impact.
- Connect MCP servers to Claude Code, Codex and Cursor
Add local and remote MCP servers to Claude Code, Codex and Cursor, choose the right scope, sign in with OAuth and check which tools actually loaded.
- MCP server
A program that exposes tools, resources or prompts to MCP clients, running locally over stdio or remotely over HTTP, so any MCP host can use them.
- Prototype an internal tool with an app builder
Build an internal tool prototype with AI with v0, Lovable or Bolt in an afternoon, test it with real users, and list what must change before it meets real data.