Skip to content
Development
Skill

/figma-code-connect

Creates and maintains Figma Code Connect template files that map Figma components to code snippets. Use when the user mentions Code Connect, Figma component mapping, design-to-code translation, or asks to create/update .figma.ts or .figma.js files.

From plugin
figma
2.2k16 skills1 MCP

Claude Code

$ npx -y skills add figma/mcp-server-guide --skill figma-code-connect --agent claude-code

SKILL.md

figma-code-connect.SKILL.md
name: figma-code-connect
description: Creates and maintains Figma Code Connect template files that map Figma components to code snippets. Use when the user mentions Code Connect, Figma component mapping, design-to-code translation, or asks to create/update .figma.ts or .figma.js files.
disable-model-invocation: false

Code Connect

Overview

Create Code Connect template files (`.figma.ts`) that map Figma components to code snippets. Given a Figma URL, follow the steps below to create a template.

> **You write `.figma.ts` template files ONLY — never `.figma.tsx`.** This skill produces *parserless templates*: a `.figma.ts` file whose default export uses a `` figma.code`...` `` tagged template. Do **NOT** write a `.figma.tsx` file and do **NOT** use `figma.connect()` — that is the separate **parser-based** Code Connect format (published a different way) and is the **wrong artifact** for this skill; output written as `.figma.tsx` is rejected outright. If a `.figma.tsx` already exists for a component, leave it untouched and add your `.figma.ts` template alongside it. A capable model may be tempted to reach for the more familiar `.figma.tsx` / `figma.connect()` pattern from memory — resist it; here the correct output is **always** `.figma.ts` + `figma.code`.

Prerequisites

  • **Figma MCP server must be connected** — verify that Figma MCP tools (e.g., `get_code_connect_suggestions`) are available before proceeding. If not, guide the user to enable the Figma MCP server and restart their MCP client.
  • **Components must be published** — Code Connect only works with components published to a Figma team library. If a component is not published, inform the user and stop.
  • **Organization or Enterprise plan required** — Code Connect is not available on Free or Professional plans.
  • **URL must include `node-id`** — the Figma URL must contain the `node-id` query parameter.
  • **TypeScript types** — for editor autocomplete and type checking in `.figma.ts` files `@figma/code-connect/figma-types` must be added to `types` in `tsconfig.json`:
  {
    "compilerOptions": {
      "types": ["@figma/code-connect/figma-types"]
    }
  }

Step 1: Parse the Figma URL

Extract `fileKey` and `nodeId` from the URL:

| URL Format | fileKey | nodeId | |---|---|---| | `figma.com/design/:fileKey/:name?node-id=X-Y` | `:fileKey` | `X-Y` → `X:Y` | | `figma.com/file/:fileKey/:name?node-id=X-Y` | `:fileKey` | `X-Y` → `X:Y` | | `figma.com/design/:fileKey/branch/:branchKey/:name` | use `:branchKey` | from `node-id` param |

Always convert `nodeId` hyphens to colons: `1234-5678` → `1234:5678`.

**Worked example:**

Given: `https://www.figma.com/design/QiEF6w564ggoW8ftcLvdcu/MyDesignSystem?node-id=4185-3778`

  • `fileKey` = `QiEF6w564ggoW8ftcLvdcu`
  • `nodeId` = `4185-3778` → `4185:3778`

Step 2: Discover Unmapped Components

The user may provide a URL pointing to a frame, instance, or variant — not necessarily a component set or standalone component. Call the MCP tool `get_code_connect_suggestions` with:

  • `fileKey` — from Step 1
  • `nodeId` — from Step 1 (colons format)
  • `excludeMappingPrompt` — `true` (returns a lightweight list of unmapped components)

This tool identifies published components in the selection that don't yet have Code Connect mappings.

**Handle the response:**

  • **"No published components found in this selection"** — the node contains no published components. Inform the user they need to publish the component to a team library in Figma first, then stop.
  • **"All component instances in this selection are already connected to code via Code Connect"** — everything is already mapped. Inform the user and stop.
  • **Normal response with component list** — extract the `mainComponentNodeId` for each returned component. Use these resolved node IDs (not the original from the URL) for all subsequent steps. If multiple components are returned (e.g. the user selected a frame containing several different component instances), repeat Steps 3–6 for each one.

Step 3: Fetch Component Properties

Call the MCP tool `get_context_for_code_connect` with:

  • `fileKey` — from Step 1
  • `nodeId` — the resolved `mainComponentNodeId` from Step 2
  • `clientFrameworks` — determine from `figma.config.json` `parser` field (e.g. `"react"` → `["react"]`)
  • `clientLanguages` — infer from project file extensions (e.g. TypeScript project → `["typescript"]`, JavaScript → `["javascript"]`)

For multiple components, call the tool once per node ID.

The response contains the Figma component's **property definitions** — note each property's name and type:

  • **TEXT** — text content (labels, titles, placeholders)
  • **BOOLEAN** — toggles (show/hide icon, disabled state)
  • **VARIANT** — enum options (size, variant, state)
  • **INSTANCE_SWAP** — swappable nested instances tied to a specific component (icon, avatar)
  • **SLOT** — flexible content regions (freeform layout, mixed children); use `getSlot()` in templates (not the same as INSTANCE_SWAP)

Save this property list — you will use it in Step 5 to write the template.

Step 4: Identify the Code Component

If the user did not specify which code component to connect:

1. Check `figma.config.json` for `paths` and `importPaths` to find where components live 2. Search the codebase for a component matching the Figma component name. Check common directories (`src/components/`, `components/`, `lib/ui/`, `app/components/`) if `figma.config.json` doesn't specify paths 3. Read candidate files and compare their props interface against the Figma properties from Step 3 — look for matching variant types, size options, boolean flags, and slot props 4. If multiple candidates match, pick the one with the closest prop-interface match and explain your reasoning to the user 5. If no match is found, show the 2 closest candidates and ask the user to confirm or provide the correct path

**Confirm with the user** before proceeding to Step 5. Present the match: which code component you found

Read more
@figma
Ships withfigma

The Figma MCP server brings Figma directly into your workflow by providing important design information and context to AI agents generating code from Figma design files. For the complete set of Figma MCP server docs, see our developer documentation.

2.2k16 skills1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
2.2k
Star history of figma/mcp-server-guide on GitHub, a chart by star-history.com

Other skills on figma.

figma-code-workflows

figma-code-workflows

Import or upload local HTML or project files into Figma, choose editable Design frames, runnable Code Layers or standalone Code…

@figma@figmaInstall Skill
figma-create-new-file

figma-create-new-file

Always use this skill when the user wants to create a new Figma Design, FigJam, or Slides file. You MUST invoke this skill BEFORE…

@figma@figmaInstall Skill
figma-design-to-code

figma-design-to-code

**MANDATORY prerequisite** — you MUST invoke this skill BEFORE calling the `get_design_context` Figma MCP tool. You MUST trigger…

@figma@figmaInstall Skill
figma-generate-design

figma-generate-design

Use this skill alongside figma-use when the task involves translating an application page, view, or multi-section layout into…

@figma@figmaInstall Skill
figma-generate-diagram

figma-generate-diagram

MANDATORY prerequisite — load this skill BEFORE every `generate_diagram` tool call. NEVER call `generate_diagram` directly…

@figma@figmaInstall Skill
figma-generate-library

figma-generate-library

Build or update a professional-grade design system in Figma from a codebase. Use when the user wants to create variables/tokens,…

@figma@figmaInstall Skill

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills11d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc12d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react1d252k
@facebook@facebookInstall Skill

Questions about figma-code-connect.

Which coding agents can use figma-code-connect?
figma-code-connect installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.