Claude Skills Guide

Claude Code Figma to Code Component Workflow

Converting Figma designs into clean, functional code is one of the most time-consuming tasks in frontend development. This workflow uses Claude Code skills to automate and streamline the Figma-to-code pipeline, reducing hours of manual work to minutes of structured collaboration.

Scope: This guide covers the CSS Modules / vanilla CSS approach to component styling — scoped class names generated at build time, no utility-class dependencies. If your project uses Tailwind CSS utility classes instead, see the companion guide: Claude Code Figma to Tailwind Component Conversion.

Setting Up Your Design-to-Code Pipeline

Before starting, ensure you have the Figma MCP server configured. This enables Claude Code to read directly from your Figma files. Install it through the standard MCP server setup process and authenticate with your Figma account.

Create a CLAUDE.md file in your project root to establish component conventions:

# Component Standards
- Use TypeScript for all components
- Follow React functional component patterns
- Use CSS modules for scoping
- Include PropTypes or type definitions
- Write storybook stories for each component

This file tells Claude Code your preferred patterns before it generates any component code.

Step 1: Extract Design Information from Figma

Use the Figma MCP server to pull component details. In Claude Code, ask it to read a specific frame or component:

Read the Button component from our Figma file and extract: all variant states, color values, spacing, and typography settings.

Claude Code will return structured data with measurements, colors, and property values. Save this information—you will reference it throughout the component creation process.

Step 2: Generate Component Structure

Load the frontend-design skill to transform design specifications into code:

Using the extracted Figma button data, generate a React button component with:
- Primary, secondary, and ghost variants
- Small, medium, and large sizes
- Loading and disabled states
- Proper TypeScript types

The frontend-design skill understands component composition and will generate a complete, production-ready component. It creates the component file, types, and often includes CSS or styled-components definitions.

Example output structure:

// Button.tsx
import React from 'react';
import styles from './Button.module.css';

export type ButtonVariant = 'primary' | 'secondary' | 'ghost';
export type ButtonSize = 'small' | 'medium' | 'large';

export interface ButtonProps {
  variant?: ButtonVariant;
  size?: ButtonSize;
  loading?: boolean;
  disabled?: boolean;
  children: React.ReactNode;
  onClick?: () => void;
}

export const Button: React.FC<ButtonProps> = ({
  variant = 'primary',
  size = 'medium',
  loading = false,
  disabled = false,
  children,
  onClick,
}) => {
  const className = [
    styles.button,
    styles[variant],
    styles[size],
    loading && styles.loading,
    disabled && styles.disabled,
  ].filter(Boolean).join(' ');

  return (
    <button
      className={className}
      disabled={disabled || loading}
      onClick={onClick}
    >
      {loading ? <span className={styles.spinner} /> : children}
    </button>
  );
};

Step 3: Generate Styling

After creating the component structure, generate corresponding CSS:

Create the CSS module for the button component with the exact colors from Figma:
- Primary: #2563EB (blue-600)
- Secondary: #64748B (slate-500)
- Hover states: 10% darker
- Border radius: 6px
- Font: Inter, 14px medium

This ensures pixel-perfect translation from design to code. The frontend-design skill converts design tokens into consistent CSS custom properties or module classes.

Step 4: Add Tests with TDD Workflow

Load the tdd skill to write tests alongside implementation:

Generate unit tests for the Button component covering:
- All variant renders
- Size variations
- Click handler invocation
- Disabled and loading states
- Snapshot tests

The tdd skill creates comprehensive test coverage using your project’s preferred testing framework (Jest, Vitest, or React Testing Library).

// Button.test.tsx
import { render, screen, fireEvent } from '@testing-library/react';
import { Button } from './Button';

describe('Button', () => {
  it('renders primary variant by default', () => {
    render(<Button>Click me</Button>);
    expect(screen.getByRole('button')).toHaveClass('primary');
  });

  it('calls onClick when clicked', () => {
    const handleClick = jest.fn();
    render(<Button onClick={handleClick}>Click me</Button>);
    fireEvent.click(screen.getByRole('button'));
    expect(handleClick).toHaveBeenCalledTimes(1);
  });

  it('does not call onClick when disabled', () => {
    const handleClick = jest.fn();
    render(<Button disabled onClick={handleClick}>Click me</Button>);
    fireEvent.click(screen.getByRole('button'));
    expect(handleClick).not.toHaveBeenCalled();
  });
});

Step 5: Create Storybook Stories

For design system components, generate Storybook stories to document variants:

Create Storybook stories for the Button component showing all variants and sizes in a stories file.

This creates an interactive component playground where designers and developers can verify implementation against the original Figma.

Automating the Full Workflow

For recurring component generation, chain these steps together. Start with the Figma extraction, then generate component, styles, and tests in sequence. The supermemory skill can remember your component patterns across sessions, learning your team’s conventions over time.

A typical multi-step request:

1. Read the Card component from Figma file "Design System"
2. Generate a React Card component with image slot, title, description, and action area
3. Create CSS module with design tokens
4. Write Vitest tests for all props and interactions
5. Create Storybook stories showing all configurations

This single prompt triggers the full pipeline, producing a complete, tested component ready for your codebase.

Handling Complex Components

For components with nested elements or intricate interactions, break the workflow into smaller steps. Extract the Figma frame first, generate the base component, then iteratively add complex features. Claude Code maintains context within the session, so you can reference earlier generated code when building more sophisticated components.

If a component requires API data, generate the component structure first, then use the frontend-design skill to add data fetching patterns and loading states. The skill understands async patterns and can generate proper loading skeletons matching your Figma designs.

Validation and Iteration

After generation, always validate the output:

If something needs adjustment, ask Claude Code to modify specific aspects rather than regenerating the entire component. This iterative approach is faster and preserves your customizations.

Summary

This Figma-to-code workflow transforms design handoff from a manual, error-prone process into an automated pipeline:

  1. Extract design data using the Figma MCP server
  2. Generate component structure with the frontend-design skill
  3. Style using extracted design tokens
  4. Test with the tdd skill for comprehensive coverage
  5. Document with Storybook for team visibility

Each skill handles a specific part of the workflow, and chaining them together eliminates the context switching between design tools, code editors, and testing frameworks. The result is consistent, tested components that match your Figma designs exactly.

Built by theluckystrike — More at zovo.one