tions, the output respects your architecture. The AI composes using your exact component library, preserves variant logic, and maintains token references. This transforms AI from a code generator into a structural assembler, drastically reducing review time and eliminating the "div soup" anti-pattern.
Core Solution
The workflow relies on four interconnected pieces: a shared component registry, a mirrored Figma kit, the Figma MCP server, and the shadcn MCP server. Each piece serves a specific architectural purpose.
Step 1: Registry Alignment
Install the shared registry into your React project. This ensures your codebase and design file reference identical component definitions, prop surfaces, and styling tokens.
// components.json
{
"style": "new-york",
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/app/globals.css",
"baseColor": "zinc",
"cssVariables": true
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
},
"registry": "@acme/design-system"
}
Install components using the CLI. The registry handles dependency resolution and ensures consistent file structure.
pnpm dlx shadcn@latest add @acme/design-system/data-table
pnpm dlx shadcn@latest add @acme/design-system/page-shell
Step 2: Figma Kit Mirroring
Open the corresponding Figma kit. Every component installed in your codebase has a matching instance in Figma. The kit uses variant properties and slot definitions that map directly to React props. Design tokens are managed via CSS variable exports, ensuring runtime alignment.
Step 3: MCP Server Configuration
Connect both MCP servers to your AI editor. The Figma MCP exposes the design file structure; the shadcn MCP exposes the component registry and installation commands.
// .vscode/mcp.json (or Cursor/Claude equivalent)
{
"mcpServers": {
"figma": {
"command": "npx",
"args": ["-y", "@figma/mcp-server"],
"env": {
"FIGMA_API_TOKEN": "${env.FIGMA_API_TOKEN}"
}
},
"shadcn-registry": {
"command": "npx",
"args": ["-y", "@shadcn/mcp-server"],
"env": {
"PROJECT_ROOT": "${workspaceFolder}",
"REGISTRY_URL": "https://registry.acme.dev"
}
}
}
}
Step 4: AI Orchestration & Composition
With both servers active, the AI agent can read Figma frames and generate React code that uses your installed components. The mapping relies on data-slot attributes. Figma layer names are structured to match these slots, enabling deterministic composition.
// Generated output example
import { PageShell } from "@/components/ui/page-shell";
import { DataTable } from "@/components/ui/data-table";
import { BillingSummary } from "@/components/ui/billing-summary";
export function SettingsPage({ invoices, plan }) {
return (
<PageShell data-slot="page-shell">
<PageShell.Header data-slot="page-header">
<h1>Billing Settings</h1>
</PageShell.Header>
<PageShell.Content data-slot="page-content">
<div className="grid gap-6 md:grid-cols-2">
<BillingSummary data-slot="plan-card" tier={plan.tier} />
<DataTable data-slot="invoice-table" rows={invoices} />
</div>
</PageShell.Content>
</PageShell>
);
}
Architecture Rationale:
- MCP over REST/GraphQL: MCP provides a standardized context-sharing layer that works across Claude, Cursor, VS Code, and Codex without custom adapters.
- Shared Registry over Custom Exports: Installing components directly into your project avoids runtime fetches and ensures type safety, tree-shaking, and IDE autocomplete.
data-slot Mapping over Visual Inference: Explicit slot naming eliminates ambiguity. The AI doesn't guess whether a frame is a Dialog or Sheet; it reads the layer name and maps it to the correct component.
Pitfall Guide
Even with a robust architecture, the workflow degrades if implementation discipline slips. Below are the most common failure modes and their production-tested fixes.
1. Detached Figma Instances
Explanation: Designers detach component instances to make one-off tweaks. The AI loses the underlying component reference and sees only raw rectangles and text layers.
Fix: Enforce variant properties and slot overrides in Figma. Never detach. Use the kit's built-in variant controls for spacing, color, and content changes.
2. Ignoring AI Output Review
Explanation: Treating generated code as production-ready leads to subtle bugs, missing accessibility attributes, and misaligned data shapes.
Fix: Treat AI output as a pull request from a fast but junior contributor. Run linting, type checking, and visual regression tests before merging.
3. Naming Convention Mismatches
Explanation: Figma layer names don't align with data-slot values. The AI defaults to generic markup or picks incorrect components.
Fix: Document the naming contract. Layer names must exactly match slot identifiers. Use Figma's description field to specify expected props.
4. Token Drift
Explanation: Design tokens in Figma diverge from CSS variables in code after manual edits or kit updates.
Fix: Automate token synchronization. Use the Figma plugin to export CSS variables on commit, and validate them in CI with a token diff script.
5. Incomplete MCP Chain
Explanation: Only one MCP server is connected. The AI can read Figma but cannot install components, or vice versa.
Fix: Verify both endpoints in your editor's MCP configuration. Test connectivity with a simple prompt before starting a session.
6. Over-Prompting Business Logic
Explanation: Asking the AI to handle data fetching, authentication, or complex state management alongside UI composition.
Fix: Scope prompts to structural assembly only. Provide data shape contracts and let engineers implement business logic manually.
7. Skipping Responsive Breakpoint Mapping
Explanation: Figma designs are static. The AI generates fixed-width layouts without responsive variants.
Fix: Include breakpoint instructions in prompts. Use Figma's auto-layout constraints and explicitly request Tailwind responsive classes in the generation prompt.
Production Bundle
Action Checklist
Decision Matrix
| Scenario | Recommended Approach | Why | Cost Impact |
|---|
| Greenfield React project | Full MCP + shared registry loop | Zero legacy debt; clean token alignment | Low setup, high velocity gain |
| Existing shadcn/ui project | Layer registry on top; migrate one screen | Preserves current architecture; validates workflow | Medium initial effort, low risk |
| Non-shadcn codebase | Adopt shadcn/ui first, then connect MCP | Registry compatibility is mandatory for AI composition | High migration cost, long-term ROI |
| Enterprise design system | Fork registry, enforce naming contract | Maintains brand consistency while enabling AI | High governance overhead, scalable |
Configuration Template
Copy this into your project root to establish the baseline configuration. Adjust paths and registry URLs to match your infrastructure.
// components.json
{
"style": "default",
"tailwind": {
"config": "tailwind.config.js",
"css": "src/styles/globals.css",
"baseColor": "slate",
"cssVariables": true
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui"
},
"registry": "@acme/design-system"
}
// .cursor/mcp.json (or equivalent editor config)
{
"mcpServers": {
"figma-context": {
"command": "npx",
"args": ["-y", "@figma/mcp-server"],
"env": { "FIGMA_API_TOKEN": "${env.FIGMA_API_TOKEN}" }
},
"component-registry": {
"command": "npx",
"args": ["-y", "@shadcn/mcp-server"],
"env": {
"PROJECT_ROOT": "${workspaceFolder}",
"REGISTRY_ENDPOINT": "https://registry.acme.dev/v1"
}
}
}
}
Quick Start Guide
- Install the registry: Run
pnpm dlx shadcn@latest init to configure components.json, then add two baseline components to verify the pipeline.
- Open the Figma kit: Load the mirrored design file. Confirm that layer names match
data-slot values and that CSS variables are exported correctly.
- Connect MCP servers: Add the Figma and shadcn MCP configurations to your editor. Restart the editor to load the context providers.
- Test the loop: Select a simple frame in Figma. Prompt your AI agent to generate the corresponding React component. Verify the output uses installed components, respects tokens, and passes type checking.
- Scale incrementally: Apply the workflow to one contained screen per sprint. Document naming conventions and token sync steps before expanding to complex layouts.