FigClaw
Design-to-code workflow for turning structured design instructions into usable interfaces.
Overview
FigClaw is a design-to-code workflow automation bridge. It connects Figma REST API node graphs directly to AI prompt pipelines by extracting layer geometry, style variables, and auto-layout bounds into structured JSON/Markdown context payloads.
The problem
Translating Figma UI designs into clean code by hand is repetitive and error-prone. Passing raw Figma screenshots to AI coding models yields approximate layouts that miss precise design system tokens, flex gaps, and exact typography specifications.
What I built
A lightweight Node.js serialization engine that calls Figma's REST API (/v1/files/:key/nodes), parses the node tree AST, prunes redundant metadata (like unused fill vectors and hidden layers), and formats structured layout instructions ready for LLM consumption.
How it works
The system transforms design node trees into code instructions via a deterministic 5-step pipeline:
Key decisions
Fetched specific target node subtrees via ?ids=... query parameters rather than fetching full 100MB+ document objects to keep memory usage minimal and API responses fast.
Normalized raw pixel values into relative CSS rem units and CSS Flexbox/Grid declarations during JSON serialization to produce production-ready code tokens.
Implementation
Core Node.js API execution function for parsing Figma node hierarchies:
async function fetchFigmaNodeContext(fileKey, nodeId) {
const response = await fetch(`https://api.figma.com/v1/files/${fileKey}/nodes?ids=${nodeId}`, {
headers: { 'X-Figma-Token': process.env.FIGMA_ACCESS_TOKEN }
});
const data = await response.json();
return parseFigmaNodeGraph(data.nodes[nodeId].document);
}
Result
Drastically streamlined design-to-interface generation workflows by producing precise structured context, eliminating manual pixel measuring and layout guesswork.
What I learned
Processing deep visual node graphs requires aggressive AST pruning. Stripping redundant vector details while preserving spatial hierarchy is critical for maximizing token efficiency in AI prompts.