Skip to content

turinglabsorg/desi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeSi Logo

DeSi — Design-to-Code Skill for Claude Code

A Claude Code skill that creates a pixel-perfect design-to-code workflow using Google Stitch MCP for AI-generated UI designs and browser-use CLI for automated screenshot comparison.

How it works

DESIGN ──▶ IMPLEMENT ──▶ COMPARE ──▶ REFINE ──┐
(Stitch)    (Your code)   (browser-use)         │
                              ◀─────────────────┘
                          (loop until pixel-perfect)
  1. Design — Generate screens with Google Stitch MCP from detailed text prompts
  2. Implement — Extract the design system and apply it to your codebase
  3. Compare — Screenshot your implementation with browser-use, compare to Stitch reference
  4. Refine — Fix every difference (fonts, colors, spacing, radius, shadows, icons)
  5. Repeat — Loop steps 3-4 until pixel-perfect

Prerequisites

Tool Purpose Install
Claude Code AI coding agent npm install -g @anthropic-ai/claude-code
Google Stitch AI UI design generation Get API key at settings
browser-use Headless browser screenshots curl -fsSL https://browser-use.com/cli/install.sh | bash

Install

1. Clone the repo

git clone https://github.com/rifaisiciliadao/desi.git

2. Install as a Claude Code skill

Personal skill (available in all your projects):

mkdir -p ~/.claude/skills
ln -s "$(pwd)/desi" ~/.claude/skills/desi

Project skill (available in one project):

mkdir -p .claude/skills
ln -s /path/to/desi .claude/skills/desi

3. Configure Google Stitch MCP

Get an API key at stitch.withgoogle.com/settings, then:

claude mcp add stitch \
  --transport http https://stitch.googleapis.com/mcp \
  --header "X-Goog-Api-Key: YOUR_API_KEY" \
  -s user

4. Install browser-use

curl -fsSL https://browser-use.com/cli/install.sh | bash

Or run the setup script which checks everything:

bash /path/to/desi/scripts/setup.sh

5. Restart Claude Code

Restart for the Stitch MCP tools to load.

Usage

Invoke directly with /desi:

/desi redesign the homepage hero section
/desi create a modern donation page with tier cards
/desi generate a mobile navigation component
/desi make our checkout page match the Stitch design

Or just discuss UI improvements — Claude will invoke the skill automatically when relevant.

What the skill does

Design generation

  • Creates a Stitch project for your work
  • Generates screen designs from detailed text prompts
  • Downloads the HTML and screenshots as references
  • Opens designs in your browser for review

Design system extraction

From every Stitch output, the skill extracts:

  • Fonts — headline + body families and weights
  • Colors — full palette from Stitch's tailwind config
  • Border radius — card, button, and input corner styles
  • Component patterns — glass cards, buttons, section labels, icons
  • Material Symbols — Google's icon font with filled variants

Implementation

  • Applies design system globally (fonts, tailwind config, CSS)
  • Updates components page by page
  • Never touches logic, routing, i18n, or event handlers — CSS only
  • Ensures consistent max-width and spacing across all pages

Pixel-perfect comparison loop

  • Screenshots your running dev server with browser-use
  • Compares against Stitch reference screenshots
  • Lists every visual difference (fonts, colors, spacing, radius, shadows)
  • Fixes each difference and re-screenshots
  • Loops until the implementation matches the design

Graphic generation (HTML → Image)

DeSi can also generate standalone graphics like Instagram banners, stories, and OG cards:

/desi create Instagram banners to promote our donation feature in Italian

It creates self-contained HTML files at exact pixel dimensions, then converts them to PNG using Playwright:

# Capture a 1080x1080 Instagram post
node /path/to/desi/scripts/capture.mjs banner.html post.png 1080 1080

# Capture a 1080x1920 Instagram story
node /path/to/desi/scripts/capture.mjs story.html story.png 1080 1920

Supported formats

Format Dimensions Use
Instagram square post 1080x1080 Feed posts
Instagram story 1080x1920 Stories, reels cover
Open Graph card 1200x630 Link previews
Twitter card 1200x675 Twitter link previews

One-time setup for capture

cd /tmp && npm install playwright
npx playwright install chromium

File structure

desi/
├── SKILL.md              # Skill entry point (loaded by Claude Code)
├── README.md             # This file (for humans)
├── reference/
│   └── browser-use.md    # Full browser-use CLI command reference
└── scripts/
    ├── setup.sh          # Prerequisite checker/installer
    └── capture.mjs       # HTML-to-image converter (Playwright)

How Stitch MCP works

Google Stitch is a remote MCP server at stitch.googleapis.com/mcp that generates UI designs from text prompts. It provides these tools:

Tool Purpose
create_project Create a design project
list_projects / get_project Browse your projects
generate_screen_from_text Generate a UI screen from a text prompt
edit_screens Edit existing screens with a prompt
generate_variants Create design variants
list_screens / get_screen Retrieve screen HTML and screenshots

The skill teaches Claude to write high-quality Stitch prompts with exact typography, colors, spacing, and component specifications.

How browser-use works

browser-use is a CLI for headless browser automation. The skill uses it to:

browser-use open http://localhost:3000    # Open a page
browser-use screenshot /tmp/page.png     # Capture screenshot
browser-use scroll down                   # Scroll 500px
browser-use keys End                      # Jump to bottom

Screenshots are read by Claude (multimodal) and compared pixel-by-pixel against Stitch references.

Example workflow

Here's what a typical session looks like:

You:    /desi redesign the donation page

Claude: [Creates Stitch project]
        [Generates screen with detailed prompt]
        [Downloads HTML, opens in browser for review]

You:    looks good, implement it

Claude: [Extracts fonts, colors, radius from Stitch HTML]
        [Updates tailwind.config, index.html, index.css]
        [Rewrites Donate.tsx with new classes]
        [Screenshots with browser-use]
        [Compares with Stitch reference]
        [Lists 5 differences: font weight, card radius, icon style...]
        [Fixes each one]
        [Re-screenshots — now matches]

You:    the buttons need to be more rounded

Claude: [Updates button classes]
        [Screenshots again]
        [Confirms match]

License

MIT

About

Design-to-code skill for Claude Code — pixel-perfect UI from Stitch MCP designs with browser-use comparison

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors