TJ PitreProduct Manager, FigmaGenerated code can look right while losing the connections that make a design system maintainable. Here’s how to make sure your agent is using your components the way it should.
Share How to prevent drift in your design system
Hero illustration by Cynthia Alfonso
I've spent most of my career inside other people's design systems. In more than fifteen years, I’ve yet to open a library that was as clean as its owners thought it was. There's always a detached instance somewhere, or a color that was supposed to be a token and is now a hex value.
For a long time, that was manageable. Most design systems are a little messy, but teams know the system well enough to spot when something is off-brand. An engineer sees an unfamiliar hex value in a spec and knows which token to replace it with. A designer comes across the wrong button in a review and knows exactly how to fix it. None of it’s documented; the system works because the people using it intuitively know what’s right in the moment.
How drift starts
Consider a button component set you have in Figma. It looks right—every variant passes a visual check. But somewhere along the way, a few variants lost their variable bindings. A border, background, or label color now uses a hardcoded value where a token reference belongs. When you hand off that set to an agent, you’ll have a problem. Using Figma's MCP server Figma’s MCP server brings your design decisions into the tools where code gets written—so what gets built actually matches what was designed. Here’s what that unlocks for everyone who builds products.
The TL;DR on MCP: Why context matters and how to put it to work
/* Hardcoded value */
background: #0DFFCF;
/* Token reference */
background: var(--color-bg-brand);

A primary action and a selected navigation item might use the same color today and change independently later. Matching that color won't tell the agent which token was intended. It needs the binding, or other context that explains the color's role. If a state or usage rule is missing from the context altogether, the agent may guess how the component should behave. That guess can look reasonable—even good—but still contradict a decision the team already made.
The potential for drift begins the moment we go from design to code, and putting AI to work using a system with poor hygiene can implement a problem we haven't caught yet. Maybe the missing binding has always been there, but it travels a lot faster when an agent is involved. The solutions are in the design system cleanup work that many teams have been meaning to get to anyway. Now is a good time to get started.
Document the decisions behind your components
Think about what happens when a new engineer joins your team. In their first week, they ask a dozen questions. When do we use the warning state? Why does this dialog only get one primary button? Someone replies because they know the answer offhand, not because they’re referencing documentation. In many cases, that documentation doesn’t exist.
Think of an agent as that new engineer, except it won’t ask those questions. An agent only knows what's in the design system. Without documented context, it makes assumptions—and in many cases, it’s wrong. I think about that context in five layers:
- Tokens: Named values the system uses, and what they mean. A color's role matters as much as its hex value.
- Components: Which are available to use, including their supported variants and states.
- Composition: How those components work together. For example, a team might specify that a dialog should have only one primary action.
- Product policy: Decisions about the experience, such as which destructive actions require confirmation and which can be undone.
- Engineering conventions: How the team implements the system, from component packages to styling and testing requirements.
Some pieces of context are simpler to document than others. Component packages can be easy to locate, but finding the decisions behind them often takes some digging. For example, while a component may define a warning state, it doesn’t come with an explanation for when to use it in the product. That explanation might be buried in an old review comment or spec, and the team simply carries that rule around in their heads.
My rule of thumb: If I keep correcting the same behavior in generated work, I check whether the rule was documented, whether it reached the agent, and whether the agent followed it. If the rule is missing, I document that guidance with the reason behind it so the agent can access it.
Reuse existing components
Without a clear reference to your components, an agent may build a new button instead of using the one that already exists. Say you ask for a banner. The banner contains a button. We don't want AI to recreate that button; we want it to import the one we already have. If that button doesn't exist in code yet, we have to build and validate it first before generating anything that depends on it. Otherwise, each banner or dialog can end up with its own slightly different version, and you have the detached-instance problem again, this time in the codebase.
Figma's MCP server can provide structured design context, including component properties and variable bindings. If your team already has a production When going from design to code, agents lack the context of your production components. With Code Connect in Figma’s MCP, they get that context. We measured its impact on token usage, task duration, and code quality.Button component, the agent should know where it is and how to use it. Tools like Code Connect
Better code, fewer tokens: The benefits of Code Connect in MCP
Appearances can be misleading, too. A button in the generated banner can look like the shared component and still be a brand-new implementation. Even an imported one can have its colors overridden with raw values, so I read the imports and the token references before I trust what's on screen.
Check both ends
Even with the right context in place, I never take the output simply on good faith. Drift can start in the Figma file or in the generated code, so I check both. In Figma, that means checking variable bindings across every variant and state of the button, confirming that nested buttons are still instances of the intended component. A lost binding might be hiding in the states you didn't open.
For the code, I make the expectation explicit:
- Use the existing
Buttoncomponent and its supported variants - Import it when building a banner or another component that depends on it
- If a required variant is missing, flag the gap before adding one
A lot of this can be checked by a machine, across all five layers of context. Types can reject unsupported prop values. Lint rules can flag raw colors in component styles. Tests can cover keyboard interaction and a team's rule, allowing only one primary action per dialog. That’s why I check token references in the component source before compilation. Some build pipelines resolve tokens into literal values, so a raw color in the compiled output doesn't necessarily mean the source lost its token reference.
Using guidelinesGuidelines help the Figma agent create designs that better reflect your design system. Add these files to your published design libraries to help you capture information the agent can’t infer from library assets alone, like how to follow established patterns and avoid anti-patterns.
Other decisions need judgment. A test can tell you a dialog receives focus. It can't tell you whether interrupting someone with that dialog was the right call. Keep that reasoning in your guidelines, a new way to give Figma’s agent information about your library, and review the experience with people who understand the product. For example, when a generated variant shows up with a hardcoded color, trace it back to the source. Is the binding intact in Figma? If it isn't, fix it there. If it is, look at the context the agent received and the code it produced. Making the fix in the output itself means the problem will keep showing up. But if the agent has already copied that button into separate implementations, fixing the original won't repair the copies. Someone has to find them and reconnect them to the system.
I don't want this to read as a warning against the workflow. AI gets designers to a coded draft sooner, which means they can review behavior alongside appearance: hover and focus states, keyboard navigation, how the layout handles resizing or a longer label, including states that weren’t in the original frame.
Engineering still needs to review implementation, tests, versioning, and integration. Designers and engineers both need to check accessibility.
Start with one component
You don't need to document the entire library before you can improve this workflow. You can start with a single component:
- Check the design component. Review the intended token bindings across its variants and states, and check nested component instances. Compare it with the existing code component if there is one.
- Make the dependencies available. Point the agent to the existing code components and their usage guidelines. Build and validate any missing foundational components before generating components that depend on them.
- Generate a small example. Inspect its imports and token references, then try the interactive result.
- Turn a recurring mistake into a check. Where the rule is enforceable, add validation. Where judgment is needed, record the decision and make ownership clear.
To get started, try working with a copy of the component set. Generate an example with a deliberately broken binding, restore the binding, and generate again with the same prompt and tools. Compare the token references and imports in both outputs. Did the agent carry the mistake through, or correct it? Don't make assumptions—check the output yourself, and go from there.
For more on design systems, learn how to make your Figma design system agent-ready and speed up design system documentation with the Figma agent. And be sure to check out all of the design systems features we recently previewed.

TJ Pitre is the product architect for AI & design systems at Figma, and has spent over 15 years building design systems. He founded Southleft, a design systems consultancy, and co-created the AI and Design Systems course with Brad Frost and Ian Frost, focused on the evolving role of design systems in AI-assisted product development.
LinkedInSubstackXSouthleft
4 ways we’re using our MCP server at Figma

Why you should care about design context

Design systems and AI: Why MCP servers are the unlock
AI Trends