screenshot-to-code
Installation
SKILL.md
Screenshot to Code
Produces faithful, maintainable front-end code from a screenshot of a UI the user owns or is licensed to reproduce, plus a list of where the result differs and why.
When to use
- "Recreate this screen in React" or "turn this screenshot into HTML/CSS."
- Rebuilding a legacy product's UI in a new stack when only screenshots remain.
- Converting an exported mockup (PNG) into code without access to the design file.
- Matching an existing internal page so a new page fits in.
Workflow
- Confirm rights. Proceed when the UI is the user's own product, a client's with permission, or an openly licensed template. If it is clearly someone else's product, offer an original layout that borrows only the general structure, and say so. Replace third-party logos, brand marks, and copyrighted photos or illustrations with labeled placeholders.
- Establish scale: detect the device pixel ratio (a 2880px-wide capture of a laptop browser is probably @2x, so halve every measurement) and note the viewport width the screenshot represents.
- Inventory regions top to bottom: header, nav, main, aside, sections, cards, footer, overlays. Assign each a semantic element and list the components inside.
- Measure sizes and gaps in CSS px, then snap to a 4/8 grid (15 becomes 16, 22 becomes 24) unless the source clearly uses another system. Record container max-width and column structure.
- Extract colors from flat interior areas, not anti-aliased edges or compression artifacts; merge near-identical values into one token. Extract type: family, sizes, weights, line heights, letter-spacing.
- Build in order: tokens (CSS custom properties or Tailwind config), layout (grid and flex), components, then content. Use the real text from the screenshot.
- Make it responsive: decide how the layout collapses below the captured width and state those assumptions (see responsive-design).
- Compare: render at the source viewport width, view side by side or overlaid at 50% opacity, fix mismatches, and list what remains.