← All posts

Agents · 6 min read

Agents for design: from design files to code and back

AI agents can now read design files, write code that uses your real components, and even edit the design canvas itself. Here's how the design-to-code loop works in 2026, where it breaks, and how to set it up so the output looks like your product.

Subhash Nunna ·

For most of the last two years, “AI for design” meant pasting a screenshot into a chat and getting back a page of HTML that looked roughly right and used none of your actual components. Useful for a prototype, useless for a product with a design system.

That has changed. Design tools and component libraries now expose themselves to agents through the Model Context Protocol (MCP), so an agent can read a design’s real structure, look up which code component a Figma component maps to, and — since this year — write back to the design canvas itself.

This post walks through the loop in both directions, what research says about the screenshot-only approach, and how to set things up so an agent’s output looks like your product rather than a generic one.

Why screenshots alone aren’t enough

The research baseline is the Design2Code benchmark (Si et al., first released in March 2024 and published at NAACL 2025, so older than the tools below). It uses 484 real-world web pages: a multimodal model sees a screenshot and must write code that renders the same page.

The headline was encouraging. Human annotators judged that GPT-4V’s pages could replace the originals in 49% of cases, and rated them better than the original in 64%. But the authors also found models mostly lag in recalling visual elements and producing correct layouts.

More importantly for product teams, a screenshot carries no information about which button component, spacing token or colour variable a designer used. Even a pixel-perfect result is a fork of your design system. That’s the problem structured design context solves.

Design to code: what the agent can now see

Figma’s MCP server is the clearest example. Its documented read tools include:

Tool What it gives the agent
get_design_context Structured context for a frame or layer (React + Tailwind by default)
get_variable_defs The variables and styles used in the selection — your tokens
get_code_connect_map Which code component each Figma component maps to
get_screenshot An image of the selection, for visual comparison
get_metadata A lightweight outline of layer IDs, names, types and sizes
search_design_system Components, variables and styles across connected libraries

The key piece is Code Connect. Figma’s guide describes it as linking your Figma components to your codebase so that generated code reuses them — “Code Connect keeps your generated code consistent with your codebase.” Without it, the agent sees a Figma “Button / Primary” and guesses. With it, the agent is told to use <Button variant="primary"> from your library.

Figma also ships a create_design_system_rules prompt that generates a rules file describing your codebase conventions, so agents writing frontend code follow them.

The code side: Storybook as the component catalogue

The other half of the loop is your component library. Storybook MCP (in preview; React support landed in Storybook 10.3) exposes three toolsets to agents:

  • Docs — list components and show their documented usage, so the agent reuses what exists.
  • Development — instructions for writing stories, plus live previews of what the agent built.
  • Testing — run component and accessibility tests, so the agent can fix its own failures and re-run.

Storybook’s announcement puts the problem bluntly: “Agents don’t know anything about your components so they make up slop that doesn’t match your coding standards.” Its own benchmark — generating UI with the Reshaped component library, with and without the MCP docs — reported 12.8% better code usage, 2.76x faster runs and 27% fewer tokens. That’s a vendor benchmark without a published method, so treat the numbers as directional, but the mechanism makes sense: less guessing, less context spent rediscovering components.

Code to design: agents on the canvas

The newer direction is agents editing design files. In March 2026, Figma opened its canvas to agents with a use_figma tool that, in Figma’s words, can “generate and modify design assets that are linked to your design system.” An existing tool, generate_figma_design, converts a live web page into editable Figma layers that use_figma can then refine. Figma said the feature is free during beta and “will eventually be a usage-based paid feature.”

Figma pairs this with skills: markdown instruction files that encode workflows and conventions, such as generating a component library or applying a design system to a screen. A built-in /figma-use skill teaches agents how Figma works; teams write their own on top.

Practical uses that follow:

  • Sync from production. Capture the shipped UI back into Figma so design files stop drifting from reality.
  • Design system chores. Bulk-update components, create variables, document components.
  • Drafting from a brief. Lay out a new screen using existing library components, for a designer to refine.

Figma’s docs are clear on the limits. Writing needs a Full seat and edit permission on the file. The docs list current limitations, including a 20 KB output limit per call, custom fonts, and the fact that components must be published manually before Code Connect completes. And as Figma itself notes, models are non-deterministic: the same prompt can give different results.

Design review agents

Once an agent can read both the design and the rendered code, review becomes possible: compare the screenshot of the design with a screenshot of the built component, check that only design-system tokens are used, and run accessibility tests. Storybook’s testing toolset already gives agents the accessibility checks; the design-side context comes from tools like get_variable_defs and get_screenshot.

A simple review prompt, run after an agent builds a component:

You are reviewing a UI change against its design.
Inputs: the Figma frame link, the Storybook story for the new component.
1. Fetch the design screenshot and variables; fetch the story preview.
2. List every colour, spacing and type value in the code that is NOT a
   design-system token. Each one is a finding.
3. List any component that was re-implemented instead of imported from
   the library (check the Code Connect map).
4. Run the accessibility tests for the story and report failures.
5. Describe visible layout differences between design and preview.
Do not change any files. Output findings as a checklist for a human reviewer.

Note the last line. Review agents are most useful as a fast first pass that a designer or engineer reads — not as an approval gate.

Trade-offs to be honest about

  • Garbage in, garbage out. Agents do far better with a well-structured file: named layers, auto layout, variables instead of hard-coded values, components instead of detached copies. A messy file gives messy code, now faster.
  • Mapping is real work. Code Connect and component docs have to be set up and maintained. The payoff is large, but it’s a design-system investment, not a toggle.
  • Canvas edits need guardrails. An agent with write access can change a shared library as easily as a draft. Figma’s guidance is to inspect first, work incrementally and review in Figma. A sensible addition: let agents work in drafts or copies before touching published libraries.
  • Visual sameness isn’t the goal. Design2Code shows models can match appearance surprisingly well. What matters for a product is that the code uses the right components and tokens, which no screenshot comparison checks.
  • Cost and seats. Canvas writing is free in beta but planned as usage-based, and needs paid seats. Budget for it if this becomes part of daily work.

Where to start

  1. Clean up one component set. Pick your most-used components (buttons, inputs, cards), make sure they use variables and auto layout, and are published.
  2. Connect them with Code Connect so get_code_connect_map returns real code components.
  3. Add Storybook MCP (or your library’s equivalent) so the agent can read component docs and run accessibility tests on what it builds.
  4. Generate design system rules with Figma’s prompt and commit them to your repo.
  5. Try one screen end to end: design link → agent builds it → review prompt above → human review. Measure how many tokens and hard-coded values slip through, and fix the context before scaling up.
  6. Only then try canvas writes, starting with low-risk chores like documenting components or syncing a shipped screen back into a draft file.

AI agentsdesign systemsMCPFigmafrontend