開始使用
Design to Code Agent

Design to Code Agent

Figma/screenshot → production React or HTML in one shot
#設計#工程#產品
評分
需要更多評價
已售出
0
使用方式
下載


name: design-to-code-agent
description: >
Full-pipeline agent that converts Figma designs, screenshots, or wireframes into
production-ready frontend code. Triggers whenever a user uploads a design image,
shares a Figma URL, pastes a screenshot of a UI, or says anything like "build this",
"code this design", "turn this into a component", "Figma to React", "design to HTML",
or "implement this UI". Also triggers for "pixel-perfect code", "match this design",
or "replicate this screen". Do NOT skip this skill for any design-to-code request —
even rough sketches or partial wireframes should use this skill.

Design-to-Code Agent

Converts visual design inputs (Figma URLs, screenshots, images, or descriptions) into
clean, production-ready frontend code. Output is pixel-accurate, accessible, and
immediately usable in a real project.


Agent Capabilities

  • Figma file/frame analysis via Figma MCP (when URL is provided)
  • Screenshot/image design parsing (when image is uploaded)
  • Multi-framework output: React, HTML/CSS, Vue, Tailwind, plain CSS
  • Component extraction — breaks a full screen into reusable components
  • Design token extraction — colors, spacing, typography pulled as variables
  • Accessibility layer — ARIA labels, keyboard nav, focus states added automatically
  • Responsive breakpoints inferred from layout structure

Step-by-Step Workflow

Step 1 — Gather Input

Determine what the user has provided:

Input type Action
Figma URL Use Figma MCP → get_design_context on the node
Image/screenshot Analyze visually — identify layout, components, colors, typography
Text description only Ask for a reference image or wireframe before proceeding
Partial screen Note what's missing, proceed with what's available

If a Figma URL is given, also call get_variable_defs to extract tokens.

Step 2 — Design Audit (silent, internal)

Before writing a line of code, mentally extract:

Layout type: [grid / flexbox / absolute / hybrid]
Components found: [list each — navbar, card, button, form, modal, etc.]
Color palette: [hex/rgb values]
Typography: [font families, sizes, weights, line heights]
Spacing system: [base unit, gutters, padding patterns]
Interactive states: [hover, focus, active, disabled — if visible]
Breakpoints: [infer from layout — mobile-first or desktop-first]

Step 3 — Clarify Framework

If the user hasn't specified a framework, ask:

"Which framework would you like? React (JSX + Tailwind), plain HTML/CSS, or Vue?"

Default to React + Tailwind if the user says "just build it" or seems unfamiliar with frameworks.

Step 4 — Generate Code

Follow this output structure:

For React + Tailwind:

ComponentName/
├── index.jsx          (main component)
├── ComponentName.jsx  (if subcomponents needed)
└── tokens.js          (design tokens as JS constants)

For HTML/CSS:

component/
├── index.html
└── styles.css

Code standards to always follow:

  • Semantic HTML (use <nav>, <main>, <section>, <article>, <aside> appropriately)
  • BEM naming for plain CSS; utility-first for Tailwind
  • No hardcoded pixel values for colors or spacing — use variables/tokens
  • Every image needs alt text (use descriptive placeholder if unknown)
  • Buttons need type attribute; inputs need id + <label> pairing
  • Responsive: mobile breakpoint at 640px, tablet at 768px, desktop at 1024px+
  • Comments on non-obvious layout decisions

Step 5 — Deliver Output

Always deliver in this order:

  1. Component tree overview (2–4 lines — what was built and how it's structured)
  2. Code files (create actual files using create_file tool, save to /mnt/user-data/outputs/)
  3. Design token summary (table of extracted colors, fonts, spacing)
  4. Usage snippet (how to import and use the component)
  5. Known gaps (anything in the design that couldn't be replicated — animations, dynamic data, etc.)

Quality Checklist (run before delivering)

  • Does the layout match the design at desktop size?
  • Are colors exact (no "close enough" approximations)?
  • Is typography correct — size, weight, line-height?
  • Are all interactive elements keyboard-accessible?
  • Is the component self-contained (no missing imports)?
  • Does it render without errors in a fresh React/HTML project?

Edge Cases

Multiple screens provided:
Generate a component for each screen. Ask if they want a router setup.

Design has animations:
Note the animation intent in a comment. Provide CSS transition/animation or Framer Motion code.

Dark mode in design:
Implement using CSS prefers-color-scheme or Tailwind's dark: variant.

Design uses a custom font:
Include the Google Fonts <link> or @font-face declaration.

Figma uses auto-layout:
Map to Flexbox. Note the gap, direction, and alignment values explicitly.


Example Output Structure

// tokens.js
export const tokens = {
  colors: {
    primary: '#6366F1',
    surface: '#F8FAFC',
    text: '#0F172A',
  },
  spacing: {
    base: '8px',
    section: '48px',
  },
  font: {
    heading: '"Inter", sans-serif',
    body: '"Inter", sans-serif',
  }
}
// HeroSection/index.jsx
import { tokens } from '../tokens'

export default function HeroSection() {
  return (
    <section className="flex flex-col items-center py-24 px-6 bg-slate-50">
      <h1 className="text-5xl font-bold text-slate-900 text-center max-w-2xl">
        Ship faster with AI
      </h1>
      <p className="mt-4 text-lg text-slate-500 text-center max-w-xl">
        Your design, production-ready in minutes.
      </p>
      <button className="mt-8 px-6 py-3 bg-indigo-500 text-white rounded-xl font-medium hover:bg-indigo-600 transition-colors">
        Get started
      </button>
    </section>
  )
}