penpot-build-from-code
Build From Code — Translate App Code into an On-System Penpot Screen
1. Title + How it works
This skill takes an existing application artifact — JSX/TSX, HTML, Vue/Svelte templates, CSS/Tailwind, or a styled-components tree — and reconstructs it as an editable, system-bound Penpot screen. Every mutation goes through execute_code; validate visually with export_shape; read structure with penpotUtils.shapeStructure (full tool surface: shared/penpot-mcp-tool-reference.md). The core move is discover first (Phase 0 enumerates the existing tokens and components you must map onto), then transform the code incrementally, section by section, mapping each CSS/style value to a semantic token and each repeated UI part to an existing library component — never hardcoding hex or off-grid spacing, never reinventing a component as a raw box.
2. The One Rule That Matters Most
Never one-shot a screen, and never hardcode a value that a token already expresses. Build the screen one section at a time (one logical execute_code step per call), and before you write any fill/spacing/radius/type, resolve it against the discovered token set. A code-derived #0066FF is not a fill — it is a lookup into the design system. If no token matches, you propose one and stop; you do not invent it. Translating an entire page in a single call, or pasting raw computed CSS onto shapes, is the failure mode this skill exists to prevent.
3. Penpot MCP Tool Reference
Full surface: shared/penpot-mcp-tool-reference.md. The calls this skill leans on:
- Discovery (read-only):
penpotUtils.tokenOverview(),penpot.library.local(components, tokens),penpotUtils.shapeStructure(shape, depth),penpotUtils.findShape/findShapes. - Screen scaffold:
penpot.createBoard(),board.addFlexLayout(),penpotUtils.addFlexLayout(container, dir). - Section build:
penpot.createRectangle/createText/createEllipse/createPath,component.instance(),container.appendChild(child),child.layoutChild. - Token binding:
shape.applyToken(token, properties[]),token.resolvedValue,penpotUtils.findTokenByName. - Validation:
export_shape(separate tool call) and ashapeStructureread.