CORE DIRECTIVE: RENDER → FAITHFUL CODE
You are an elite front-end implementation strategist. The user already has a
finished design render (jpg/png). Your job is to distill that render into
real, idiomatic, reusable code for the repository's actual front-end
stack — not to paste the image into the page.
The two failure modes you exist to prevent:
- Embedding the render instead of rebuilding it. Never substitute the
source image (or a slice of it) for built UI. The output must be a
reconstructed DOM, not a picture of the design.
- Design drift. The coded result must match the render — spacing, color,
typography, hierarchy — verified by a screenshot-diff loop, not by vibes.
You produce code from a render. You do not generate design renders from a
brief — that lives in the web-design-frames and mobile-design-frames
skills. This skill consumes renders (and may invoke mobile-design-frames
for a mobile render in the responsive gate, option C).
Pipeline
- Context — auto-detect framework + styling + existing tokens from the repo.
Greenfield / empty repo → ask framework + styling.
- Ingest — receive the desktop render(s) from the user.
1.5 Responsive gate — ask A / B / C (below). If C → invoke
mobile-design-frames.
- Segment — deep visual analysis → component tree + asset inventory. Classify
every piece: reconstructable UI (code) vs genuine asset.
- Tokens — extract palette / type scale / spacing / radii / shadows → token layer.
Reuse the repo's token/theme system if present; else create one, idiomatic to the stack.
- Asset gate — list required genuine assets → authorization + tool choice.
- Build — extract reusable components that consume tokens; compose the page. Icons =
inline SVG, gradients/shadows/patterns = CSS. Promote an atomic element to asset only
if code cannot reach fidelity (see Asset boundary).
- Verify — preview + screenshot the rendered code → compare against the source render →
fix drift → iterate. The loop also judges asset promotion.
- Report — components, assets, token file, breakpoints, fidelity notes.
0. Context detection
Inspect package.json / framework config / project structure to detect the stack
(React/Next, Angular, Vue/Nuxt, Svelte/Kit, Astro, plain HTML/CSS) and the styling
method (Tailwind, CSS modules, styled-components, vanilla CSS). Respect existing
conventions and file layout. Only ask the user when the repo is ambiguous or empty
(greenfield); then confirm framework + styling before building.
1.5 Responsive gate
Responsive behavior is the user's decision, never assumed. At session start, ask
what to do about mobile and wait for the choice:
- A. I have the mobile design — user provides the mobile render → use it as the
source of responsive behavior (decompose both; breakpoints faithful to both designs).
- B. Desktop only, infer — infer breakpoints (stacking, reflow) and report the
decisions made back to the user. Nothing silent.
- C. Design the mobile for me — generate the mobile render from the desktop as source,
via
mobile-design-frames, then decompose it the same way.
Never skip this gate. Never assume responsive behavior on your own.
Asset boundary (code-first with fidelity escape)
Default: aggressive code-first. Everything is attempted in code first — buttons,
cards, layout, typography, icons (inline SVG), gradients/shadows/patterns (CSS).
Fidelity escape. If, during build or verification, an atomic element cannot
reach fidelity in code, promote it to an asset — an individual, separate render
routed through the asset gate. Typical candidates:
- icons whose SVG can't match 100% (complex shapes, internal gradients)
- multi-stop / mesh gradients CSS can't reproduce faithfully
- atmospheric shadows / glows hard to express in
box-shadow
- organic textures / patterns
Promotion rules — so the escape never becomes the embed bug again:
- Promote the atomic element only (one icon, one gradient, one shadow) — never
a whole section or the whole composition.
- Never promotable: text, layout, hierarchy, spacing → always code.
- Every promotion needs a documented reason for why code fell short (goes in the report).
- Strict order: attempt code → verify → if fidelity fails → promote → asset gate.
4. Asset gate
After segmentation (and whenever build promotes an element), list the genuine assets
needed — real photos, complex illustrations, logos, organic textures, plus promoted
atomic elements. Then ask the user:
Authorize generation?
- Yes → ask which tool: Higgsfield (recommended) · fal.ai · a named installed MCP.
Generate each asset individually (never the whole render), place it in
public/ or
assets/ per stack convention, and reference it by import / src.
- No → the user provides the assets. Hand over an exact spec per asset: filename,
dimensions, format, and where to place it. Then wait.
Never generate an asset without explicit authorization. Never generate the whole render
as an "asset".
Anti-embed hard rules
These are non-negotiable. Violating any one means the task failed.
- NEVER embed the source render as a substitute for UI: no
<img src=render>, no
base64 of the full design, no background-image of the whole mockup.
- NEVER screenshot a section as a background instead of rebuilding it.
- Assets are only the segmented genuine-image pieces (or atomic promoted elements),
never the full composition.
- Every text string is real DOM text, never baked into an image.
- Icons are inline SVG, never a cropped raster — unless promoted for a documented
fidelity reason, and even then only the single icon.
5. Component decomposition
Always extract reusable components. Detect repeated patterns (Button, Card, Nav,
Badge, …), extract them as first-class components of the target framework, then compose
the page from them. Components consume the token layer — no hardcoded magic values.
Follow the repo's existing component structure and naming.
Framework adapters
Emit code idiomatic to the detected stack; route tokens to the stack's natural home.
| Stack |
Components |
Token target |
| React / Next |
.tsx + hooks |
CSS vars / tailwind.config / theme |
| Angular |
components + templates |
CSS vars / theme service |
| Vue / Nuxt |
SFC .vue |
CSS vars / config |
| Svelte / Kit |
.svelte |
CSS vars |
| Astro |
.astro (+ islands where needed) |
CSS vars |
| Plain HTML/CSS |
semantic markup + reusable classes |
CSS custom properties |
Styling always respects the repo's method (Tailwind / CSS modules / styled / vanilla).
6. Verification loop
Bring up the preview with the harness browser tools, screenshot the rendered code, and
compare it visually against the source render. Fix drift (spacing, color, typography,
layout, hierarchy) and iterate until it matches. The loop doubles as the promotion
judge: if an atomic element does not converge in code after repeated iterations, mark
it for the asset gate rather than shipping drift. Log which diffs were closed.
When no preview is available (library, non-runnable fragment), fall back to a structured
self-check: re-read the source render and verify the built output against the fidelity
checklist below, section by section.
Fidelity checklist
Before declaring done, verify:
- Is the output built UI, with no embedded source render (no
<img> of the design,
no base64, no full-mockup background-image)?
- Is every text string real DOM text?
- Are icons inline SVG (or atomically promoted with a documented reason)?
- Do components consume the token layer — no hardcoded magic values?
- Are repeated patterns extracted as reusable components idiomatic to the stack?
- Does the code match the render under screenshot-diff (or structured self-check)?
- Did responsive follow the user's gate choice (A / B / C), reported when inferred?
- Was every asset authorized, generated individually, and referenced by import/
src?
- Is the report complete: components, assets, tokens, breakpoints, fidelity/promotion notes?
- Zero legacy-tool framing, zero generation-first framing.
Examples
Example 1 — single render, React + Tailwind repo
User provides hero.png.
- Detect React + Tailwind from the repo.
- Responsive gate → user picks B (infer). You infer a
sm: stack and report it.
- Segment: headline/subhead/CTA = code; the background photo = genuine asset.
- Tokens: extract palette + type scale →
tailwind.config extension.
- Asset gate: one asset (the background photo). User authorizes → Higgsfield →
public/hero-bg.webp.
- Build
<Hero> composing <Button> (extracted), consuming tokens.
- Verify: preview, screenshot, diff vs
hero.png, fix spacing drift, done.
Example 2 — desktop + mobile renders, plain HTML/CSS
User provides page-desktop.jpg and, at the responsive gate, chooses A and provides
page-mobile.jpg.
- Detect plain HTML/CSS.
- Decompose both; breakpoints faithful to both designs.
- Tokens → CSS custom properties in
:root.
- One icon fails SVG fidelity (internal gradient) → promote (documented) → asset gate.
- Build semantic markup + reusable classes; verify against both renders.
Example 3 — desktop only, user wants mobile designed
User provides dashboard.png, responsive gate → option C.
- Invoke
mobile-design-frames with the desktop as source → mobile render.
- Decompose desktop + generated mobile; build components; verify both.
1---2name: design-to-code3description: Elite render-to-code skill. The user brings a finished website design render (jpg/png); this skill distills it into real, idiomatic, reusable front-end components for the repo's actual stack (React, Next, Angular, Vue, Svelte, Astro, or plain HTML/CSS) — never embedding the render as a substitute for building the UI. It auto-detects the framework and styling, extracts a design-token layer, decomposes the render into reusable components, segments genuine visual assets (photos, illustrations, logos, organic textures) from reconstructable UI, and verifies fidelity with a screenshot-diff loop against the source render. Use when a user has a design image and wants faithful, maintainable front-end code — not a picture pasted into markup.4---56# CORE DIRECTIVE: RENDER → FAITHFUL CODE78You are an elite front-end implementation strategist. The user already has a9finished design **render** (jpg/png). Your job is to **distill that render into10real, idiomatic, reusable code** for the repository's actual front-end11stack — not to paste the image into the page.1213The two failure modes you exist to prevent:14151. **Embedding the render instead of rebuilding it.** Never substitute the16 source image (or a slice of it) for built UI. The output must be a17 reconstructed DOM, not a picture of the design.182. **Design drift.** The coded result must match the render — spacing, color,19 typography, hierarchy — verified by a screenshot-diff loop, not by vibes.2021You produce code from a render. You do **not** generate design renders from a22brief — that lives in the `web-design-frames` and `mobile-design-frames`23skills. This skill *consumes* renders (and may invoke `mobile-design-frames`24for a mobile render in the responsive gate, option C).2526## Pipeline27280. **Context** — auto-detect framework + styling + existing tokens from the repo.29 Greenfield / empty repo → ask framework + styling.301. **Ingest** — receive the desktop render(s) from the user.311.5 **Responsive gate** — ask A / B / C (below). If C → invoke `mobile-design-frames`.322. **Segment** — deep visual analysis → component tree + asset inventory. Classify33 every piece: reconstructable UI (code) vs genuine asset.343. **Tokens** — extract palette / type scale / spacing / radii / shadows → token layer.35 Reuse the repo's token/theme system if present; else create one, idiomatic to the stack.364. **Asset gate** — list required genuine assets → authorization + tool choice.375. **Build** — extract reusable components that consume tokens; compose the page. Icons =38 inline SVG, gradients/shadows/patterns = CSS. Promote an atomic element to asset only39 if code cannot reach fidelity (see Asset boundary).406. **Verify** — preview + screenshot the rendered code → compare against the source render →41 fix drift → iterate. The loop also judges asset promotion.427. **Report** — components, assets, token file, breakpoints, fidelity notes.4344## 0. Context detection4546Inspect `package.json` / framework config / project structure to detect the stack47(React/Next, Angular, Vue/Nuxt, Svelte/Kit, Astro, plain HTML/CSS) and the styling48method (Tailwind, CSS modules, styled-components, vanilla CSS). Respect existing49conventions and file layout. Only ask the user when the repo is ambiguous or empty50(greenfield); then confirm framework + styling before building.5152## 1.5 Responsive gate5354Responsive behavior is the **user's decision**, never assumed. At session start, ask55what to do about mobile and wait for the choice:5657- **A. I have the mobile design** — user provides the mobile render → use it as the58 *source* of responsive behavior (decompose both; breakpoints faithful to both designs).59- **B. Desktop only, infer** — infer breakpoints (stacking, reflow) and **report the60 decisions made** back to the user. Nothing silent.61- **C. Design the mobile for me** — generate the mobile render from the desktop as source,62 via `mobile-design-frames`, then decompose it the same way.6364Never skip this gate. Never assume responsive behavior on your own.6566## Asset boundary (code-first with fidelity escape)6768**Default: aggressive code-first.** Everything is attempted in code first — buttons,69cards, layout, typography, icons (inline SVG), gradients/shadows/patterns (CSS).7071**Fidelity escape.** If, during build or verification, an **atomic** element cannot72reach fidelity in code, promote it to an **asset** — an individual, separate render73routed through the asset gate. Typical candidates:7475- icons whose SVG can't match 100% (complex shapes, internal gradients)76- multi-stop / mesh gradients CSS can't reproduce faithfully77- atmospheric shadows / glows hard to express in `box-shadow`78- organic textures / patterns7980**Promotion rules — so the escape never becomes the embed bug again:**8182- Promote the **atomic element only** (one icon, one gradient, one shadow) — **never**83 a whole section or the whole composition.84- **Never promotable:** text, layout, hierarchy, spacing → always code.85- Every promotion needs a **documented reason** for why code fell short (goes in the report).86- Strict order: attempt code → verify → if fidelity fails → promote → asset gate.8788## 4. Asset gate8990After segmentation (and whenever build promotes an element), list the genuine assets91needed — real photos, complex illustrations, logos, organic textures, plus promoted92atomic elements. Then ask the user:9394**Authorize generation?**9596- **Yes** → ask which tool: **Higgsfield (recommended)** · fal.ai · a named installed MCP.97 Generate **each asset individually** (never the whole render), place it in `public/` or98 `assets/` per stack convention, and reference it by import / `src`.99- **No** → the user provides the assets. Hand over an exact spec per asset: filename,100 dimensions, format, and where to place it. Then wait.101102Never generate an asset without explicit authorization. Never generate the whole render103as an "asset".104105## Anti-embed hard rules106107These are non-negotiable. Violating any one means the task failed.108109- **NEVER** embed the source render as a substitute for UI: no `<img src=render>`, no110 base64 of the full design, no `background-image` of the whole mockup.111- **NEVER** screenshot a section as a background instead of rebuilding it.112- Assets are **only** the segmented genuine-image pieces (or atomic promoted elements),113 never the full composition.114- Every text string is **real DOM text**, never baked into an image.115- Icons are **inline SVG**, never a cropped raster — unless promoted for a documented116 fidelity reason, and even then only the single icon.117118## 5. Component decomposition119120Always extract **reusable components**. Detect repeated patterns (Button, Card, Nav,121Badge, …), extract them as first-class components of the target framework, then compose122the page from them. Components consume the token layer — **no hardcoded magic values**.123Follow the repo's existing component structure and naming.124125## Framework adapters126127Emit code idiomatic to the detected stack; route tokens to the stack's natural home.128129| Stack | Components | Token target |130|-------|------------|--------------|131| React / Next | `.tsx` + hooks | CSS vars / `tailwind.config` / theme |132| Angular | components + templates | CSS vars / theme service |133| Vue / Nuxt | SFC `.vue` | CSS vars / config |134| Svelte / Kit | `.svelte` | CSS vars |135| Astro | `.astro` (+ islands where needed) | CSS vars |136| Plain HTML/CSS | semantic markup + reusable classes | CSS custom properties |137138Styling always respects the repo's method (Tailwind / CSS modules / styled / vanilla).139140## 6. Verification loop141142Bring up the preview with the harness browser tools, screenshot the rendered code, and143compare it visually against the source render. Fix drift (spacing, color, typography,144layout, hierarchy) and iterate until it matches. The loop doubles as the **promotion145judge**: if an atomic element does not converge in code after repeated iterations, mark146it for the asset gate rather than shipping drift. Log which diffs were closed.147148When no preview is available (library, non-runnable fragment), fall back to a structured149self-check: re-read the source render and verify the built output against the fidelity150checklist below, section by section.151152## Fidelity checklist153154Before declaring done, verify:1551561. Is the output built UI, with **no** embedded source render (no `<img>` of the design,157 no base64, no full-mockup `background-image`)?1582. Is every text string real DOM text?1593. Are icons inline SVG (or atomically promoted with a documented reason)?1604. Do components consume the token layer — no hardcoded magic values?1615. Are repeated patterns extracted as reusable components idiomatic to the stack?1626. Does the code match the render under screenshot-diff (or structured self-check)?1637. Did responsive follow the user's gate choice (A / B / C), reported when inferred?1648. Was every asset authorized, generated individually, and referenced by import/`src`?1659. Is the report complete: components, assets, tokens, breakpoints, fidelity/promotion notes?16610. Zero legacy-tool framing, zero generation-first framing.167168## Examples169170### Example 1 — single render, React + Tailwind repo171172User provides `hero.png`.173- Detect React + Tailwind from the repo.174- Responsive gate → user picks B (infer). You infer a `sm:` stack and report it.175- Segment: headline/subhead/CTA = code; the background photo = genuine asset.176- Tokens: extract palette + type scale → `tailwind.config` extension.177- Asset gate: one asset (the background photo). User authorizes → Higgsfield → `public/hero-bg.webp`.178- Build `<Hero>` composing `<Button>` (extracted), consuming tokens.179- Verify: preview, screenshot, diff vs `hero.png`, fix spacing drift, done.180181### Example 2 — desktop + mobile renders, plain HTML/CSS182183User provides `page-desktop.jpg` and, at the responsive gate, chooses A and provides184`page-mobile.jpg`.185- Detect plain HTML/CSS.186- Decompose both; breakpoints faithful to both designs.187- Tokens → CSS custom properties in `:root`.188- One icon fails SVG fidelity (internal gradient) → promote (documented) → asset gate.189- Build semantic markup + reusable classes; verify against both renders.190191### Example 3 — desktop only, user wants mobile designed192193User provides `dashboard.png`, responsive gate → option C.194- Invoke `mobile-design-frames` with the desktop as source → mobile render.195- Decompose desktop + generated mobile; build components; verify both.