跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
设计与 UI

figma-to-code

Generate production-ready React/Next.js code from Figma designs. Instructs proper Figma MCP tool usage, component reuse strategies, and variant mapping. **CRITICAL: ALWAYS use this skill when user provides a Figma link or mentions implementing/redesigning from Figma design.** Never attempt manual implementation without invoking this skill first.

scoobynko · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add scoobynko/claude-code-design-skills --skill figma-to-code

技能说明


name: figma-to-code description: Generate production-ready React/Next.js code from Figma designs. Instructs proper Figma MCP tool usage, component reuse strategies, and variant mapping. CRITICAL: ALWAYS use this skill when user provides a Figma link or mentions implementing/redesigning from Figma design. Never attempt manual implementation without invoking this skill first.

Figma to Code Generator

Purpose

Generate production-ready React/Next.js code from Figma designs. Provides systematic workflows for using Figma MCP tools, enforces component reuse, maps Figma variants to code props.

When to Use

Use this skill when:

  • User provides a Figma link to implement as code
  • Creating a new page from Figma design
  • Redesigning an existing page based on updated Figma designs
  • Implementing a new component or component variant from Figma

Do not use this skill when:

  • No Figma design is provided (user describes requirements verbally)
  • Working on backend or non-UI code
  • Making minor text or content updates to existing pages

Prerequisites

Required dependency: Figma MCP Server must be installed.

Before using Figma MCP tools, verify the server is available by attempting to use any Figma MCP tool (e.g., mcp__figma-desktop__get_metadata). If you receive an error indicating the tool is not available:

Prompt user with:

❌ Figma MCP Server Not Installed

To use Figma designs with Claude Code, you need to install the Figma MCP server.

Installation steps:
1. Open Figma Desktop app
2. Navigate to the MCP server installation guide:
   https://developers.figma.com/docs/figma-mcp-server

3. Follow the installation instructions for your operating system

4. Restart Claude Code after installation

Also ensure:
- Figma Desktop app is running
- You're logged into Figma
- The design file is open or you have access to it

Only proceed with Figma MCP tools after confirming the server is installed.

Figma MCP Tool Usage Protocol (MANDATORY)

Critical Rule: ALWAYS Use This Workflow When User Provides Figma Link

When user provides a Figma link or node ID, YOU MUST follow this exact tool sequence. Do NOT skip steps or change the order.

Required Tool Order: Metadata → Context → Screenshot → Variables

Step 1: Get Metadata (REQUIRED FIRST)

Tool: mcp__figma-desktop__get_metadata
Extract:
- Component/frame names and hierarchy
- Layer types (COMPONENT, FRAME, INSTANCE)
- Variant property names
- Child element structure

Look for: Component or frame? Variant properties? Children organization? Naming patterns?

Step 2: Get Design Context (REQUIRED SECOND)

Tool: mcp__figma-desktop__get_design_context
Extract:
- Colors (with variable references like "colors/iris/950")
- Spacing (padding, gaps, margins)
- Typography (font family, size, weight)
- Border radius, shadows, effects
- Component variant values

Look for: Which Figma variables? Spacing values? Hard-coded values?

Step 3: Get Screenshot (REQUIRED THIRD)

Tool: mcp__figma-desktop__get_screenshot
Use for: Visual verification, understanding layout

Step 4: Get Variables (REQUIRED FOURTH)

Tool: mcp__figma-desktop__get_variable_defs
When: Design uses Figma variables extensively or checking token consistency

MCP Tool Parameters

Always include for proper logging:

{ clientLanguages: "typescript,javascript", clientFrameworks: "react,nextjs" }

MCP Tool Rules

Do: ✓ Start with metadata, ✓ Use context for details, ✓ Use parameters Don't: ✗ Skip metadata, ✗ Wrong order, ✗ Screenshot alone

Critical Boundaries: Frontend Layer Focus

Default Scope: Frontend Only

Operate exclusively in the frontend layer by default. Figma designs represent UI/UX and should translate to frontend code only.

Frontend scope:

  • [FRONTEND_DIR]/app/ - Next.js pages and routes
  • [FRONTEND_DIR]/components/ - React components
  • [FRONTEND_DIR]/lib/ - Frontend utilities
  • [FRONTEND_DIR]/hooks/ - Custom React hooks
  • [FRONTEND_DIR]/public/ - Static assets

Do NOT touch without permission:

  • [BACKEND_DIR]/ - Backend directories and files
  • Backend routes, database schemas, or API endpoints

Backend Change Protocol

ALWAYS ask user before:

  1. Creating new API routes
  2. Modifying existing API endpoints
  3. Changing database schemas
  4. Adding backend dependencies
  5. Touching any files outside [FRONTEND_DIR]/

Ask with this format:

⚠️ Backend Change Required

To implement this Figma design, the following backend changes are needed:
[Specific backend changes listed]

Frontend can be mocked with placeholder data until backend is ready.

Would you like me to:
1. Implement frontend with mocked data (recommended)
2. Implement both frontend and backend
3. Only implement frontend and document backend requirements

Only proceed WITHOUT asking if:

  • User explicitly stated "implement both frontend and backend"
  • User is actively working in backend and asks to "complete the implementation"

Mock Data Pattern

Implement frontend with mock data first, document required API shape.

// TODO: Replace with actual API call to [BACKEND_DIR]/[API_MODULE]
const mockProducts = [{ id: 1, name: "Product 1", price: 99 }]

/**
 * Backend API Required:
 * GET /api/products
 * Response: { products: Array<{id, name, price, imageUrl}> }
 * Backend file: [BACKEND_DIR]/[API_MODULE]/routes.ts
 */
export function ProductList() {
  const products = mockProducts
  return // Render using mock data
}

Component Reuse Strategy

Priority: Reuse > Extend > Create

Check Existing Components First

Search locations:

  • [COMPONENTS_DIR]/ui/ - UI library base components
  • [COMPONENTS_DIR]/ - Custom components

Search method:

  1. Extract base name from Figma (e.g., "Button" from "Button/Primary/Large")
  2. Use Glob to find: [COMPONENTS_DIR]/ui/{name}.tsx
  3. Read component file to check variants and props
阅读完整来源 ↗