Pixelwright GitHub

Pixelwright docs

Quick start

Requires Node.js 24.11 or newer and Figma Desktop. Run the setup in a terminal:

npx -y pixelwright@latest setup

It connects Claude Code and Cursor, shows what to paste for Codex and other MCP clients, and puts the Figma plugin in ~/.pixelwright/plugin. Then, in Figma Desktop:

  1. Plugins → Development → Import plugin from manifest… and pick ~/.pixelwright/plugin/manifest.json, once. Figma loads the plugin from there every time you run it, and the setup puts the new one there on every update.
  2. Open your file and run Plugins → Development → Pixelwright. Keep its small window open while you work.
  3. The first time, the window asks for a pairing code: your agent shows it (from status); type it in.
  4. Select a section in Figma and ask your agent to build it.

npx -y pixelwright@latest setup --print asks nothing: it puts the plugin in place and prints the commands and config blocks, for scripts.

Try it on the demo

Open the Orbit demo in Figma: a small pricing site made for Pixelwright. Duplicate it to your drafts, run the plugin in your copy and ask your agent to read it: three breakpoints, an A/B hero, a prototype flow, Dev Mode notes and measurements, variables and styles, and components with variants, an exposed instance and a slot.

How it works

Claude Code ──stdio──► pixelwright ──ws://localhost:18720──► Pixelwright plugin ──Plugin API──► your Figma file

The plugin runs inside the file and answers the server on your computer. Every read goes through the Figma Plugin API, so nothing reaches api.figma.com and no seat or plan limits the number of calls. Several files can be connected at once; tools work on the one whose plugin window was in front last, or on the file you name.

Safety

  • No REST API, no token. The plugin reads the file through Figma's Plugin API, on your computer. The server listens on localhost only, and a plugin pairs once with a code you type in; unpaired windows get nothing.
  • Writes wait for your switch. design_apply, nodes_delete, version_save, tokens_apply and tokens_bind change the file, and so can execute, which runs plugin code the agent writes (its scripts over the reads never write). Allow edits in the plugin window is off until you turn it on for a file; while it is off, the plugin refuses every write, and the agent can still check a change with a dry run. Your choice is remembered per file on your computer.
  • Undo. One design_apply, nodes_delete, tokens_apply or tokens_bind call is one undo step in Figma. With version, a call first saves a named version you can go back to; the plugin cannot delete a version, so it stays in the file's history.
  • execute runs code the agent writes: use Pixelwright with agents you trust, as you would with their build scripts.
  • What is stored where. ~/.pixelwright/ holds the plugin, the bridge's state (bridge.json), the shared log in logs/, npm's newest version (latest.json), the asset files written (written-files.json) and the library catalogues library_search saved (libraries/). Baselines go into the project's .pixelwright/baselines/. The plugin keeps its pairing key and your Allow edits choice in Figma's storage on your computer.
  • What goes online. The server asks npm for the newest version once a day, and fonts_check asks Fontsource and Google Fonts which fonts they serve. The plugin's only network access is the server on localhost.

Limits

  • The file must be open in Figma Desktop with the plugin's window open. Figma slows plugins in background tabs: keep the file's tab in front during a long read.
  • design_apply writes what guide write lists: anything else is refused with its reason, or listed in the answer as not written yet. Replacing texts across a file, effects like noise and glass, reattaching detached components, inserting icons and the design checks come back in a later version.
  • Tested on macOS. On Windows the setup gives Claude Code cmd /c npx …, as its documentation asks; Windows itself is not tested yet.

Commands

pixelwright                 in a terminal: the setup; started by an MCP client: the MCP server on stdio
pixelwright setup           the setup: connects your MCP clients and puts the Figma plugin in place
pixelwright setup --print   no questions: the plugin put in place, the commands and config blocks printed
pixelwright serve           the MCP server, however it is started
pixelwright logs            follow the logs of every running server on this machine: tool calls, plugins, errors
pixelwright --version

PIXELWRIGHT_HOME moves ~/.pixelwright; CLAUDE_PROJECT_DIR names the project (baselines, and relative paths when the client gives no root); PIXELWRIGHT_PLUGIN_BRIDGE=off starts the server without the bridge; PIXELWRIGHT_NO_UPDATE_CHECK=1 stops asking npm for a newer version (see Updating); PIXELWRIGHT_LOG_LEVEL=debug adds the bridge's details to the log.

Updating

MCP clients start pixelwright@latest, so a client started again runs the newest server. The plugin is a copy on your computer: run npx -y pixelwright@latest setup again (or setup --print) to put the matching one in ~/.pixelwright/plugin. Figma Desktop loads it the next time you run the plugin. When the plugin's window says the protocol versions differ, this is the fix.

When a newer version is out, the plugin's window says so at the top. Close it, and it stays closed until the next version. The server asks npm for the newest version once a day (the answer kept in ~/.pixelwright/latest.json); PIXELWRIGHT_NO_UPDATE_CHECK=1 turns that off.

Every MCP client session runs its own server. The first one holds the bridge port and the others work through it, so every client sees every connected file. A newer server takes the bridge over; the older one then asks you to restart Pixelwright in its client (/mcp in Claude Code).

From 0.7.0 to 0.9.0

  • Put the new plugin in place. Run npx -y pixelwright@latest setup and run the plugin again: a 0.7.0 plugin cannot connect to 0.8.0, whose protocol changed. The plugin's path is the same, so you import nothing again.
  • Restart Pixelwright in every MCP client still open (/mcp in Claude Code): a 0.7.0 server that keeps running keeps 0.7.0's answers.
  • Writing comes back in part. 0.8.0 only read; 0.9.0 writes again with design_apply, nodes_delete, version_save, tokens_apply and tokens_bind, behind Allow edits. Replacing texts across a file, putting on effects, reattaching components, inserting icons and the design checks come in a later version. Code Connect is gone too: the XML no longer carries your project's code for an instance.
  • An argument a tool does not name is an error now, which names it; 0.7.0 ignored it.
  • Baselines 0.7.0 saved still read: baseline_diff compares against them as they are.

Tools

Every tool the server registers, as your agent sees it. A tool marked can write changes the file only while Allow edits is on in the plugin's window.

assets_export Export assets

Writes files out of the design into dir. nodes: up to 50 layers, one file each (SVG for an icon, PNG at 2x otherwise, or the format and scale given; PDF too; WEBP keeps transparency exactly at any quality, which sets how lossy its colours are, 85 by default). from: every true asset inside one layer, the icons and images design_read would plan. original: the images as they were placed instead of renders (photos at full size, in their own format). Files are named after their layer (Rectangle 61: rectangle-61.png), or as names gives a layer id. The same bytes are written once, a name taken by other bytes gets -2, and a file already in dir is never overwritten with other bytes. A layer that cannot be exported is reported in errors and the rest are still written.

ParameterTypeWhat it is
nodesoptionalstring[]Layers to write, one file each: SVG for an icon, PNG otherwise, unless format says. Give nodes or from.
fromoptionalstringA layer to write every true asset of (its icons and images, as design_read plans them): an image fill behind a layer's content is written as placed, an image layer is rendered as design_read plans it (its export settings, else 2x); scale and format apply to nodes only. Give nodes or from.
dirstringThe folder to write into; created if missing. Files already there are never overwritten with other bytes. A relative path starts in the project folder: the MCP client's root, else CLAUDE_PROJECT_DIR, else the server's working directory.
namesoptionalobjectA file name per layer id, e.g. {"54:12": "hero-mountains"}: slugged, the extension added. The other layers are named after themselves (Rectangle 61: rectangle-61.png).
formatoptional"PNG" | "JPG" | "WEBP" | "SVG" | "PDF"For nodes: the format of every file. WEBP is rendered as PNG by Figma and encoded here.
scaleoptionalnumberFor nodes rendered as PNG, JPG or WEBP: pixels per Figma pixel, or per CSS px with width. Default 2. Ignored with from: an image fill behind a layer's content is written as placed, an image layer is rendered at its export settings, else 2x.
widthoptionalnumberFor nodes as PNG, JPG or WEBP: the CSS width the build shows the layer at; the file is width × scale px wide (110 at scale 2: 220 px).
qualityoptionalintegerFor WEBP: the colours' quality, 1 to 100. Default 85. Transparency is kept exactly at any quality.
originaloptionalboolean
default false
Write the images as they were placed (not cropped, filtered or scaled) instead of renders, with their real format: with nodes, each layer's topmost visible image fill, any others noted. A video fill cannot be exported.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

baseline_diff What changed since a baseline

What the designer changed since baseline_save, in design_read's terms: each layer changed (its attributes as [before, after], a text's content as XML), added (with its XML when short), removed or hidden, moved to another parent or reordered; a change made in a component once, with the instances it reached and how many were compared (of); tokens whose value changed in any mode, renamed, newly used or no longer used; icons and images drawn anew (drawing: export them again). Layers are followed by id, a replaced one by its name. It sees what changes_since and Figma's own Changed mark miss: edits made while the plugin was closed, accepted library updates, variable and style values. Without name: every baseline in the project with how much changed; call it when a session starts or the user says the design changed. It reads the file the baseline came from and works while Allow edits is off. Change only the code it names (code lists the files), then call baseline_save with the accept it gives.

ParameterTypeWhat it is
nameoptionalstringOne baseline in detail. Without it: every baseline in the project, with how much changed.
nodeoptionalstringCompare with this layer instead of the baseline's own, e.g. a v2 the designer made beside it. Needs name.
fileoptionalstringWith name: compare in this file (a session from status, or a file name). Without name: only this file's baselines. Default: the file each baseline came from.

baseline_save Keep a baseline

Keeps a layer as you build code from it, so baseline_diff can tell later what the designer changed: its read and the values of the tokens it uses, in every mode, go into .pixelwright/baselines/<name>.json in the project (it holds the design's texts: commit the folder to share it, or leave it out of git). Save one only when the user wants to track what the designer changes later, right after the design_read you build that screen or section from; name it after your code (pricing, plan-card) and list in code the files you build from it. Once your code has the changes a baseline_diff listed, pass the accept it gave: exactly the design it compared is kept, so what the designer changed after it still shows next time. An existing name is replaced only with accept or replace: true; code alone changes its file list. Writes nothing to Figma, so it works while Allow edits is off.

ParameterTypeWhat it is
nodeoptionalstringThe layer the code is built from: a frame, section, component or instance. Default: the one selected layer. Not with accept.
nameoptionalstringNamed after the code: pricing, plan-card. Default: the layer's name as a slug. Required with accept.
codeoptionalstring[]The project's files built from the layer, relative to the project. Default: the list the baseline already has.
acceptoptionalstringThe accept a baseline_diff answer gave: keeps exactly the design that diff compared.
replaceoptionalboolean
default false
Start the named baseline over from the layer as it is now. Not with accept.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

breakpoints_find Find a screen's other widths

Finds the screen a layer is on at the page's other widths (Desktop, Tablet, Mobile): the page's frames, and those in its sections, whose names match once size words are left out (Desktop, Mobile, 1440, 375px) and whose children share names with it, narrowest first, each with a score. Compare them with nodes_diff to write the media queries.

ParameterTypeWhat it is
nodestringA screen's id, or a layer's on it.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

changes_since What changed

What changed in the file since the plugin started watching (its window opened) or since an earlier answer's cursor: each layer created, deleted or changed (with the properties), by the user, a collaborator or Pixelwright itself, on the page the user was on. Ask with no cursor once to start, then with the cursor it gives, to read again only what the designer changed. Only pages the user had open while the plugin ran are watched. Pixelwright's own are the layers its writes touched, and what execute's code changed while it ran (or within a second after); in a background tab Figma tells of changes up to a minute late, so those of execute then count as the user's, as do changes from code execute left running. What changed while the plugin was closed, and token values, baseline_diff tells against a saved baseline.

ParameterTypeWhat it is
cursoroptionalintegerThe cursor an earlier answer gave: only what changed after it. Default: all the plugin has seen.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

components_read Read the components

Lists components: scope used (default) gives the ones the instances on the current page, or inside within, come from (a library's among them, with how many instances use each); scope local gives every component defined in the file. Each comes with its key, variants, properties (type, default, and for a VARIANT property its options: the values it can take), description and exposed (the nested instances whose properties its instances show: in code they are its props too). instances: true lists its instances in instanceNodes {id, name, page} (100 at most, instanceNodesMore past them; for the first 25 components listed only, the rest carry instanceNodesSkipped); references: true lists per property the layers bound to it {id, name, field}: the layers inside the component, nested instances' contents included, bound to this component's own properties; a component Figma cannot read the properties of lists none. It says nothing about visibility: hidden layers are nodes_find with visible: false. links: true also reads the links people attached to it in Dev Mode (code, stories, docs), on Figma plans that keep them; a link to a GitHub, GitLab or Bitbucket file, or a vscode://file link, names the project file it points at in path. A big section lists long: fields keeps only the ones named, so scope local with query "icon/" and fields ["name"] lists the icon sets by name.

ParameterTypeWhat it is
scopeoptional"local" | "used"
default "used"
used: what the page (or within) uses; local: what the file defines.
withinoptionalstringA layer or page id to look in. Default: the current page (used) or every page (local).
queryoptionalstringOnly components whose name contains this, e.g. "icon/" for the icon sets.
limitoptionalinteger
default 100
fieldsoptional"id" | "key" | "type" | "name" | "page" | "remote" | "description" | "variants" | "properties" | "instances" | "instanceNodes" | "instanceNodesMore" | "instanceNodesSkipped" | "references" | "exposed" | "links" | "error"[]Only these fields of each component, e.g. ["name", "id", "description"]. Default: all.
linksoptionalboolean
default false
Also read the links people attached in Dev Mode (Figma's servers, paid plans only).
instancesoptionalbooleanAlso list each component's instances (a set's, of every variant) with their pages, those on no page (inside a removed layer) left out, 100 at most, for the first 25 components listed (the rest say instanceNodesSkipped).
referencesoptionalbooleanAlso list, per property, the layers inside the component bound to it and the field each binds (visible, characters, mainComponent). The layers inside the component, nested instances' contents included, bound to this component's own properties; a component Figma cannot read the properties of lists none.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

design_apply Write a design can write

Writes Pixelwright XML, the format design_read returns, into Figma: changes layers by id and creates them (Frame, Section, Text, TextPath, Rectangle, Ellipse, Line, Image, Icon, Component, ComponentSet, Instance, Slot, and a Page). It writes names, visibility, auto layout and grids, sizes, places and rotation, moves and copies, opacity, clipping, fills and gradients, borders, radii, shadows and blurs, blend modes and masks, colour tokens and styles, images and icons from files, text with its fonts, Spans and links, text on a path, variable modes, Dev Mode notes, instances (component, variant, props), component properties, variant sets and slots. Read guide write before the first call (Allow edits, dryRun, version, errors and every rule), and guide layout for flex, grid and absolute placement.

ParameterTypeWhat it is
xmlstringPixelwright XML, as design_read writes it: an element with id changes that layer (only the attributes it gives), one without id creates a layer.
parentoptionalstringWhere top-level new layers go: a frame's, section's or page's id. Default: the current page, beside its layers.
dryRunoptionalboolean
default false
Check without writing: the answer says what would change. Works with Allow edits off.
versionoptionalstringA name for a version saved in the file's history before writing, for the designer to go back to (not in a dry run, nor when nothing would change). Pass one when the user wants to be able to go back.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

design_read Read a design

Reads a layer (a section, a card, a screen) as Pixelwright's XML: Figma's layer types as tags, ids to name a layer in the other tools; a hidden layer is a stub with display="none". The first text block is the XML; the second is JSON with node (the layer read), tokens, textStyles, fonts, assets, measurements (the designer's Dev Mode measurements, when there are any), hints (what the code should know or fix, one per kind with a count and examples) and truncated (ids of layers the read cut: $children="N" where not all children were read, $truncated="true" where a branch or a text was cut to fit maxChars: read each on its own); with repeats, runs of three or more alike neighbours read as their first with $repeat="N", and JSON repeats holds each one's own values as rows; with nearby, JSON nearby lists the designer's notes around the screen. For a big frame, find its sections with outline first. The answer is complete for a build; guide xml explains every tag and attribute, guide workflow what comes next, and guide write how design_apply takes this XML back for an edit.

ParameterTypeWhat it is
nodeoptionalstringThe layer's id, e.g. 54:243. Default: the one layer selected in Figma.
depthoptionalintegerLevels below the layer to read. Default: all.
screenshotoptionalboolean
default false
Also return the layer's image, to compare your build with.
maxCharsoptionalinteger
default 80000
The most characters of XML: past it the deepest branches, then long lists, then long texts are cut. Default: 80000.
repeatsoptionalboolean
default false
Read each run of three or more alike neighbours as its first, with $repeat and JSON rows. Default: false.
autoLineHeightoptional"normal" | "px"
default "normal"
How to write Figma's Auto line height: normal (default), or px, the px Figma renders it at where the read can tell (a text that hugs its lines shows it for its font and size), normal elsewhere.
nearbyoptionalintegerAlso list the designer's notes on the canvas within this many px of the screen holding the layer (texts, stickies, small frames of text beside it or over it), e.g. 400: the JSON's nearby.
assetsDiroptionalstringWrite the read's assets into this folder (icons as SVG, images as PNG at 2x, backgrounds as the original image) and point each src at its file; created if missing, a file already there is never overwritten with other bytes. Without it src names are plans. A relative path starts in the project folder: the MCP client's root, else CLAUDE_PROJECT_DIR, else the server's working directory.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

execute Run plugin code can write

Runs JavaScript for what no other tool reads, or a change design_apply cannot say, given one of three: code, Plugin API code run in the Pixelwright plugin, for what the read tools do not show; codePath, the path of a file of such code; script, code run on the server where pw.<read>(args) calls a read tool by its camelCase name with its own arguments (pw.nodesFind, pw.inspect, pw.designRead; not screenshot, node_show or selection_wait: a script cannot show an image or act on the user's view, so call screenshot yourself) and utils helps filter and join their answers, for one answer that needs several reads filtered or joined: a script never writes, and reading a key its answer type lacks throws (types_read gives each read's answer type before you write a script; guide script has the limits and utils). Plugin code is the body of an async function given figma (the Plugin API, without clientStorage, ui, closePlugin and showUI), console and pw; return gives result (layers come back as {id, type, name}, figma.mixed as "mixed"), and what it logs comes back as logs. What it throws comes back as error, with the logs before it. pw stays between calls while the plugin window is open: pw.state for your data, your own functions added to pw, and Pixelwright's helpers: await pw.node(id) (the layer, or an error), await pw.fonts(layer) (loads every font its texts use, before you change them). The plugin runs with documentAccess "dynamic-page": use the Async calls (getNodeByIdAsync, getMainComponentAsync, getLocalPaintStylesAsync, setFillStyleIdAsync…), and await page.loadAsync() before reading another page. figma.skipInvisibleInstanceChildren is Figma's own, false in the editor and true in Dev Mode: set to true, findAll, findOne and children skip hidden layers inside instances and getNodeByIdAsync gives null for them (it is set back after the call). Keep long plugin code in a file and pass its path as codePath: it is read at every call, so after a plugin restart or a change to the file run it again rather than calling the functions it once added to pw. What it changes during the call is one undo step in Figma. Refused while the plugin's Allow edits switch is off, but code it starts that outlives the call (timers, listeners, work past the timeout) keeps running until the plugin window is closed, the switch notwithstanding. timeout waits up to 300 s for a long task; an endless loop, synchronous or of awaits, freezes Figma until the plugin is closed. Change the file with design_apply (design_read's XML, with a dryRun to check it first), tokens_apply, tokens_bind, nodes_delete and version_save; plugin code that writes is for what they cannot say. The reads answer what code is most often written for: layers by text (a list, or textRegex), size, visibility, component and the properties instances change, with their ancestors and page (nodes_find, outline, file_map, components_read); a whole subtree with its auto layout gaps and paddings, parent layout, text runs and component properties (inspect within and fields); a token by name with its id and alias chain (tokens_read query); colours bound to no token (tokens_usage raw: true). Before code, try the read tools (design_read, inspect, measure, nodes_find): they need no code and work with Allow edits off, and their answers come from the same Plugin API, so do not re-check a read's answer with code (an absent field is its default, as each read's description says); code in which nothing writes (no property set, no create*, remove, set*… call, no helper of your own) is told so in note.

ParameterTypeWhat it is
codeoptionalstringJavaScript run in the plugin as the body of an async function with figma (the Plugin API) and console: await works, return gives the result. Give one of code, codePath or script.
codePathoptionalstringA file of such code on the server's disk, run instead of code. It is read at every call, so the file as it is now runs, after a plugin restart too. A relative path starts in the project folder: the MCP client's root, else CLAUDE_PROJECT_DIR, else the server's working directory.
scriptoptionalstringJavaScript run on the server, apart from Figma, as the body of an async function given pw (each read tool by its camelCase name: await pw.nodesFind({ ... })), utils and console: return gives the result, cut past 24000 characters. At most 50 pw calls a run, 4 at once; nothing in it writes, and it cannot show an image (no pw.screenshot): call screenshot yourself.
timeoutoptionalnumberSeconds to wait: 10 by default for code and 30 for a script, up to 300 for a long task.
versionoptionalstringA name for a version saved in the file's history before the code runs, for the designer to go back to. execute has no dry run to check first, so a version is always saved when you pass one, even if the code then changes nothing. A version goes with code or codePath, not with script: a script never writes.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

file_map Map the file

Every page of the file by id and name, with its top layers (frames, sections, components) and, inside each section, its own, with their types, sizes and childCount (how many children each has; a page's childCount is its top layers), in one call: where to start in a big file. Pages load one at a time; past the time a call has, more: true and the pages left have no nodes (outline them one by one). A page Figma cannot load (its connection is down, say) has no nodes either and is in pagesNotRead with Figma's words; the other pages are still mapped.

ParameterTypeWhat it is
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

flow_read Map the prototype

A page's prototype as a map, for an app's routes: where its flows start, its screens (the page's frames, and those in its sections) with their sizes, and every interaction that leaves its layer: from which screen and layer, on what trigger, to which screen (or back, close, a URL), and how it moves ("navigate to Detail; smart animate 300ms ease-out"). A variant switch stays inside its component and is read by design_read as $on-*.

ParameterTypeWhat it is
pageoptionalstringThe page's id. Default: the current page.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

fonts_check Check the fonts

The fonts a layer's texts use (the selected layer's by default), by family with the weights used, and where the build gets each: whether Google Fonts serves it, with a ready css2 link for those weights, and the weights it lacks; a family Google Fonts does not have needs its own files. A variable family also lists its axes (such as wght, wdth or opsz) with their ranges and defaults, the values font-variation-settings takes. Google Fonts' public catalogue is read once (no key); offline, the fonts are still listed.

ParameterTypeWhat it is
nodeoptionalstringThe layer whose texts' fonts to check (a section, a screen). Default: the one layer selected in Figma.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

guide Pixelwright guide

How to work with Pixelwright and read what it returns. Without a topic: the topics. Topics: workflow (Which tool to use when, from finding a section to its files and writing it back, and how to read a design like a web developer.); xml (The XML design_read returns: tags, metadata, CSS attributes and values, layout, read-only attributes.); tokens (How tokens are named, read, written and bound: styles, variables, modes, aliases, units, libraries.); assets (What becomes a file, in which format, how files are named, and what no file holds (a video).); script (An execute script over the reads: its limits, its utils, images and the answer types it reads by.); write (design_apply, nodes_delete and version_save: changing, creating, copying and moving layers, pages, components, images, icons, notes and text with design_read's XML.); layout (design_apply layouts: when to use flex, grid or absolute placement; grid tracks, spans and cells; pinned and centred layers.). Read workflow first in a new task, xml before building from design_read, write before design_apply, and layout before setting a frame's flex, grid or absolute placement.

ParameterTypeWhat it is
topicoptional"workflow" | "xml" | "tokens" | "assets" | "script" | "write" | "layout"The topic to read. Default: the list of topics.

image_compare Compare a layer with an image or a layer

Renders a layer as screenshot does (scale, effects and clip alike) and compares it with a PNG on disk, typically a screenshot of your build at the same size, or with another layer (against) rendered the same way, a variant against its default or a rebuilt frame against the original: rmse (0 to 255) and the share of differing pixels over the part both cover, the box around the differences, and the edges: each horizontal (rows, by y) and vertical (columns, by x) edge of the reference matched, shifted by a few px (by: how far the render's is off), missing, or extra in the render. diff writes a PNG of the difference. Take the reference at the render's density (scale 2 for a 2x screenshot). Works while Allow edits is off.

ParameterTypeWhat it is
nodestringThe layer's id, e.g. 54:243.
referenceoptionalstringThe PNG to compare with, e.g. a screenshot of your build at the same size: its path. A relative path starts in the project folder: the MCP client's root, else CLAUDE_PROJECT_DIR, else the server's working directory.
againstoptionalstringAnother layer's id to compare with instead of a PNG, rendered the same way: a variant against its default, a rebuilt frame against the original.
scaleoptionalnumber
default 1
Pixels per Figma pixel of the render: the reference's density.
effectsoptionalboolean
default true
Render shadows and outside strokes around the layer; false renders only its own box.
clipoptionalobjectOnly this region of the layer, in Figma px from its box's top left (before scale); with effects on it may reach into what paints around the box.
diffoptionalstringA .png path to write the difference to: the render faded, every differing pixel red. A relative path starts in the project folder: the MCP client's root, else CLAUDE_PROJECT_DIR, else the server's working directory.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

inspect Inspect layers

Reads layers as Figma has them, for what design_read's CSS cannot say, without running code (works while Allow edits is off). Recipes: fills, strokes and bound variables of every layer under a card: within + fields ["fills","strokes","bound"]; a layer's and its parent's auto layout (padding, gap, direction): fields ["layout"] gives layout and parentLayout; a mixed text's runs: fields ["text"] gives segments; how far a layer overflows its parent, and its boxes: fields ["box"]; its ancestors by id and its page: fields ["path"]. An absent field is at its default (no padding-* keys is padding 0: with any side set, all four are listed, 0 included; no gap key means no gap shown, which includes a spread layout, one visible child or a negative gap; no flex-direction is row; no overflow is none, absolute-positioned layers excepted) and the answer is complete unless more is true or a note says the scan stopped. inspect does not say whether a layer is hidden: use nodes_find with visible: false. Also: the layout box and the painted box (centred or outside strokes, shadows and blur reach past it), the blend mode of the layer and of each fill, the fill as a CSS value with the paint style or variables behind it and every fill's type, the variables bound to its padding, gap, radius and size, how strokes paint (align, per-side weights, dashes, the variables their colours are bound to), every effect with Figma's own parameters, a text's lines with what ended each (Enter or Shift+Enter) and its line heights, its prototype interactions, its Dev Mode notes (fields ["notes"]: each one's text, category and the properties it pins), its component's variant and every component property with its value and the component's default. within reads a whole subtree in one call (depth levels); nested instance ids such as I54:244;54:205;54:188 work as nodes. Boxes and each layer's centre are measured from relativeTo's top left, so it also measures: give a list of layers and their section. For layers set around a circle, around (the circle's id, or a point) adds each centre's distance from it and its angle as CSS rotate() turns (0 up, clockwise). Up to 100 layers a call: left counts the selected layers past them, more and leftIds a subtree's.

ParameterTypeWhat it is
nodesoptionalstring[]The layers' ids, e.g. ["54:243"]. Default: the layers selected in Figma.
withinoptionalstringInstead of nodes: this layer and every layer under it, in document order, at most 100 a call (more: true and leftIds when there are more). With fields, only the layers that carry one of those groups are listed and counted.
depthoptionalintegerWith within: how many levels below it to read (0: the layer alone). Default: all.
fieldsoptional"box" | "parent" | "path" | "fills" | "strokes" | "effects" | "layout" | "bound" | "text" | "component" | "interactions" | "notes"[]Only these groups of each layer, besides id, name and type (without fields every group comes): box, parent, path, fills, strokes, effects, layout, bound, text, component, interactions, notes. With within, only the layers that carry one are listed: fields ["layout"] lists the auto layout and grid frames of a subtree. layout also gives parentLayout (the parent layout), text gives segments (the runs of a mixed text), box gives center, paintedBox, rotation and overflow, path gives page. box (with center) and parent come only when asked: fields ["layout", "box"]. fills, strokes and bound name each bound variable by token and by its Figma name (variable).
relativeTooptionalstringA layer (a section, a frame) whose top left the boxes are measured from. Default: the page's.
aroundoptionalstring | objectA point to measure each layer's distance and angle from: a layer's id (its centre, e.g. a ring's), or {x, y} in the boxes' origin (relativeTo's top left, or the page's). The angle matches CSS rotate(): 0 straight up, then clockwise to 360.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

measure Measure between layers

Measures the distances between layers, each from the one before it in the list (a→b, b→c, so a row's rhythm shows): the gap between their boxes on each axis (negative where they overlap), how their edges and centres line up (B's minus A's: 0 is aligned), and, when one holds the other, how far it sits from each edge, as padding. Layout boxes by default; painted: true measures what is painted (strokes, shadows). A sentence per pair says it plainly. Works while Allow edits is off.

ParameterTypeWhat it is
nodesoptionalstring[]The layers' ids in the order to measure, each from the one before, e.g. ["54:244", "54:268"]. Default: the layers selected in Figma.
paintedoptionalboolean
default false
Measure what is painted (centred or outside strokes, shadows, blur) instead of the layout boxes.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

node_show Show layers

Brings layers into view in Figma (switching to their page when needed) and selects them, so the user sees what you mean: one layer, or several on one page, fitted in view or at a zoom (1 is 100%) centred on them; select: false only moves the view. Changes only the view and the selection, never the file.

ParameterTypeWhat it is
nodeoptionalstringThe layer's id, e.g. 54:243. Give node or nodes.
nodesoptionalstring[]Several layers on one page, fitted in view together.
zoomoptional"fit" | number
default "fit"
"fit" (default), or a zoom: 1 is 100%, 0.5 is 50%.
selectoptionalboolean
default true
Select them too (default), or only bring them into view.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

nodes_delete Delete layers can write

Deletes up to 500 layers by id, each on its own: one Figma will not delete (a layer inside an instance, which comes from its component) stays, with why. What an instance's slot holds is the instance's own and is deleted. One call is one undo step in Figma. dryRun lists what would be deleted and works with Allow edits off; version saves a named version first. Refused while the plugin's Allow edits switch is off.

ParameterTypeWhat it is
nodesstring[]The layers' ids, e.g. ["54:243"].
dryRunoptionalboolean
default false
Check without writing: the answer says what would change. Works with Allow edits off.
versionoptionalstringA name for a version saved in the file's history before writing, for the designer to go back to (not in a dry run, nor when nothing would change). Pass one when the user wants to be able to go back.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

nodes_diff Compare two layers

Compares two layers (A/B variants of a screen, a card and its copy) as design_read reads them: layers are matched by their path of names below each root (same-named siblings in order), and the answer lists the layers only A or only B has, and for each layer both have, the attributes that differ as [A's, B's] (text as $text, an instance's variant and props too) and whether an icon's or image's own drawing differs (paths, colours, inner layers). Ids and the two roots' own names and places are left out. Works while Allow edits is off. To compare a layer with how it was when you built it, use baseline_diff.

ParameterTypeWhat it is
astringThe first layer's id (variant A), e.g. 54:243.
bstringThe second layer's id (variant B).
depthoptionalintegerLevels below each layer to compare. Default: all.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

nodes_find Find layers

Recipe: texts holding words anywhere in the file: within "file" + text ["word", ...] + fields ["path","page","hidden"]; path[0] is the top-level layer a text sits in (an empty path: the text is top-level). Finds layers on the current page, or inside within (a layer or page id, a list of them for several roots in one call, or "file" for every page), by name (substring), type (FRAME, TEXT, INSTANCE…), text content (a substring, or a list of them: any matches; textRegex: a JavaScript regular expression, any case), component (an instance's component or component set name), componentId (an instance's component, or any variant of a component set, by id) or variant (an instance's variant values, "State=Hover, Size=L") or fill (a visible fill of a Figma paint type: IMAGE gives the image layers). Returns ids, names, types, boxes, a text's characters (its first 200, cut: true past them), and its ancestors' ids, names and types in path (within "file" also its page), with hidden: true on a layer a viewer does not see (visible: true or false keeps only shown or hidden ones), a text's fontSize (its distinct sizes when mixed) and an instance's component (its main component's name, and set for a variant) and changed properties (those differing from its component's defaults; properties: true gives every property's value, variant values included), fontSize (lt, lte, gt and gte keep texts with a size under, up to, over or from that many px: {"gte": 12, "lt": 16} keeps 12 up to under 16), and fields keeps only the named fields of each layer (id, name and type stay: fields ["fontSize"] drops box and path), at most limit (more: true when there were more). Combine criteria to narrow down. counts: true also counts every instance found, past the limit, by component and variant: before deleting variants, which ones layers still use, without code. An absent field is at its default (no hidden is visible; no changed means no changed properties, or the component's defaults could not be read) and the answer is complete unless more is true or a note says the scan stopped.

ParameterTypeWhat it is
nameoptionalstringLayers whose name contains this, in any case.
typeoptionalstringLayers of this Figma type, e.g. FRAME, TEXT, INSTANCE, COMPONENT, RECTANGLE.
textoptionalstring | string[]Texts whose characters contain this, or any of these phrases, in any case.
textRegexoptionalstringTexts whose characters match this JavaScript regular expression, in any case, e.g. "^$\d+".
fontSizeoptionalobjectTexts by font size in px: lt (under), lte (up to), gt (over) and gte (from), e.g. {"gte": 12, "lt": 16} for 12 up to under 16; a text with mixed sizes matches when any size does.
componentoptionalstringInstances whose component or set name contains this, in any case ("Button" also matches "Icon Button"), at any depth, inside other instances too; each comes with component, the component and set it is of, and changed, the properties it sets away from the component's defaults.
componentIdoptionalstringInstances of this component, or of any variant of this component set, by id.
propertiesoptionalbooleanAlso give every component property's value on each instance found, by name; a variant property's value is among them (State: "Hover"), so the variant of each instance needs no other call.
variantoptionalstringInstances of one variant, e.g. "State=Hover, Size=L": every value given must be the main component's (in any order and case; the rest may be anything).
countsoptionalbooleanAlso count every instance found, by component and variant, past the limit listed: before deleting a variant, how many layers use it.
visibleoptionalbooleantrue: only layers a viewer sees (the layer and every ancestor visible); false: only hidden ones: within a component's id, its hidden layers and those under a hidden one. Default: both.
filloptional"IMAGE" | "SOLID" | "GRADIENT_LINEAR" | "GRADIENT_RADIAL" | "GRADIENT_ANGULAR" | "GRADIENT_DIAMOND" | "VIDEO" | "PATTERN"Layers with a visible fill of this Figma paint type: IMAGE, SOLID, GRADIENT_LINEAR, GRADIENT_RADIAL, GRADIENT_ANGULAR, GRADIENT_DIAMOND, VIDEO or PATTERN; IMAGE gives every image layer.
withinoptional"file" | string | string[]Where to search: a layer or page id, a list of up to 50 (each searched in turn, one answer; a layer under two roots is listed once), or "file" alone for every page. Default: the current page.
limitoptionalinteger
default 50
At most this many layers listed; more: true when there were more. counts still counts them all.
fieldsoptional"id" | "name" | "type" | "box" | "path" | "characters" | "cut" | "properties" | "hidden" | "fontSize" | "changed" | "component" | "page"[]Only these fields of each layer found, besides id, name and type, e.g. ["fontSize"] drops box and path. Default: all.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

outline Outline a frame

The layer tree of a frame, a page or the current page, as light XML: tag (the Figma type), id, name and box (x and y relative to the outlined node; absolute: true gives them in page coordinates) per layer, to depth levels; an instance also names its component and variant, so repeated components show. Use it to find the sections of a big frame before reading one with design_read. A layer with $children="N" has N children not listed here: outline it on its own.

ParameterTypeWhat it is
nodeoptionalstringThe layer or page id, or 0:0 for the list of pages. Default: the current page.
depthoptionalinteger
default 3
How many levels below the node to list (1 to 10).
absoluteoptionalbooleantrue: x and y in page coordinates, as Figma's absoluteBoundingBox. Default: relative to the outlined node.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

screenshot Screenshot a layer

Renders a layer to PNG so you can see it: a section to build, or your result to check. Returned inline at most 2000 px on a side: a larger layer comes scaled down to fit, and the text says its full size. For details of a tall layer screenshot one section of it (outline lists them), or pass clip for a region of it; pass save to write the PNG full size to a file instead.

ParameterTypeWhat it is
nodestringThe layer's id, e.g. 54:243.
scaleoptionalnumber
default 1
Pixels per Figma pixel: 2 for a sharp look, below 1 to fit.
effectsoptionalboolean
default true
Include shadows and outside strokes around the layer; false renders only its own box.
saveoptionalstringWrite the PNG to this file (any size) instead of returning it. A relative path starts in the project folder: the MCP client's root, else CLAUDE_PROJECT_DIR, else the server's working directory.
clipoptionalobjectOnly this region of the layer, in Figma px from its box's top left (before scale); with effects on it may reach into what paints around the box.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

selection_get Read the selection

Lists the layers the user selected in Figma (id, name, type, box in page coordinates). Call it when the user says "this", "the selected one" or "what I picked", then read those ids with design_read or outline.

ParameterTypeWhat it is
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

selection_wait Wait for a selection

Waits until the user selects something in Figma, then answers with the selection, as selection_get does (changed: false when the time ran out first). Tell the user what to select before calling it: "select the card you mean in Figma".

ParameterTypeWhat it is
timeoutoptionalnumber
default 60
Seconds to wait for the user to select something: 60 by default, 300 at most.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

status Connection status

Lists the Figma files whose Pixelwright plugin is connected (name, current page, editor, whether Allow edits is on) and marks the active one: the file whose plugin window was in front last, which every tool uses when no file is named. Call it first, and whenever a tool says no file is connected: hint says what to do. While a plugin waits to be paired, pairing holds the code: tell the user to type it into the Pixelwright window, and never type or send it yourself. probe: true also pings the active file's plugin. key is the file key of figma.com links, given by Figma to private organization plugins only, so it is mostly null: then ask the user for the file's link.

ParameterTypeWhat it is
probeoptionalboolean
default false
Also ping the active file's plugin and report the round trip.

styles_compare Compare a build's styles with the design

Whether a build has each style the design sets, property by property. Give pairs: a layer (design_read's id) and the computed styles of the element that draws it, as the browser gives them: Object.fromEntries([...getComputedStyle(el)].map((p) => [p, getComputedStyle(el).getPropertyValue(p)])), or only the properties a first call lists in notGiven. Each layer is read as design_read writes it: in its parent when another pair's layer holds it, else as a read of its own (its size, not its place); its tokens and text style in and its shorthands spread into longhands (padding into padding-top…, border into each side's width, style and colour, font into family, size, weight, style and line height, gap into row-gap and column-gap, the main axis's only in a flex that does not wrap). mismatches gives each property the build has otherwise with both values and the token or text style it comes from; notGiven what the build's styles leave out; notCompared what a computed style cannot be held against (offsets in percent or calc(), fr tracks). Sizes and places may be off by tolerance px; other lengths, colours (hex or rgb()), shadows, gradients and transforms compare by value. What the design leaves unset is not checked, nor a hidden layer. Layers with differences come first. image_compare compares the pixels. Works while Allow edits is off.

ParameterTypeWhat it is
pairsobject[]Each layer with the build's computed styles for it.
toleranceoptionalnumber
default 1
How far a size or a place may be off, in px (1 by default): layout rounds them. Other lengths, colours and numbers compare as CSS computes them.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

tokens_apply Write design tokens can write

Writes design tokens in the shape tokens_read returns with format json: tokens takes tokens_read's tokens as they are (their ids, aliasOf, defaultMode and selectors are read past), or the same shape by hand: collections with their modes and variables, each mode's value in CSS (a colour, px or a number, a quoted string, true/false, var(--token) for an alias), optionally scopes (where Figma's pickers offer it: a font weight or an opacity needs FONT_WEIGHT or OPACITY to stay a plain number) and codeSyntax per platform, and styles: paint (a colour or colour variable), text (the font shorthand, its letter spacing and case in also as tokens_read lists them, or after it: "500 12px/16px 'Inter'; letter-spacing: 0.04em; text-transform: uppercase"; left out, the style keeps its own) and effect (a box-shadow list, a shadow's colour a colour or var(--colour variable), its blurs after it or in also, or alone: "backdrop-filter: blur(20px)"; the effects a value leaves out, the style keeps). Collections, modes, variables and styles are found by name among the file's own or made (a style's token says which of styles sharing a name it is); what the file already holds, as tokens_read writes it, is left as it is, and nothing is deleted. A library's collection or style is never copied into the file: change it in the library. Send only what you change. errors name each variable, mode or style that could not be written while the rest goes in; notes, what was written but will not read back as given. One undo step in Figma; refused while the plugin's Allow edits switch is off (dryRun checks without writing).

ParameterTypeWhat it is
tokensobjecttokens_read's tokens (format json) as they are, or the same by hand: collections and styles, only what you change.
dryRunoptionalboolean
default false
Check without writing: the answer says what would change. Works with Allow edits off.
versionoptionalstringA name for a version saved in the file's history before writing, for the designer to go back to (not in a dry run, nor when nothing would change). Pass one when the user wants to be able to go back.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

tokens_bind Bind raw values to tokens can write

Binds the raw values under a layer, a page or the file to the styles and variables that hold them exactly, in each layer's variable mode and within the variables' scopes: colours to colour variables or paint styles, gaps, padding, radii, border widths and opacity to number variables, texts to text styles, shadows and blurs to effect styles. A value one token holds is bound; one several hold is listed with its candidates (pick with choose); one none holds is listed too, for tokens_apply. choose also snaps a near value to a token. remap rebinds every use of one token to another of its kind, for merging duplicates, and with instances: override inside instances too, as their overrides (a dark copy on a plan with one mode). Instances are left to their main components, all but what was put into their slots. Results are grouped by value. One undo step in Figma; refused while the plugin's Allow edits switch is off (dryRun lists without writing).

ParameterTypeWhat it is
withinoptional"file" | stringThe layers to bind in: a layer id, a page id (all its layers), or "file". Default: the layers selected in Figma.
kindsoptional"color" | "number" | "text" | "effect"[]
default ["color","number","text","effect"]
What to bind: color (fills, strokes, text colours), number (gaps, padding, radii, border widths, opacity), text (text styles), effect (effect styles). Default: all.
chooseoptionalobject[]
default []
Picks: for a value several tokens hold, the one it takes; or a value to snap to a token (a near colour, an off-scale gap), which then takes the token's value. Values as this tool lists them.
remapoptionalobject[]
default []
Rebind every use of one token to another of its kind (--blue-500 to --brand, a duplicate style to the one kept); raw values are then left alone.
instancesoptional"leave" | "override"
default "leave"
With remap: leave (default) keeps instances to their main components; override rebinds the uses inside them, nested instances too, as overrides on each instance, for a copy that must differ from its components (a dark copy in a file whose plan has one mode).
dryRunoptionalboolean
default false
Check without writing: the answer says what would change. Works with Allow edits off.
versionoptionalstringA name for a version saved in the file's history before writing, for the designer to go back to (not in a dry run, nor when nothing would change). Pass one when the user wants to be able to go back.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

tokens_read Read the design tokens

Reads the file's design tokens: every variable collection with all its modes (light, dark…), and the paint, text and effect styles, its own and those the current page uses from a team library, named the way design_read writes them (var(--Name)). query keeps only the variables and styles whose name or token has that text (a substring, or a list of them: any matches; any case; no regex), each variable carries its Figma id and, for an alias, aliasOf with the tokens it passes through down to the one holding the value (format json). format css (default) returns ready CSS: :root holds each collection's default mode and the styles, and every mode of a collection with several is a block [data-<collection>="<mode>"] (the default's too, so an element in it resets inside another mode's) to put on the element a theme applies to, the attribute design_read writes where a layer sets a mode; format json returns the same per collection and mode, with each variable's scopes (when not every field) and code syntax; format dtcg returns Design Tokens Format (DTCG 2025.10) trees, one per collection mode and one of styles, to save as token files for Style Dictionary or Tokens Studio. libraries: true also lists the enabled libraries' variables by name. notes say what could not be written.

ParameterTypeWhat it is
collectionsoptionalstring[]Only these variable collections, by name (case does not matter). Default: all of them.
queryoptionalstring | string[]Only the variables and styles whose name or token contains this text, or any of these texts (any case, no regex), e.g. "primary" or ["gray", "border"]. Default: all of them.
librariesoptionalboolean
default false
Also list the enabled libraries' variables, by name and type: their values are read only once the file uses them.
usedoptionalboolean
default true
Also take the styles and variables the layers on the current page (or within) use, a team library's among them. A file that uses a library has its tokens there.
withinoptionalstringThe layer or page whose used tokens to take. Default: the current page.
formatoptional"css" | "json" | "dtcg"
default "css"
css: ready custom properties, a block per extra mode. json: the token model, per collection and mode. dtcg: Design Tokens Format (DTCG 2025.10) trees, one per collection mode (<collection>.<mode>) and one of styles, each to save as its own .json file.
maxCharsoptionalinteger
default 80000
Longest output; past it the summary comes back with the first whole tokens that fit, and you read collections one at a time.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

tokens_usage Where a token is used

The layers on the current page (or inside within, or on every page with within: "file") that use a style or variable, named by its token as design_read and tokens_read write it (--White-2 is the second style named White, --h1-font a text style), with where each uses it (fill, stroke, effect, text, a text run, or a bound field). Use it to tell same-named styles apart or to see what a change to a token would touch. raw: true in place of token lists the colours bound to no style and no variable (fills, strokes, text runs, effects, gradient stops), each as #RRGGBB with its count and layers, most used first; under within it is complete when more is not true and there is no cut note (500 layer uses at most); paints with opacity 0 or hidden are not counted. At most 500 layers come back (more says there are others); the scan stops at budgetMs with what it found and a note.

ParameterTypeWhat it is
tokenoptionalstringA style's or variable's token as design_read or tokens_read writes it: --White-2, --h1-font, --color-bg. Give token or raw, not both.
rawoptionaltruetrue: list the colours bound to no style and no variable (fills with gradient stops, strokes, a mixed text's runs, effect colours) instead of a token's layers. Under within, complete when more is not true and there is no cut note (500 layer uses at most); paints with opacity 0 or hidden are not counted.
withinoptional"file" | stringThe layer or page to look in, or "file" for every page (loading them all is slow on a big file). Default: the current page.
budgetMsoptionalinteger
default 20000
How long the scan may take, in ms; when it is spent the layers found so far come back with a note. Default: 20000.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

types_read Read answer types

Gives the whole answer type of each named read as TypeScript, every field at every level with its comment, from the tool's own output schema: read it before an execute script uses an answer, since a script that reads a key the type lacks throws. Name a tool as this list does (nodes_find) or as a script calls it (nodesFind, pw.nodesFind); names that are no read come back in unknown.

ParameterTypeWhat it is
toolsstring[]The reads to describe, e.g. nodes_find, inspect, design_read.

variants_read Read a component's states

How each variant of a component set differs from its default one (the top-left, as Figma takes it), as nodes_diff says it: the attributes each changes as [the default's, this one's], the layers only one has, its properties, and the CSS pseudo-class a state value suggests (Hover → :hover, Pressed → :active, Focused → :focus-visible, Disabled → :disabled). Give the set, a variant or an instance. Build the default, then each state as its difference.

ParameterTypeWhat it is
nodestringA component set's id, or one of its variants', or an instance's: its set is read.
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

version_save Save a named version can write

Saves a named version in the file's Figma version history, for people: the designer can open the design as it was, and developers on a paid plan can pick it in Dev Mode's Compare changes. Save one only when the user asks: Figma's plugin API cannot list, read or delete a version, so it stays in the history. baselines: the baselines it goes with; it is saved only while the design still matches them, and they record it. Needs edit access to the file and the plugin's Allow edits; the same title is refused twice within ten minutes.

ParameterTypeWhat it is
titlestringThe version's name in Version history, e.g. "Built: pricing".
descriptionoptionalstringShown under the title. Everyone with the file sees it: no local paths or private repository names.
baselinesoptionalstring[]The baselines this version goes with: it is saved only while the design still matches each one, and they record it.
fileoptionalstringA session from status, or a file name. Default: the file of the first baseline, else the active file.

viewport_get What the user sees

What the user is looking at in Figma now: the page, the zoom, the part of the page in view (page px), and the page's layers and their children that meet it, outermost first. Use it when the user says "this" or "here" without selecting anything; selection_get gives what is selected.

ParameterTypeWhat it is
fileoptionalstringThe file to work on: its session from status or its name. Default: the active file.

Guide: workflow

Which tool to use when, from finding a section to its files and writing it back, and how to read a design like a web developer. The agent reads this with guide topic workflow.

Pixelwright reads and writes the files open in Figma Desktop through its plugin; nothing goes through Figma's REST API. design_apply, nodes_delete, version_save, tokens_apply and tokens_bind change the file (step 8); every other tool reads. Every tool that works on a file takes file (a session id from status, or a file name); without it, the active file, except baseline_diff, which compares a baseline in the file it was saved from.

  1. Connection. status lists the connected files and which one is active. None connected: the user runs the Pixelwright plugin in Figma Desktop and keeps its window open (the first time, they type the pairing code status shows into the plugin window; never type or send it yourself).
  2. Find what to read.
    • file_map: every page with its frames, sections and components, in one call: where to start in a big file.
    • selection_get: what the user selected ("this", "the selected one"). selection_wait: ask the user to select something, then wait for it. viewport_get: what the user is looking at, when "this" comes with no selection.
    • outline: the layer tree with boxes, x and y relative to the outlined layer; node: "0:0" lists the pages. A layer with $children="N" has more children than listed: outline it on its own. An instance names its component and variant, so repeated cards show without a read; dev marks what the designer handed over for development: build those first, not drafts.
    • nodes_find: layers by name, type, text, component or an instance's variant ("State=Hover, Size=L"), on the current page, inside a layer or across the file (within: "file"). counts: true counts every instance found by component and variant: which variants the layers use. Each layer says hidden when a viewer does not see it (visible: true or false keeps only shown or hidden ones), a text its fontSize, an instance the properties it changed from its component's defaults.
    • node_show: brings layers into view and selects them, so the user sees which you mean.
    • changes_since: what the designer changed since you last looked (a cursor), to read again only that.
  3. Read one section. design_read returns the section as XML (guide xml explains every tag and attribute), then JSON with tokens, text styles, fonts, assets, hints and truncated, plus measurements (the designer's Dev Mode measurements, in px) when the section has them. That answer is complete for a build: write the code from it. Read sections, not whole pages: past maxChars (80 000) the deepest branches are left empty with $truncated="true" and their ids listed in truncated; read each on its own. Pass assetsDir (e.g. src/assets) to get its icons and images written as files (guide assets). repeats: true reads a list of alike items once ($repeat), with their data as rows: shorter, and the list's shape plain. nearby: 400 adds the designer's notes on the canvas around the screen (texts and stickies beside it, nearest first): read them, they often say what the layers cannot (states, motion, copy to change).
  4. Look at it. screenshot renders a layer to PNG (inline up to 2000 px a side, scaled down to fit; save writes a .png file full size; clip takes a region of it, in px from its box). Compare your build with it: image_compare renders a layer the same way and compares it with a PNG of your build, or with another layer (against): rmse, the share of pixels that differ, the box around them, edges off by N px; diff writes the difference as a PNG. styles_compare checks the build's computed styles (getComputedStyle) against each layer, property by property: the values that differ with the token or text style behind them, and the properties the build left out. Measure it. inspect reads layers as Figma has them, without code: the layout box and the painted box (a centred stroke, shadows and blur reach past it), the blend mode of the layer and of each fill, the fill with the style or variables behind it (what a var() resolves to) and every fill's type (a video's too), how strokes paint and the variables their colours are bound to, a frame's auto layout as layout (design_read's CSS longhands in px: padding-top, gap, row-gap), every effect's parameters (a progressive blur's start and end), a text's lines and line heights, overflow, interactions with their transitions, a component's variant and properties with their defaults, and each layer's centre. Items set around a circle (a round menu, labels on a dial): around (the circle's id, or a point) gives each centre's distance from it and its angle as CSS rotate() turns, 0 at the top, clockwise. measure gives the distances between layers, each from the one before (gaps, aligned edges, insets). Compare. nodes_diff says how one layer differs from another (A/B screens, a card and its copy): the layers only one has, the attributes that differ, and icons whose drawing differs. variants_read gives a component's states as differences from its default (build :hover, :active, :disabled from them). breakpoints_find finds a screen at the page's other widths, for the media queries. flow_read maps the prototype: screens and the links between them.
  5. The design system. tokens_read: variables with every mode (light, dark…) and styles, as CSS, JSON or DTCG token files (guide tokens); query keeps the ones whose name has that text, each variable carries its id. tokens_usage: the layers a token is used on; with raw: true, the colours bound to no style or variable, each with the layers using it. components_read: the components a page uses, or the file defines, with variants and properties. library_search: components of the team's libraries, saved once from each library file. fonts_check: the fonts used and where the build gets each (Google Fonts links).
  6. Files. assets_export: several layers, or every asset inside one, as PNG, JPG, WebP, SVG or PDF, or the images as they were placed (original: true); width sizes a render by the CSS width the build shows it at (110 at scale 2: 220 px). When a file gets another name than design_read planned (planned), use the path it gives.
  7. Keep the code in step with the design. Only when the user wants to track what the designer changes later: right after the design_read you build a screen or section from, baseline_save {node, name, code} keeps it in the project (.pixelwright/baselines/: commit it to share, or leave it out of git, since it holds the design's texts). When a session starts, or the user says the design changed, baseline_diff says which baselines changed; with name it lists the changes in the XML's terms. Change only the code they name: export again what is marked drawing; build added layers from their xml (or design_read when it is left out). Then baseline_save {name, accept} with the accept the diff gave. changes_since stays the live view while the plugin is open.
  8. Write. design_apply writes the same XML back into Figma: change layers by id, create, copy and move them. nodes_delete deletes layers by id. version_save leaves the designer a named version, when the user asks. Read guide write first (Allow edits, dry runs, versions and every rule), and guide layout for flex, grid and absolute placement. tokens_apply makes the variables and styles a design lacks, and tokens_bind binds the raw values under a layer to the tokens that hold them (guide tokens).
  9. Code, the exception. The reads answer what code is most often written for, a line per question:
    • texts by content, size or visibility, instances by component or changed property, with ancestors and page: nodes_find (text list, textRegex, fontSize, visible, componentId, properties, fields);
    • every auto layout gap and padding, a text's style runs, a component's properties in a frame: inspect with within (+ depth, fields: ["layout"] lists only the layers that carry it), nested instance ids too;
    • a layer's parent layout and ancestors by id: inspect (parentLayout, path);
    • a token by name, its Figma id and what an alias leads to: tokens_read with query;
    • colours bound to no token: tokens_usage with raw: true. execute runs JavaScript in the plugin, for what no tool reads and for a change design_apply cannot say: try the tools first (design_read, inspect, measure, nodes_find to read, design_apply to write), which need no code and answer in the XML's terms.

Checking a build without a browser

When the agent has no browser of its own, the design and the build still meet as two PNGs of one size:

  1. screenshot the frame with save (scale 1, or the build's device pixel ratio) and note its width and height.
  2. Render the build at that size with what the project already has: a headless Playwright script (page.setViewportSize, then page.screenshot of the section's element), the framework's own preview or screenshot test, or Storybook's test runner. Wait for fonts and images before the shot. A project with no renderer has nothing to compare: use the read checks of step 4 alone and tell the user the render check was skipped.
  3. image_compare the frame's id with the build's PNG as reference and the same scale, with diff set: rmse and different say how far apart they are, box where, and rows and columns which edges moved and by how many px. Fix what the diff shows, render again, compare again.
  4. What reading alone checks, with no render: inspect gives each layer's size, auto layout gaps and paddings, and text runs; measure gives the distances between layers; compare those numbers with the build's CSS. When the headless render can also hand back an element's computed styles (getComputedStyle), styles_compare lists every property that differs.

Reading a design like a web developer

A design shows the look, not the build. design_read's hints say where the two part; read them before you write code.

  1. Workarounds. Children placed absolutely inside an auto layout parent, empty layers that only make space, and texts broken into lines by hand are often how the design tool got the look: build a flow with that gap, use the parent's gap or padding, and let the text wrap in its width.
  2. Gaps and components. Children spaced evenly in a frame without auto layout are a flex or grid with that gap. A structure built three times or more without a component (cards, rows, tabs) is one component with instances (repeats: true reads them once, their data as rows).
  3. Fixed sizes. A text or content frame of fixed width narrower than its column fills it with a max-width; a frame of fixed height that clips its content grows with it, unless the build means to cut it.
  4. Baked fades. A fade baked into an image (a gradient over a photo, often at a section's edge) stretches with the box once exported flat: export the raw image (assets_export with original: true) and build the gradient in CSS (guide assets).
  5. Tiled textures. A frame filled with a tiled texture renders coarser or finer at another scale: the hint gives the scale; export one tile at it and repeat it.
  6. Blend modes and video. They change the look completely: inspect gives the layer's and each fill's blend mode and each fill's type; design_read writes mix-blend-mode, and lists a video fill as an asset no file holds (guide assets).
  7. States. Top-level frames of one size that share most of their layers (a section and its copy with another tab active) are states of one component: build it once, with variants; nodes_diff lists what differs.
  8. Missing fonts. A text whose font is not installed here was laid out with a fallback, and the hints name it: its spacing may differ only for that reason, so do not "fix" it. fonts_check says where the build gets each font.

Build the code from the XML with the project's own components, tokens and layout conventions: the XML is the spec, not the code to paste. Hints in design_read also say what Figma left unbound (raw colours equal to tokens, raw spacing, radii and strokes Figma itself matches to a token, unnamed layers, frames without auto layout) and what instances changed outside their component's properties.

Guide: xml

The XML design_read returns: tags, metadata, CSS attributes and values, layout, read-only attributes. The agent reads this with guide topic xml.

design_read writes a section as XML: one element per layer, Figma's layer type as the tag, CSS properties as attributes. The XML is the design's spec: build the code from it with the project's own components and tokens, do not paste it.

Tags

  • Figma's types in PascalCase: Frame, Group, Section, Component, ComponentSet, Instance, Text, Rectangle, Ellipse, Line, Slot…
  • Image: a true image (a photo, a layer filled with an image, a masked group, a layer with an effect CSS cannot draw). Its src is a PNG of what it shows.
  • Icon: a vector, or a group or instance drawn only with vector shapes (a logo). Its src is one SVG.
  • TextPath: Figma's text on a path (a label along an arc), its text written as a Text's (see Text below).
  • Span: a run inside a Text whose style differs from the text's own.
  • A hidden layer is a stub with display="none": its id and name (and $visibleProp when a component property shows it), no box and no children. Slices are left out.

Metadata attributes, in this order

id (instance children keep I…;… ids), name (left out on a text named by its content), component and variant ("Size=Large, State=Default") on instances, props (an instance's text and boolean properties, "Label=Sign up, Icon=true"; a comma, = or backslash inside a name or value comes escaped with a backslash), $exposed, description (components), note (Dev Mode annotations, see Notes), $override, $dev, $locked (see Read-only attributes), href (a prototype link, or a text's hyperlink), target (_blank when the prototype link opens in a new tab), data-<collection> (a variable mode set on the layer, data-color-modes="dark"; the read's root also has the modes it takes from above), textStyle, mask (alpha, vector or luminance: the layer masks the layers above it in its parent), src (assets), d and start (a text on a path). The CSS attributes come next, then $prop, $visibleProp, $swapProp, $css, $grid-style and $on-…, and last $children, $truncated and $repeat.

A data-<collection>="<mode>" attribute is the selector tokens_read's CSS writes for that mode: put it on the element in the build too, and the element takes that mode's values.

CSS attributes

Ready CSS values, in this order: display, flex-direction, flex-wrap, position, left, right, top, bottom, width, height, min/max sizes, flex, align-self, grid-row, grid-column, justify-self, padding, justify-content, align-items, align-content, gap, column-gap, row-gap, grid-template-columns/rows, transform, opacity, mix-blend-mode, overflow, text-overflow, white-space, border-radius, border (or border-top…, outline), background, box-shadow, text-shadow, filter, backdrop-filter, font, font-variation-settings, letter-spacing, text-transform, text-decoration (with text-underline-offset, text-decoration-thickness), text-align, text-wrap, color.

  • Sizes: fixed sizes in px; hug writes nothing; fill is flex: 1 along the parent's direction and align-self: stretch across it. The layer you read always has its width and height.
  • A turned layer has transform: rotate() and is placed by its centre; a mirrored one scaleX(-1).
  • Colours bound to a style or variable are var(--Name), a shadow's colour too (see guide tokens); the values behind them are in the JSON tokens. In a Display P3 file every colour is color(display-p3 r g b) (as tokens_read writes it too): keep it so, it is what the designer chose. A text with a textStyle carries only what differs from the style; textStyles holds the style's font.
  • Lengths are whole pixels; stroke widths and blurs keep two decimals, and letter spacing keeps its fractions.
  • filter: blur() and backdrop-filter: blur() are 0.43 of Figma's blur radius: Figma renders a radius R as a Gaussian of about 0.43 R (measured on layer and background blurs of radius 4 to 40 against Chrome), so radius 20 is blur(8.6px), and a blur(v) here is Figma's radius v / 0.43. Dev Mode writes radius / 2, which is softer.

Values

  • Lengths are px (0 stays bare); a token where the designer bound one (gap="var(--space-16)").
  • font is the shorthand [italic] weight size/line-height 'Family': font="italic 500 14px/20px 'Inter'", the line height in px, or normal for Figma's Auto (see Text).
  • font-variation-settings="'wdth' 90, 'GRAD' 50": a variable font's axes the font does not say already, on a Text and on a Span. wght is the font's weight (a variable weight such as 560 is written there), opsz follows the size (CSS's font-optical-sizing: auto), and wdth 100, slnt 0 and ital 0 are what a browser draws anyway, so none of them is written at those values. fonts_check lists each axis's range and default.
  • background holds colours and gradients, the top paint first as CSS stacks them: linear-gradient(<angle>, <stops>), radial-gradient(<rx> <ry> at <x> <y>, <stops>) and conic-gradient(from <angle> at <x> <y>, <stops>), a stop a colour or a token and its place in percent. A diamond gradient, a turned radial one and repeating gradients are in $css, as Figma's own CSS.
  • mix-blend-mode is how the layer blends (multiply, screen, overlay…); a blend mode CSS has no name for is in $css.
  • background-blend-mode follows background when a fill blends with the fills under it: one mode per background, top first (multiply, normal). A mode it has no name for (linear burn or dodge) is in $css, and so is a text's (fill-blend-mode: color cannot blend).
  • A text's stroke follows color as -webkit-text-stroke="2px #3B2FD9", which CSS centres on the glyph's edge: an outside stroke is twice as wide with paint-order="stroke fill", so the fill hides its inner half; an inside one has no CSS and is in $css as stroke-align: inside.
  • text-decoration is on a Text only when every run has it: CSS draws a parent's underline through every child, so otherwise each underlined or struck-through Span carries its own.
  • A drop shadow Figma shows behind a see-through layer is filter="drop-shadow(0 4px 6px #000)", before the layer's blur(): CSS cuts a box-shadow out under the box, while drop-shadow() draws under the layer's see-through pixels, following their alpha (children too). Its blur is a standard deviation, half a box-shadow's blur radius, so it is half Figma's radius. One with a spread, which drop-shadow() has not, stays a box-shadow with shadow-behind in $css.
  • mask="alpha" (or vector, luminance) makes the layer the mask of the layers above it in its parent.

Layout as the XML shows it

  • Flex. Auto layout is display="flex": a row, or flex-direction="column", flex-wrap="wrap" when it wraps; defaults are left out (row, flex-start, gap 0), and a gap is written only between two or more children. justify-content aligns along the direction (flex-start, center, flex-end, space-between), align-items across it (flex-start, center, flex-end, baseline). Figma aligns all children alike, so a child's align-self is only ever stretch.
  • Grid. Grid auto layout is display="grid" with grid-template-columns and grid-template-rows, each a list of tracks: 200px is fixed, 1fr takes a share of the room left, auto fits its content; three or more equal tracks are repeat(3, 1fr). row-gap and column-gap space them. Each child has its grid-row and grid-column, lines counted from 1 as in CSS, with span when it spans (grid-column="1 / span 2"); a cell holds one child. In its cell a child sits where justify-self (horizontally) and align-self (vertically) put it: start, center, end, or stretch when it fills the cell. A grid has no justify-content or align-items: each child aligns in its cell.
  • Absolute. A child of a frame without auto layout, a section's child, and a child taken out of an auto layout flow have position: absolute and are placed against their parent element: give that parent position: relative in the build. Their edges follow the constraints: left/top when pinned to the start, right/bottom when pinned to the end, left and right without a width when stretched, calc(50% - Npx) when centred (left="calc(50% - 24px)" centres a layer 48 px wide, half its size), and percents when scaled with the parent. Later in the XML is drawn on top (there is no z-index).

Notes

note="Spacing: Gap is \[8] [gap, padding] | Check the hover state | [background]" is the layer's Dev Mode annotations in order, joined by |: each one's category (Spacing: ), its text, and in a closing bracket the properties the designer pinned in it, in CSS words (gap, padding, background, border-radius, font-size, text style, component; a text's fills are color): take those values exactly. A note of pins alone is its bracket. A |, \ or [ inside a note's text comes escaped with a backslash. inspect with fields: ["notes"] gives each note as Figma has it (text, category, Figma's property types).

Read-only attributes (start with $)

  • $css: what the CSS attributes cannot say, as Figma's own CSS: a diamond gradient, a turned radial one, blend modes CSS has no name for, a video fill, line clamps, lists, a negative gap ("children overlap"). It holds property: value pairs only, explained in hints: blur: progressive from 0px at 50% 0% to 8.6px at 50% 100% (a blur that changes across the layer; filter holds its end radius), stroke-align: center (half of the stroke paints outside the box, which a border-box border does not; inspect gives the painted box), list-spacing: 8px (the space between a list's items, apart from paragraph spacing), stroke-linecap: round (a line's round or square ends, which a CSS border does not draw), corner-smoothing: 60% (Figma's smoothing runs the corner's curve on past the radius into the edges; CSS's corner-shape keeps it inside the radius and has no match, so border-radius is the nearest) and shadow-behind: 0 4px 12px 2px #000 (a box-shadow Figma also shows through the layer's see-through fill, which CSS cuts out under the box: draw it on an element behind).
  • $children="N": the layer has N children and not all are listed (depth, or maxChars).
  • $truncated="true": the branch was emptied, or the text shortened, to fit maxChars; its id is in truncated.
  • $repeat="N": with repeats: true, the first of N alike neighbours (list items, cards, rows) stands for all of them; the JSON's repeats lists the run's layers and, a row per layer, the values they hold apart (texts, src, variant, props, href, position). Build one component and map the rows over it.
  • $exposed="true": a nested instance its component exposes: its properties are the component's API too.
  • $visibleProp="Show subtitle", $prop="Title", $swapProp="Icon": a component's layer bound to its properties: the boolean one that shows it, the text one its characters show, the instance swap one it is. In code they are the component's props.
  • $override="text, background": what this layer of an instance changes that its component's properties do not say (a feature text rewritten, an icon recoloured). Code built from the component cannot show it: give the component a property or a variant for it, or build that instance as a one-off. A hint lists them all.
  • $locked="true": the layer is locked on Figma's canvas. Nothing to build; it is said so an agent leaves it be.
  • $dev="ready for dev" on the read's root: the designer marked it (or a frame or section around it) ready for development (or completed).
  • $grid-style="Desktop 12": the grid style the frame's layout grid comes from.
  • $on-click, $on-hover, $on-press, $on-drag, $on-mouse-enter, $on-mouse-leave, $on-mouse-down, $on-mouse-up, $on-key, $after-timeout, $on-media-hit, $on-media-end (any other trigger as $on-<trigger>): the layer's prototype interactions, e.g. $on-hover="change to Type=Hover; smart animate 300ms ease-out" (a variant to switch to on hover, and how: build it as the hover state); the easing is valid CSS, and a spring, which has no CSS, is named by its Figma type (200ms gentle). A link stays href, with target="_blank" when it opens in a new tab.

Text

  • &#10; is a paragraph break (Enter), &#8232; a line break inside a paragraph (Shift+Enter, <br> in HTML): never spaces.
  • line-height: normal is Figma's Auto line height, the font's own spacing (about 1.2× the size for most fonts). Where the build must match, read with autoLineHeight: "px": it writes the px Figma renders where the read can tell (a text that hugs its lines shows it for its font and size), and normal elsewhere.
  • A TextPath is a text set along a path. Its characters, spans and text CSS are a Text's (it has no line height, decoration, wrapping or truncation of its own); d is the path in the layer's own box, which left and top place as for any layer, and start where the text begins on it: the path's segment (from 0) and the place along that segment (0 to 1). text-align is anchored there: center centres the text on start, right ends it there. In code an SVG <textPath> over a <path d="…"> draws it:
<TextPath id="12:41" name="Label" d="M 0 50 C 55.23 -16.67 144.77 -16.67 200 50" start="0 0.5" position="absolute" left="100px" top="20px" width="200px" height="50px" font="500 14px/normal 'Inter'" color="var(--color-ink)">Share</TextPath>

Example (Orbit, a pricing card, abridged)

<Instance id="54:268" name="Plan – Pro" component="Plan Card" props="Price=$12, Popular=true, Description=For freelancers shipping fast., Name=Pro" note="The price comes from the billing API. Show the Popular badge only on the plan the API marks popular." display="flex" flex-direction="column" flex="1" padding="var(--space-32)" gap="var(--space-24)" border-radius="var(--radius-lg)" border="2px solid var(--color-brand)" background="var(--color-surface)" box-shadow="var(--Shadow-Card)" $on-click="go to Checkout – Desktop; dissolve 300ms ease-out">
  <Frame id="I54:268;54:203" name="Header" display="flex" align-self="stretch" justify-content="space-between" align-items="center" overflow="hidden">
    <Text id="I54:268;54:204" name="Name" textStyle="Heading/H3" color="var(--color-ink)">Pro</Text>
    <Instance id="I54:268;54:205" name="Badge" component="Badge" props="Label=Popular" display="flex" padding="var(--space-4) var(--space-12)" align-items="center" border-radius="var(--radius-pill)" background="var(--color-accent)">
      <Text id="I54:268;54:205;54:188" name="Label" textStyle="Label" color="var(--color-on-brand)">Popular</Text>
    </Instance>
  </Frame>
  …
  <Instance id="I54:268;54:211" name="Button" component="Button" variant="Variant=Primary, State=Default" props="Label=Get started" display="flex" align-self="stretch" padding="var(--space-12) var(--space-24)" justify-content="center" align-items="center" border-radius="var(--radius-md)" background="var(--color-brand)">
    <Text id="I54:268;54:211;54:190" name="Label" textStyle="Button" color="var(--color-on-brand)">Get started</Text>
  </Instance>
  <Frame id="I54:268;54:213" name="Features" display="flex" flex-direction="column" align-self="stretch" gap="var(--space-12)" overflow="hidden">
    <Frame id="I54:268;54:214" name="Feature" display="flex" align-items="center" gap="var(--space-8)" overflow="hidden">
      <Icon id="I54:268;54:215" name="Icon/Check" component="Icon/Check" src="assets/icon-check-4.svg" width="20px" height="20px"/>
      <Text id="I54:268;54:217" name="Text" textStyle="Body Small" color="var(--color-ink)">Unlimited projects</Text>
    </Frame>
    …
  </Frame>
</Instance>

Guide: tokens

How tokens are named, read, written and bound: styles, variables, modes, aliases, units, libraries. The agent reads this with guide topic tokens.

design_read writes a bound colour or length as var(--Name) and lists the values it used in tokens; tokens_read returns the whole set, and tokens_usage the layers that use one. tokens_apply writes tokens, and tokens_bind binds the raw values on layers to them (Writing tokens, below).

Names

  • A style: its name with every run of other characters than letters, digits, _ and - turned into "-": "Dark" → --Dark, "Brand/Primary 500" → --Brand-Primary-500. Letters of any script stay.
  • A variable: its Web code syntax when the designer set one (var(--surface) → --surface), else its name the same way ("space/4" → --space-4).
  • A text style is --<name>-font, holding its font shorthand: font: var(--h3-font). Its letter spacing and case, when they are not the default, are --<name>-letter-spacing and --<name>-text-transform; an effect style's blurs are --<name>-filter and --<name>-backdrop-filter beside its shadows.
  • Two styles of one kind with one name (two paint styles "Black") are different tokens: the file's first keeps --Black, the next are --Black-2, --Black-3 (tokens_read notes them with their values). Use the one the layer names. The file's own styles come first; library styles are numbered among those the page uses, so every tool means one style by a name on that page (a read from another page may number a library's Black differently). Text styles are numbered alike: the second "h1" is --h1-2-font and textStyle="h1-2".

tokens_read

  • It takes the file's own styles and variables, and with used those the current page (or within) uses, a team library's among them: a file built on a library has its tokens there.
  • format css (default): :root holds every collection's default mode and the styles; every mode of a collection with several is a block [data-<collection>="<mode>"] with that collection's variables, the default's too (an element in it takes the default back inside another mode's). Put the attribute where design_read writes it (data-brand="dark" on a section) or on the html element for the whole page: a token in :root that points at another collection's token is computed in :root and does not follow a mode set lower in the page.
  • format json: per collection, its modes and each variable's value in every mode, with its scopes (when not every field) and its code syntax.
  • format dtcg: Design Tokens Format (DTCG 2025.10) trees, one per mode of each collection, keyed <collection>.<mode> (the collection alone when it has one mode), and one of styles, each to save as its own .json file for Style Dictionary or other DTCG tools. Aliases are {path}; a token whose path is also a group sits at the group's $root; a token takes the type of the tokens it is aliased with (a number a gap points at is a dimension), and one whose alias target took another type is written resolved, with a note. Named in notes: an alias to a token no tree here holds (a library's, a collection left out), a name taken twice (the second suffixed -2), what DTCG has no type or field for (a text variable, a boolean, an image style, a gradient's angle, a text style's case).
  • collections keeps only the named ones; libraries: true adds the enabled libraries' variables by name and type.
  • Past maxChars (80 000) the summary comes back with the first whole tokens that fit, and the collections to read one at a time.
  • An alias to a token the output leaves out (a collection you did not ask for) is named in notes.

tokens_usage

tokens_usage {token} lists the layers on the current page (or inside within, or on every page with within: "file") that use a style or variable, named by its token as above (--White-2, --h1-font, --h1-letter-spacing), with where each uses it (fill, stroke, effect, text, a text run, or a bound field). Use it to tell same-named styles apart, or to see what a change to a token would touch.

Writing tokens

Both tools write, so Allow edits, dryRun and version are as guide write has them: run dryRun first (it works with Allow edits off). Each tool's own text holds every input.

  • tokens_apply takes tokens_read's json (format json) or its shape by hand: collections with their modes and variables, and styles (paint, text, effect). Send only the change. What the file holds, as tokens_read writes it, is left as it is, so tokens_read's own output sent back writes nothing; nothing is deleted; a library's collection or style is never copied into the file (change it in the library).
  • A variable's values are CSS per mode: a colour, px, a number, a quoted string, true or false, and var(--other) for an alias to a variable of the call or of the file. Its type comes from its first value (COLOR, FLOAT, STRING and BOOLEAN are written) and never changes: a new type is a new name, which has no ., {, } or $.
  • A number that is no length (a font weight, an opacity) needs its scopes (FONT_WEIGHT, OPACITY): a new variable is offered for every field, and Figma then reads its number as px, which a note says.
  • A new variable's token is its name as Names above writes it (space/4 → --space-4), or its codeSyntax.WEB.
  • A style's value is the CSS tokens_read lists for it: a paint style's colours, a text style's font shorthand, an effect style's shadows, with a text style's letter spacing and case, or an effect style's blurs, after it or in also. What a value leaves out, the style keeps.
  • A new collection's first mode renames Figma's default. More modes than the file's Figma plan allows (Starter: one a collection) are refused mode by mode, the others written; a dry run cannot always know the plan, and a note says so.
  • errors name each variable, mode or style that could not be written while the rest goes in; notes, what was written but will not read back as given.
  • tokens_bind works on within (a layer, a page or "file"; default: the selection), in each layer's mode and within the variables' scopes. Its dry run lists values in groups: bound (one token holds it exactly), ambiguous (several do: choose: [{value, token}] picks, field narrows a pick to background, border, gap…), unmatched (none does: make one with tokens_apply, then bind again). A choose for a near value snaps its layers to the token's value (snapped).
  • remap: [{from: "--blue-500", to: "--brand"}] merges duplicates: every use of one token moves to another of its kind, and raw values are left alone. Instances follow their main components; instances: "override" rebinds the uses inside instances as their overrides, for a copy that must differ from its components.

Values

  • Colours as hex (rgba when see-through); a colour with an opacity variable as color-mix(in srgb, … N%, transparent).
  • Numbers in px, except opacity and font weight, which have no unit.
  • Strings quoted; booleans as true or false (CSS has no booleans: a note says so).
  • An alias is var(--other). One that points nowhere is a comment and a note.
  • A gradient paint style is a token as linear-, radial- or conic-gradient().

Not tokens yet

Paint styles CSS cannot draw (an image, a diamond or a turned radial gradient, one without stops), effect styles with no shadow or blur CSS can write, and library variables the file does not use (Figma gives their values only once they are imported into the file: libraries: true lists them by name and type). The styles left out are named in notes; a var() design_read writes without a value is named in its hints.

Guide: assets

What becomes a file, in which format, how files are named, and what no file holds (a video). The agent reads this with guide topic assets.

Only true assets become files; everything else is CSS.

What is an asset

  • Icon (SVG): a vector, Figma Draw's transform group, or a group, frame or instance without auto layout drawn only with vector shapes, at least one of them a true vector (a logo, an arrow in a circle). Exported with everything it draws, strokes outside its box included, and sized by that box.
  • Image (PNG at 2x): a layer filled with an image, a mask group (its bottom layer is the mask), a layer with a pattern or shader fill or a noise, texture or glass effect. Exported as its own box: its corners, drop shadows and outline stay CSS around it, and the rest of its look (opacity, blur, inner shadows) is left to the file, as Figma renders it.
  • A layer the designer marked for export (PNG, JPG or SVG; a PDF export is not a web asset), in that format, when it holds no text (an export on a section with text is a preview, read as layers). A frame with an image fill and children keeps its children: the image is its background, written as the original image.
  • Plain rectangles, ellipses, buttons, cards, shadows are CSS, never images.

Video

A layer filled with a video is no file: the Plugin API exports none. design_read lists it in assets with kind: "video" and no src, its $css says the fill is a video, inspect gives the fill's type VIDEO, and assets_export reports it in errors with kind: "video" while it writes the rest. The build brings its own video file: ask the user for it, and use a render of the layer (screenshot) only as its poster.

Fades and textures baked into images

  • A fade baked into an image (a gradient fill on the photo's layer, or a gradient layer over a photo at a section's edge; design_read's hints name them) is flattened by an export and stretches with the box on wide screens. Export the raw image with assets_export and original: true, and build the gradient in CSS over it.
  • A frame filled with a tiled texture (a noise image repeated at a scale) renders coarser or finer at another scale: the hint gives the scale. Export one tile at that scale and repeat it in CSS, or replace it.

design_read vs assets_export

  • design_read with assetsDir writes the assets of the section it reads, and its XML points at the files.
  • assets_export writes files on their own: nodes (up to 50 layers, one file each, in the format and scale you give: PNG, JPG, WebP, SVG or PDF; width, the CSS width the build shows a layer at, sets the render to width × scale px) or from (every asset inside one layer). original: true writes the images as they were placed, full size and in their own format, instead of renders.
  • WebP keeps transparency exactly: its alpha is stored without loss at any quality. quality (1 to 100, 85 by default) is how lossy its colours are, so a transparent PNG becomes a WebP with the same see-through pixels.
  • design_read without assetsDir only plans names. When assets_export writes a file under another name (the name holds other bytes, the same bytes are another layer's file, an original is a JPEG), the file has planned: use its path in the src.

Files

Named after the layer (Hero photo → hero-photo.png, a component's variant added: brand-logo-dark.svg), or, in assets_export, as names gives a layer id ({"54:12": "hero-mountains"} → hero-mountains.png, slugged the same way). The same bytes are written once and shared; a name already taken by other bytes gets -2; a file already in the folder is never overwritten with other bytes.

Guide: script

An execute script over the reads: its limits, its utils, images and the answer types it reads by. The agent reads this with guide topic script.

execute with script runs JavaScript on the server, where every read tool is an async function on pw: one call can loop over layers, filter or join what several reads answer, and give back only what the task needs. The reads stay the first answer; a script is for an answer that needs several of them.

A script

  • The body of an async function, in JavaScript, not TypeScript: await works, return gives result; what console.log prints comes back as logs.
  • pw.<read>(args) is the read tool by its camelCase name, with the arguments it takes as a tool: pw.nodesFind, pw.inspect, pw.designRead, pw.tokensRead. Nothing a script calls writes.
  • types_read gives each read's whole answer type: read it before the script. Reading a key the type does not have throws pw.inspect: no field "nodes" here; fields: layers, ...; a key the type has but this answer lacks is undefined, so if (answer.more) works.
  • A number past its bound (limit over 500) runs at the bound and is listed in clamped; a key the tool does not take is refused with the keys it does.
  • A failed call throws an Error naming the function and what was wrong, e.g. pw.inspect: nodes: Invalid input: expected array; catch it to go on. A failed run still lists in calls the calls that succeeded.

Limits

  • 30 s a run by default, timeout up to 300 s; a call gets what is left of it.
  • 50 pw calls a run, 4 at once (the rest wait their turn).
  • 64 MB of memory; code that keeps the CPU busy 1 s without a pause (an endless loop) is stopped.
  • result is cut past 24,000 characters: a long list or text ends in a --- TRUNCATED --- marker, and resultChars gives the size before the cut. logs keeps the last 4,000 characters.
  • No Node, no network, no timers, no Plugin API: only pw, utils and console. Plugin code goes in code.

Images

A script cannot show an image: there is no pw.screenshot (nor pw.nodeShow or pw.selectionWait, which act on the user's view), because a client that shows only execute's structured answer drops the image blocks. Call screenshot itself for an image. pw.designRead with screenshot: true answers a handle, image: "image-1"; returned, execute sends the image after its answer, but a client may not show it.

Design XML in a script

pw.designRead answers { xml, json, tree }: the XML, its JSON block, and tree, the XML's elements as data (id, tag, attributes with the CSS and metadata such as name and textStyle, a Text's text, children), to filter layers without parsing the XML.

Utils

utils holds helpers built on pw, each of their pw calls counted in the run's limits like the script's own:

  • utils.layers(find?, { fields? }): pw.nodesFind(find), then pw.inspect of what it found, 100 ids a call, each layer's find entry with its inspect fields over it (only fields when given).
  • utils.walk(tree, visit) and utils.find(tree, test): depth first over pw.designRead's tree or utils.outlineTree(xml) of pw.outline's XML; each element comes with { path, depth, hidden }.
  • utils.map(items, fn, { limit? }): at most 4 at once, the answers in order. utils.chunk(items, size).
  • utils.color(value): a CSS colour as { r, g, b, a }, null when it is none; utils.color.same(one, other, tolerance?).

Every text of a frame with its font sizes, in a few calls rather than one per text:

const { layers } = await utils.layers({ type: "TEXT", within: "185:239" }, { fields: ["text"] });
return layers.map(({ id, text }) => ({ id, sizes: text.fontSizes }));

Every text of the frame that is shown, with its text style:

const { tree } = await pw.designRead({ node: "185:239" });
const texts = [];
utils.walk(tree, (element, { hidden }) => {
  if (element.tag === "Text" && !hidden) texts.push({ id: element.id, style: element.attributes.textStyle ?? null });
});
return texts;

Guide: write

design_apply, nodes_delete and version_save: changing, creating, copying and moving layers, pages, components, images, icons, notes and text with design_read's XML. The agent reads this with guide topic write.

design_apply writes the XML design_read returns back into Figma, in the same dialect (guide xml); guide layout says how it lays out a frame's children. nodes_delete deletes layers and version_save saves a named version. The plugin's Allow edits switch, which the user turns on in the plugin window, gates every write: while it is off, a write is refused. dryRun: true runs the same checks in the plugin without writing, with the switch on or off, and lists what the call would create and change, and every refusal. version: "<name>" saves a named version in the file's history first, when the user wants to be able to go back (not in a dry run, nor when nothing would change); when it cannot be saved, nothing is written.

Changing a layer

  • An element with id changes that layer, and only the attributes it gives: <Frame id="54:243" gap="48px"/> changes the gap and nothing else. Read the layer first, edit the XML, send back what you changed. What a layer already has is not written again, so a read sent back unchanged changes nothing.
  • An attribute left out stays as it is. To remove one, write the value that means none: background="none", border="none", box-shadow="none", width="auto" (hug), max-width="none", flex="none", left="auto", transform="none", display="block" (no auto layout), display="none" (hide). A hidden layer shows again with the display it is laid out with: flex, grid or block.
  • A text: <Text id="…">New words</Text> replaces the characters, and they keep the look of the text's longest run; a <Span> (HTML's <span> too) styles a run of them. A Text without content keeps its characters, so <Text id="…" color="var(--Dark)"/> only recolours it. CSS on the Text restyles the runs that had the text's own look, as CSS inherits; its Spans then set theirs. A text inside an instance changes by its I…;… id; when the instance binds its characters to a text property, the new characters go to that property.
  • What Figma keeps together is completed from the layer: a new column-gap keeps its direction and wrap, a new filter keeps its shadows, a new border-bottom or padding-top keeps the other sides, a new width keeps the edge the layer is pinned to. A new left or right replaces both edges.
  • Moving: an element with id under another parent element moves the layer there, before="id" / after="id" puts it next to that layer, and listing layers in another order reorders them. A top-level element moves only by before or after. A layer inside an instance comes from its component and stays where it is (an instance takes new layers only through its slots). An element alone (<Frame id="…"/>) moves its layer with everything inside it.
  • design_apply first reads every layer the call names, with everything inside it. Send only the layers you change, nested as design_read writes them (a deep one may also stand alone at the top level: <Text id="54:250">New words</Text>); a call that names more layers than one read can take fails with an error: split it.
  • A text design_read shortened ($truncated) keeps its characters: read that layer on its own to change them.
  • Each tag takes its own attributes: no background or gap on a Text (its colour is color), no text styles on a Frame, no auto layout on a shape; an element's id is given once (a copy has none).

Creating

  • An element without id creates a layer: Frame, Section, Text, TextPath (below), Rectangle, Ellipse, Line, Image, Icon, and Component, ComponentSet, Instance and Slot (below). It goes inside its parent element, after the element before it (alone: last); at the top level into parent or the current page beside its layers, next to a layer with before="id" / after="id", or onto a page (below). Groups and vectors come from an SVG, as an Icon.
  • A page: a top-level <Page name="Screens">…</Page> makes a new page, last in the file, and creates the layers inside it there in the XML's order, each placed by its left and top (without them, beside the ones before it); a layer named by its id inside it moves onto the new page. A dry run lists the page it would make. <Page id="…"> (an id from file_map) is a page the file has: name renames it, the layers inside it are written where they are, new ones go on it. A page takes only a name, stands only at the top level, and stays where it is in the file. Figma's Starter plan allows 3 pages: past that the error names the limit, and nothing inside that page is made.
  • A new layer has what its XML says and nothing more: no fill without background, no clipping without overflow; a new auto layout frame hugs unless sized; a new text is Inter Regular in black unless font and color say otherwise.
  • A copy: <Frame copyOf="54:268" name="Card 2"> clones that layer (everything the XML cannot show comes along) and then writes the element onto the copy. Inside it, elements with the source's ids write the copy's layers, and before/after with a source's id put a layer next to the copy's: copy a card's XML, drop the root's id, add copyOf, change the title, add a new layer in the same call.

Components and instances

  • <Instance component="Heading" variant="Property 1=Green" props="Label=Our work, Has icon=false"/> makes an instance by the names design_read and components_read write: the file's components, the ones its page uses from a library, or component="key:<key>" for a library one the file does not use yet (library_search finds those keys in the libraries saved with it). variant picks the variant (values left out are the set's default), props sets its properties by their names without Figma's #id: a text, true or false for a boolean, and for an instance swap the component to show, by the name a component takes (a set's name shows its default variant) or key:<key> (props="Icon=Heart").
  • Inside a new instance, elements with another instance's ids (of the same component and variant) or the component's own write the new instance's layers, as overrides; the other instance stays as it is. <Instance copyOf="id"> copies an instance with its overrides instead.
  • An existing instance: variant switches it, props changes its properties, component swaps it to another component. A comma or = inside a name or value is escaped with a backslash, as design_read writes it. A switch or a swap gives the instance's layers new ids, so a call that switches an instance (or a copy, or one nested in a new instance) refuses edits of its layers by their old ids: switch first, read it again, then edit.
  • <Component name="Badge">…</Component> makes a component like a frame; inside it, prop="Label" on a Text makes a text property bound to it, visibleProp="Shown" a boolean property bound to the layer's visibility, and swapProp="Icon" on an Instance an instance swap property whose default is that instance's component (instances then take props="Icon=Heart"). <ComponentSet name="Badge"> holds <Component variant="Tone=Dark"> variants: they are combined into one set (the properties defined once on it) and laid out in a grid; a set given display="flex" or "grid" lays them out itself, each variant placed by its own grid-row/grid-column, align-self or flex. description describes a component or a set; an instance of a new component can follow later in the same XML.
  • An existing component takes properties the same way, so it is extended where it is: prop, visibleProp and swapProp on its layers by their ids (<Instance id="54:12" swapProp="Icon"/>), or on new layers inside its <Component id="…">, bind each layer to the property of that name the component has (a variant's: its set's), or add the property once when it has none, its default the layer's value now (the text, whether it shows, the instance's component). A name a property of another kind holds is an error; a layer no component holds, or one inside an instance, is refused. properties in the answer lists what was added to components there before the call (a dry run's: what would be).
  • <Slot name="Content"> makes a slot directly inside a component; in an instance, give its <Slot id="…"> new layers.

Images, icons and notes

  • <Image src="photos/hero.jpg" width="600px" height="400px"/> makes an image from a file (PNG, JPG or GIF, up to 32 MB and 4096 px a side; convert WebP first), <Icon src="icons/arrow.svg" width="24px"/> an icon from an SVG (up to 2 MB); background="url(…)" fills any layer that takes a background with one, a new or an existing frame, rectangle or ellipse (an avatar). Paths are on the server's machine; a relative one starts in the project folder (the MCP client's root, else CLAUDE_PROJECT_DIR, else the server's working directory).
  • An existing Image with another file in src takes that image, keeping how it fits and is cropped. A file design_read or assets_export wrote for that layer (a render of it) changes nothing wherever it went, so a read sent back keeps the originals; a picture saved over it is a new image. An existing icon keeps its drawing: to draw another, delete the icon and create a new one from the file.
  • An Icon's width or height, new or existing, scales it whole as Figma's scale tool does: its lines and corners grow with it (a 24px icon with a 2px line at 48px has a 4px line). The drawing keeps its ratio: the width decides when both are given, else the height. The size is the one design_read writes (what the icon draws past its box included); a Frame with the same id only resizes, its lines staying as they are.
  • note="Behavior: opens the modal | Spacing: 8px [gap]" writes the layer's Dev Mode notes, the whole list, as design_read writes it (guide xml, Notes; note="" removes them, and a note left out of the list is removed). Behavior: files a note under the file's annotation category of that name; a name the file has no category for stays part of the text (no category is made). A closing bracket pins those properties in the note, in design_read's CSS words ([gap, padding], a text's [color], [] pins none); a bracket with any other word is text, and \[ keeps one as text. [background] alone is a note of pins without text. A pin needs the layer to have that property: a radius pin a layer with radius 0, an opacity pin one at 1, a limit pin (min-width, ...) one that is not set, background, border, gap and the like one without fills, strokes or auto layout are refused. A | with a space on each side separates the layer's own notes sent back and comes before a note a category starts or after one with pins; elsewhere it is text, so note="Tabs: Days | Weeks" is one note (two new notes without a category take two calls). A note sent back as it was keeps its category, Markdown formatting and pins; the same words under another category or with other pins keep their formatting. A new note's text is plain.

Text on a path

  • <TextPath id="…">New words</TextPath> changes the characters of a text on a path and keeps its look, as a Text's do; its spans and text CSS (font, letter-spacing, text-transform, color, textStyle) are written as on a Text. It has no line height, underline, wrapping or truncation. start="1 0.25" moves where its text begins: the path's segment (from 0) and the place along it (0 to 1). Its path stays as Figma made it: a changed d is refused, so delete the layer and make it again. The characters go in the TextPath itself, as its content.
  • A new one is made along d, an SVG path in its own box that left and top place (relative commands and arcs are taken, and written as Figma's lines and curves), or along arc="<cx> <cy> <r> <from> <to>", an arc of a circle in the parent: its centre and radius in px, its ends in degrees as CSS turns (0 at the top, clockwise). An arc places the layer itself, absolutely, so it takes no left or top. A to smaller than from runs back, counter-clockwise: below the centre, arc="200 200 160 225 135" runs left to right.
  • text-align is anchored at start: left begins there, center centres the text on it, right ends it there, and letters that would fall before the path's beginning are not drawn. So text-align="center" or "right" given without start also puts the start in the middle of the path (by length) or at its end, on a new one or an existing one; give start with it to anchor the text elsewhere.
<Frame id="12:30" name="Round menu">
  <TextPath id="12:41" start="0 0.25">Share</TextPath>
  <TextPath name="Label" arc="200 200 160 -40 40" font="500 14px 'Inter'" color="var(--color-ink)">Settings</TextPath>
</Frame>

Values

  • Lengths in px: a bare number in a size, a place, a gap, a padding or a radius is taken as px; a bare line height is a multiple of the font size, as in CSS. Sizes, edges and centring: guide layout.
  • font is the shorthand [italic] weight size/line-height 'Family'. The family is found in any case, the weight is the nearest one within 50, the plain style before the others; a family this Figma lacks is refused with the near ones ("Did you mean Inter?"), on a dry run too. A text whose font this Figma cannot load keeps its characters until it gets a font this Figma has.
  • font-variation-settings="'wdth' 90, 'GRAD' 50" sets a variable font's axes on a Text or a Span, over the font it has or the one font gives: the axes named, the weight and optical size the font has, and every other axis back to the font's own (normal or leaving it out returns them all). An axis the family lacks, a static family, and a value outside the range fonts_check lists are refused, on a dry run too.
  • Colours: hex, rgb(), hsl() or color(display-p3 …). In a Display P3 file, color(display-p3 …) (as design_read writes it) is written as it is, and hex, rgb() or hsl() are taken as sRGB and converted to P3.
  • var(--Name) binds the token of that name, as design_read and tokens_read write it: a colour variable or a paint style on background, color, a border or a shadow's colour, inset and in text-shadow too (box-shadow="0 4px 12px 0 var(--shadow)"); an effect style on box-shadow, filter or backdrop-filter (backdrop-filter="var(--Blur-Backdrop)"), which is then the layer's whole list of effects. textStyle="h3" applies a text style. A shadow's colour variable is its whole colour, its alpha too: write it alone, or a colour. A number variable binds a size, a min or max size, a gap, a padding side or a radius (gap="var(--space-md)"); a number over a bound one takes the variable off. A section is sized in px only.
  • design_apply binds the tokens the file and the libraries it uses have: tokens_read lists them. A var() that names none is refused with the near names; a token the design lacks is made with tokens_apply (dry run first) and written here as var(--name), or its raw value is bound afterwards with tokens_bind (guide tokens).
  • data-<collection>="<mode>" sets the layer's mode of that variable collection (by name or slug, as design_read writes it), and "" clears it.
  • Gradients: background takes linear-gradient(<angle>, <stops>) (or to right…), radial-gradient(<rx> <ry> at <x> <y>, <stops>) and conic-gradient(from <angle> at <x> <y>, <stops>), a stop a colour or a token (var(--brand) 0%) and its place in percent. A text's colour and borders take colours and tokens; a repeating gradient is refused.
  • filter="blur(8.6px)" and backdrop-filter="blur(…)" are written as Figma's radius v / 0.43, the rule design_read reads them by (guide xml).
  • mix-blend-mode sets how a layer blends (multiply, screen, overlay…; normal is Figma's pass through on a frame); mask="alpha" (or vector, luminance) makes a layer the mask of the layers above it in its parent, mask="none" makes it a layer again. href links a Text or a Span.
  • Refused with an error: overflow: scroll (scrolling is a prototype setting), links on frames, dashed underlines (grow weights: guide layout). Read but not written yet, listed in an element's notWritten: background-blend-mode, -webkit-text-stroke, paint-order.

Errors and undo

nodes_delete deletes up to 500 layers by id, each on its own: a layer inside an instance comes from its component and stays, with why (hide it with display="none"); what an instance's slot holds is its own and is deleted. It takes dryRun and version as design_apply does.

The XML is strict: an unclosed or wrongly closed tag, a duplicate attribute, a bare & or a < in a value refuses the whole call as INVALID_XML, with its line and column. HTML entities like &mdash; are read, CDATA is text as written, and names may hold $ ($css).

Each element is written on its own: an error names its line, column and attribute, and the rest of the XML still goes in; the layers inside a refused element are not made. The XML may hold several top-level elements; a bare <Root> wrapped around them is left out. created lists the new layers' ids and names by line, changed the layers written to (inside a copy or a new instance, by their ids there); a dry run lists the same as what it would do, its new layers without ids or names. One call is one undo step in Figma: the user's Cmd+Z takes the whole call back.

Effects CSS cannot write (noise, texture, glass, hidden effects) stay when a layer's box-shadow or filter changes, and a shadow sent back as it was keeps its colour variable and blend mode.

A change the XML cannot say (removing a variable, a prototype link, a plugin data field) is execute's plugin code, the last resort: it needs Allow edits too, has no dry run, and is one undo step.

Guide: layout

design_apply layouts: when to use flex, grid or absolute placement; grid tracks, spans and cells; pinned and centred layers. The agent reads this with guide topic layout.

design_apply lays out a frame's children as Figma does: auto layout as flex, grid auto layout as grid, or each child placed on its own (absolute), with the attributes design_read writes (guide xml). Pick the one that says what should happen when the content or the frame's size changes.

Which one

  • Flex (display="flex"): one direction. A row of buttons, a nav bar or toolbar, a list, a stack of sections, a card's content. Children follow each other; one can take the room left.
  • Grid (display="grid"): two directions, items lined up in rows and columns at once. Card grids, bento boxes, galleries, forms with a label column and a field column, pricing tables, footers with link columns.
  • Absolute (position="absolute" with left, right, top, bottom): a layer over the others or pinned to a corner or an edge. A badge, a close button, an overlay, a decorative shape, layered images in a hero. Content that should reflow flows instead: an absolute layer stays where it is pinned when the text or the cards around it grow.
  • Nest them: a grid of cards, each card a flex column with an absolute badge.

Flex

  • display="flex" is a row, flex-direction="column" a column (auto layout has no reverse order); flex-wrap="wrap" wraps either. gap spaces the children and the wrapped lines; row-gap and column-gap set one axis each, as in CSS.
  • padding takes 1 to 4 lengths. justify-content aligns along the direction (flex-start, center, flex-end, space-between, space-around, space-evenly; a spread leaves no room for gap), align-items across it (flex-start, center, flex-end, baseline). Figma aligns all children alike: a child's align-self takes only stretch or auto.
  • A child's size: width/height in px (or a number variable, var(--size-card)) is fixed; none (or auto) hugs its content; flex="1" takes the room left along the direction (Figma has no other weights); align-self="stretch" fills across it; min-width, max-width, min-height and max-height set limits (none removes one). A new frame with display hugs what it holds unless sized or filling.
  • flex needs a flex parent (a grid refuses it), align-self a flex or grid parent; justify-self, grid-row and grid-column work only in a grid: on any other parent each is refused.

Grid

  • display="grid" with grid-template-columns and grid-template-rows, each a list of tracks: 200px is fixed, 1fr takes a share of the room left (2fr twice as much), auto fits its content; repeat(3, 1fr) repeats one track.
  • Give both lists: a new grid has 2 columns and 2 rows, and an empty row still takes room. fr tracks share the grid's own size: give the grid a width (a height for fr rows) or let it fill its parent; on an axis where the grid hugs, Figma turns fr into auto.
  • gap="16px" spaces rows and columns alike, gap="12px 24px" rows then columns; row-gap and column-gap set one each (design_read writes these two). padding works as in flex. justify-content and align-items are refused on a grid: align each child in its cell.
  • Place a child with grid-column and grid-row, lines counted from 1 as in CSS: grid-column="3" is the third column, grid-column="1 / span 2" (or "1 / 3") two columns from the first, grid-row="2 / span 3" three rows from the second. Always give the start line.
  • A child without them takes the next free cell, row by row in the XML's order, and a cell holds one child: place every child of a grid, or none. A child with no free cell left goes into a new row at the end, sized like the last one (columns are never added). A cell past the tracks, a span past the last track or a taken cell is refused with Figma's error, and the child stays in the next free cell.
  • In its cell a child keeps its size and sits in the top left corner, or where justify-self (horizontally) and align-self (vertically) put it: start, center, end, or stretch to fill the cell's width or height instead of a size of its own. stretch fills a cell; flex="1" on a grid's child is refused.
  • Move or delete the children of a row or column before taking it out of the tracks: Figma keeps a track that holds a child.

Absolute

  • position="absolute" takes a layer out of its flex or grid parent's flow: the other children, the padding and the gap act as if it were not there. It is placed against its parent and moves with it, so nest it in the frame it belongs to (the card, not the grid around the cards). position="relative" puts it back in the flow.
  • Every child of a frame without auto layout (no display, or display="block"), of a section and of the page is placed so, by its edges (design_read writes position="absolute" there; nothing flows, so it may be left out). Without edges it lands in the top left corner. A layer that flows in auto layout takes left or top only with position="absolute": without it they are refused.
  • Edges in px: left/top pin it to the start; right/bottom to the end, where it stays when the parent is resized (right="12px" top="12px" is a top right badge; right="-8px" top="-8px" hangs it over the corner of a parent that does not clip); left and right stretch it with the parent (top and bottom likewise), between them without a width; a width given too wins over right, as in CSS, and it still stretches.
  • Centred: left="calc(50% - 24px)" puts the left edge 24 px left of the centre, which centres a layer 48 px wide (half its size; top likewise), and keeps it there when the parent is resized; left="50%" puts the edge on the centre. Scaled with the parent: left="5%" with width="25%" (top with height). Only left and top take calc() and percents; edges take lengths, so a token places nothing.
  • On the page itself a layer is placed by left and top alone (<Section id="…" top="800px"/> moves a section down); without them a new one goes beside the page's layers.

What is taken

  • Grid tracks: px, fr, auto, and repeat() of one track.
  • Flex: a row or a column, flex-wrap, flex="1" and the alignments above.
  • Absolute: edges in px, and left and top in percents or calc(50% ± Npx) too.

Anything else is refused with its reason.

Examples

A bento grid: three equal columns, two rows of 160 px, a card across two columns, one placed on the second row across the last two, and a dot centred in the cell left free.

<Frame name="Bento" display="grid" width="920px" grid-template-columns="repeat(3, 1fr)" grid-template-rows="160px 160px" gap="16px">
  <Frame name="Wide" grid-row="1" grid-column="1 / span 2" justify-self="stretch" align-self="stretch" border-radius="16px" background="#FFFFFF"/>
  <Frame name="Side" grid-row="1" grid-column="3" justify-self="stretch" align-self="stretch" border-radius="16px" background="#E4E4E7"/>
  <Frame name="Row two" grid-row="2" grid-column="2 / span 2" justify-self="stretch" align-self="stretch" border-radius="16px" background="#18181B"/>
  <Frame name="Dot" grid-row="2" grid-column="1" justify-self="center" align-self="center" width="64px" height="64px" border-radius="32px" background="#A1A1AA"/>
</Frame>

A form: a fixed label column and a field column that takes the rest.

<Frame name="Form" display="grid" width="480px" grid-template-columns="120px 1fr" grid-template-rows="auto auto" gap="12px 16px" padding="24px" border-radius="16px" background="#FFFFFF">
  <Text grid-row="1" grid-column="1" justify-self="end" align-self="center" font="500 14px/20px 'Inter'" color="#18181B">Email</Text>
  <Frame name="Email field" grid-row="1" grid-column="2" justify-self="stretch" height="40px" border="1px solid #D4D4D8" border-radius="8px" background="#FFFFFF"/>
  <Text grid-row="2" grid-column="1" justify-self="end" align-self="center" font="500 14px/20px 'Inter'" color="#18181B">Password</Text>
  <Frame name="Password field" grid-row="2" grid-column="2" justify-self="stretch" height="40px" border="1px solid #D4D4D8" border-radius="8px" background="#FFFFFF"/>
</Frame>

A card: a flex column with a row whose field takes the room left, and a badge pinned to the top right corner.

<Frame name="Plan" display="flex" flex-direction="column" width="320px" padding="24px" gap="12px" border-radius="16px" background="#FFFFFF">
  <Text font="600 18px/24px 'Inter'" color="#18181B">Pro plan</Text>
  <Frame name="Actions" display="flex" align-self="stretch" align-items="center" gap="12px">
    <Frame name="Field" flex="1" height="36px" border-radius="8px" background="#F4F4F5"/>
    <Text font="500 14px/20px 'Inter'" color="#18181B">Buy</Text>
  </Frame>
  <Frame name="Badge" position="absolute" right="12px" top="12px" display="flex" padding="4px 10px" border-radius="999px" background="#E11D48">
    <Text font="600 12px/16px 'Inter'" color="#FFFFFF">New</Text>
  </Frame>
</Frame>