$npx -y skills add google-labs-code/stitch-skills --skill manage-design-systemManage design systems in Stitch using MCP tools. Includes retrieval of assets, creating/updating design systems in Stitch, and applying them to screens.
| 1 | # Design-System |
| 2 | |
| 3 | Create a "source of truth" for your project's design language to ensure |
| 4 | consistency across all future screens. |
| 5 | |
| 6 | > [!NOTE] |
| 7 | > Refer to your system prompt for instruction on handling MCP tool prefixes for |
| 8 | > all tools mentioned in this skill (e.g., `get_screen`, |
| 9 | > `create_design_system_from_design_md`, `apply_design_system`). |
| 10 | |
| 11 | ## 📥 Retrieval |
| 12 | |
| 13 | To analyze a Stitch project, you must retrieve metadata and assets using the |
| 14 | Stitch MCP tools: |
| 15 | |
| 16 | 1. **Project lookup**: Use `list_projects` to find the target `projectId`. |
| 17 | 2. **Screen lookup**: Use `list_screens` for that `projectId` to find |
| 18 | representative screens (e.g., "Home", "Main Dashboard"). |
| 19 | 3. **Metadata fetch**: Call `get_screen` for the target screen to get |
| 20 | `screenshot.downloadUrl` and `htmlCode.downloadUrl`. |
| 21 | 4. **Asset download**: Use `read_url_content` to fetch the HTML code. |
| 22 | |
| 23 | ## 🧠 Synthesis from Description |
| 24 | |
| 25 | If you need to extract a design system from existing screens, use the `design-md` skill (in the `stitch-utilities` plugin). |
| 26 | |
| 27 | If there are no existing screens (new project), or the user provides a direct description (e.g., "dark theme, blue and purple, rounded, Inter font"): |
| 28 | |
| 29 | 1. Map the user's vague terms to precise values using the design mappings (see `design-md` skill in `stitch-utilities` or `generate-design` skill). |
| 30 | 2. Select concrete hex codes, font families, and roundness values. |
| 31 | 3. Generate the `DESIGN.md` file (refer to the `design-md` skill in `stitch-utilities` for structure). |
| 32 | 4. Proceed to the "Create or Update Design System in Stitch" step below. |
| 33 | |
| 34 | ## 📝 Output Structure |
| 35 | |
| 36 | The `DESIGN.md` file should follow the structure defined in the `design-md` skill (in the `stitch-utilities` plugin). |
| 37 | |
| 38 | ## 🚀 Create or Update Design System in Stitch |
| 39 | |
| 40 | After generating `.stitch/DESIGN.md`, make sure to also create or update the |
| 41 | design system in Stitch. |
| 42 | |
| 43 | **Two-step design system creation:** |
| 44 | |
| 45 | > [!WARNING] |
| 46 | > **Checkpoint — User Confirmation Required.** |
| 47 | > Before uploading, you **MUST** pause and ask the user for |
| 48 | > confirmation. Present a summary of the design system you are about to create |
| 49 | > (display name, key colors, fonts, and roundness) and wait for explicit approval |
| 50 | > before proceeding. Do **NOT** upload until the user confirms. |
| 51 | |
| 52 | 1. **Upload `DESIGN.md`**: |
| 53 | - **Option A (Recommended - Uploader Script)**: Use the modified `upload-to-stitch` Python script which natively handles `.md` files. It base64-encodes the markdown file in-process and sends it to the `/v1/projects/{projectId}/screens:batchCreate` endpoint, bypassing output token limits. |
| 54 | ```bash |
| 55 | python3 stitch-skills/plugins/stitch-design/skills/upload-to-stitch/scripts/upload_to_stitch.py \ |
| 56 | --project-id <PROJECT_ID> \ |
| 57 | --file-path /path/to/DESIGN.md \ |
| 58 | --api-key <API_KEY> \ |
| 59 | --generated-by <GENERATED_BY> |
| 60 | ``` |
| 61 | Set `<GENERATED_BY>` to identify the skill or tool that produced the |
| 62 | `DESIGN.md`. Use the calling skill name when invoked from another skill |
| 63 | (e.g. `stitch::code-to-design`), or the agent/tool name for standalone |
| 64 | use (e.g. `Gemini`, `Claude Code`). If omitted, the script defaults to |
| 65 | `UserUploadedDesignMd`. |
| 66 | |
| 67 | This returns the `sourceScreen` ID and the `screenInstance` ID. |
| 68 | - **Option B (Direct MCP Tool)**: If the `DESIGN.md` is small (under ~5KB), you can call the `upload_design_md` MCP tool directly, passing the base64-encoded design markdown content as `designMdBase64`. |
| 69 | 2. **Create Design System**: Call the `create_design_system_from_design_md` tool immediately after the upload, passing the `projectId` and the `selectedScreenInstance` (containing the `id` and `sourceScreen` returned from the upload step). |
| 70 | |
| 71 | Once the upload script and `create_design_system_from_design_md` have both completed, |
| 72 | Stitch holds the design tokens at the project level — you do NOT need to repeat |
| 73 | them in generation prompts. |
| 74 | |
| 75 | ## 🎨 Apply Design System to Screens |
| 76 | |
| 77 | Use `apply_design_system` to apply a design system to existing screens. |
| 78 | |
| 79 | > [!IMPORTANT] |
| 80 | > `selectedScreenInstances` must contain **only** `id` and `sourceScreen` — do |
| 81 | > NOT include position/dimension fields (`x`, `y`, `width`, `height`) or the |
| 82 | > request will fail with "invalid argument". Get the screen instance IDs from |
| 83 | > `get_project`. |
| 84 | |
| 85 | ```json |
| 86 | { |
| 87 | "projectId": "...", |
| 88 | "assetId": "...", |
| 89 | "selectedScreenInstances": [ |
| 90 | { |
| 91 | "id": "...", |
| 92 | "sourceScreen": "projects/.../screens/..." |
| 93 | } |
| 94 | ] |
| 95 | } |
| 96 | ``` |
| 97 | |
| 98 | **How to get the required IDs:** |
| 99 | 1. Call `get_project` to retrieve `screenInstances` — each has an `id` and |
| 100 | `sourceScreen`. |
| 101 | 2. Call `list_design_systems` to retrieve the design system `name` (format: |
| 102 | `assets/{assetId}`) — use the part after `assets/` as the `assetId`. |
| 103 | 3. Filter |