A plain-English explanation of what the tool does and how the browser fits in.
See also: CLI reference · Output structure · Architecture · Docs index
design-memory is a CLI tool that learns a design system from a live website (or from a screenshot) and writes it into a folder (.design-memory/) so that you or an AI can reuse the same colors, typography, spacing, components, and layout when building UI.
In one sentence: You give it a URL (or an image); it opens the site in a headless browser, extracts styles and structure, asks an AI to label and explain them, and outputs markdown files and skills that describe the design system.
When you run:
design-memory learn https://stripe.comthe tool runs a pipeline in four stages:
URL (or image / multi-page)
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ 1. ACQUIRE (browser, or image / cache) │
│ One Chromium: crawl, screenshot, computed styles, CSS vars │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ 2. ANALYZE (no browser) │
│ Parse: colors, fonts, spacing, components, motion, etc. │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ 3. INTERPRET (OpenAI) │
│ LLM: roles, doctrine; Vision: layout spec from screenshot │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ 4. PROJECT (no browser) │
│ Write .design-memory/: reference.md, skills/, style, etc. │
└─────────────────────────────────────────────────────────────────┘
│
▼
.design-memory/ (ready for AI or humans to use)
Only stage 1 (Acquire) uses the browser (unless you use --from-image or a cache hit). The rest is data processing and file writing.
We use Playwright to control Chromium in headless mode (no visible window). The browser is used only to load the page and read data from it.
We launch one Chromium process. Inside it we run four jobs in parallel, each in its own page (tab):
| Job | What it does |
|---|---|
| Crawl | Go to the URL, wait for networkidle, optionally wait for SPA hydration, then read the HTML (full DOM). |
| Screenshot | Go to the same URL, set viewport (1920×1080), wait, then take a full-page screenshot (PNG). |
| Computed styles | Go to the same URL, wait, then for semantic elements (headings, buttons, links, etc.) read computed CSS (color, font, padding, motion, etc.) via getComputedStyle(). |
| CSS variables | Go to the same URL, wait, then read custom properties (--*) from :root and body. |
All four run at the same time (Promise.all), so we pay for one browser startup. Each navigation can be retried (e.g. 2 retries with exponential backoff) if the page fails to load.
--from-image <path>— Skip the browser. Use a local image (screenshot or mockup) as the only visual input. Analyze and interpret still run; layout comes from the vision model. No HTML or computed styles.- Multi-page —
learn <url> --pages <url2> <url3>: crawl several URLs with the same browser, then merge HTML, styles, and variables into one design system. - Cache — The first time you run
learnfor a URL, we save the raw capture under.design-memory/.cache/. The next run can reuse it (within 24 hours) and only re-run analyze, interpret, and project (faster, no browser).
- To get real computed styles (after CSS and JS run), not just raw stylesheets.
- To get a screenshot so the vision model can describe layout and sections.
- To get final HTML after client-side rendering (SPAs). We optionally wait for framework hydration (Next.js, React, Vue, etc.) before reading the DOM.
- We don’t click or scroll (except as needed for a full-page screenshot).
- We don’t log in or fill forms.
- We don’t run multiple sites in one run; one
learn= one design system (optionally built from one primary URL + extra pages).
- Input: A URL (e.g.
https://stripe.com), or an image path (--from-image), or a cache key for the URL. - Process:
- URL mode: Launch Chromium (cached path). Create four pages; in parallel (with retry and optional SPA wait):
- Crawl:
page.goto(url)→networkidle→ optionalwaitForSPA→page.content(). - Screenshot:
page.goto(url)→ wait →page.screenshot({ fullPage: true }). - Computed styles:
page.goto(url)→ wait → for each semantic selector getgetComputedStyle()(color, font, spacing, motion, etc.). - CSS variables:
page.goto(url)→ wait → read--*from:rootandbody.
- Crawl:
- Image mode: Read image file, build a minimal bundle (no HTML, no styles; screenshot = image).
- Cache: If cache exists and is fresh, load bundle from disk and skip browser.
- URL mode: Launch Chromium (cached path). Create four pages; in parallel (with retry and optional SPA wait):
- Output: A capture bundle:
{ url, crawl, screenshot, styles, variables }.
- Input: The capture bundle.
- Process: Pure TypeScript:
- Colors — From
color,backgroundColor; normalize to hex; dedupe. - Typography — From
fontFamily,fontSize,fontWeight,lineHeight; build tokens. - Spacing / radius / elevation — From
padding,margin,borderRadius,boxShadow. - Layout — From
display,gridTemplateColumns,flexDirection, etc. - Components — Pattern-based detection (card, nav, hero, footer, form, etc.).
- Motion —
transition,animation,transformfrom computed styles. - Breakpoints — Parse
@media (min|max)-widthfrom inline styles in HTML. - Class / Tailwind — Scan
classattributes; detect Tailwind usage.
- Colors — From
- Output: A partial design IR (tokens without semantic roles or doctrine).
- Input: Partial IR + screenshot + your OpenAI API key.
- Process:
- Colors → LLM assigns roles (primary, text, muted, etc.) and usage.
- Typography → LLM assigns roles (heading, body, caption, etc.).
- Components → LLM enriches with usage, do’s and don’ts.
- Doctrine → LLM produces principles, constraints, anti-patterns.
- Layout spec → Vision model describes sections (hero, features, etc.) from the screenshot.
- Output: Full design IR + layout spec.
- Input: Full IR + layout spec + URL + optional project root.
- Process: Write
.design-memory/:- Core files:
INSTRUCTIONS.md,principles.md,style.md,layout.md,components.md,motion.md,qa.md. - reference.md — Single consolidated file (tokens, Tailwind snippet, palette, typography, components, layout, breakpoints, principles).
- skills/ — One file per skill (design-system, color-palette, typography, component-patterns, layout-structure, motion-guidelines) for AI replication.
- Optionally append a design-reference block to
CLAUDE.mdor.cursorrulesin the project root.
- Core files:
- Output: A folder that an AI (e.g. Cursor) or a human can use to replicate the design.
After design-memory learn <url>:
- .design-memory/ in your project root (or the path you passed).
- reference.md — One place for tokens, Tailwind, and guidelines (paste into prompts or use with AI).
- skills/ — Structured instructions so an AI can follow the design system precisely.
- Other markdown files for principles, style, layout, components, motion, and QA.
So the “feature” is: turn a live website (or image) into a written design system so it can be reused consistently by humans and AI.
| Stage | Uses browser? | Uses OpenAI? | Input | Output |
|---|---|---|---|---|
| Acquire | Yes (or image/cache) | No | URL / image | HTML, screenshot, styles, variables |
| Analyze | No | No | Capture bundle | Partial IR (tokens) |
| Interpret | No | Yes | Partial IR + screenshot | Full IR + layout spec |
| Project | No | No | Full IR + layout spec | .design-memory/* |
| Command | What it does |
|---|---|
design-memory learn <url> |
Full pipeline; create/update .design-memory/. Supports --from-image, --pages, --no-cache. |
design-memory install |
Detect project (Next/Vite/CRA/plain + Tailwind), write tokens to globals.css, tailwind config, and optional design-tokens.ts. |
design-memory diff <url-a> <url-b> |
Learn both URLs, compare design systems, write a diff report (e.g. design-diff.md). |
design-memory add <pkg> |
Stub. |
design-memory mix |
Stub. |
Only learn uses the browser (in URL mode, when not using cache or --from-image). For full options, see CLI reference.