← Learning Path
Lesson 1 of 7

What the agent sees when it looks at your design

An agent never sees your Figma file the way you do. It asks a server a question and gets back text. Your tokens are well defined when that text is enough to write the right code.

MCP (Model Context Protocol) is a standard plug between an AI agent and an outside system. The system runs an MCP server, which offers a list of tools. A tool is a named action with a description, such as "get the variables used in this frame". The agent reads the list, picks a tool, calls it, and reads the reply.

For design work the usual server is Figma's. Its get_variable_defs tool returns the variables and styles used in a selection, and get_design_context returns a code starting point for the same selection. Everything the agent learns about your tokens arrives through replies like these.

Try the three ways the same blue button can be defined, and watch what reaches the agent.

One button, three definitionsSimplified illustration of real responses
1 · In Figma
2 · MCP reply the agent reads
3 · Code the agent writes
The rule for the whole guide: the token name, its value, and its code syntax are what travel reliably. Anything you want the agent to know should live in one of those three, or in a rules file the agent always reads (lesson 6).
Lesson 2 of 7

Three tiers, and which one the agent should use

A token system is a chain of references. Each link answers a different question, and an agent needs the link that says what a value is for.

Primitives list the raw options: every blue, every spacing step. Semantic tokens point at a primitive and name a job: brand background, danger text. Component tokens are optional and point at a semantic token for one part of one component.

Click any token to trace its chain. Switch the mode and notice that only the semantic tier changes where it points. That is why themes work, and why code should reference the semantic tier.

Alias chain explorer

Primitive · the options

Semantic · the job

Component · the part

Save changes

What this means for the agent

If the agent is offered blue/600 and color/bg/brand side by side, both resolve to the same hex and it has no way to know one of them breaks in dark mode. Reduce the choice:

  • Bind every layer to a semantic or component token, never a primitive. The agent reports whatever is bound.
  • Keep primitives in their own collection and hide them from publishing, so library searches return jobs and not paint chips.
  • Put modes (light and dark, brand A and brand B) on the semantic collection only.
Lesson 3 of 7

Naming: the name is the interface

An agent often has only the name to go on. A good name can be read cold, by someone who has never opened your file, and still say where the token belongs.

Use a fixed order of slash-separated segments. Figma turns each slash into a group, and the same path maps cleanly onto a token file and a CSS variable.

category / property / role / emphasis / state
color / bg / danger / subtle / hover

Not every token needs every segment. Keep the order, and skip what does not apply. Type a name below, or pick an example, to see how it reads.

Token name linter
    Read cold, an agent infers
    CSS variable
    Token file path

    Habits that help

    • Name the job in semantic tokens and the value in primitives. color/text/danger survives a rebrand. color/text/red does not.
    • Use pairs that explain themselves: color/bg/brand with color/text/on-brand.
    • Put the state last so related tokens sort together.
    • Pick one spelling for each idea and never vary it. If half the file says danger and half says error, the agent treats them as two things.
    • Avoid . { } and a leading $. The token file format reserves them.
    Lesson 4 of 7

    Anatomy of a well-defined variable

    A Figma variable has six parts you control. Each one either reaches the agent directly or makes sure the right variable is the one that gets bound.

    Click each field in the variable below.

    Edit variableClick a field
    Collection: Semantic
    Highest return for the least work: code syntax. Figma's own guidance is that it tells the MCP server how each variable is written in your codebase, so the agent receives the exact string your developers use.
    Lesson

    Set up the variables in Figma

    This is the build, click by click, for a small starter set: two collections, a light and a dark mode, and every field from the last lesson filled in.

    Do it once in a scratch file before touching a real library. The menu labels below come from Figma's current help pages. Figma moves things around, so if a label is missing, look for the nearest match in the same place.

    Walkthrough

      Scope cheat sheet

      In the Scope tab, uncheck "Show in all" and tick only these. The scope names are Figma's. The pairing with token groups is a recommendation, so adjust it to your own naming.

      Token groupTypeTick these scopes
      color/bg/*ColorFrame fill, Shape fill
      color/text/*ColorText fill
      color/border/*ColorStroke
      color/icon/*ColorShape fill, plus Stroke for outlined icons
      color/shadow/*ColorEffects
      space/*NumberGap, Padding
      radius/*NumberCorner radius
      size/*NumberWidth and height
      border/width/*NumberStroke
      font/size/*, font/line-height/*NumberFont size, Line height
      font/family/*StringFont family

      Four things that catch people out

      • Numbers have no unit. Type 16, not 16px. The unit is added in code syntax or at export.
      • An alias must match the type. A colour can only point at a colour, a number at a number.
      • Dragging detaches. Changing padding or gap with the handles on the canvas removes the number variable from that property. Change bound values in the right sidebar.
      • The mode switch can seem to be missing. "Apply variable mode" only appears on a layer or frame once something in it uses a variable that has more than one mode.

      Let the agent do the typing

      Steps 2 to 7 are repetitive, and code syntax has to be entered one variable at a time by hand. With the remote Figma server connected, the agent can create the whole structure through the use_figma tool. Do the first few by hand so you know what it should look like, then hand over the rest. Edit the lists below to match your own tokens.

      Prompt for your agent
      
            

      Open the variables view afterwards and check a few rows against the walkthrough: aliases in both modes, scopes, code syntax, and that the primitives are hidden.

      Lesson 5 of 7

      The same token as a file

      Outside Figma, tokens live in a JSON file. Since October 2025 there is a stable, vendor-neutral format for it, published by the Design Tokens Community Group and usually called DTCG.

      A file in the repository is something an agent can read with no connection at all, and something a build tool can turn into CSS, Swift or Kotlin. It is worth knowing how your Figma variable looks in this form. The rules are few:

      • Groups are nested objects. Each slash in a Figma name becomes one level.
      • A token is any object with a $value. $type, $description and $deprecated sit beside it.
      • An alias is the target path in braces: {color.blue.600}.
      • Values are structured. A dimension is a number plus a unit, never the string "16px".
      • Save as .tokens or .tokens.json.

      Build one below.

      Token builder · DTCG 2025.10

      Where Figma and the file differ

      IdeaFigma variableDTCG file
      Groupingcolor/bg/brandNested objects, referenced as color.bg.brand
      AliasPick another variable as the value"$value": "{color.blue.600}"
      ModesColumns in one collectionOne file per mode in Figma's built-in export. The spec's separate Resolver module describes how to combine them.
      TypesColor, number, string, booleanColor, dimension, duration, font family, font weight, number and more. There is no plain string type, so string variables need a decision at export.
      Code syntax, scopingBuilt inNo standard field. Tools keep extras under $extensions.
      Check your export. Users of Figma's built-in variable export have reported that descriptions were left out of the JSON. Open one exported file and confirm what survived before you rely on it.
      Lesson 6 of 7

      Connecting tokens to the agent

      There are three routes from your tokens to an agent. Most teams need the first two together. The third is rarely needed.

      Route A · Figma's MCP server

      Tokens stay in Figma variables. The agent calls tools to read what a frame uses. Best when the agent is turning designs into code.

      Route B · A file in the repo

      Tokens are exported to .tokens.json and built into CSS. The agent reads the files like any other code. No server involved.

      Route C · Your own MCP server

      A small service that answers "which token for this job?". Worth it only when tokens live in a separate system shared by many repositories.

      A sound default: author in Figma, export to the repository, and tell the agent in a rules file which one wins when they disagree.

      What each Figma tool gives the agent

      Pick a request to see which tool handles it.

      Tool explorer · Figma MCP server
      You ask
      Agent calls

      Your tokens matter because

      Connect it

      The remote server lives at https://mcp.figma.com/mcp. In Claude Code you add it once and sign in with your Figma account when prompted:

      claude mcp add --transport http figma https://mcp.figma.com/mcp

      Setup steps change, so confirm against Figma's current instructions in the reading list. Then paste a link to a frame and ask: "List the variable names and their values used in this frame." If the reply shows hex values with no names, those layers are not bound to variables.

      Write the rules down

      The agent follows a rules file on every task. In Claude Code that file is CLAUDE.md at the root of the repository. This is where knowledge that names cannot carry belongs. Figma's server can also draft one for you with its create_design_system_rules prompt.

      CLAUDE.md · starter section
      
            
      Lesson 7 of 7

      Readiness checklist

      Run this against your own file. Ticks are saved in this browser.

      A first test to run

      1. Pick one small component, such as a card or a button, with every property bound to a semantic variable.
      2. Ask the agent to list the variable names and values used in it. Fix anything that comes back as a bare value.
      3. Ask the agent to build it. Search the result for # and px. Each hit is a token that was missing, unbound, or unclear.

      Further reading

      Reference

      Glossary

      Every term the guide uses, in plain words, with an example and the lesson where it comes up.