К основному содержанию
скилл CX Codex

design-to-react-algorithms — скилл для Claude Code: как установить

Скилл design-to-react-algorithms задаёт алгоритмический пайплайн переноса макетов Sketch и Figma в чистый React с CSS без регрессий вёрстки.

MIT 142 установок ★ 227 обновлён 2026-08-15

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add pproenca/dot-skills --skill design-to-react-algorithms -a claude-code
Открыть на GitHub

Что делает design-to-react-algorithms

Пайплайн разбит на восемь приоритетных уровней с префиксами от iter- до path-. Главное правило — каскад зависимостей: ошибка в дереве слоёв или геометрии ломает все нижележащие этапы. Сначала извлекаются дизайн-токены в CSS-переменные и топологически сортируются символы. Только потом генерируются компоненты.

Для геометрии скилл требует перемножать 2D-аффинные матрицы предков и переносить дробные координаты до границы вывода в CSS. Свободное позиционирование преобразуется во Flexbox через проекции на разделяющие оси, а CSS Grid выявляется кластеризацией координат с допуском ε.

Для визуальных тестов обычный попиксельный diff не годится: сглаживание шрифтов даёт ложные срабатывания. Скилл фиксирует проверку через метрику SSIM с бюджетами допуска — 0.99 для текста и 0.95 для градиентов.

Какие задачи решает

  • разобрать геометрию макета Sketch или Figma на структуру Flexbox и Grid
  • предотвратить поломку готовых компонентов при доработке конвертера
  • настроить визуальное тестирование через SSIM с порогами для текста и графики
  • преобразовать примитивы MSImmutableFlexGroupLayout в семантический CSS

Примеры запросов агенту

  • Сконвертируй этот артборд из Sketch в компонент React, используя алгоритм проекций для флексбокса
  • Проверь расхождения вёрстки карточки через SSIM и покажи ошибки выше порога 0.99 для текста
  • Разбери дерево символов с переопределениями overrideValues перед генерацией пропсов

Как установить design-to-react-algorithms

1Через Skills CLI (Vercel)

npx skills add pproenca/dot-skills --skill design-to-react-algorithms -a claude-code

2Вручную: положить файлы

~/.claude/skills/design-to-react-algorithms/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/design-to-react-algorithms/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о design-to-react-algorithms

Как установить design-to-react-algorithms в Claude Code?

Выполните команду npx skills add pproenca/dot-skills --skill design-to-react-algorithms -a claude-code. Файл навыка будет записан по пути ~/.claude/skills/design-to-react-algorithms/SKILL.md.

Что делает скилл design-to-react-algorithms?

Он предоставляет агенту правила и алгоритмы для конвертации макетов Sketch в код на React и CSS. Навык описывает разбор деревьев слоёв, преобразование свободных координат во Flexbox и Grid, а также защиту от регрессий.

Почему скилл требует алгоритм SSIM вместо попиксельного сравнения?

Попиксельный diff даёт постоянные ложные срабатывания из-за сглаживания текста. SSIM оценивает структурное сходство с заданными порогами точности для разных типов контента.

Исходный текст

SKILL.md · MIT
---
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-` |
| 4 | Coordinate & Geometry Math | HIGH | `geom-` |
| 5 | Visual Regression & Diff Algorithms | HIGH | `diff-` |
| 6 | Style Translation (Color, Gradient, Shadow, Border) | MEDIUM-HIGH | `style-` |
| 7 | Typography Math | MEDIUM | `type-` |
| 8 | Path & Shape Rendering | MEDIUM | `path-` |

## Quick Reference

### 1. Reverse-Engineering Iteration Strategy (CRITICAL)

- [`iter-bisect-from-root`](references/iter-bisect-from-root.md) — Convert top-down, bisect bottom-up to localize regressions in O(log n)
- [`iter-baseline-snapshot-gate`](references/iter-baseline-snapshot-gate.md) — Every change must pass committed baselines before merge
- [`iter-convert-symbols-before-instances`](references/iter-convert-symbols-before-instances.md) — Topologically sort symbols → instances; never inline duplicates
- [`iter-freeze-design-tokens-first`](references/iter-freeze-design-tokens-first.md) — Extract sharedSwatches/layerStyles to CSS variables BEFORE any component
- [`iter-one-family-per-pr`](references/iter-one-family-per-pr.md) — Scope conversions to one component family per iteration
- [`iter-keep-known-good-branch`](references/iter-keep-known-good-branch.md) — Maintain a baseline branch as a three-way regression triage anchor

### 2. Tree Reconstruction & Symbol Resolution (CRITICAL)

- [`tree-resolve-overrides-before-emit`](references/tree-resolve-overrides-before-emit.md) — Apply `overrideValues` against master into named props
- [`tree-hash-subtrees-for-componentization`](references/tree-hash-subtrees-for-componentization.md) — Structural hashing finds repetition designers missed
- [`tree-collapse-passthrough-groups`](references/tree-collapse-passthrough-groups.md) — Drop no-style single-child groups; preserve world coords
- [`tree-hoist-shared-style-via-subtree-equivalence`](references/tree-hoist-shared-style-via-subtree-equivalence.md) — Subtree equivalence + modifier classes, not per-property dedup
- [`tree-clipping-mask-is-stacking-context`](references/tree-clipping-mask-is-stacking-context.md) — `hasClippingMask` requires `isolation: isolate` + clip-path
- [`tree-foreign-symbols-become-library-imports`](references/tree-foreign-symbols-become-library-imports.md) — Foreign symbols are package imports, not duplicates

### 3. Layout Algorithms (CRITICAL)

- [`layout-flex-group-enum-mapping`](references/layout-flex-group-enum-mapping.md) — Map `MSImmutableFlexGroupLayout` enums 1:1 to CSS flex properties
- [`layout-infer-flex-from-axis-projection-overlap`](references/layout-infer-flex-from-axis-projection-overlap.md) — 1D separating-axis test for freeform → flex row/column
- [`layout-detect-grid-via-2d-coordinate-clustering`](references/layout-detect-grid-via-2d-coordinate-clustering.md) — Cluster edge coordinates with ε to detect CSS Grid
- [`layout-promote-freeform-when-equal-gaps`](references/layout-promote-freeform-when-equal-gaps.md) — Equal gaps within tolerance → `display: flex; gap: Npx`
- [`layout-reverse-engineer-padding-not-margin`](references/layout-reverse-engineer-padding-not-margin.md) — Insets become parent padding; rebase children
- [`layout-preserve-wrapping-enabled`](references/layout-preserve-wrapping-enabled.md) — `wrappingEnabled` is the only way the source signals responsive intent
- [`layout-ignore-layout-is-absolute-escape`](references/layout-ignore-layout-is-absolute-escape.md) — `flexItem.ignoreLayout: true` → `position: absolute` over `position: relative` parent

### 4. Coordinate & Geometry Math (HIGH)

- [`geom-compose-parent-transforms-before-emit`](references/geom-compose-parent-transforms-before-emit.md) — Compose 2D affine matrices, don't concatenate raw x/y
- [`geom-round-only-at-leaves`](references/geom-round-only-at-leaves.md) — Carry floats through; round once at the CSS boundary
- [`geom-rotation-is-css-transform`](references/geom-rotation-is-css-transform.md) — Frame is unrotated AABB; emit `transform: rotate()`
- [`geom-shape-group-bounds-via-union`](references/geom-shape-group-bounds-via-union.md) — Bounds = axis-aligned union of children, rebase to origin
- [`geom-clipping-bounds-intersect-not-union`](references/geom-clipping-bounds-intersect-not-union.md) — Nested clips intersect; never union or replace

### 5. Visual Regression & Diff Algorithms (HIGH)

- [`diff-use-ssim-for-aa-content`](references/diff-use-ssim-for-aa-content.md) — SSIM for antialiased content; raw pixel diff false-positives on every retest
- [`diff-region-budgeted-tolerances`](references/diff-region-budgeted-tolerances.md) — Per-region SSIM floors (text 0.99, gradient 0.95, image 1.0)
- [`diff-antialias-aware-pixelmatch-threshold`](references/diff-antialias-aware-pixelmatch-threshold.md) — Pixelmatch `includeAA: false` for icon defect detection
- [`diff-perceptual-hash-for-wrong-component-detection`](references/diff-perceptual-hash-for-wrong-component-detection.md) — Hamming distance buckets route triage automatically
- [`diff-subtree-bisection-to-localize-regression`](references/diff-subtree-bisection-to-localize-regression.md) — Disable subtrees in binary search to find the offending node
- [`diff-baseline-per-component-not-per-page`](references/diff-baseline-per-component-not-per-page.md) — Storybook per-story snapshots; scope = blast radius

### 6. Style Translation (MEDIUM-HIGH)

- [`style-srgb-float-to-hex-via-gamma-correct-path`](references/style-srgb-float-to-hex-via-gamma-correct-path.md) — Sketch sRGB floats are already gamma-encoded; direct conversion only
- [`style-preserve-display-p3`](references/style-preserve-display-p3.md) — `colorSpace: 1` → emit `color(display-p3 …)` with sRGB fallback
- [`style-gradient-angle-via-atan2`](references/style-gradient-angle-via-atan2.md) — `atan2(dx, -dy)` reframes Sketch vector to CSS gradient angle
- [`style-stack-multi-shadow-in-paint-order`](references/style-stack-multi-shadow-in-paint-order.md) — Reverse shadow array — Sketch paints last-first, CSS first-last
- [`style-reconcile-border-position`](references/style-reconcile-border-position.md) — Border position 0/1/2 → frame expansion or `outline` for outside
- [`style-per-corner-radii-shorthand`](references/style-per-corner-radii-shorthand.md) — Per-corner radii map to `TL TR BR BL` clockwise (not Sketch's row order)

### 7. Typography Math (MEDIUM)

- [`type-split-attributed-string-runs-only-when-differ`](references/type-split-attributed-string-runs-only-when-differ.md) — Coalesce identical adjacent attribute runs; single-run case needs no inner span
- [`type-pt-lineheight-to-unitless`](references/type-pt-lineheight-to-unitless.md) — `lineHeight / fontSize` → CSS unitless that scales with the font
- [`type-kerning-pt-to-em-letter-spacing`](references/type-kerning-pt-to-em-letter-spacing.md) — `kerning / fontSize` → em-relative `letter-spacing`
- [`type-build-font-fallback-ladder`](references/type-build-font-fallback-ladder.md) — Sketch family → web stack; SF Pro needs `-apple-system, BlinkMacSystemFont, …`
- [`type-paragraph-spacing-between-not-after`](references/type-paragraph-spacing-between-not-after.md) — Use `gap` on the parent, not `margin-bottom` with `:last-child`

### 8. Path & Shape Rendering (MEDIUM)

- [`path-curve-point-to-svg-cubic-bezier`](references/path-curve-point-to-svg-cubic-bezier.md) — `M` + per-segment `C` from `curveFrom`/`curveTo`
- [`path-rectangle-with-fixed-radius-is-css`](references/path-rectangle-with-fixed-radius-is-css.md) — Detect axis-aligned rounded rects early; emit `<div>` not `<svg>`
- [`path-apple-smooth-corners-via-superellipse`](references/path-apple-smooth-corners-via-superellipse.md) — Apple smooth corners are superellipses (n≈5), not circular arcs
- [`path-flatten-boolean-ops-at-parse-time`](references/path-flatten-boolean-ops-at-parse-time.md) — Resolve union/subtract via paper.js in Node; ship one flat path
- [`path-honor-winding-rule`](references/path-honor-winding-rule.md) — `windingRule` 0/1 → SVG `fill-rule` nonzero/evenodd; explicit, not default

## How to Use

1. **Read [`references/_sections.md`](references/_sections.md)** for category definitions and the cascade rationale
2. **Start with the iteration strategy (`iter-*`)** — without the regression gate, every other rule is just techniques
3. **Then tree (`tree-*`) and layout (`layout-*`)** — these are the load-bearing structural decisions
4. **Then geometry (`geom-*`) and diff (`diff-*`)** — these are the precision and validation layers
5. **Style, type, and path** are the polish layer — high fidelity but mostly local impact

For a brand-new converter, follow the rules in priority order. For an existing converter, identify which stage owns the regression you're seeing (use [[diff-subtree-bisection-to-localize-regression]] + [[diff-perceptual-hash-for-wrong-component-detection]] to triage) and fix at the highest stage that owns it.

## Reference Files

| File | Description |
|------|-------------|
| [references/_sections.md](references/_sections.md) | Category definitions, impact levels, cascade rationale |
| [assets/templates/_template.md](assets/templates/_template.md) | Template for adding new rules to this skill |
| [metadata.json](metadata.json) | Version, discipline, references |
| [AGENTS.md](AGENTS.md) | Auto-built TOC (regenerate via `scripts/build-agents-md.js`) |

© pproenca · MIT · pproenca/dot-skills

Похожие скиллы

Все скиллы по теме «Фронтенд и UI» →
ui-design-system Alireza Rezvani Скилл ui-design-system для Claude Code собирает дизайн-токены, палитры, типографику и структуру компонентов. Помогает создавать дизайн-системы и передавать макеты разработчикам. CX Codex +1 1 076установок figma-design-handoff OrchestKit Скилл figma-design-handoff для Claude Code помогает переносить макеты Figma в код и описывать компоненты. Включается при подготовке дизайн-токенов, разборе Dev Mode или сравнении интерфейса с макетом. CX Codex +1 136установок design-system-engineer josstei Субагент design-system-engineer проектирует иерархию дизайн-токенов, строит контракты API для компонентов и настраивает переключение тем без прямого указания цветов и отступов в коде. CX Codex ★ 489звёзд репо tailwindcss-advanced-design-systems JosiahSiegel Скилл tailwindcss-advanced-design-systems для Claude Code помогает собирать дизайн-системы на Tailwind v4. Активируется при настройке @theme, токенов и тем для нескольких брендов. CX Codex +1 659установок brand-design-md podo Скилл brand-design-md загружает дизайн-токены известных брендов вроде Stripe или Linear и применяет их цвета, шрифты и отступы в коде проекта. CX Codex +1 224установок design-tokens-sync OneWave-AI Скилл design-tokens-sync для Claude Code ищет расхождения между эталонными дизайн-токенами и стилями интерфейса. Находит захардкоженные цвета, устаревшие копии и забытые токены в кодовой базе. CX Codex +1 107установок

Из того же набора139

Весь набор →
base-ui-migrator Скилл base-ui-migrator переводит React-компоненты с Radix UI, Headless UI или самописных оверлеев на Base UI (@base-ui/react). Помогает стандартизировать интерфейс без потери стилей. CX Codex +1 144установок implementation-design-patterns-python Скилл implementation-design-patterns-python для Claude Code помогает выбирать и применять паттерны проектирования в современном Python. Он помогает разбираться с разрастающимися ветвлениями, наследованием и связями между объектами. CX Codex +1 143установок better-auth-scaffold Скилл better-auth-scaffold раскладывает Better Auth по файлам в проекте Next.js с App Router и Drizzle: шаблоны, три набора плагинов, генерация схемы и миграции. CX Codex +1 143установок expo-ui Скилл помогает писать и проверять React Native-интерфейсы на @expo/ui для iOS. Пригодится при переносе экранов на SwiftUI и работе с компонентами iOS 26. CX Codex +1 142установок acceptance-pipeline-catalog Скилл acceptance-pipeline-catalog направляет агента при сборке и отладке пайплайна приёмочных тестов на базе Gherkin и мутационного тестирования по спецификации Роберта Мартина. CX Codex +1 142установок nuqs-codemod-runner Скилл nuqs-codemod-runner находит устаревшие паттерны nuqs версий до 2.5, показывает сухой отчёт изменений и безопасно переписывает код с проверкой типов и линтером. CX Codex +1 142установок inngest-nextjs-patterns Скилл inngest-nextjs-patterns для Claude Code собирает шаблоны Inngest для фоновых задач в Next.js App Router: клиент, обработчик, типизированные события, cron и функции с шагами. CX Codex +1 141установок acceptance-pipeline-feature-design Скилл acceptance-pipeline-feature-design помогает спроектировать расширения Acceptance Pipeline: от синтаксиса Gherkin и полей JSON IR до новых стадий и форматов отчётов. CX Codex +1 141установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой