Figma Code Connect links each component in your Figma library to the matching component in your code, so Dev Mode and Figma’s MCP server give agents your real imports and props instead of generated React and Tailwind.
If you’ve ever worked on a design system, you know that each component exists twice: once in the Figma library, where a designer iterates and finally creates all its variants, and once in the codebase, where it then becomes a component with props and an import path. Until recently, the link between the two was a developer looking at the design and knowing which component to use, and where.
Now more and more code is written by agents, which can also read the Figma file through Figma’s MCP server, to gather context. The problem is that the MCP route doesn’t have an explicit way to inform the agent that the rectangle in the frame is the Button: it works because agents are good enough to interpret the context they read and understand that on their own. And after that, the agent builds the component from scratch, usually with a handful of divs and Tailwind classes. The code is good but not great, and over a component library that difference builds up.
That’s why Figma tried to fix that with Code Connect, which lets you publish a mapping from your repo to your Figma library that says "this Figma component is this code component, and this is how its properties become props". Dev Mode lets you see that snippet, which then gets passed by the MCP server to your agents. We spent some time going through how it works today (the CLI is at version 2.1.1 as we write this, end of November 2026), and this is what we’d tell a colleague who wants to set it up.
The same page header in our benchmark’s design context, without and with a mapping
TL;DR
Code Connect maps your Figma components to your code components, so agents using Figma’s MCP server get your real component and props.
The file format changed in August. Version 2 made the old
.figma.tsxfiles withfigma.connect()legacy; the maintained format is now template files (.figma.ts). A lot of tutorials still show the old one.Figma measured about 30% fewer tokens with Code Connect, and EDL’s benchmark measured 18% fewer tokens with Claude Sonnet 5.5 across 7 tasks. With Claude Haiku 5.5 the 6% difference was within the noise, and the quality of the code was about the same with and without mappings on both models.
It doesn’t fix mismatches between Figma and code. If your library and your components have drifted apart, the mapping just hides it. Remember, garbage in, garbage out.
Why bother
When you point an agent at a Figma frame and ask it to build the screen, it gets layers, auto-layout, colours and text. Figma says as much in its own docs: for a component without Code Connect or a mapping, the MCP server’s default output is React with Tailwind.
We ran into the same issue from the code side in our previous article, where we measured agents working in a codebase with no context layer set up: they invented CSS classes, forgot required parameters, copied the inside of components instead of using them, and spent most of their tokens reading files to figure out conventions they would have had otherwise. Code Connect goes at the same problem from the design side, by putting the component description and usage directly into what the agent reads from Figma.
What the agent gets from the MCP
When a component is mapped, the MCP tool get_design_context wraps each instance of it in a <CodeConnectSnippet> block, with the import, the snippet filled in with that instance’s values, and any instructions you’ve written for that component. So instead of "a 36px-high rounded rectangle with a label and a chevron", the agent reads something like <Button variant="primary" size="lg" trailingIcon={<ChevronRight />}>Continue</Button> and knows where to import it from.
Figma published a test of this on 5 August 2026: 27 test cases on two React design systems, run with Claude Sonnet 4.5 and Opus 4.7. With Code Connect, the median task took 19.6% less time and 29.5% fewer tokens, and code quality went from 2 to 3 on a four-point scale.
We found that interesting next to our own numbers. When we gave agents a search-and-get interface over our design system, tokens went down 31%, on a different stack and with a different mechanism. Our guess is that the saving comes from the same thing in both cases: once the agent is told what exists, it stops searching for it. The difference is that Figma graded quality with an LLM judge, and they only tested two strong models; in our tests the strong model already wrote correct code without any help, and the quality difference only showed up on a weaker model, so we expected Code Connect to matter more for quality on smaller models. We tested that ourselves, and it turned out differently (more on that below).
From the Figma library to the code the agent writes
Before you start
Plans and seats
You need a Dev or Full seat on a Professional, Organization or Enterprise plan (Education and Government are listed too, Government with the CLI only). On Professional you get one active library and one framework, and there’s a forum thread from late October where people on Professional couldn’t find the Code Connect scope when creating a token, and couldn’t create mappings through MCP. Figma’s staff told them to use the CLI or the in-Figma UI. So if you’re on Professional, we’d publish one test mapping before planning anything bigger.
CLI or UI
There are two ways to make mappings, which can also be mixed together.
The Code Connect UI is inside Figma: you can access it from your library in Dev Mode, then click "Connect components to code", and give each component a file path and a component name. It works with any language, you can map one Figma component to several frameworks, and you can also attach written instructions for MCP to each component. The downside is that you don’t get a real snippet: Dev Mode only shows the file and component name (plus an AI-generated preview), and MCP gets a generated snippet.
The CLI, on the other hand, works from your repo: you write a small file per component describing how the Figma properties turn into props, publish it, and both Dev Mode and MCP show your snippet. It’s versioned with the code, it goes through pull requests like everything else, and you can publish it from CI.
For a design system team we’d suggest using the CLI for anything with props, because the property mapping should prevent the agent from guessing values, and then using the UI to add MCP instructions on top. Just remember that while mappings published from the CLI show up in the UI, you can only edit them from the CLI.
Version 2 changed the format
Most tutorials (and some of Figma’s older docs pages) show React mappings like this:
Since Code Connect 2.0.0 (18 August 2026, see the changelog), this API and the framework parsers behind it (React, HTML, SwiftUI, Compose) are legacy. They won’t get updates or support anymore: publish and preview now stop and tell you to migrate when they find parser files, and create always writes a template. The format Figma maintains is the template file: a plain .figma.ts or .figma.js file that reads the selected instance and returns a snippet, for any framework.
This is easy to miss if you set Code Connect up a few months ago: a config with the React parser and a glob for *.figma.tsx files now points at a format Figma isn’t developing anymore, and with v2 of the CLI it won’t publish at all (v1 is still available as @figma/code-connect@1). So if you’re starting now, start with templates, and if you already have parser files, the figma connect migrate command (migration guide) converts them into templates for you (with --delete it also removes the old files once it’s done).
Setting it up
Step 1: Install the CLI and get a token
We’d install the package as a dev dependency, so the version is pinned in the repo:
Then create a personal access token in Figma (Settings → Security → Personal access tokens) with Code Connect set to Write and File content set to Read, and put it in an environment variable:
Personal tokens last 90 days at most. That’s fine on your laptop, less so in CI (see step 6).
If you remember npx figma connect opening a setup wizard: that was removed in 2.1.0 (26 October 2026). Now it just prints the help, and Figma suggests using its figma-code-connect agent skill to generate mappings.
Step 2: Add a config file
Create a figma.config.json in the root of the repo. Everything goes inside codeConnect; if you put keys at the top level, the CLI either stops with "No options specified under ’codeConnect’" or ignores them and scans the whole folder.
includeandexcludeare globs relative to the config file.labelis the framework name for this set of mappings. It’s really important because the agent asks for snippets for a given framework, and this is what gets matched.languageis just for syntax highlighting in Dev Mode.
If you see parser, importPaths or paths in older configs, those only apply to the legacy parsers.
For type checking in template files, add the types to tsconfig.json:
Step 3: Write your first template
Start with a component that’s everywhere and has a few properties, like a button or another atomic component: copy the link to the main component in Figma (right-click → Copy link to selection) and let the CLI create the file:
It will generate a file, but it’s just a starting point, because the important step is the property mapping (where you will also find out how far apart your Figma library and your code are). In a library that has been around for a while, it’s common to find variant values capitalised in Figma (Primary) and lowercase in code (primary), interaction states as a variant in Figma (Rest, Hover, Focus, Disabled) while the code only has a disabled prop, or a checkbox that in Figma is only the box, while the code component also renders the label, hint and error message.
The template has to translate all of that. Here’s what a button could look like:
A few things that apply to every template:
The comments at the top:
urllinks the file to the Figma component, andsourceandcomponenttell Dev Mode and the agent where the code lives.The keys you pass to
getEnumhave to match the Figma option names exactly, including case.Build snippets with the
figma.codetag instead of concatenating strings. This way, nested snippets and imports are handled for you.A nested instance, like the icon above, only produces code if it has its own mapping:
executeTemplate()runs the icon’s template; if the icon isn’t mapped, the agent gets nothing for it.Check hidden layers in
preview: if the icon is part of the component but switched off in a variant, make sure it doesn’t still end up in the snippet.
Step 4: Do the icons in one go
For icons, don’t create one file per component: 300 icons would mean 300 almost identical templates. Instead, template files support batches for this: a .figma.batch.ts template plus a .figma.batch.json file listing each icon’s Figma URL and code name, and each entry’s data reaches the template as figma.batch. We’d do icons early, since buttons, inputs and menu items all nest them.
Step 5: Preview and publish
Before publishing anything, you can render the snippets locally:
--all renders every combination of a component’s properties (up to 500) in a table, and --unique does the same but hides the identical ones. It’s the quickest way to notice that a property you mapped doesn’t change anything, or that you misspelled an enum key. Then check what would be published:
npx figma connect publish --dry-run
For the first real publish, Figma’s docs suggest a small trick:
set
"label": "TEST"in the configpublish and check the result in Dev Mode and through MCP
unpublish and publish again with the real label
To remove a mapping you use npx figma connect unpublish --node=<url> --label=<label>; careful, without --node it removes everything in your Code Connect files.
Two flags you’ll probably need once the library grows: --batch-size splits the upload when Figma says it’s too large, and --force overwrites mappings that someone made in the UI for the same components.
Step 6: Publish from CI
If you publish by hand, there’s a chance that sooner or later the mappings will stop matching the code. We suggest publishing from CI on every merge to main, only when template files change:
--exit-on-unreadable-files makes the job fail if a template is broken: without it, the CLI just skips that file, and the outdated mapping stays live without anyone noticing.
For the token, Figma recommends a plan access token instead of a personal one, since it belongs to the plan (so it keeps working when the person who created it leaves) and it can last up to a year. Just remember that Professional plans can’t create them, so there you’ll have to renew a personal token every 90 days (assuming you can create one with the Code Connect scope, see the note on Professional above).
Step 7: Connect the MCP server to your agent
Figma offers two MCP servers. The remote one doesn’t need the Figma desktop app, which makes it the easier option, and in Claude Code you can add it with:
and then run /mcp inside Claude Code to sign in. If you use Cursor or VS Code instead, you just add the server to their config file:
Cursor, in
.cursor/mcp.json:
VS Code, in
.vscode/mcp.json:
The other one is the desktop server, at http://127.0.0.1:3845/mcp, which you can turn on from Dev Mode in the Figma app. The main difference is in how they pick the mapping: the desktop server uses whatever mapping is selected in Dev Mode, while the remote one asks for the framework that matches your label.
To check that everything works, we suggest a quick test:
select a frame with your button in it (or, with the remote server, paste its link)
ask the agent to call
get_code_connect_mapon it, and look for your component and source path in the answerask it to build the frame, and check the imports it writes
As a last step, you can go back to the UI and add MCP instructions to the components that need them. The mapping tells the agent how to call a component, while the instructions tell it when to use it and what to avoid, for example "use DialogAlert for destructive confirmations, not a plain Dialog". The agent then gets them as rules, next to the snippet.
We tested it ourselves
We wanted to see this for ourselves, so we ran it on the same Smarty codebase from our previous benchmark, together with its Figma library. We took the 7 tasks (out of the original 10) that have a matching screen in Figma, wrote Code Connect templates for 44 of the 55 components those screens use, and gave the agent the brief plus the Figma frame in two versions: one where every component instance is described as layers and properties, and one where every mapped instance is replaced by its snippet, which is what Code Connect does inside get_design_context. Everything else was the same in both: the brief, the codebase (the undocumented version, without doc blocks or manifest) and the scorer from last time.
We ran it with Sonnet 5.5 and Haiku 5.5, one run per task and version, 28 runs in total. These are the totals across the 7 tasks, without and with mappings:
Model | Mappings | Tokens | Files opened | Searches | Pages compiled |
|---|---|---|---|---|---|
Claude Sonnet 5.5 | without | 6,001,167 | 27 | 73 | 7 of 7 |
Claude Sonnet 5.5 | with | 4,922,491 (−18%) | 22 | 56 | 7 of 7 |
Claude Haiku 5.5 | without | 7,281,754 | 49 | 69 | 7 of 7 |
Claude Haiku 5.5 | with | 6,844,235 (−6%) | 50 | 69 | 7 of 7 |
With Sonnet the saving is clear, though smaller than Figma’s 29.5% (theirs is a median per task, ours a total): with the snippets in front of it, it opened fewer component files (22 instead of 27), ran about a quarter fewer searches (56 instead of 73) and went back to the design file less often. Haiku, on the other hand, didn’t really save anything (6%, within the noise): it opened the same component files with and without mappings (50 and 49) and ran the same number of searches, so it seems to double-check everything on its own, whatever the snippet says.
Design context per screen, and what each model did with it
On quality there was no clear difference: all 28 pages compile, both versions found the same components, no run invented props or missed required ones, and every task passed its trap check (our scorer flagged one Haiku run, but it had solved the tab reload problem with a different variable name, so we counted it as a pass). Haiku invented a few more CSS classes with mappings (3 against 1) and copied a component’s internals once without them, which is too little to call either way. This is also where our earlier guess was wrong: we expected the smaller model to gain the most in quality, but both models were already close to the ceiling on these tasks, which says more about the tasks being too easy for the current models than about Code Connect.

Quality on both models, without and with mappings. * One Haiku run was flagged by the scorer and counted as a pass, as explained above
So, in short: with a strong model Code Connect makes the agent cheaper, with a small one it doesn’t change much, and in both cases the code was already good. One run per task is still not enough to trust the exact numbers, so read them as a direction; the next step would be harder tasks and more repetitions.
What can go wrong
Open issues on Figma’s side
The MCP integration is still fairly new, and if you look at the forum you’ll find a few open issues. The one that seems to come up most often has been reported since at least December 2025, most recently on 27 August 2026: mappings that publish without errors, but then get_code_connect_map returns an empty object and get_design_context ignores them. As we write this, there’s no official fix yet. Other people have reported:
snippets disappearing when a component becomes a variant set (February)
nested variant properties not showing up in the parent’s snippet (March)
the same node returning mapped components on one call, and plain React with Tailwind on the next
We don’t think this is a reason to wait before starting, but we’d suggest running the test from step 7 on a few real frames after each publish, so you know the agent is actually seeing your mappings.
It doesn’t fix the gap between Figma and code
Code Connect assumes that the Figma component and the code component are aligned, and in a library that has been growing for a few years, that’s rarely the case: some components often exist only in code, so there’s nothing to map them to, and others exist on both sides but with different properties.

Typical mismatches a template has to translate
The template hides those differences behind a clean snippet, which is good for the agent, but it also means there’s a chance nobody notices them: the agent builds the code version of the component, the designer keeps working on the Figma version, and you find out only when a screen comes back different from the design. In other words, Code Connect is useful when working with agents, but keeping Figma and code aligned is still a separate job, and we’d suggest some kind of drift check between the two, ideally run every time you publish.
Wrapping up
If you want agents to use your components when they build from Figma, Code Connect is the most direct way to do it right now, and EDL’s benchmark measured 18% fewer tokens with Claude Sonnet 5.5 across 7 tasks, smaller than Figma’s 30% but in the same direction, while a smaller model didn’t gain much. The setup itself isn’t big: a config file, a template per component, a batch for the icons and a CI job. Most of the time goes into the property mapping, since that’s where all the differences between your Figma library and your code come out.
So, to sum up, our suggestion is to:
start with template files, and skip the legacy parsers
check the MCP output by hand after each publish
keep in mind that the mapping doesn’t keep Figma and code in sync for you: garbage in, garbage out
If you’d like to know how far apart your Figma library and your code are before you start mapping, you can get a score for your design system, or book a call and we’ll go through it together.

alessandro-longo.jpg
Alessandro Longo
Design Systems
Alessandro builds the design system foundations that scale products and keep them LLM-ready. He treats the architecture behind a product as a creative challenge, not just an engineering task.


