Connecting Figma components to code
A skill that writes Code Connect files for a design system, and a Figma plugin that attaches them to components so Dev Mode and AI agents can see which code each design uses.
- CodePL-02
- Type Figma plugin
- Date 2026
- Status Paused
- Built with Claude Code, Figma, TypeScript
Why I built it
AI agents can build an interface from a Figma file, but without help they build their own components instead of using the ones in your design system. Figma’s Code Connect addresses that. It ties each Figma component to the code that implements it, so an agent reading a design knows which component to use and with which props.
Up until late 2026, Code Connect’s publishing could only run on Figma’s Organization and Enterprise plans, and I wanted that same experience on my own. So I built the two halves I was missing: a skill that writes the Code Connect files for my design system, and a Figma plugin that attaches them to my components and shows the code in Dev Mode.
Was it worth building?
Before I built anything, I wanted to know whether it was worth recreating Code Connect’s capabilities for a Professional plan, so I ran an experiment. I gave fresh AI agents the same job: build one component from a Figma design in code. I ran it 78 times on two components from a demo design system, with two Claude models, Haiku and Sonnet, and changed one thing each time: how the agent could find out which code the component maps to.
There were three ways. With Code Connect (on an Enterprise plan), the agent asks Figma, which runs the mapping and hands back the answer. In the second, a dev resource link on the component leads the agent to a Code Connect template in the repo, which it has to read and work out for itself. In the third, the link goes straight to the component’s code, with no mapping files at all.
Code Connect was right every time, 20 out of 20 in the matched runs. Reading the template was right 14 times out of 20, and the code alone only 7. The gap was widest on the trickiest component, where turning a label off quietly swaps one component for another, a change nothing in the design shows. There, Sonnet went from 100% with Code Connect, to 36% reading the template, to 0% with only the code. Haiku, the smaller model, didn’t follow the same pattern.
That’s what told me it was worth building. Without Code Connect, a readable template was the best thing I could give an agent, and for Sonnet it was the difference between the right component with small mistakes and the wrong component every time. It also puts Figma’s own Code Connect up against fallbacks, and Code Connect won, so if you can use it, you should.
The agent test results
A few limits on what this shows: I tested on only two components in one design system, with two Claude models and just five runs per setup (for a total of 78 runs). I read the result as a strong signal, not a concrete proof.
What I built
The skill is an instruction file for Claude Code. It reads a component in my design system and its Figma component, then writes a Code Connect template: a small file that says which properties in Figma map to which props in code.
The plugin reads those template files and saves the code they generate onto the matching Figma components. In Dev Mode, selecting an instance shows real code for its variant, and an agent can read the same data through Figma’s Plugin API.
The Figma plugin
Checking the design before writing a line
A component like Button comes in many variants. This one could technically have up to 144, from every mix of style, size, hover and disabled. A Code Connect template has to write correct code that covers all of the variants, but whoever writes it (a person or an AI) usually looks at only one.
So before it writes a template, the skill runs a script that checks how each property changes what is inside the button. It picks a subset of the variants and changes one property at a time while the rest stay at their defaults. For each, it lists the layers inside: the text, the icon slots, the background. If the layers differ between a property’s values, that property changes the button’s structure, and the template has to handle it.
Button: 144 variants, 15 sampled, one property changed at a time
variant same layers in all 6 values
isHovered same layers in both values
isDisabled DIFFERENT
false focus, startIcon, text, endIcon, bg
true startIcon, text, endIcon, bg
size DIFFERENT
default, xs, sm, lg focus, startIcon, text, endIcon, bg
icon, icon-xs, icon-sm, icon-lg focus, Star, bgWhen the design is the problem
The check above finds the problem. The skill also says what to do about it: the agent is allowed to push back on the design itself.
When a component’s properties behave differently from one variant to the next, the easy move is to keep adding conditions to the template until every case is covered. The skill tells the agent to stop and ask whether the Figma component should be cleaner instead.
If making a property behave correctly across variants requires increasingly
convoluted conditional logic — checking `size` strings, guessing which variant group
a property "really" belongs to — say so explicitly and ask whether a dedicated Figma
property would be cleaner than compensating for the overload in code. That's how
Button's `hasStartIcon`/`startIcon` overload got resolved: a distinct `icon` property
in Figma, not deeper branching in the template.What I ran into
I could check my work, but not see it
Code Connect has a command line tool that can tell you whether a template file is well formed and whether the property names in it really exist in Figma. What it couldn’t do for me was show the code a component would actually produce, so I never had a way to confirm a template was right. That’s why the skill ends by handing the result to me to review, instead of declaring anything done on its own.
Don’t let the agent work from memory
In an earlier experiment, an AI agent looked at a component once, and when it wrote the code later it swapped in property names that sounded right but didn’t exist in the Figma file. So now a script pulls the exact names straight from Figma, and the agent copies them instead of retyping. It reads the source at the moment it writes, not from memory.
One property doing two jobs
Button looks like a simple component, but in its icon-only sizes the icon isn’t switched on and off like it is everywhere else. It’s just a bare layer. So the same property had to mean two different things depending on the size, and it took several rounds of checking specific buttons for me to notice. I built a script that changes one property at a time across a sample of the variants and tells me which ones change what’s inside. The real fix was in the design: I gave the component its own icon property, so the template didn’t have to juggle both cases.
Say what the design doesn’t say
Some things never make it into a design file, like the accessible name for a button that only shows an icon. The skill won’t make one up. It leaves a TODO comment right inside the generated code, because a note in a chat window might not reach the developer or the agent who copies the snippet, but a comment inside the snippet travels with it.
Updates
Next
Transition the skill
Since Code Connect is now officially available on all paid plans, I can retire my plugin. However, I can convert the skill I built to work with the real Code Connect and continue improving how it writes the templates.
Early September 2026
Slots and a Manage tab
Slot content, such as the items inside an avatar group, now shows up in the generated code. The Manage tab shows what is synced to the selected component and clears it.
Late August 2026
The first plugin
It reads the Code Connect template files, attaches the generated code to a component, and shows it in Dev Mode with an import block above it.
Early August 2026
The first skill
Started with the Code Connect files for Button, Badge and Avatar, written by following the skill’s steps.