|
| 1 | +# Figma Integration Guide (Designer-to-Code Workflow) |
| 2 | + |
| 3 | +This guide details how to integrate **Figma** with the **QuanuX Platform** to enable AI agents to generate production-ready, compliant React code directly from your designs. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The workflow relies on **MCP Server Composition**. By connecting your AI Client to two servers simultaneously, you give the AI access to both the *Design* and the *Rules*: |
| 8 | + |
| 9 | +1. **Figma Desktop MCP Server** (Official): Provides the raw design data (layout, props, colors). |
| 10 | +2. **QuanuX Local MCP Server**: Provides the `react-frontend-standards` Agent Skill (architectural rules, Shadcn usage, Backend-Driven protocols). |
| 11 | + |
| 12 | +```mermaid |
| 13 | +graph TD |
| 14 | + User((User)) -->|Prompt| AI[AI Client/Agent] |
| 15 | + AI -->|Read Design| Figma[Figma MCP Server] |
| 16 | + AI -->|Read Rules| QuanuX[QuanuX MCP Server] |
| 17 | + Figma -.->|Design Node| AI |
| 18 | + QuanuX -.->|Frontend Skill| AI |
| 19 | + AI -->|Generates| Code[QuanuX-Compliant Code] |
| 20 | +``` |
| 21 | + |
| 22 | +## Prerequisites |
| 23 | + |
| 24 | +1. **Figma Desktop App**: Ensure you are running the latest version with **Dev Mode** availability (Beta). |
| 25 | +2. **MCPClient**: A desktop agent application (e.g., Claude Desktop, Cursor, or a custom scripted agent) that supports multiple MCP servers. |
| 26 | +3. **QuanuX Server**: Running locally (`python3 -m server.mcp.server`). |
| 27 | + |
| 28 | +## Configuration |
| 29 | + |
| 30 | +### 1. Enable Figma MCP |
| 31 | +1. Open Figma Desktop. |
| 32 | +2. Enter **Dev Mode** (Shift + D). |
| 33 | +3. Open the **Inspect** panel. |
| 34 | +4. Enable "MCP Server" (if available in your Beta/Plan). |
| 35 | + * *Default URL*: `http://127.0.0.1:3845/mcp` |
| 36 | + |
| 37 | +### 2. Configure Your Agent |
| 38 | +Add both servers to your agent's configuration file (e.g., `claude_desktop_config.json`). |
| 39 | + |
| 40 | +```json |
| 41 | +{ |
| 42 | + "mcpServers": { |
| 43 | + "figma": { |
| 44 | + "command": "npx", |
| 45 | + "args": ["-y", "@figma/mcp-server"] |
| 46 | + // OR point to the local desktop URL if supported via a bridge |
| 47 | + }, |
| 48 | + "quanux": { |
| 49 | + "command": "python3", |
| 50 | + "args": ["-m", "server.mcp.server"], |
| 51 | + "env": { "PYTHONPATH": "/absolute/path/to/QuanuX" } |
| 52 | + } |
| 53 | + } |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +## The Workflow |
| 58 | + |
| 59 | +### Step 1: Design in Figma |
| 60 | +Create your UI in Figma using standard best practices (Auto Layout, named layers). |
| 61 | + |
| 62 | +### Step 2: Select & Prompt |
| 63 | +1. **Select** the frame or component in Figma (e.g., `OrderEntryForm`). |
| 64 | +2. **Prompt** your connected Agent: |
| 65 | + |
| 66 | +> "Inspect the selected Figma node. Generate a React component for this design. |
| 67 | +> **IMPORTANT**: Use the `react-frontend-standards` skill to ensure the code follows QuanuX architecture (Backend-Driven UI, Shadcn, Tailwind)." |
| 68 | +
|
| 69 | +### Step 3: Verification |
| 70 | +The Agent will: |
| 71 | +1. Call `figma.get_selection()` to parse the layout. |
| 72 | +2. Call `agent.skills.read('react-frontend-standards')` to load our coding rules. |
| 73 | +3. Output a `.tsx` file that: |
| 74 | + * Uses **Tailwind** for styling (matching Figma tokens). |
| 75 | + * Uses **Shadcn** components where appropriate. |
| 76 | + * **Does NOT** contain mock logic (per Backend-Driven rule). |
| 77 | + |
| 78 | +## Troubleshooting |
| 79 | +* **"Skill not found"**: Ensure QuanuX server is running and `client/skills/react-frontend-standards/SKILL.md` exists. |
| 80 | +* **Figma Connection Refused**: Ensure Figma Desktop is open and Dev Mode is active. |
0 commit comments