# stitch-ui

Adopt this skill: https://proskills.md/skills/other/rexnode-stitch-ui-skill

Page: https://proskills.md/skills/other/rexnode-stitch-ui-skill
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: SKILL.md
size: 7727
upstream: https://github.com/rexnode/stitch-ui-skill/blob/HEAD/SKILL.md

````text
---
name: stitch-ui
description: |
  Generate UI designs and export production-ready code via Google Stitch Remote MCP API.
  Supports API Key (recommended) and OAuth authentication. Includes Design System management.
  Use when: user asks to design a UI, generate a page/screen, create an app interface, build a landing page, make a dashboard, or mentions "Stitch", "Google Stitch", or "stitch.withgoogle.com".
  通过 Google Stitch Remote MCP API 生成 UI 设计并导出生产级代码。支持 API Key（推荐）和 OAuth 认证。包含设计系统管理。
---

# Stitch UI — Google Stitch Design Automation

Generate UI screens from text prompts and export production-ready HTML+Tailwind code via the official Stitch Remote MCP Server.

## First-Time Setup (API Key)

1. Go to [Stitch Settings](https://stitch.withgoogle.com) → API Keys → Create API Key
2. Run once in terminal:
```bash
claude mcp add stitch \
  --transport http https://stitch.googleapis.com/mcp \
  --header "X-Goog-Api-Key: YOUR_KEY" \
  -s user
```
For OAuth or other clients, see [references/mcp-setup.md](references/mcp-setup.md).

---

## MCP Tools — Correct Usage

### Project Management

**`create_project`** — creates a project container
```
title: "My App"   # optional
```

**`list_projects`** — lists all projects
```
filter: "view=owned"  # or "view=shared"
```

**`get_project`** — gets project details including screen instances (needed for apply_design_system)
```
name: "projects/PROJECT_ID"   # format: projects/{id}
```

---

### Screen Management

**`list_screens`** — lists all screens in a project
```
projectId: "PROJECT_ID"   # no "projects/" prefix
```

**`get_screen`** — retrieves screen details and HTML code
```
# Use ONLY the name field. projectId/screenId are deprecated.
name: "projects/PROJECT_ID/screens/SCREEN_ID"
```
> ⚠️ Always use `name` only. The old `projectId` + `screenId` params are deprecated.

---

### AI Generation

**`generate_screen_from_text`** — generates a new screen from prompt
```
projectId: "PROJECT_ID"        # no "projects/" prefix
prompt: "A pricing page..."
modelId: "GEMINI_3_FLASH"      # or GEMINI_3_1_PRO
deviceType: "DESKTOP"          # MOBILE | DESKTOP | TABLET | AGNOSTIC
```
> ⚠️ Takes 1–2 minutes. **DO NOT RETRY** on timeout — the generation may still be running.
> After call: if `output_components` contains suggestions (e.g. "Yes, add dark mode"), show them to the user. If user accepts one, call `generate_screen_from_text` again with that as the prompt.

**`edit_screens`** — edits existing screens with a prompt
```
projectId: "PROJECT_ID"
selectedScreenIds: ["SCREEN_ID"]   # no "screens/" prefix
prompt: "Switch to dark mode"
modelId: "GEMINI_3_FLASH"          # optional
```
> ⚠️ **DO NOT RETRY** on timeout.

**`generate_variants`** — generates design variations of existing screens
```
projectId: "PROJECT_ID"
selectedScreenIds: ["SCREEN_ID"]
prompt: "Explore color variations"
variantOptions:                    # REQUIRED
  variantCount: 3                  # 1–5, default 3
  creativeRange: "EXPLORE"         # REFINE | EXPLORE | REIMAGINE
  aspects: ["COLOR_SCHEME"]        # optional: LAYOUT | COLOR_SCHEME | IMAGES | TEXT_FONT | TEXT_CONTENT
```

---

### Design Systems

**`create_design_system`** — creates a design system with brand tokens
```
projectId: "PROJECT_ID"   # optional
designSystem:
  displayName: "My Brand"
  theme:
    colorMode: "LIGHT"         # LIGHT | DARK
    customColor: "#0056D2"     # seed/primary color (hex)
    headlineFont: "INTER"      # see font list below
    bodyFont: "INTER"
    roundness: "ROUND_EIGHT"   # ROUND_FOUR | ROUND_EIGHT | ROUND_TWELVE | ROUND_FULL
    colorVariant: "TONAL_SPOT" # optional: see color variants below
    overridePrimaryColor: "#0056D2"    # optional: override exact primary
    overrideSecondaryColor: "#7B2FF7"  # optional
    overrideTertiaryColor: "#00BFA5"   # optional
    overrideNeutralColor: "#F5F5F5"    # optional
    designMd: "## Brand Guidelines\n..." # optional: free-form markdown
```
> ⚠️ **Must call `update_design_system` immediately after** to apply and display in UI.

**`update_design_system`** — updates or finalizes a design system (call after create)
```
name: "assets/ASSET_ID"     # from create_design_system response
projectId: "PROJECT_ID"
designSystem: { ... }       # same structure as create
```

**`list_design_systems`** — lists all design systems for a project
```
projectId: "PROJECT_ID"   # optional
```
Returns `assetId` needed for `apply_design_system`.

**`apply_design_system`** — applies a design system to screens
```
projectId: "PROJECT_ID"
assetId: "ASSET_ID"        # from list_design_systems (no "assets/" prefix)
selectedScreenInstances:   # MUST come from get_project, NOT list_screens
  - id: "INSTANCE_ID"              # screen instance id (from get_project)
    sourceScreen: "projects/PROJECT_ID/screens/SCREEN_ID"
```
> ⚠️ `selectedScreenInstances.id` is the **instance ID**, not the screen ID.
> Get it from `get_project` response → screen instances list.

---

## Models

| Model | Speed | Quality | Use |
|-------|-------|---------|-----|
| `GEMINI_3_FLASH` | Fast | Good | Default for most tasks |
| `GEMINI_3_1_PRO` | Slower | Best | Complex or detailed UI |
| `GEMINI_3_PRO` | — | — | ⛔ Deprecated, do not use |

## Device Types

`MOBILE` · `DESKTOP` · `TABLET` · `AGNOSTIC`

## Font Options (headlineFont / bodyFont / labelFont)

`INTER` · `GEIST` · `DM_SANS` · `IBM_PLEX_SANS` · `MANROPE` · `MONTSERRAT` · `RUBIK` · `NUNITO_SANS` · `WORK_SANS` · `PLUS_JAKARTA_SANS` · `SPACE_GROTESK` · `SOURCE_SANS_THREE` · `SORA` · `LEXEND` · `PUBLIC_SANS` · `EPILOGUE` · `HANKEN_GROTESK` · `ARIMO` · `BE_VIETNAM_PRO` · `SPLINE_SANS` · `NEWSREADER` · `NOTO_SERIF` · `LITERATA` · `EB_GARAMOND` · `LIBRE_CASLON_TEXT` · `SOURCE_SERIF_FOUR` · `DOMINE` · `METROPOLIS`

## Color Variants (colorVariant)

`TONAL_SPOT` (default) · `MONOCHROME` · `NEUTRAL` · `VIBRANT` · `EXPRESSIVE` · `FIDELITY` · `CONTENT` · `RAINBOW` · `FRUIT_SALAD`

## Roundness Options

`ROUND_FOUR` · `ROUND_EIGHT` · `ROUND_TWELVE` · `ROUND_FULL`  _(ROUND_TWO is deprecated)_

---

## Typical Workflows

### Basic: Generate a screen
```
1. list_projects → find projectId (or create_project)
2. generate_screen_from_text → wait 1-2 min, check output_components for suggestions
3. get_screen (name only) → retrieve HTML code
4. edit_screens → iterate with follow-up prompts
```

### Brand: Apply design system
```
1. create_design_system → get asset name
2. update_design_system → apply immediately (required step)
3. get_project → get screen instances (id + sourceScreen)
4. apply_design_system → apply brand tokens to screens
```

### Variants: Explore alternatives
```
1. generate_variants → variantOptions required (variantCount, creativeRange, aspects)
2. list_screens → see all generated variants
3. get_screen → retrieve preferred variant's HTML
```

---

## Prompt Tips

- Specific: "Pricing page, 3 tier cards (Basic $9/mo, Pro $29/mo, Enterprise), yearly toggle, dark header"
- Reference real products: "Like Stripe's pricing page but for eSIM plans"
- Specify brand: "Primary #0056D2, dark theme, Inter font"
- Include real content: actual text, prices, feature names — not lorem ipsum

---

## Fallback: Playwright Browser Automation

If MCP is not configured, use the browser automation script:

```bash
node scripts/stitch-generate.js \
  --prompt "A dashboard with sidebar nav and stats cards" \
  --type web \
  --output ./my-output
```

Requires Chrome with CDP enabled. See [references/playwright-mode.md](references/playwright-mode.md).
````

## File: README.md
upstream: https://github.com/rexnode/stitch-ui-skill/blob/HEAD/README.md

````text
# stitch-ui

> Google Stitch UI design automation for [OpenClaw](https://github.com/openclaw/openclaw) and AI agents.
>
> 通过 Google Stitch Remote MCP API 自动生成 UI 设计，导出生产级 HTML+Tailwind 代码。

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

## What is this? / 这是什么？

An [AgentSkill](https://docs.openclaw.ai) that lets AI agents generate production-ready UI code from natural language prompts using [Google Stitch](https://stitch.withgoogle.com)'s official Remote MCP API.

一个 AgentSkill 插件，通过 Google Stitch 官方 Remote MCP API 用自然语言生成生产级 UI 代码。

**Input:**
> "A pricing page with 3 tier cards, monthly/yearly toggle, dark header, primary color #0056D2"

**Output:**
- Production-ready HTML + Tailwind CSS code
- Design system tokens (colors, fonts, components)
- Design screenshots and variants

## Two Modes / 两种模式

| | MCP API (Recommended) | Playwright (Fallback) |
|---|---------|------------|
| **How** | Direct Remote MCP calls | Browser automation via Chrome CDP |
| **Auth** | API Key or OAuth | Logged-in Chrome browser |
| **Setup** | 2 steps (generate key + configure) | `openclaw browser start` + login |
| **Output** | Screen data, HTML code, design systems | Full ZIP (HTML + screenshot + design doc) |
| **Best for** | All workflows, programmatic use | When MCP is unavailable |

## Quick Start / 快速开始

### Install / 安装

```bash
# OpenClaw users / OpenClaw 用户
openclaw skills install stitch-ui

# Manual / 手动安装
git clone https://github.com/cloudlinkhk/stitch-ui-skill.git
cp -r stitch-ui-skill ~/.openclaw/workspace/skills/stitch-ui
```

### Mode 1: MCP API (Recommended) / MCP 模式（推荐）

**Step 1 — Get API Key / 获取 API Key:**

Go to [Stitch Settings](https://stitch.withgoogle.com) → API Keys → Create API Key.

前往 Stitch 设置页面 → API Keys → 创建 API Key。

**Step 2 — Configure / 配置:**

```bash
# Claude Code
claude mcp add stitch \
  --transport http https://stitch.googleapis.com/mcp \
  --header "X-Goog-Api-Key: YOUR_KEY" \
  -s user
```

```json
// Cursor (.cursor/mcp.json)
{
  "mcpServers": {
    "stitch": {
      "url": "https://stitch.googleapis.com/mcp",
      "headers": { "X-Goog-Api-Key": "YOUR_KEY" }
    }
  }
}
```

For VSCode, Antigravity, Gemini CLI, and OAuth setup — see [references/mcp-setup.md](references/mcp-setup.md).

**Step 3 — Verify / 验证:**

Ask your AI agent: "List my Stitch projects" — it should return your projects.

**Use / 使用:**

Once configured, your AI agent has direct access to all Stitch MCP tools. Just describe what you want:
- "Create a new project called My App"
- "Generate a pricing page with 3 tier cards"
- "Edit the screen to use dark mode"
- "Create a design system with brand colors #0056D2 and Inter font"

### Mode 2: Playwright (Fallback) / Playwright 模式（备选）

**Prerequisites / 前置条件:**
```bash
npm install -g playwright-core
```

**Start Chrome / 启动 Chrome：**
```bash
# OpenClaw
openclaw browser start

# Or manually / 或手动
open -a "Google Chrome" --args --remote-debugging-port=18800
```

Then log into Google at https://stitch.withgoogle.com.

**Generate / 生成：**
```bash
node scripts/stitch-generate.js \
  --prompt "A dashboard for IoT device management with sidebar nav and stats cards" \
  --type web \
  --output ./my-dashboard
```

**Output / 输出：**
```
my-dashboard/
├── code.html       ← Open in browser / 浏览器直接打开
├── screen.png      ← Design preview / 设计预览
├── DESIGN.md       ← Design system / 设计系统文档
└── stitch.zip      ← Original archive / 原始压缩包
```

See [references/playwright-mode.md](references/playwright-mode.md) for details.

## MCP Tools (12) / MCP 工具列表

### Project Management / 项目管理
| Tool | Description / 描述 |
|------|-------------------|
| `create_project` | Create a new design project / 创建设计项目 |
| `list_projects` | List all projects / 列出所有项目 |
| `get_project` | Get project details / 获取项目详情 |

### Screen Management / 页面管理
| Tool | Description / 描述 |
|------|-------------------|
| `list_screens` | List screens in a project / 列出项目中的页面 |
| `get_screen` | Get screen details and HTML code / 获取页面详情和代码 |

### AI Generation / AI 生成
| Tool | Description / 描述 |
|------|-------------------|
| `generate_screen_from_text` | Generate UI from text prompt / 从描述生成 UI |
| `edit_screens` | Edit existing screens with prompt / 编辑现有页面 |
| `generate_variants` | Generate design variations / 生成设计变体 |

### Design Systems / 设计系统
| Tool | Description / 描述 |
|------|-------------------|
| `create_design_system` | Create design system with tokens / 创建设计系统 |
| `update_design_system` | Update design system / 更新设计系统 |
| `list_design_systems` | List all design systems / 列出设计系统 |
| `apply_design_system` | Apply design system to screens / 应用设计系统到页面 |

## Models / 可用模型

| Model | Speed | Quality | Notes |
|-------|-------|---------|-------|
| `GEMINI_3_FLASH` | Fast | Good | Default, recommended / 默认推荐 |
| `GEMINI_3_1_PRO` | Slower | Best | Complex UI / 复杂界面 |

## Device Types / 设备类型

`MOBILE` · `DESKTOP` · `TABLET` · `AGNOSTIC`

## Variant Options / 变体选项

`generate_variants` supports `variantOptions`:
- `count`: Number of variants (default: 4)
- `creativeRange`: `REFINE` (subtle) | `EXPLORE` (moderate) | `REIMAGINE` (dramatic)
- `aspects`: Specific aspects to vary

## Environment Variables / 环境变量

| Variable | Default | Description |
|----------|---------|-------------|
| `CDP_URL` | `http://127.0.0.1:18800` | Chrome CDP URL (Playwright mode only) |

## Prompt Tips / Prompt 技巧

```
Good: "A pricing page with 3 tier cards (Basic $9/mo, Pro $29/mo, Enterprise custom),
       monthly/yearly toggle, dark gradient header, CTA buttons, FAQ section below.
       Primary #0056D2, Inter font, minimal style like Stripe."

Bad:  "a pricing page"
```

- **Be specific / 描述具体**: Include layout, colors, content, number of elements
- **Reference real products / 参考真实产品**: "Like Notion's sidebar" or "Stripe's pricing layout"
- **Specify brand / 指定品牌**: Colors, fonts, dark/light theme
- **Include content / 包含内容**: Real text, prices, feature names — not lorem ipsum

## Project Structure / 项目结构

```
stitch-ui/
├── SKILL.md                    ← Agent entry point / AI 代理入口
├── README.md                   ← This file / 本文件
├── LICENSE                     ← MIT
├── package.json
├── references/
│   ├── mcp-setup.md            ← MCP setup guide (API Key + OAuth) / MCP 配置指南
│   └── playwright-mode.md      ← Playwright guide / Playwright 使用指南
└── scripts/
    └── stitch-generate.js      ← Browser automation script / 浏览器自动化脚本
```

## Requirements / 系统要求

**MCP mode (recommended):**
- API Key from Stitch Settings, OR Google Cloud project with gcloud CLI
- MCP-compatible client (Claude Code, Cursor, VSCode, Gemini CLI, Antigravity)

**Playwright mode (fallback):**
- Node.js >= 18
- Chrome browser
- `playwright-core` npm package
- Google account with Stitch access

## License / 许可证

[MIT](LICENSE) © CLOUD(HK)LIMITED

## Links / 相关链接

- [Google Stitch](https://stitch.withgoogle.com)
- [Stitch MCP Docs](https://stitch.withgoogle.com/docs/mcp/setup)
- [OpenClaw](https://github.com/openclaw/openclaw)
- [AgentSkills Docs](https://docs.openclaw.ai)
- [ClawHub Skills Marketplace](https://clawhub.com)
````
