# Figma Agent Context

- [Case study](https://tesselpunt.com/projects/figma-context)

A Figma plugin that gives coding agents structured design context and visual references.

Shorten the distance between design and code.

Role: Tool design & TypeScript development

Period: 2026

Technologies: Figma Plugin API, TypeScript, React, SCSS

I built Figma Agent Context to make design handoffs more explicit for coding agents. A screenshot shows the intended appearance, but leaves measurements, asset boundaries and layout relationships open to interpretation. The plugin exports those details as versioned JSON, alongside downloadable artwork and a reference render.

I used the output with AI coding agents to implement nearly all of Pebbler Telegram’s HolyWheel screen, its bundle offer dialogs, and most of its career page. The tool grew out of that implementation work: making the decisions behind a design easier to carry into React and SCSS.

## The tool in use

The TypeScript plugin reads the selected Figma subtree, extracts its geometry and styles, then builds a semantic record for React, TSX and co-located SCSS. It resolves actual variable bindings and referenced styles, and keeps implementation warnings alongside the output. The default contract is the bridge.figma-react-scss-context schema, version 3: implementation context for an agent to interpret.

For this HolyWheel frame, I marked artwork with [asset] layer names so it could be downloaded separately. The resulting export contains 48 context nodes, with 33 assets ready for download and 14 asset subtrees omitted. The panel shows 193 KB and roughly 49,000 estimated tokens. Hidden layers and asset/vector internals are still enabled here, but explicitly marked asset descendants remain excluded from the JSON.

Extraction runs locally in Figma; the plugin’s manifest blocks network access, and I choose when to copy the context into an agent conversation. The default handoff also omits unmarked asset/vector internals and hidden layers to keep the record focused on implementation.

### Figma Agent Context in use

The optimised HolyWheel frame: 48 context nodes, 33 assets ready for separate download and 14 asset subtrees omitted from the JSON.

Image description: HolyWheel frame selected in Figma beside the Figma Context for Agents panel, showing 33 ready assets, 48 nodes, 14 omitted asset subtrees and a 193 KB context export

Artwork in this HolyWheel frame is explicitly marked with [asset] layer names. The context is 193 KB, with approximately 49,000 estimated tokens. Hidden layers and asset/vector internals are still enabled; marked asset descendants remain omitted.

- [Image](https://tesselpunt.com/media/figma-agent-context-large.webp)

- [Screenshot page](https://tesselpunt.com/projects/figma-context/gallery/figma-agent-context)

## Turning geometry into implementation context

Figma’s layer hierarchy does not always map directly to the DOM. A group may exist only to organise artwork, while React needs a different component structure. Each measurable node therefore retains both parent-local coordinates in box.local and flattened coordinates in box.selection, relative to the selected frame. If a parent group disappears during implementation, the agent can use selection-space positions without mixing measurements from different coordinate systems.

Authored scale is explicit too. With a confirmed @4x design, 80 Figma units become 20 CSS pixels. The exporter preserves the unrounded source values and adds derived cssBaseline measurements for geometry, spacing, typography, strokes and effects. An unknown scale remains a question to resolve rather than silently assuming one Figma unit equals one CSS pixel.

Authored Auto Layout is kept distinct from inferred layoutHints. Conservative geometry checks can suggest flex alignment, padding or gap when text sits inside a visual container; overlapping artwork can remain positioned separately. These hints carry confidence and provenance. They guide implementation, while responsive behaviour beyond the reference viewport still requires judgment.

### Source geometry and its CSS baseline

Illustrative node excerpt with a user-confirmed @4x authored scale. Every source length is divided by four for the CSS baseline; other node fields are omitted here.

```json
{
  "box": {
    "local": {
      "x": 80,
      "y": 40,
      "width": 320,
      "height": 160,
      "relativeTo": "PARENT_AXIS_ALIGNED_BOUNDS"
    }
  },
  "cssBaseline": {
    "unit": "CSS_PX_AT_TARGET_VIEWPORT",
    "derived": true,
    "box": {
      "local": {
        "x": 20,
        "y": 10,
        "width": 80,
        "height": 40
      }
    }
  }
}
```

## Keeping artwork separate—and checking the result

Explicit layer names such as [asset] coin.svg and [asset] portrait@2x.png define downloadable asset boundaries. The semantic tree keeps the asset’s geometry and filename, while its vector descendants stay out of the context. Repeated filenames produce one logical export with multiple usages; the PNG scale suffix controls export density without changing the display size.

Ready assets are authoritative: the context tells the agent to import the exact downloaded file and report a missing asset instead of approximating it. This keeps detailed game artwork out of generated CSS and makes the handoff easier to inspect.

The Assets panel makes that boundary visible. In this frame, Download ready collects 33 marked assets, while individual files such as wheel-middle.svg can be previewed and downloaded separately. The artwork is never embedded in the agent-context JSON; the agent receives the files alongside their geometry and filename references.

A separate reference PNG closes the loop. I give the agent structured context, the exported assets and a visual target, then compare the rendered implementation at the intended CSS viewport. Compilation and linting cannot establish visual fidelity. The plugin supplies the reference image; it does not perform an automatic pixel diff or infer every responsive state.

### Separate asset exports

The Assets panel offers 33 ready files for download and a separate reference render. Marked artwork stays out of the agent-context JSON.

Image description: Figma Context for Agents Assets panel showing 33 ready assets, Download reference and Download ready controls, and a wheel-middle.svg asset preview

Asset export controls for the optimised HolyWheel frame. Explicit [asset] layer names define the downloadable files; the JSON retains their geometry and filename references.

- [Image](https://tesselpunt.com/media/figma-agent-assets-large.webp)

- [Screenshot page](https://tesselpunt.com/projects/figma-context/gallery/figma-agent-assets)

## Used in production work

HolyWheel and the bundle dialogs provide concrete examples of the design-to-code workflow in the Pebbler application.

### Holy Wheel

A playful reward wheel with animated feedback, multipliers, and a reward collection flow.

Image description: Pebbler Holy Wheel screen with a colourful prize wheel and a large Spin button

- [Image](https://tesselpunt.com/media/holy-wheel-large.webp)

- [Screenshot page](https://tesselpunt.com/projects/figma-context/gallery/holy-wheel)

### A clear offer in a busy world

The VIP bundle dialog brings pricing, rewards, availability, and purchase feedback together.

Image description: VIP bundle dialog showing included coins, energy, clothing and spins, with a purchase button

- [Image](https://tesselpunt.com/media/bundle-offer-large.webp)

- [Screenshot page](https://tesselpunt.com/projects/figma-context/gallery/bundle-offer)

### A career, one quest at a time

The Pirate Cook scene: character animation, an animated ship galley, and three skill tracks.

Image description: Pebbler career scene showing a gnome in a pirate cook outfit in a ship galley above three progression cards

- [Image](https://tesselpunt.com/media/career-large.webp)

- [Screenshot page](https://tesselpunt.com/projects/figma-context/gallery/career)

## Screenshots

### Figma Agent Context in use

The optimised HolyWheel frame: 48 context nodes, 33 assets ready for separate download and 14 asset subtrees omitted from the JSON.

Image description: HolyWheel frame selected in Figma beside the Figma Context for Agents panel, showing 33 ready assets, 48 nodes, 14 omitted asset subtrees and a 193 KB context export

Artwork in this HolyWheel frame is explicitly marked with [asset] layer names. The context is 193 KB, with approximately 49,000 estimated tokens. Hidden layers and asset/vector internals are still enabled; marked asset descendants remain omitted.

- [Image](https://tesselpunt.com/media/figma-agent-context-large.webp)

- [Screenshot page](https://tesselpunt.com/projects/figma-context/gallery/figma-agent-context)

### Separate asset exports

The Assets panel offers 33 ready files for download and a separate reference render. Marked artwork stays out of the agent-context JSON.

Image description: Figma Context for Agents Assets panel showing 33 ready assets, Download reference and Download ready controls, and a wheel-middle.svg asset preview

Asset export controls for the optimised HolyWheel frame. Explicit [asset] layer names define the downloadable files; the JSON retains their geometry and filename references.

- [Image](https://tesselpunt.com/media/figma-agent-assets-large.webp)

- [Screenshot page](https://tesselpunt.com/projects/figma-context/gallery/figma-agent-assets)

### Holy Wheel

A playful reward wheel with animated feedback, multipliers, and a reward collection flow.

Image description: Pebbler Holy Wheel screen with a colourful prize wheel and a large Spin button

- [Image](https://tesselpunt.com/media/holy-wheel-large.webp)

- [Screenshot page](https://tesselpunt.com/projects/figma-context/gallery/holy-wheel)

### A clear offer in a busy world

The VIP bundle dialog brings pricing, rewards, availability, and purchase feedback together.

Image description: VIP bundle dialog showing included coins, energy, clothing and spins, with a purchase button

- [Image](https://tesselpunt.com/media/bundle-offer-large.webp)

- [Screenshot page](https://tesselpunt.com/projects/figma-context/gallery/bundle-offer)

### A career, one quest at a time

The Pirate Cook scene: character animation, an animated ship galley, and three skill tracks.

Image description: Pebbler career scene showing a gnome in a pirate cook outfit in a ship galley above three progression cards

- [Image](https://tesselpunt.com/media/career-large.webp)

- [Screenshot page](https://tesselpunt.com/projects/figma-context/gallery/career)
