End-to-End Walkthrough

This walkthrough covers the complete Layout workflow, from pasting a URL to having your AI agent automatically generate on-brand UI. Each step builds on the previous one, so read it in order the first time through.

Just want the CLI? Run npx @layoutdesign/context install to configure the MCP server for Claude Code, Cursor, Windsurf, Copilot, Codex, or Gemini CLI — then skip to step 7. Three free starter kits are bundled so you can test without extracting first. See the CLI guide for the full reference.

1. Extract from Figma

Paste a Figma file URL (e.g. https://www.figma.com/file/AbCdEf/My-Design-System) on the Studio home screen and enter your Figma Personal Access Token. You can create one at Figma → Settings → Account → Personal access tokens. The token is stored only in your browser and is never sent to Layout servers.

Layout calls the Figma REST API in two passes: first to list styles and component metadata, then to resolve actual values for each node. The following data is extracted:

What Gets ExtractedDetails
Colour stylesActual fill values resolved via node API, not just metadata
Typography stylesFont family, size, weight, line-height, and letter-spacing as composites
Effect stylesDrop shadows, inner shadows, and blur values
Component inventoryName, description, variant count, and property definitions for every component
VariablesEnterprise plans only. The Variables API returns 403 on free/professional plans, which is treated as non-fatal and skipped automatically
The Figma Variables API returns 403 on non-Enterprise plans. This is expected. Layout treats it as non-fatal and continues extraction using colour and typography styles instead. You will still get a complete layout.md.

2. Extract from a Website

No Figma file? Paste any live website URL instead. Layout uses Playwright to load the page in a headless browser and extract design data directly from the rendered DOM and computed styles. This works on any public website, whether it is your own staging environment, a competitor site, or a design reference you admire.

The following is extracted from the live page:

What Gets ExtractedDetails
CSS custom propertiesEvery --variable declaration found on the page
Font declarations@font-face rules and computed font families in use
Computed stylesColours, typography, spacing, borders, shadows, and transitions sampled from DOM elements
Animations@keyframes rules defined in the page stylesheets
Library detectionIdentifies Tailwind CSS, Bootstrap, and other CSS frameworks
ScreenshotsFull-page and viewport captures for visual reference
Website extraction uses Playwright and cannot run on Vercel serverless. Self-hosted deployments on Coolify, Hetzner, or Railway work without any extra configuration.

3. Generate layout.md

Once extraction completes, click Generate layout.md in the Studio. Claude Sonnet analyses the raw extracted data and synthesises a structured, LLM-optimised context file. Generation typically finishes in under 2 minutes and streams into the editor in real time.

The output follows a fixed 9-section structure with 2 appendices:

SectionContents
Quick ReferenceOne-page cheat sheet with the most important tokens and rules at a glance
1. Colour SystemAll colour tokens with hex values and usage guidance
2. TypographyType scale, font families, weights, and line-heights
3. Spacing & LayoutSpacing scale and grid conventions
4. Component SpecsPer-component usage rules, variants, and TSX code examples
5. Elevation & DepthShadow tokens and z-index scale
6. Motion & AnimationDuration values, easing curves, and animation patterns
7. Border & RadiusBorder widths, styles, and border-radius scale
8. Anti-PatternsExplicit list of what the AI must not do, including hardcoded colours, wrong tokens, and off-brand patterns
9. Icons & AssetsIcon library in use and asset conventions
Appendix ARaw CSS custom properties from the extraction
Appendix BRaw typography declarations
The Quick Reference section is the highest-value part of layout.md. It is placed at the top because most AI agents read context top-to-bottom and may truncate long files. If you manually edit layout.md, prioritise keeping the Quick Reference accurate.

4. The Studio

After generation completes, the Studio opens with two modes: Editor mode and Explore mode. All changes auto-save to browser storage with a 2-second debounce. There is no Save button and no account required.

Source Panel (left)

Displays the raw extracted data: colour tokens, typography styles, spacing values, component inventory, and screenshots. Use this to verify what was captured before or after generation. If something is missing or misidentified, you can re-extract without losing any edits made in the editor.

Editor Mode (Source Panel + Monaco Editor)

A Monaco-based markdown editor, the same editor used in VS Code. This is where you refine layout.md: fix misidentified tokens, strengthen the anti-patterns section, rewrite component specs, or add brand guidance that extraction cannot infer. Section navigation pills let you jump between the 9 sections quickly. An AI edit bar below the editor lets you make targeted changes using natural language prompts.

Explore Mode (Source Panel + Explorer)

The Explorer is the AI generation surface. Generate multiple component variants simultaneously, compare output with and without layout.md in a side-by-side comparison view, check the per-variant health score, and iterate until the AI reliably produces on-brand output. You can also push variants to Figma directly from the canvas.

5. Test Your Context

The Explorer is the most important step before exporting. It tells you whether layout.md actually improves AI output, and by how much.

Comparison View

The comparison view generates variants side by side, with and without layout.md context. Run a prompt and compare the two results directly. A well-written context file produces noticeably better output: correct token usage, proper spacing, on-brand typography, and no hardcoded colours. This A/B comparison is the clearest signal that your layout.md is working.

Quick Prompts

Preset component requests appear as one-click buttons in the Explorer: primary button, card, form input, badge, and more. If your extraction included Figma components, the Explorer also generates dynamic prompts for each extracted component name, giving you targeted tests for your specific design system rather than generic UI patterns.

Health Score

Each generated variant in the Explorer shows a 0-100 health score measuring token faithfulness, component accuracy, and anti-pattern violations. The score reflects how closely the generated code follows the rules in layout.md. Aim for 80 or higher before exporting.

Live Variant Preview

Each variant card in the Explorer renders the generated TSX live in a sandboxed iframe with React and Tailwind CSS loaded. You see the actual component, not just code, so visual errors such as wrong colours or broken layouts are immediately obvious without leaving the Studio.

If the health score is consistently below 60, check that the Colour System and Typography sections of layout.md contain well-formed CSS code blocks. The AI needs concrete, parseable examples to reference at generation time. Prose descriptions alone are not enough.

6. Export Your AI Kit

Click Export in the top bar to open the export modal. layout.md is always included. The ZIP bundle can contain up to 8 additional files, each optimised for a different AI tool or framework:

FileOptimised For
layout.mdAll AI agents. The primary context file
CLAUDE.mdClaude Code. Persistent project context injected on every prompt
AGENTS.mdCodex, Jules, Factory, Amp. Agents following the agents.md convention
.cursorrulesCursor. Legacy rules format applied across all Composer and Chat sessions
copilot-instructions.mdGitHub Copilot. Workspace instructions file read by Copilot Chat
.windsurfrulesWindsurf. Global rules applied to all Cascade sessions in the project
tokens.cssAny stylesheet. CSS custom properties ready to import directly
tokens.jsonStyle Dictionary, Theo, and W3C DTCG-compatible tooling
tailwind.config.jsTailwind CSS. Theme extension with extracted colours, spacing, and radii
The tailwind.config.js uses theme.extend so it merges with your existing config without overwriting defaults. tokens.css can be imported at the top of your global stylesheet with no modifications required.

7. Set Up the CLI

The @layoutdesign/context CLI imports your Studio export and configures the MCP server so your AI agent automatically reads the design system on every session. Two commands are all that is needed:

bash
npx @layoutdesign/context import ./layout-export.zip
npx @layoutdesign/context install

The import command unpacks the ZIP into a .layout/ directory in your project. The install command detects Claude Code, Cursor, Windsurf, Copilot, Codex, and Gemini CLI and writes the MCP server configuration to whichever are present. No manual JSON editing required.

After running install, restart your AI agent once so it picks up the new MCP server configuration. From that point on, every session in the project directory has automatic access to the design system tools.

8. MCP Tools Reference

Once the MCP server is configured, your AI agent can call 14 tools automatically when building UI. You do not need to invoke them manually. The agent decides when to use them based on the task.

ToolWhat It Does
get_design_systemReturns the full layout.md, or a specific section by number
get_tokensReturns CSS, JSON, or Tailwind tokens filtered by type (colour, spacing, etc.)
get_componentReturns the spec and TSX code example for a named component
list_componentsReturns the full inventory of components in the design system
check_complianceValidates a code snippet against design rules and returns violations
previewRenders a component in a local browser canvas at localhost:4321
push_to_figmaSends a rendered component to Figma as editable frames. Supports capture (default) and native mode (editable auto-layout objects, no Playwright needed)
push_tokens_to_figmaPushes design system tokens to Figma as native variables and styles via Figma MCP
url_to_figmaCaptures a public URL as editable Figma frames with auto-layout via Figma MCP and Playwright
design_in_figmaDesigns UI directly in Figma using extracted tokens from a natural language prompt
update_tokensUpdates or adds design tokens in the loaded kit in CSS, JSON, or Tailwind format
get_screenshotsReturns screenshots captured during website extraction for visual reference
scan_projectScans for React components and Storybook stories. Auto-runs on startup so agents reuse existing code.
check_setupDiagnoses and auto-fixes MCP setup issues (Figma transport, OAuth, plugin shadows)

9. The Figma Workflow

Layout bridges the gap between code and design. Preview components locally at localhost:4321, push them to Figma for designer review, and design directly in Figma using the extracted tokens. A typical workflow looks like this:

text
Developer prompts Claude
  -> Claude calls get_design_system for context
  -> Claude generates on-brand TSX
  -> Claude calls preview -> renders at localhost:4321
  -> Developer reviews, requests changes
  -> Claude calls push_to_figma -> frames placed in Figma
  -> Designer reviews and refines using the same tokens
  -> Developer uses Figma MCP to read designer feedback

Each step uses the same design tokens extracted from the source. The AI generates code with the tokens, the preview renders using Tailwind, and the Figma frames reference the same values, keeping code and design aligned.

The push_to_figma and design_in_figma tools require the Figma MCP server to be configured in your AI agent separately. See the Figma MCP documentation for setup instructions.

10. Tips & Troubleshooting

Health Score Ranges

ScoreWhat It Means
80-100Excellent. layout.md is providing strong, reliable context. Safe to export and ship.
60-79Good. Context is working but some tokens or anti-patterns may be ignored. Review the weakest sections before exporting.
Below 60Needs work. The AI is not reliably following your design system. Check that CSS code blocks are well-formed and the anti-patterns section is explicit.

Re-Extracting After a Design Update

When the design system changes (new brand colours, updated type scale, redesigned components), paste the URL again on the home screen and re-extract. The Studio loads the updated data into the Source panel. You can then re-generate layout.md or manually update only the changed sections in the editor.

Comparison View A/B Testing

The comparison view in the Explorer is the fastest way to validate whether layout.md is providing value. Generate variants with and without context side by side using the same prompt. If the output looks identical, the context file is not doing its job and needs strengthening. Focus on the Quick Reference section and the anti-patterns list first.

Free Starter Kits

If you want to try the CLI without extracting a design system first, three free starter kits are bundled with the package. Each was extracted from a live website using Playwright and includes a Quick Reference, core tokens, and 5 component specs, enough to get meaningful on-brand output immediately.

KitAesthetic
linear-liteDeveloper tool, dark-first, minimal
stripe-liteClean, trust-focused, enterprise
notion-liteDocument-first, typography-heavy, neutral
bash
npx @layoutdesign/context init --kit linear-lite
npx @layoutdesign/context init --kit stripe-lite
npx @layoutdesign/context init --kit notion-lite
Starter kits are a good way to test your AI agent integration end to end before committing to a full extraction. Import a kit, run install, and verify the MCP tools are working before bringing in your own design system.

Next Steps

  • Studio Guide. Deeper reference for the editor, Explorer, and all extraction options.
  • CLI Guide. Full CLI command reference including kit management and auto-configure options.
  • layout.md Spec. The formal specification for each section of the context file.
  • Claude Code Integration. Add the export files to your project for persistent on-brand context.
  • Cursor Integration. Set up MDC rules files for Cursor 0.43+.