Figma to code

From TerminalSkills/skills · View interactive version

Figma to code is an AI agent skill from the GitHub repository TerminalSkills/skills. Converts Figma designs into production-ready frontend code. Use when someone shares a Figma URL, design screenshot, or exported design tokens and needs React/Vue/HTML components, responsive layouts, or design system code. Trigger words: Figma, design to code, mockup, wireframe, UI implementation, pi

How to use this skill

Skill file

Figma to Code

Overview

This skill converts Figma designs into production-ready frontend components. It extracts layout structure, spacing, typography, colors, and interactive states from designs and generates clean, responsive code using the team's existing tech stack and design system.

Instructions

Getting Design Information

There are three ways to receive design input:

  1. Figma URL — A link such as https://www.figma.com/design/Kp7dRw2xLm9QeTz4uVn8Ys/Billing-Dashboard?node-id=1289-4127 carries the file key (Kp7dRw2xLm9QeTz4uVn8Ys) and the node id (1289-4127, written 1289:4127 in the API). Read it one of two ways:

Figma MCP server (preferred; only clients in Figma's MCP catalog, such as Claude Code, Codex, Cursor and VS Code, can connect). Add the server once, authorize it in the browser (in Claude Code: run /mcp, select figma, then Authenticate), then pass the link to its tools:

```bash

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

codex mcp add figma --url https://mcp.figma.com/mcp # Codex CLI

```

Figma REST API. Use a personal access token (Figma Settings → Security) with the file_content:read scope, kept in FIGMA_TOKEN:

```bash

curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \

"https://api.figma.com/v1/files/Kp7dRw2xLm9QeTz4uVn8Ys/nodes?ids=1289:4127" \

| jq '.nodes["1289:4127"].document'

# Export icons and illustrations as SVG (returns temporary download URLs)

curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \

"https://api.figma.com/v1/images/Kp7dRw2xLm9QeTz4uVn8Ys?ids=1301:88,1301:92&format=svg"

```

Parse the node JSON for layout (layoutMode, itemSpacing, paddingLeft, absoluteBoundingBox), styles (fills, effects, cornerRadius, text style.fontFamily / fontSize / fontWeight / lineHeightPx), and component structure (children, componentId).

  1. Screenshot/Image — Analyze the image visually to identify:
  1. Exported Design Tokens — Parse JSON/CSS design tokens directly.

Generating Components

  1. Identify the component tree — Break the design into a hierarchy:
  1. Extract design tokens:
  1. Generate the code following these rules:
  1. Handle responsive breakpoints:
  1. Handle interactive states:

Output Structure

Deliver code as individual files:

components/
  ComponentName/
    ComponentName.tsx       # Component code
    ComponentName.module.css # Styles (omit when styling with Tailwind classes)
    index.ts                # Re-export

Examples

Example 1: Pricing Card from Figma Screenshot

User provides: Screenshot of a pricing card with three tiers

Agent output:

// components/PricingCard/PricingCard.tsx
import { CheckIcon } from "../icons/CheckIcon";
import styles from "./PricingCard.module.css";

interface PricingCardProps {
  name: string;
  price: number;
  period: "monthly" | "yearly";
  features: string[];
  ctaLabel: string;
  highlighted?: boolean;
  onSelect: () => void;
}

export function PricingCard({ name, price, period, features, ctaLabel, highlighted, onSelect }: PricingCardProps) {
  return (
    <article className={`${styles.card} ${highlighted ? styles.highlighted : ""}`}>
      <h3 className={styles.planName}>{name}</h3>
      <div className={styles.price}>
        <span className={styles.currency}>$</span>
        <span className={styles.amount}>{price}</span>
        <span className={styles.period}>/{period === "monthly" ? "mo" : "yr"}</span>
      </div>
      <ul className={styles.features} role="list">
        {features.map((feature) => (
          <li key={feature} className={styles.feature}>
            <CheckIcon aria-hidden="true" />
            {feature}
          </li>
        ))}
      </ul>
      <button className={styles.cta} onClick={onSelect}>
        {ctaLabel}
      </button>
    </article>
  );
}

Example 2: Dashboard Layout from Figma URL

User provides: "Build this dashboard in React: https://www.figma.com/design/Kp7dRw2xLm9QeTz4uVn8Ys/Billing-Dashboard?node-id=1289-4127" — a frame with sidebar navigation, stats cards, and a data table

Agent fetches the frame (or calls get_design_context and get_variable_defs with the same link when the Figma MCP server is connected):

curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \
  "https://api.figma.com/v1/files/Kp7dRw2xLm9QeTz4uVn8Ys/nodes?ids=1289:4127" > dashboard.json

Agent extracts from the response:

Layout: 240px fixed sidebar + fluid main content
Grid: Stats row (4 columns) + full-width table below
Colors: --bg-primary: #0F172A, --bg-surface: #1E293B, --accent: #3B82F6
Type scale: heading-lg: 24/32 Inter 600, body: 14/20 Inter 400

Agent generates: Sidebar component, StatsGrid component, DataTable component with responsive collapse behavior, and a shared theme file with extracted design tokens.

Guidelines

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.