Skip to content

AI-native design editor. Open-source Figma alternative.

Remove dead files: codegen.md duplicate and planning doc

Danila Poyarkovec741a9388aa
diff --git a/docs/design-to-code-overview.md b/docs/design-to-code-overview.md
deleted file mode 100644
index 19c99e254..000000000
--- a/docs/design-to-code-overview.md
+++ /dev/null
@@ -1,244 +0,0 @@
-# Design → Code Pipeline: Overview
-
-## Goal
-
-Take a .fig design and produce production-ready code on the user's target stack (React, Vue, Svelte, etc. + Tailwind/CSS Modules/etc.) via AI-assisted code generation through the MCP server.
-
-## Current State
-
-### What exists (extraction layer)
-
-| Capability | Tool/Module | Output |
-|-----------|-------------|--------|
-| Read node tree | `get_page_tree`, `get_node`, `find_nodes`, `query_nodes` | JSON node properties |
-| Semantic analysis | `describe` | Role, layout, visual style, issues |
-| JSX representation | `get_jsx` | OpenPencil JSX (`<Frame flex="col" w={320}>`) |
-| Tailwind JSX | `export-jsx.ts` (tailwind format) | `<div className="flex flex-col w-80">` |
-| SVG export | `export_svg` | SVG markup string |
-| Image export | `export_image` | PNG/JPG/WEBP raster |
-| Components list | `get_components` | Component IDs, names, pages |
-| Design tokens | `list_variables`, `find_variables`, `list_collections` | Variable names, types, values, modes |
-| Color analysis | `analyze_colors` | Palette, frequencies, variable bindings, similar clusters |
-| Typography analysis | `analyze_typography` | Font families, sizes, weights, frequencies |
-| Spacing analysis | `analyze_spacing` | Gaps, paddings, grid compliance |
-| Pattern detection | `analyze_clusters` | Repeated structures → potential components |
-| Structural diff | `diff_jsx`, `diff_create` | Unified diff between two nodes |
-| XPath queries | `query_nodes` | `//FRAME[@width < 300]`, `//TEXT[contains(@text, 'Hello')]` |
-
-### What does NOT exist
-
-1. **System/instructions prompt for code generation** — no guidance for the AI on how to convert design → code
-2. **Component decomposition** — `analyze_clusters` finds repeated patterns, but doesn't determine component boundaries, props, variants, slots
-3. **Design token → CSS variable mapping** — `list_variables` returns raw Figma variables, but nothing maps them to `--color-primary`, `var(--spacing-4)`, etc.
-4. **Target stack awareness** — no concept of "this project uses Vue 3 + Tailwind" vs "React + CSS Modules"
-5. **Production JSX output** — `export-jsx.ts` tailwind format produces unstyled `<div>` soup without component structure, prop interfaces, or framework idioms
-6. **Verification** — no way to compare generated code output against the design visually
-
----
-
-## Architecture
-
-```
-.fig design file
- │
- ▼
-┌──────────────────────────────────────────────────────────────┐
-│ PHASE 1: EXTRACTION (tools exist) │
-│ │
-│ get_page_tree → full structure │
-│ get_components → component inventory │
-│ list_variables → design tokens │
-│ analyze_colors/typography/spacing → design system snapshot │
-│ analyze_clusters → repeated patterns │
-│ describe → semantic roles per node │
-│ get_jsx → structural JSX │
-│ export_svg → vector assets │
-│ export_image → screenshots for verification │
-└──────────────┬───────────────────────────────────────────────┘
- │
- ▼
-┌──────────────────────────────────────────────────────────────┐
-│ PHASE 2: DECOMPOSITION (needs: prompt + possibly tools) │
-│ │
-│ Which nodes are screens vs components vs primitives? │
-│ What props does each component accept? │
-│ Which components have variants (state, size, theme)? │
-│ Which design variables map to which CSS tokens? │
-│ What's the component hierarchy / dependency graph? │
-└──────────────┬───────────────────────────────────────────────┘
- │
- ▼
-┌──────────────────────────────────────────────────────────────┐
-│ PHASE 3: CODE GENERATION (needs: prompt) │
-│ │
-│ Generate component files on target stack │
-│ Map design tokens → CSS/theme variables │
-│ Extract SVG assets for icons/illustrations │
-│ Wire up component hierarchy and props │
-│ Match typography, spacing, colors exactly │
-└──────────────┬───────────────────────────────────────────────┘
- │
- ▼
-┌──────────────────────────────────────────────────────────────┐
-│ PHASE 4: VERIFICATION (needs: prompt guidance) │
-│ │
-│ Compare generated code visually against design │
-│ Check token coverage, missing styles │
-│ Verify responsive behavior │
-└──────────────────────────────────────────────────────────────┘
-```
-
----
-
-## What to Build
-
-### 1. MCP System Prompt for Code Generation
-
-A system prompt served when AI is asked to generate code from a design. Not the same as the design-chat prompt in `use-chat.ts`. This one instructs the AI to use extraction tools, decompose the design, and output production code.
-
-**Content outline:**
-
-```
-You are a frontend engineer generating production code from Figma designs.
-
-# Workflow
-
-1. UNDERSTAND the design
- - get_page_tree → scan structure
- - get_components → inventory reusable parts
- - list_variables + list_collections → design tokens
- - analyze_colors, analyze_typography, analyze_spacing → design system snapshot
-
-2. PLAN the component tree
- - analyze_clusters → find repeated patterns
- - describe on key nodes → semantic roles
- - Determine: which frames are pages/screens, which are components, which are primitives
- - Map Figma components → code components
- - Identify props: text content, colors, sizes, visibility, children (slots)
- - Identify variants: if component has states (hover, active, disabled), map to props
-
-3. EXTRACT design tokens
- - list_variables → get all variables with values per mode (light/dark)
- - Map to CSS custom properties or theme object
- - Color variables → --color-{name}
- - Number variables → --spacing-{name}, --radius-{name}, etc.
- - Fonts → font-family definitions
-
-4. GENERATE code
- - One component per file
- - Use get_jsx on each component to read structure
- - Use export_svg for vector icons/illustrations
- - Apply design tokens as CSS variables / theme references
- - Match pixel values exactly: font sizes, spacing, radii, colors
- - Framework-specific:
- - React: functional components, TypeScript props interface, named exports
- - Vue: <script setup lang="ts">, defineProps, <template>
- - Svelte: $props, <script lang="ts">
- - Styling:
- - Tailwind: utility classes, arbitrary values for exact matches
- - CSS Modules: .module.css with variables
- - Styled-components: tagged templates with theme
-
-5. VERIFY
- - Re-read the design with describe
- - Compare against generated code structure
- - Check: all text content matches, all colors use tokens, spacing is correct
- - List any deviations
-```
-
-### 2. Tool: `design_to_tokens`
-
-Automates Phase 2 token mapping. Could be a tool or a prompt-guided workflow.
-
-```typescript
-defineTool({
- name: 'design_to_tokens',
- description: 'Extract design tokens as CSS custom properties from Figma variables.',
- params: {
- format: { type: 'string', enum: ['css', 'tailwind', 'json'], description: 'Output format' }
- },
- execute: (figma, args) => {
- const vars = figma.getLocalVariables()
- const collections = figma.getLocalVariableCollections()
- // Map variables to CSS custom properties
- // Group by collection → mode → variable
- // Output :root { --color-primary: #3b82f6; ... }
- // Or tailwind.config.ts theme extension
- // Or JSON token file
- }
-})
-```
-
-### 3. Tool: `design_to_component_map`
-
-Automates Phase 2 decomposition. Analyzes the document and returns a structured component map.
-
-```typescript
-defineTool({
- name: 'design_to_component_map',
- description: 'Analyze document structure and return a component decomposition map.',
- params: {
- page: { type: 'string', description: 'Page name to analyze' },
- depth: { type: 'number', description: 'Max nesting depth (default: 3)' }
- },
- execute: (figma, args) => {
- // 1. Get all COMPONENT/COMPONENT_SET nodes
- // 2. For each, analyze: name, variants, instance count, props (overridden fields)
- // 3. Get all top-level frames that aren't components → these are screens/pages
- // 4. For each screen, walk tree and record which components are used where
- // Return:
- // {
- // components: [{ id, name, variants, props, instanceCount, usedIn }],
- // screens: [{ id, name, components: [refs] }],
- // tokens: { colors: [...], typography: [...], spacing: [...] }
- // }
- }
-})
-```
-
-### 4. Enhanced `get_jsx` with Production Format
-
-Add a third format to `export-jsx.ts` that outputs framework-aware code:
-
-```typescript
-// format: 'react' | 'vue' | 'svelte'
-// Uses component names from Figma, maps design tokens, adds prop interfaces
-```
-
-Or this could be entirely prompt-driven, using existing `get_jsx` output as input and letting the AI transform it.
-
-### 5. MCP Prompt File Serving
-
-The MCP server needs a way to serve the code generation prompt. Options:
-
-**Option A: Bake into system prompt** — The MCP server's `createServer()` sets instructions in server metadata. External AI clients (Claude Code, Cursor, etc.) receive it automatically.
-
-**Option B: Dedicated tool** — `get_codegen_guidelines` tool that returns the prompt text. AI calls it when code generation is requested.
-
-**Option C: MCP Resource** — Serve as an MCP resource (`prompts/codegen`) that clients can read.
-
-Recommendation: **Option A** — system prompt in MCP server metadata + **Option B** as fallback for clients that don't read server instructions.
-
----
-
-## What NOT to Build
-
-1. **Framework-specific design-generation prompts** — those are for generating designs, not code. We already have the design-chat prompt.
-
-2. **Batch operation DSL** — we have `render` with JSX + 88 atomic tools, no need for a custom batch language.
-
-3. **Hardcoded framework templates** — Don't bake React/Vue/Svelte templates into tools. Let the AI generate idiomatic code guided by the prompt. The prompt tells it the target stack; the AI writes the code.
-
-4. **Style guide / inspiration system** — That's for design generation, not code generation. Out of scope.
-
----
-
-## Implementation Order
-
-1. **Write the system prompt** — the code generation instruction document. Test with MCP + Claude Code on a real .fig file.
-2. **Add `design_to_tokens` tool** — deterministic token extraction, CSS/Tailwind/JSON output.
-3. **Add `design_to_component_map` tool** — structural component decomposition.
-4. **Integrate prompt into MCP server** — serve via server instructions + tool fallback.
-5. **Test & iterate** — run on real designs, evaluate output quality.
-
-Step 1 is the highest leverage: a good prompt with existing tools will already produce usable code. Steps 2-3 improve quality by reducing AI guesswork.
diff --git a/packages/core/src/tools/prompts/codegen.md b/packages/core/src/tools/prompts/codegen.md
deleted file mode 100644
index b2f7588a2..000000000
--- a/packages/core/src/tools/prompts/codegen.md
+++ /dev/null
@@ -1,233 +0,0 @@
-# Design to Code
-
-You convert Figma designs into production frontend code. You have full access to the design document through tools. Never guess — always read the actual design data.
-
-> Note: Auto-layout and visual property names match the JSX props in the render system. See `describe` tool output for semantic role and layout analysis of any node.
-
-## Workflow
-
-### Step 1 — Survey
-
-Understand the full picture before writing any code.
-
-```
-get_page_tree → document structure, all top-level frames
-get_components → reusable components defined by the designer
-list_variables → design tokens (colors, numbers, strings, booleans)
-list_collections → variable collections and modes (light/dark, density, etc.)
-analyze_colors → color palette, frequencies, which colors use variables
-analyze_typography → font stacks, sizes, weights in use
-analyze_spacing → gap and padding values, grid compliance
-```
-
-After this step you should know:
-- How many screens/pages the design has
-- What components exist
-- What the token system looks like (or if there is none)
-- The typographic scale
-- The spacing system (4px grid? 8px grid? irregular?)
-
-### Step 2 — Decompose
-
-Identify the component architecture.
-
-```
-analyze_clusters → find repeated visual patterns that should be components
-describe (per node) → semantic role, layout direction, visual properties, issues
-get_jsx (per node) → structural JSX to understand nesting and layout
-```
-
-Build a component map:
-- **Screens** — top-level frames that represent pages/views
-- **Components** — COMPONENT/COMPONENT_SET nodes or repeated patterns from analyze_clusters
-- **Primitives** — leaf elements (text, icons, dividers) that don't need their own component file
-
-For each component determine:
-- **Props** — what content varies between instances (text, color, icon, visibility)
-- **Variants** — if the component has multiple states (default/hover/active, small/medium/large)
-- **Slots** — where child content is injected
-
-### Step 3 — Extract tokens
-
-```
-list_variables → all variables with values per mode
-list_collections → collection structure and mode names
-```
-
-Map design variables to code tokens. The approach depends on the target stack:
-
-#### Tailwind projects
-
-Do NOT create CSS custom properties for font sizes, font weights, spacing, or border radius — Tailwind has its own system for these. Use Tailwind utility classes directly:
-- Font sizes → `text-[13px]`, `text-sm`, `text-base`, etc.
-- Font weights → `font-bold`, `font-medium`, `font-[600]`
-- Spacing → `gap-3`, `p-4`, `px-5`, `py-[14px]`, or arbitrary `gap-[12px]`
-- Border radius → `rounded-xl`, `rounded-[14px]`, `rounded-full`
-
-Only create CSS custom properties for **semantic colors** — these are the values that would change across themes. Name them to avoid conflicts with Tailwind's built-in variables (do NOT use names like `--font-bold`, `--text-sm`, `--radius-lg`):
-
-```css
-:root {
- --movie-bg: #0F0F1A;
- --movie-surface: #1A1A2E;
- --movie-accent: #7C3AED;
- --movie-text: #FFFFFF;
- --movie-text-dim: #FFFFFF80;
-}
-```
-
-Reference in Tailwind classes: `bg-[var(--movie-bg)]`, `text-[var(--movie-text)]`
-
-#### CSS Modules / plain CSS projects
-
-Create CSS custom properties for all token categories (colors, spacing, typography, radius). Use a project-specific prefix to avoid collisions:
-
-```css
-:root {
- --app-color-bg: #0F0F1A;
- --app-space-sm: 4px;
- --app-text-sm: 12px;
- --app-radius-md: 8px;
-}
-```
-
-#### No design variables in the file
-
-If the design has no Figma variables, extract implicit tokens from `analyze_colors` and `analyze_typography` output — identify the de facto palette and type scale. For Tailwind projects, only extract semantic colors as CSS custom properties; use Tailwind utilities for everything else.
-
-#### Multi-mode collections (light/dark)
-
-- Generate token values for each mode
-- Use CSS custom properties with class-based switching (`.dark { ... }`)
-
-### Step 4 — Generate code
-
-For each component, bottom-up (primitives first, then composites, then screens):
-
-```
-get_jsx id=<component_id> → read structure
-describe id=<component_id> → understand semantic role
-export_svg ids=[<icon_ids>] → extract vector assets
-```
-
-**Rules:**
-- One component per file
-- Component name comes from the Figma node name, converted to PascalCase
-- Props interface reflects the variable content identified in Step 2
-- Use design tokens from Step 3 for semantic colors
-- For Tailwind: use utility classes directly for spacing, font sizes, weights, radius — do NOT wrap them in `var()` indirection
-- Match measurements exactly: font sizes, spacing, border radii, colors
-- Use auto-layout data to determine flex direction, gap, padding, alignment
-- Absolute positioning only when `layoutPositioning` is `ABSOLUTE` or layout mode is `NONE`
-- If a node has `clipsContent: true`, use `overflow: hidden`
-- Text nodes: preserve font family, size, weight, line height, letter spacing, alignment
-- Images/illustrations: use `export_svg` for vectors, placeholder `<img>` for raster
-
-**Interactive states:**
-
-Figma designs rarely include hover/active/focus states unless the component has explicit variants for them. Always add sensible interactive feedback to clickable elements:
-
-- **Buttons (primary):** `hover:brightness-110 active:brightness-90 transition-all`
-- **Buttons (secondary/ghost):** `hover:bg-white/[0.12] active:bg-white/[0.06] transition-colors`
-- **Icon buttons:** `hover:bg-white/[0.15] active:scale-95 transition-all`
-- **Cards/list items (if clickable):** `hover:bg-white/[0.04] transition-colors`
-- **Links/text buttons:** `hover:underline` or `hover:opacity-80`
-- **All interactive elements:** add `cursor-pointer` and `select-none`
-- **Focus visible:** add `focus-visible:ring-2 focus-visible:ring-offset-2` with accent color for accessibility
-
-If the design HAS explicit hover/active variants (COMPONENT_SET with state property), use those exact styles instead of defaults above.
-
-### Step 5 — Verify
-
-After generating code, verify against the design:
-
-```
-describe id=<root> → re-check structure matches
-get_jsx id=<root> → compare JSX structure with generated component tree
-```
-
-Check:
-- All text content from the design appears in the code
-- All colors reference tokens or use correct hex/opacity values
-- Spacing values match the design
-- Component hierarchy matches the design's node tree
-- No nodes were skipped or merged incorrectly
-
-List any deviations with rationale.
-
-## Target stack
-
-The user specifies the target stack. Adapt code generation accordingly:
-
-**React + Tailwind** — functional components, TypeScript, utility classes, `className`
-**React + CSS Modules** — functional components, TypeScript, `.module.css` files, `styles.className`
-**Vue 3 + Tailwind** — `<script setup lang="ts">`, `defineProps`, `<template>`, Tailwind utility classes
-**Vue 3 + CSS** — `<script setup lang="ts">`, `defineProps`, `<template>`, scoped `<style>`
-**Svelte + Tailwind** — `<script lang="ts">`, `$props()`, Tailwind utility classes
-**HTML + CSS** — semantic HTML, BEM or utility classes, CSS custom properties
-
-If the user hasn't specified a stack, ask before generating code.
-
-## Component file structure
-
-```
-components/
- Button.tsx (or .vue, .svelte)
- Card.tsx
- Header.tsx
- ...
-tokens.css (semantic color tokens only, for Tailwind projects)
-pages/
- HomePage.tsx (or routes, views — depends on framework)
-assets/
- icon-arrow.svg
- icon-check.svg
-```
-
-## Common patterns
-
-**Auto-layout → Flexbox**
-- `layoutMode: HORIZONTAL` → `flex-direction: row`
-- `layoutMode: VERTICAL` → `flex-direction: column`
-- `itemSpacing` → `gap`
-- `paddingTop/Right/Bottom/Left` → `padding`
-- `primaryAxisAlign: CENTER` → `justify-content: center`
-- `counterAxisAlign: CENTER` → `align-items: center`
-- `layoutWrap: WRAP` → `flex-wrap: wrap`
-- `primaryAxisSizing: HUG` → no explicit size on primary axis (content-sized)
-- `primaryAxisSizing: FILL` → `flex: 1` or `width: 100%` depending on context
-- `counterAxisSizing: FILL` → `align-self: stretch` or explicit `width/height: 100%`
-
-**Grid layout**
-- `layoutMode: GRID` → `display: grid`
-- `gridTemplateColumns` → `grid-template-columns`
-- `gridTemplateRows` → `grid-template-rows`
-- `gridColumnGap/gridRowGap` → `column-gap/row-gap`
-
-**Sizing**
-- `layoutGrow > 0` → `flex-grow: 1`
-- `layoutAlignSelf: STRETCH` → cross-axis fill
-- Fixed width/height only when sizing mode is `FIXED`
-
-**Corner radius**
-- `independentCorners: true` → per-corner border-radius
-- `cornerRadius` → uniform border-radius
-
-**Effects**
-- `DROP_SHADOW` → `box-shadow`
-- `INNER_SHADOW` → `box-shadow: inset ...`
-- `LAYER_BLUR` → `filter: blur(...)`
-- `BACKGROUND_BLUR` → `backdrop-filter: blur(...)`
-
-**Text**
-- `fontFamily` → `font-family`
-- `fontSize` → `font-size`
-- `fontWeight` → `font-weight`
-- `lineHeight` → `line-height` (null = normal/auto)
-- `letterSpacing` → `letter-spacing`
-- `textAlignHorizontal` → `text-align`
-- `textAutoResize: WIDTH_AND_HEIGHT` → no explicit dimensions
-- `textAutoResize: HEIGHT` → fixed width, auto height
-- `textAutoResize: NONE` → fixed width and height
-- `textDecoration` → `text-decoration`
-- `textCase` → `text-transform`