01 The Problem β Hallucinated UIs and Design Degradation
Early AI coding tools suffer from a fundamental flaw: they generate hallucinated generic UIs that break across screen sizes and ignore design intent. The root cause is that LLMs are probabilistic text generators β they approximate visual layouts rather than engineering them with precision.
The challenge Alex Hitt frames is clear: the industry needs to move from probabilistic text generation to deterministic, rigidly constrained UI engineering. The solution he walks through is building a local AI agent that pulls visual design data from the cloud, processes it through structured constraints, and outputs production-ready React components.
Prerequisites
- Node.js 18+ β runtime for all Stitch tooling
- Google Chrome β required for authentication flows
- AI coding environment β Claude Code or Cursor
- Active Google Stitch account β access at stitch.withgoogle.com
02 API Setup & Stitch MCP Initialization
The first hands-on step is generating your API key. Navigate to the Stitch web console β Profile β Stitch Settings β Generate new API key. This key authenticates your local machine against Google's generative infrastructure.
Initialization Command
npx @davideast/stitch-mcp init
The initialization wizard handles several critical tasks automatically:
- Detecting and installing any missing Google Cloud dependencies
- Configuring authentication flows with your API key
- Registering your local machine as an authenticated node ready to pull high-fidelity visual data from Google's generative infrastructure
03 The MCP Proxy Connection β Why Not HTTP
The correct approach is to bypass HTTP entirely and use the proxy command:
npx @davideast/stitch-mcp proxy
This creates a stable stdin/stdout stream directly between your IDE and the Stitch server. Instead of serializing design data into HTTP request/response cycles, the proxy maintains a persistent bidirectional pipe that ensures deterministic stability and no lost design tokens.
IDE Configuration
- Claude Code: Paste the proxy command into your
claude.jsonconfig file - Cursor: Paste into the MCP menu in the visual composer
04 Installing Stitch Skills
Stitch Skills are structured knowledge packages that give the AI agent explicit frontend engineering capabilities. Install them with:
npx plugins add @google-labs-code/stitch-skills
Add the appropriate --scope and --target flags for your specific IDE.
Skill Library Structure
The skills are organized into a highly structured library across 3 macro directories:
- Verticals β isolate specific tasks so concerns don't bleed across boundaries
- Utility suite β handles standards enforcement, separated from production builds
- Validation logic β provides the agent with explicit directory structures and validation rules for frontend engineering tasks
05 DESIGN.md β The Semantic Truth Document
Before writing any React code, you must prevent the agent from hallucinating the aesthetic layout. This is done by generating a DESIGN.md file β a semantic truth document that locks in all design constraints.
Generating DESIGN.md
Run the design MD utility skill with the prompt:
"Analyze the Stitch project and generate a design.md"
The agent connects to the cloud, pulls all design data, and synthesizes a local document that explicitly locks in:
- Exact typography families β no font substitution or guessing
- Padding scales β precise spacing values from the design system
- Color roles β semantic color assignments (primary, secondary, error, etc.)
06 Converting Designs to React Components
With the proxy connected, skills installed, and DESIGN.md generated, the final generation step is a single prompt:
"Convert all screens in the stitch project to react components"
What the Agent Does
The agent performs a multi-stage pipeline:
- Extracts raw HTML from the cloud design data
- Mathematically validates ASTs β abstract syntax trees are compared against the design spec
- Configures modular imports β establishes clean dependency graphs
- Writes JSX files β production-ready React components
Because the agent referenced the semantic truth document first, the generated components mirror the original cloud design without aesthetic degradation.
Verification
npx @davideast/stitch-mcp serve
This spins up a local Vite dev environment where you can inspect the generated components visually. From here, you can issue surgical natural language commands:
- "Add a checkbox to the form component"
- "Alter the hover color state on the navigation"
These modifications are applied without destabilizing the surrounding UI architecture because the agent always references the DESIGN.md constraints.
07 Stitch Loop β Automated Multi-Page Generation
The final capability Alex demonstrates is Stitch Loop β an automation mode that handles end-to-end generation of complex multi-page applications completely unattended.
Instead of issuing one prompt per screen, Stitch Loop iterates through all pages in the design project, generating components, validating them against DESIGN.md, and assembling the full application structure automatically.
With Stitch Loop handling the repetitive generation work, developers can shift their focus to what matters most: business logic and overall architecture. The pixel-perfect UI layer is handled deterministically by the pipeline.
π― Key Takeaways
- Google Stitch MCP bridges cloud design tools with local AI coding agents for deterministic UI generation β eliminating the hallucinated UI problem.
- Use stdin/stdout proxy, not HTTP β HTTP drops packets on large design payloads, breaking generation. The proxy command ensures stable, lossless communication.
- DESIGN.md acts as a "semantic truth document" that locks in typography, spacing, and color constraints before any code is generated.
- Stitch Skills give the agent structured frontend engineering knowledge β directory structures, validation logic, and standards enforcement.
- Generated React components mathematically validate against original designs via AST comparison, ensuring zero aesthetic degradation.
- Stitch Loop enables fully automated multi-page application generation, removing manual pixel reconciliation from the workflow.
π Resources & Links
- stitch-mcp GitHub Repository β MCP server and proxy for Google Stitch
- Google Stitch β Official Stitch design platform
- Original Video β Google Stitch MCP Tutorial by Alex Hitt