Figma + Claude Code Integration Guide
███████╗██╗ ██████╗ ███╗ ███╗ █████╗
██╔════╝██║██╔════╝ ████╗ ████║██╔══██╗
█████╗ ██║██║ ███╗██╔████╔██║███████║
██╔══╝ ██║██║ ██║██║╚██╔╝██║██╔══██║
██║ ██║╚██████╔╝██║ ╚═╝ ██║██║ ██║
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝Figma + Claude Code Integration Guide
Focus: Design-to-code workflows, component inspection, and Figma canvas automation from Claude Code using the official Figma MCP server.
Overview
Figma is the standard design tool for UI/UX. Its official MCP server gives Claude Code direct access to design files — reading component specs, extracting tokens, generating code from components, writing content back to the canvas, and running Code Connect mappings. This enables a true design-to-code pipeline: Claude reads Figma, writes the component, and links it back.
Here is the big picture — the MCP bridges design and code both ways, and you get to use both directions:
Official Documentation
| Resource | URL |
|---|---|
| Figma Developers | https://developers.figma.com |
| Figma MCP Server | https://developers.figma.com/docs/figma-mcp-server/ |
Write to Canvas (use_figma) | https://developers.figma.com/docs/figma-mcp-server/write-to-canvas/ |
Code to Canvas (generate_figma_design) | https://developers.figma.com/docs/figma-mcp-server/code-to-canvas/ |
| MCP Help Guide | https://help.figma.com/hc/en-us/articles/32132100833559-Guide-to-the-Figma-MCP-server |
| Figma REST API | https://www.figma.com/developers/api |
| Code Connect | https://www.figma.com/developers/code-connect |
MCP Server Setup
Official Figma MCP Server (Remote, Recommended)
Figma recommends the hosted remote MCP server — it requires no desktop app and provides the broadest feature set.
# Add remote Figma MCP server to Claude Code
claude mcp add --transport http figma \
https://mcp.figma.com/v1/mcp \
-H "X-Figma-Token: ${FIGMA_ACCESS_TOKEN}".mcp.json Configuration (Remote)
{
"mcpServers": {
"figma": {
"type": "http",
"url": "https://mcp.figma.com/v1/mcp",
"headers": {
"X-Figma-Token": "${FIGMA_ACCESS_TOKEN}"
}
}
}
}npm-based Local Server (figma-developer-mcp)
claude mcp add figma -- npx -y figma-developer-mcp \
--figma-api-key=${FIGMA_ACCESS_TOKEN} \
--stdio.mcp.json (npm local):
{
"mcpServers": {
"figma": {
"command": "npx",
"args": [
"-y",
"figma-developer-mcp",
"--figma-api-key=${FIGMA_ACCESS_TOKEN}",
"--stdio"
]
}
}
}Get your access token at: https://www.figma.com/settings → Personal access tokens
Available MCP Tools
| Tool | Description |
|---|---|
get_design_context | Get full design specs, code hints, and screenshot for a node |
get_screenshot | Capture a screenshot of a Figma node |
get_metadata | Get file metadata (name, pages, last modified) |
get_figjam | Get FigJam board content |
get_design_pages | List all pages in a Figma file |
get_libraries | Get shared component libraries |
search_design_system | Search for components by name |
get_variable_defs | Get design tokens (colors, spacing, typography) |
get_code_connect_map | Map Figma components to codebase components |
add_code_connect_map | Link a Figma component to a code component |
generate_diagram | Create a diagram in FigJam |
get_screenshot | Export a node as an image |
Figma REST API Integration
npm install axios # or use fetchExtract Component Info
const FIGMA_TOKEN = process.env.FIGMA_ACCESS_TOKEN!;
const FILE_KEY = "your-file-key"; // from figma.com/design/{fileKey}/...
// Get file structure
const file = await fetch(`https://api.figma.com/v1/files/${FILE_KEY}`, {
headers: { "X-Figma-Token": FIGMA_TOKEN },
}).then((r) => r.json());
// Get specific node
const nodeId = "1:23"; // from URL param node-id=1-23
const nodes = await fetch(
`https://api.figma.com/v1/files/${FILE_KEY}/nodes?ids=${nodeId}`,
{ headers: { "X-Figma-Token": FIGMA_TOKEN } }
).then((r) => r.json());
// Export node as PNG
const images = await fetch(
`https://api.figma.com/v1/images/${FILE_KEY}?ids=${nodeId}&format=png&scale=2`,
{ headers: { "X-Figma-Token": FIGMA_TOKEN } }
).then((r) => r.json());
console.log(images.images[nodeId]); // URL to the exported PNGEnvironment Variables
# Required
FIGMA_ACCESS_TOKEN=figd_... # Personal access token from Figma settings
# Optional for automation scripts
FIGMA_FILE_KEY=... # Default file key for automation
FIGMA_TEAM_ID=... # Team ID for shared library accessAutomation Workflows
Design-to-Code Workflow
The core Claude Code + Figma workflow follows four clean steps — here is how the calls flow:
- Share a Figma URL or node ID
- Claude calls
get_design_context→ gets specs, colors, spacing, component screenshot - Claude generates a React/Vue component matching the design
- Claude calls
add_code_connect_map→ links the Figma component to the generated component
Example prompt inside Claude Code:
"Implement the
Button/Primarycomponent from figma.com/design/AbCdEf/Design-System?node-id=1:23"
Slash Command: Figma to Component
.claude/commands/figma.md:
Implement the Figma design at URL or node: $ARGUMENTS
1. Use the Figma MCP tool `get_design_context` with the file key and node ID extracted from $ARGUMENTS
2. Use `get_screenshot` to see the visual
3. Generate a TypeScript React component that matches the design exactly:
- Use Tailwind CSS for styling
- Extract all colors as CSS variables or Tailwind tokens
- Make it responsive
- Add proper TypeScript props interface
4. Write the component to the appropriate file in `src/components/`
5. Create a Storybook story for it
6. Report the component code and any design tokens usedUsage: /project:figma figma.com/design/AbCdEf/Design-System?node-id=1-23
Code → design (write to canvas)
The MCP is not read-only. Claude Code can write native Figma structure back into a file — real frames, components, variants, variables, and auto layout — not just flat screenshots. This is the inverse of the design-to-code flow above and is what keeps the motionstack design system in sync when code moves ahead of the canvas.
Three official write tools cover this direction:
| Tool | Direction | What it produces |
|---|---|---|
create_new_file | scaffold | A fresh, blank Figma / FigJam / Slides file to write into |
use_figma | code/intent → canvas | Native Figma objects via the Plugin API — components, variables, frames, auto layout, with awareness of the existing design system |
generate_figma_design | running app → canvas | "Code to canvas" — captures live rendered UI from the browser as standard, flat Figma layers for human review |
MANDATORY skill note: You MUST load the
/figma-useskill before everyuse_figmacall, and the/figma-create-new-fileskill before everycreate_new_filecall. Calling these tools without first loading the matching skill causes common, hard-to-debug failures. For pushing a whole page or layout, also load/figma-generate-design.
Workflow: generate a component into Figma from a description or code
- (If no target file) load
/figma-create-new-file, then callcreate_new_fileto scaffold a blank file - Load
/figma-use— this is required before the next step - Discover what already exists:
search_design_systemplusget_variable_defsso the new work reuses real tokens and components instead of hardcoded values - Call
use_figma, which executes Plugin API JavaScript inside the file to assemble the component section-by-section, binding design-system variables - For a full app screen instead of one component, capture the running UI with
generate_figma_design("code to canvas") for the team to review before implementation
Example prompt inside Claude Code:
"Create a
Button/Primarycomponent in our design-system file fromsrc/components/Button.tsx, reusing our existing color and spacing variables."
Gotcha: use_figma is beta and intentionally limited — there is a ~20 KB response cap per call, no image / asset import, no custom fonts, and a Full seat with edit access is required (Dev seats are read-only). Make large changes incrementally across several calls rather than one giant payload, and expect to manually review and clean up the result.
Code Connect: Link Figma to Codebase
Code Connect creates a permanent mapping between Figma components and real code:
// Button.figma.tsx — Code Connect definition
import figma from "@figma/code-connect";
import { Button } from "./Button";
figma.connect(Button, "https://www.figma.com/design/[FILE_KEY]?node-id=[NODE_ID]", {
props: {
variant: figma.enum("Variant", {
Primary: "primary",
Secondary: "secondary",
Destructive: "destructive",
}),
disabled: figma.boolean("Disabled"),
label: figma.string("Label"),
},
example: ({ variant, disabled, label }) => (
<Button variant={variant} disabled={disabled}>{label}</Button>
),
});# Publish Code Connect mappings to Figma
npx figma connect publishGitHub Actions: Auto-generate Types from Design Tokens
# .github/workflows/design-tokens.yml
name: Sync Figma Tokens
on:
schedule:
- cron: "0 9 * * 1" # Every Monday morning
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '22' }
- name: Fetch design tokens
env:
FIGMA_ACCESS_TOKEN: ${{ secrets.FIGMA_ACCESS_TOKEN }}
FIGMA_FILE_KEY: ${{ secrets.FIGMA_FILE_KEY }}
run: node scripts/sync-tokens.js
- name: Commit updated tokens
run: |
git config user.name "Design Sync Bot"
git config user.email "noreply@figma.com"
git add src/tokens/
git diff --staged --quiet || git commit -m "chore: sync Figma design tokens"
git pushCommon Use Cases
| Use Case | Approach |
|---|---|
| Design to React component | MCP get_design_context → generate code |
| Component library sync | get_libraries + search_design_system |
| Design token extraction | MCP get_variable_defs → CSS/TypeScript |
| Visual regression check | get_screenshot → compare to rendered component |
| Code Connect linking | add_code_connect_map + figma connect publish |
| FigJam diagrams | MCP generate_diagram |
Troubleshooting
| Issue | Fix |
|---|---|
| 403 Forbidden | Token lacks access to that file — check sharing settings |
| Node not found | Extract node-id from URL; convert - to : (e.g., 1-23 → 1:23) |
| Design context empty | Component may be in a library — use get_libraries first |
| Screenshot fails | Node must be visible (not hidden) in the file |
| Code Connect not publishing | Run npx figma connect publish from project root |