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.
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 Extracted | Details |
|---|---|
| Colour styles | Actual fill values resolved via node API, not just metadata |
| Typography styles | Font family, size, weight, line-height, and letter-spacing as composites |
| Effect styles | Drop shadows, inner shadows, and blur values |
| Component inventory | Name, description, variant count, and property definitions for every component |
| Variables | Enterprise plans only. The Variables API returns 403 on free/professional plans, which is treated as non-fatal and skipped automatically |
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 Extracted | Details |
|---|---|
| CSS custom properties | Every --variable declaration found on the page |
| Font declarations | @font-face rules and computed font families in use |
| Computed styles | Colours, typography, spacing, borders, shadows, and transitions sampled from DOM elements |
| Animations | @keyframes rules defined in the page stylesheets |
| Library detection | Identifies Tailwind CSS, Bootstrap, and other CSS frameworks |
| Screenshots | Full-page and viewport captures for visual reference |
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:
| Section | Contents |
|---|---|
| Quick Reference | One-page cheat sheet with the most important tokens and rules at a glance |
| 1. Colour System | All colour tokens with hex values and usage guidance |
| 2. Typography | Type scale, font families, weights, and line-heights |
| 3. Spacing & Layout | Spacing scale and grid conventions |
| 4. Component Specs | Per-component usage rules, variants, and TSX code examples |
| 5. Elevation & Depth | Shadow tokens and z-index scale |
| 6. Motion & Animation | Duration values, easing curves, and animation patterns |
| 7. Border & Radius | Border widths, styles, and border-radius scale |
| 8. Anti-Patterns | Explicit list of what the AI must not do, including hardcoded colours, wrong tokens, and off-brand patterns |
| 9. Icons & Assets | Icon library in use and asset conventions |
| Appendix A | Raw CSS custom properties from the extraction |
| Appendix B | Raw typography declarations |
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.
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:
| File | Optimised For |
|---|---|
| layout.md | All AI agents. The primary context file |
| CLAUDE.md | Claude Code. Persistent project context injected on every prompt |
| AGENTS.md | Codex, Jules, Factory, Amp. Agents following the agents.md convention |
| .cursorrules | Cursor. Legacy rules format applied across all Composer and Chat sessions |
| copilot-instructions.md | GitHub Copilot. Workspace instructions file read by Copilot Chat |
| .windsurfrules | Windsurf. Global rules applied to all Cascade sessions in the project |
| tokens.css | Any stylesheet. CSS custom properties ready to import directly |
| tokens.json | Style Dictionary, Theo, and W3C DTCG-compatible tooling |
| tailwind.config.js | Tailwind CSS. Theme extension with extracted colours, spacing, and radii |
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:
npx @layoutdesign/context import ./layout-export.zip
npx @layoutdesign/context installThe 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.
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.
| Tool | What It Does |
|---|---|
| get_design_system | Returns the full layout.md, or a specific section by number |
| get_tokens | Returns CSS, JSON, or Tailwind tokens filtered by type (colour, spacing, etc.) |
| get_component | Returns the spec and TSX code example for a named component |
| list_components | Returns the full inventory of components in the design system |
| check_compliance | Validates a code snippet against design rules and returns violations |
| preview | Renders a component in a local browser canvas at localhost:4321 |
| push_to_figma | Sends a rendered component to Figma as editable frames. Supports capture (default) and native mode (editable auto-layout objects, no Playwright needed) |
| push_tokens_to_figma | Pushes design system tokens to Figma as native variables and styles via Figma MCP |
| url_to_figma | Captures a public URL as editable Figma frames with auto-layout via Figma MCP and Playwright |
| design_in_figma | Designs UI directly in Figma using extracted tokens from a natural language prompt |
| update_tokens | Updates or adds design tokens in the loaded kit in CSS, JSON, or Tailwind format |
| get_screenshots | Returns screenshots captured during website extraction for visual reference |
| scan_project | Scans for React components and Storybook stories. Auto-runs on startup so agents reuse existing code. |
| check_setup | Diagnoses 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:
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 feedbackEach 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.
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
| Score | What It Means |
|---|---|
| 80-100 | Excellent. layout.md is providing strong, reliable context. Safe to export and ship. |
| 60-79 | Good. Context is working but some tokens or anti-patterns may be ignored. Review the weakest sections before exporting. |
| Below 60 | Needs 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.
| Kit | Aesthetic |
|---|---|
| linear-lite | Developer tool, dark-first, minimal |
| stripe-lite | Clean, trust-focused, enterprise |
| notion-lite | Document-first, typography-heavy, neutral |
npx @layoutdesign/context init --kit linear-lite
npx @layoutdesign/context init --kit stripe-lite
npx @layoutdesign/context init --kit notion-liteinstall, 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+.