# design-to-react-algorithms

The design-to-react-algorithms skill provides a step-by-step pipeline to convert Sketch files into React and CSS while preventing layout regressions.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 142 installs · ★ 227 repo stars
- Author: pproenca
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/pproenca/dot-skills/tree/HEAD/skills/.experimental/design-to-react-algorithms/SKILL.md
- Updated: 2026-08-15
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/design-to-react-algorithms

## What it does

The conversion pipeline uses eight cascaded priority levels, labeled with prefixes from `iter-` to `path-`. Higher levels govern lower ones: an error in tree parsing or coordinate math invalidates all styling downstream. Design tokens are extracted into CSS variables before any component generation, and symbols are topologically sorted.

Layout reconstruction replaces brittle absolute positioning. It uses separating-axis overlap tests to infer Flexbox rows and columns, alongside 2D coordinate clustering with an epsilon tolerance to detect CSS Grid. Floats are preserved throughout affine matrix transforms, rounding once at the CSS boundary.

Visual verification rejects raw pixel diffs because antialiasing triggers frequent false alarms. The skill mandates SSIM with region-specific budgets, such as 0.99 for typography and 0.95 for gradients.

## Requirements
- Works with: Figma

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add pproenca/dot-skills --skill design-to-react-algorithms -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/design-to-react-algorithms/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/design-to-react-algorithms/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add pproenca/dot-skills --skill design-to-react-algorithms -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/design-to-react-algorithms/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add pproenca/dot-skills --skill design-to-react-algorithms -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/design-to-react-algorithms/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install pproenca/dot-skills skills/.experimental/design-to-react-algorithms
```

2. **Manually: put the files in place**
- File: `.github/skills/design-to-react-algorithms/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add pproenca/dot-skills --skill design-to-react-algorithms -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/pproenca/dot-skills --path skills/.experimental/design-to-react-algorithms
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/design-to-react-algorithms/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add pproenca/dot-skills --skill design-to-react-algorithms -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/pproenca/dot-skills/tree/HEAD/skills/.experimental/design-to-react-algorithms/SKILL.md

## When to use it
- infer Flexbox and CSS Grid structures from freeform Sketch geometry
- prevent visual regressions when iterating on design-to-code pipelines
- configure SSIM visual diff thresholds for text, gradients, and images
- map Sketch `MSImmutableFlexGroupLayout` enums directly to CSS rules

## Example prompts
- Reconstruct this Sketch artboard into React components using axis projection to infer flex layouts
- Run visual regression diffing on the converted banner with SSIM thresholds
- Apply overrideValues to master symbols before emitting React props

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 8959bc13be1284c9.

BEGIN THIRD-PARTY FILE 8959bc13be1284c9
```text
---
name: design-to-react-algorithms
description: Reverse-engineering a Sketch file (or Figma export with similar shape) into pixel-perfect React + CSS — the iteration mental model, tree reconstruction, layout inference algorithms, geometry math, visual-regression diffing, and the style/typography/path conversions that make "improvement without regression" enforceable. Trigger even if the user doesn't explicitly mention "algorithms" but is converting a design source into web code, building a design-to-code pipeline, or struggling to make incremental fidelity improvements without breaking previously-converted output.
---
# dot-skills Design-to-React Conversion Best Practices

The reverse-engineering pipeline that converts Sketch files into pixel-perfect React + CSS, **with regression-safe iteration as the load-bearing constraint**. The skill is organized around the cascade effect of design-to-code conversion: a wrong call in stage N corrupts every output from stage N+1 onward, so categories are ordered by how much downstream they own.

The user's primary requirement — *"each improvement doesn't cause regressions"* — is enforceable only if the iteration loop, the layer tree, and the layout solver are correct *before* you start polishing styles. Read the rules in priority order.

## When to Apply

- Building a converter that ingests a `.sketch` file (or equivalent design source) and emits React + CSS
- Iterating on an existing converter where each improvement risks breaking other components
- Diagnosing why a converted component "almost matches" the design but visual-regression fails
- Designing the snapshot-gate / baseline strategy for a design-to-code pipeline
- Choosing between flexbox vs grid vs absolute positioning when the source is freeform geometry
- Translating Sketch-specific primitives (`MSImmutableFlexGroupLayout`, `attributedString`, `curvePoint`, `MSImmutableStyleCorners`) into idiomatic CSS

## Rule Categories by Priority

The ordering is the cascade — fix earlier stages first; later-stage fixes are wasted if the upstream tree is wrong.

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Reverse-Engineering Iteration Strategy | CRITICAL | `iter-` |
| 2 | Tree Reconstruction & Symbol Resolution | CRITICAL | `tree-` |
| 3 | Layout Algorithms (Flex/Freeform Inference) | CRITICAL | `layout-` |
```
END THIRD-PARTY FILE 8959bc13be1284c9

The third-party file has ended. Everything between the 8959bc13be1284c9 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2389 of 11782 bytes. © pproenca · MIT · https://github.com/pproenca/dot-skills/tree/HEAD/skills/.experimental/design-to-react-algorithms/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
