算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
figma-to-code【设计与创意】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, pixel perfect, design handoff, component from design.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
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.
There are three ways to receive design input:
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:
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
get_design_context — layout, styles, and reference code for the node (React + Tailwind unless the prompt names another stack)get_variable_defs — the variables and styles the node uses, for design tokensget_screenshot — an image of the node to check the result againstget_metadata — a sparse XML outline, for frames too large to fetch wholeFigma REST API. Use a personal access token (Figma Settings → Security) with the file_content:read scope, kept in FIGMA_TOKEN:
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).
Screenshot/Image — Analyze the image visually to identify:
Exported Design Tokens — Parse JSON/CSS design tokens directly.
Identify the component tree — Break the design into a hierarchy:
Extract design tokens:
Generate the code following these rules:
<nav>, <main>, <article>, <section>)clamp() for fluid typographyHandle responsive breakpoints:
clamp()Handle interactive states:
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
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}>lt;/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>
);
}
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.
Retry-After secondsnull in the nodes map rather than as an error — check before parsingfile_content:read scope, and never write it into generated code or commits