Stitch HTML / URL to Pencil design (pencil-design-from-stitch-html)
Constraint: Use this skill when the user wants to turn a Stitch screen (HTML or Stitch URL/IDs) into a Pencil .pen design that matches the page layout and style (100% precise correspondence). Combines Stitch MCP (get_screen, htmlCode) when input is URL with Pencil MCP (open_document, batch_design, find_empty_space_on_canvas, get_screenshot).
This skill belongs to pencil-skills. When input is a Stitch URL or projectId/screenId, Stitch MCP (get_screen) is used to obtain HTML; Stitch skills are responsible for PRD→prototype only, and this skill is responsible for prototype→.pen design.
You are a design conversion specialist: Stitch exports Tailwind-based HTML; Pencil uses a node tree and batch_design (I/U/R/M/D/C/G). This skill defines HTML element → Pencil node mapping rules, strict execution order, and Tailwind → .pen style mapping (background, color, size, margin, padding, shadow, border-radius) so the drawn artboard is a precise visual match.
Prerequisites
- Stitch MCP Server (https://stitch.withgoogle.com/docs/mcp/guide/) when user provides Stitch URL or projectId/screenId
- Pencil MCP (batch_design, batch_get, open_document, find_empty_space_on_canvas, get_screenshot)
- Stitch projectId and screenId (from URL or list_projects / list_screens), or user-pasted HTML
- Optional: existing .pen file with design system (pencil-ui-design-system-*); otherwise use primitive nodes (frame, text, icon_font)
Core References (must follow)
- HTML → Pencil mapping — Which HTML element/semantic block maps to which Pencil node type and batch_design operation (frame, text, ref, icon_font).
- Execution order and batch split — Defined in the section below: strict phase order, ≤25 ops per batch_design; canvas prep → root → header → main → sections/cards → forms → footer.
- Tailwind → Pencil styles — Background, color, size, margin, padding, shadow, border-radius, typography: Tailwind class → .pen property value (fill, padding, gap, stroke, cornerRadius, fontSize, fontWeight, textColor).
- Per-framework style docs — When a target framework is set, use that framework’s *-to-pencil-styles.md (sections 0, 12, 14, 15) for component styles, tokens, and design-system refs/constraints: uview, uviewpro, element, bootstrap, layui, vant. Cross-framework mapping and "refs vs primitives": tailwind-to-pencil-styles.md sections 15–16.
Optional Target Framework
- Agnostic (default): No target → use primitive nodes (frame, text, icon_font) and tailwind-to-pencil-styles.md for maximum layout/style fidelity without design-system dependency.
- Target set: User or config specifies one of: uView 2, uView Pro, Bootstrap, Element Plus, Layui, Vant → (1) use the corresponding *-to-pencil-styles.md for full style mapping and section 15 for design-system refs and batch_design conventions; (2) ensure .pen has the corresponding pencil-ui-design-system-* initialized so the .pen aligns with the stitch-*-components skills.
Retrieval and HTML
- Resolve screen: From Stitch design URL parse projectId/screenId, or use
list_projects → list_screens → pick screen. If user provides pasted HTML, skip to Parse.
- get_screen: Call Stitch MCP
get_screen with projectId and screenId; obtain htmlCode.downloadUrl, screenshot.downloadUrl, width, height, title.
- Download HTML: Fetch HTML from
htmlCode.downloadUrl (Bash script or web_fetch); save to e.g. temp/source.html. If fetch fails, ask user to paste HTML.
- Parse: Extract DOM tree and per-node class list (Tailwind). Preserve element semantics: header, main, section, form, input, button, label, etc.
Conversion Pipeline
- Apply mapping (see html-to-pencil-mapping.md): For each HTML element, determine Pencil node type (frame / text / ref / icon_font), parent binding, and default layout/size. If target framework is set, prefer design-system refs per that framework's *-to-pencil-styles.md section 15 and tailwind-to-pencil-styles.md section 16.
- Apply styles (see tailwind-to-pencil-styles.md): For each node, resolve Tailwind classes to .pen properties; when target framework is set, prefer that framework's tokens (section 12 of its *-to-pencil-styles.md) and refs (section 15).
- Build execution plan (see Execution order and batch split below): Split operations into ordered batches (Batch 1: document + root + header + main placeholder; Batch 2: header content; Batch 3–N: per section/card; etc.). Each batch ≤25 ops. When target framework is set, use refs for section/card/hint/divider per that framework's *-to-pencil-styles.md section 15.
- Run Pencil: Open document (
open_document('new') or path); optionally find_empty_space_on_canvas for root frame position; then call batch_design once per batch in order. After each batch (or at end), call get_screenshot on root frame to verify.
Execution Steps
- Stitch (if URL/IDs): Get projectId/screenId → get_screen → download HTML (and optionally screenshot for reference). Else use user-pasted HTML.
- Parse HTML: Build DOM tree + class list per node; identify semantic regions (header, main, sections, forms).
- Plan batches: From the execution order phases below, produce N batch_design payloads (filePath + operations string). Use unique binding names per batch; parent refs from previous batch (e.g.
main from Batch 1 used as parent in Batch 3).
- Pencil: open_document → find_empty_space_on_canvas (if needed) → batch_design(Batch 1) → batch_design(Batch 2) → … → get_screenshot(root) for verification.
- Verify: Compare screenshot with Stitch screenshot; note any layout or style gaps for next iteration.
Execution order and batch split
Strict execution order for converting Stitch HTML into Pencil batch_design calls: parents must exist before children; each batch at most 25 operations (Pencil recommendation).
1. Phase overview
| Phase |
Description |
Typical batch |
Parent ref |
| 0 |
Canvas prep (optional) |
— |
— |
| 1 |
Document + root + header + main placeholder |
Batch 1 |
document → root, main |
| 2 |
Header content (back, title, actions) |
Batch 2 |
header |
| 3 |
Tabs bar (if present) |
Batch 3 |
root |
| 4 |
Section 1 (card + title + body placeholder) |
Batch 4 |
main |
| 5 |
Section 1 body (form rows, inputs, buttons) |
Batch 5 |
card1Body |
| 6 |
Section 2 (card + …) |
Batch 6 |
main |
| 7 |
Section 2 body |
Batch 7 |
card2Body |
| … |
One batch per section body if large |
… |
… |
| N |
Footer or final dividers |
Batch N |
main |
Parents created in an earlier batch are referenced by binding name in later batches (e.g. I(main, ...), I(card1Body, ...)). Binding names are unique per batch; do not reuse the same name across batches for different nodes.
When a target framework is set, use that framework's refs for section/card, hints, divider, button, input, tabs per that framework's *-to-pencil-styles.md section 15 and tailwind-to-pencil-styles.md section 16.
2. Phase 0: Canvas prep (optional)
- When: Before any
batch_design, if the artboard must be placed at a specific position on the canvas.
- Actions: Call
find_empty_space_on_canvas with desired width/height (e.g. screen width × height from Stitch get_screen). Use returned position when creating the root frame in Phase 1 (x, y on document). No batch_design in this phase.
3. Phase 1: Root and main structure (Batch 1)
Goal: Create the root frame, header frame, and main content placeholder so all later content has a parent.
Order of operations (≤25): (1) Insert root frame under document: layout vertical, width from screen (e.g. 390), height a fixed value (844 or 884) so the canvas is not blank—avoid root fit_content when children use fill_container. Fill = page background. (2) Insert header frame under root: layout horizontal, height 56 or 64, width fill_container, padding, fill #fff, optional stroke bottom. (3) Insert main frame under root: layout vertical, width fill_container, height fit_content(800), padding 16, gap 16, placeholder true.
Binding names for later batches: root, header, main. Style: root fill from <body> or wrapper class (bg-*); header/main padding and gap from Tailwind (p-4, space-y-4 → 16).
4. Phase 2: Header content (Batch 2)
Goal: Fill the header with back icon, title text, and optional right actions. Parent: header. Insert backIcon (icon_font arrow_back), titleText (content = page title), and optionally headerRight frame with actions. Binding names: backIcon, titleText, headerRight.
5. Phase 3: Tabs bar (Batch 3, if present)
Goal: Create the tab row. Parent: root. Insert tabsWrap frame under root (horizontal, height 48), then tab1/tab1Text, tab2/tab2Text, tab3/tab3Text under tabsWrap. If more than 3 tabs, split into Batch 3a/3b or keep under 25 ops total.
6. Phase 4–5: First section / card (Batch 4 + 5)
Batch 4 — Parent: main. Insert card1 frame (vertical, fill_container, padding 24, gap 16, fill #fff, cornerRadius 12, stroke 1px); card1Header under card1; card1Title under card1Header; optional card1Right; card1Body under card1 (vertical, placeholder true).
Batch 5 — Parent: card1Body. For each form row: insert row frame, label text, input frame (or ref). If more than ~8 rows, split into Batch 5a, 5b. Binding names: card1, card1Header, card1Title, card1Body.
7. Phase 6–7: Second section (Batch 6 + 7)
Same pattern: Batch 6 — card2, card2Header, card2Title, card2Body under main. Batch 7 — card2Body children. Repeat for Section 3, 4, … (Batch 8, 9, …). If one section has very many rows, use multiple batches with same parent (e.g. card3Body).
8. Phase N: Footer and final elements
Insert any footer frame under main, or final divider lines. Keep under 25 ops; if many small elements, group into one batch.
9. Batch size and naming rules
- Max 25 operations per
batch_design call. Split large section bodies (e.g. 15 form rows → Batch 5 first 7, Batch 5b next 8).
- Binding names: Unique per batch; use descriptive names (card1, card1Body, inputRow1, labelName). In the next batch, reference parents by the binding name from the previous batch.
- Placeholder: Use
placeholder: true on frames that will receive many children in the next batch (main, card1Body).
10. Execution order checklist
Before running Pencil: [ ] Phase 0 optional find_empty_space_on_canvas; [ ] Phase 1 Batch 1 — root, header, main; [ ] Phase 2 Batch 2 — header content; [ ] Phase 3 Batch 3 — tabs if any; [ ] Phase 4–5 Batch 4–5 — card1 + card1Body + body children; [ ] Phase 6–7 Batch 6–7 — card2 + card2Body; [ ] … repeat for remaining sections; [ ] Phase N footer/final; [ ] After all batches: get_screenshot(root) to verify.
11. Example: Minimal page (header + 1 card + 2 rows)
| Batch |
Ops |
Content |
| 1 |
3 |
root, header, main |
| 2 |
2 |
backIcon, titleText under header |
| 3 |
6 |
card1, card1Header, card1Title, card1Body |
| 4 |
5 |
row1, label1, input1; row2, label2, input2 under card1Body |
Total: 4 batches, 16 operations. Order is fixed: 1 → 2 → 3 → 4.
Integration
- Stitch screens: Same pattern as stitch-remotion / stitch-uviewpro-components: list_projects, list_screens, get_screen, download URLs (when user provides Stitch URL/IDs).
- Pencil: Same pattern as pencil-ui-designer / pencil-mcp-batch-design: open_document, batch_design (≤25 ops per call), get_screenshot for visual check.
- Design system: If .pen has a design system (e.g. uView Pro), prefer refs for Card, Button, Input, Tabs; otherwise use primitive frame + text + icon_font for 100% control over size/margin/shadow.
File Structure
skills/pencil-design-from-stitch-html/
├── SKILL.md
├── LICENSE.txt
├── references/
│ ├── html-to-pencil-mapping.md # Element → node + op rule
│ ├── tailwind-to-pencil-styles.md # Generic Tailwind → Pencil; §15–16 framework mapping + refs vs primitives
│ ├── uview-to-pencil-styles.md # uView 2 → Pencil (full style table + §15 refs/constraints)
│ ├── uviewpro-to-pencil-styles.md
│ ├── element-to-pencil-styles.md
│ ├── bootstrap-to-pencil-styles.md
│ ├── layui-to-pencil-styles.md
│ └── vant-to-pencil-styles.md
└── examples/
├── usage.md # When to use, steps, MCP flow, example prompts
├── sample-batch-ops.md # Minimal page → one batch_design (≤25 ops)
├── sample-multi-batch.md # Header + card + form rows → four batches
├── sample-with-framework-refs.md # Same page with target framework (refs + tokens)
└── sample-simple-create-product.md # Simplified Create Product (1–2 batches) for quick validation
Keywords
English: Stitch, Pencil, batch_design, .pen, HTML to design, Tailwind, layout, fidelity.
中文关键词: Stitch、Pencil、绘图、HTML 转设计稿、批动作。
References
- Stitch MCP
- Pencil MCP tools / pencil-skills stitch-html-to-pencil-batch.md
- HTML → Pencil mapping
- Tailwind → Pencil styles (includes §15–16 framework mapping and refs vs primitives)
- Per-framework style tables (incl. refs/constraints §15): uview, uviewpro, element, bootstrap, layui, vant
- Examples: usage, single batch, multi-batch, with framework refs, simplified Create Product
能力边界
✅ 适用场景
- 当你需要使用此技能对应的技术栈时
- 当项目需要遵循最佳实践时
- 当需要快速上手或深入理解核心概念时
⚠️ 需要注意
- 复杂业务逻辑需要结合具体场景调整
- 性能优化需要根据实际数据量评估
❌ 不适用场景
常见陷阱 (Gotchas)
- 版本兼容性:注意框架版本与依赖库的兼容性,不同版本 API 可能有差异
- 配置文件格式:配置文件格式错误是最常见的问题,建议使用编辑器的语法检查
- 环境变量:确保所有必要的环境变量已正确设置,敏感信息不要硬编码
- 依赖冲突:多版本共存时注意依赖冲突,使用 lock 文件锁定版本
- 性能陷阱:大数据量场景下注意性能优化,避免 N+1 查询等常见问题
使用流程
Step 1: 环境准备
确保开发环境已安装必要的依赖和工具。
Step 2: 配置初始化
根据项目需求进行基础配置。
Step 3: 核心功能使用
按照示例代码实现核心功能。
Step 4: 测试验证
运行测试确保功能正常。
Step 5: 部署上线
完成开发后进行部署和监控。
1---2name: pencil-design-from-stitch-html3description: When you need to turn Stitch page HTML (or a Stitch URL) into a Pencil .pen design. Parses DOM and Tailwind, applies HTML→Pencil mapping and execution order, outputs sequential batch_design for layout and style fidelity (background, color, size, margin, padding, shadow). Supports multi-framework tokens.4---567# Stitch HTML / URL to Pencil design (pencil-design-from-stitch-html)89**Constraint**: Use this skill when the user wants to turn a **Stitch screen** (HTML or Stitch URL/IDs) into a **Pencil .pen design** that matches the page layout and style (100% precise correspondence). Combines Stitch MCP (get_screen, htmlCode) when input is URL with Pencil MCP (open_document, batch_design, find_empty_space_on_canvas, get_screenshot).1011This skill belongs to **pencil-skills**. When input is a Stitch URL or projectId/screenId, Stitch MCP (get_screen) is used to obtain HTML; Stitch skills are responsible for PRD→prototype only, and this skill is responsible for **prototype→.pen design**.1213You are a **design conversion specialist**: Stitch exports Tailwind-based HTML; Pencil uses a node tree and `batch_design` (I/U/R/M/D/C/G). This skill defines **HTML element → Pencil node** mapping rules, **strict execution order**, and **Tailwind → .pen style** mapping (background, color, size, margin, padding, shadow, border-radius) so the drawn artboard is a precise visual match.1415## Prerequisites1617- Stitch MCP Server (https://stitch.withgoogle.com/docs/mcp/guide/) when user provides Stitch URL or projectId/screenId18- Pencil MCP (batch_design, batch_get, open_document, find_empty_space_on_canvas, get_screenshot)19- Stitch projectId and screenId (from URL or list_projects / list_screens), or user-pasted HTML20- Optional: existing .pen file with design system (pencil-ui-design-system-*); otherwise use primitive nodes (frame, text, icon_font)2122## Core References (must follow)2324- **[HTML → Pencil mapping](references/html-to-pencil-mapping.md)** — Which HTML element/semantic block maps to which Pencil node type and batch_design operation (frame, text, ref, icon_font).25- **Execution order and batch split** — Defined in the section below: strict phase order, ≤25 ops per batch_design; canvas prep → root → header → main → sections/cards → forms → footer.26- **[Tailwind → Pencil styles](references/tailwind-to-pencil-styles.md)** — Background, color, size, margin, padding, shadow, border-radius, typography: Tailwind class → .pen property value (fill, padding, gap, stroke, cornerRadius, fontSize, fontWeight, textColor).27- **Per-framework style docs** — When a target framework is set, use that framework’s **\*-to-pencil-styles.md** (sections 0, 12, 14, 15) for component styles, tokens, and design-system refs/constraints: [uview](references/uview-to-pencil-styles.md), [uviewpro](references/uviewpro-to-pencil-styles.md), [element](references/element-to-pencil-styles.md), [bootstrap](references/bootstrap-to-pencil-styles.md), [layui](references/layui-to-pencil-styles.md), [vant](references/vant-to-pencil-styles.md). Cross-framework mapping and "refs vs primitives": [tailwind-to-pencil-styles.md](references/tailwind-to-pencil-styles.md) sections 15–16.2829## Optional Target Framework3031- **Agnostic (default):** No target → use primitive nodes (frame, text, icon_font) and [tailwind-to-pencil-styles.md](references/tailwind-to-pencil-styles.md) for maximum layout/style fidelity without design-system dependency.32- **Target set:** User or config specifies one of: **uView 2**, **uView Pro**, **Bootstrap**, **Element Plus**, **Layui**, **Vant** → (1) use the corresponding **\*-to-pencil-styles.md** for full style mapping and section 15 for design-system refs and batch_design conventions; (2) ensure .pen has the corresponding **pencil-ui-design-system-*** initialized so the .pen aligns with the stitch-*-components skills.3334## Retrieval and HTML35361. **Resolve screen**: From Stitch design URL parse projectId/screenId, or use `list_projects` → `list_screens` → pick screen. If user provides pasted HTML, skip to Parse.372. **get_screen**: Call Stitch MCP `get_screen` with projectId and screenId; obtain `htmlCode.downloadUrl`, `screenshot.downloadUrl`, width, height, title.383. **Download HTML**: Fetch HTML from `htmlCode.downloadUrl` (Bash script or web_fetch); save to e.g. `temp/source.html`. If fetch fails, ask user to paste HTML.394. **Parse**: Extract DOM tree and per-node class list (Tailwind). Preserve element semantics: header, main, section, form, input, button, label, etc.4041## Conversion Pipeline42431. **Apply mapping** (see [html-to-pencil-mapping.md](references/html-to-pencil-mapping.md)): For each HTML element, determine Pencil node type (frame / text / ref / icon_font), parent binding, and default layout/size. If **target framework** is set, prefer design-system refs per that framework's *-to-pencil-styles.md section 15 and [tailwind-to-pencil-styles.md](references/tailwind-to-pencil-styles.md) section 16.442. **Apply styles** (see [tailwind-to-pencil-styles.md](references/tailwind-to-pencil-styles.md)): For each node, resolve Tailwind classes to .pen properties; when target framework is set, prefer that framework's tokens (section 12 of its *-to-pencil-styles.md) and refs (section 15).453. **Build execution plan** (see **Execution order and batch split** below): Split operations into ordered batches (Batch 1: document + root + header + main placeholder; Batch 2: header content; Batch 3–N: per section/card; etc.). Each batch ≤25 ops. When target framework is set, use refs for section/card/hint/divider per that framework's *-to-pencil-styles.md section 15.464. **Run Pencil**: Open document (`open_document('new')` or path); optionally `find_empty_space_on_canvas` for root frame position; then call `batch_design` once per batch in order. After each batch (or at end), call `get_screenshot` on root frame to verify.4748## Execution Steps49501. **Stitch** (if URL/IDs): Get projectId/screenId → get_screen → download HTML (and optionally screenshot for reference). Else use user-pasted HTML.512. **Parse HTML**: Build DOM tree + class list per node; identify semantic regions (header, main, sections, forms).523. **Plan batches**: From the execution order phases below, produce N batch_design payloads (filePath + operations string). Use unique binding names per batch; parent refs from previous batch (e.g. `main` from Batch 1 used as parent in Batch 3).534. **Pencil**: open_document → find_empty_space_on_canvas (if needed) → batch_design(Batch 1) → batch_design(Batch 2) → … → get_screenshot(root) for verification.545. **Verify**: Compare screenshot with Stitch screenshot; note any layout or style gaps for next iteration.5556## Execution order and batch split5758Strict execution order for converting Stitch HTML into Pencil `batch_design` calls: parents must exist before children; each batch **at most 25 operations** (Pencil recommendation).5960### 1. Phase overview6162| Phase | Description | Typical batch | Parent ref |63|-------|-------------|---------------|------------|64| 0 | Canvas prep (optional) | — | — |65| 1 | Document + root + header + main placeholder | Batch 1 | document → root, main |66| 2 | Header content (back, title, actions) | Batch 2 | header |67| 3 | Tabs bar (if present) | Batch 3 | root |68| 4 | Section 1 (card + title + body placeholder) | Batch 4 | main |69| 5 | Section 1 body (form rows, inputs, buttons) | Batch 5 | card1Body |70| 6 | Section 2 (card + …) | Batch 6 | main |71| 7 | Section 2 body | Batch 7 | card2Body |72| … | One batch per section body if large | … | … |73| N | Footer or final dividers | Batch N | main |7475Parents created in an earlier batch are referenced by **binding name** in later batches (e.g. `I(main, ...)`, `I(card1Body, ...)`). Binding names are **unique per batch**; do not reuse the same name across batches for different nodes.7677When a target framework is set, use that framework's refs for section/card, hints, divider, button, input, tabs per that framework's *-to-pencil-styles.md section 15 and [tailwind-to-pencil-styles.md](references/tailwind-to-pencil-styles.md) section 16.7879### 2. Phase 0: Canvas prep (optional)8081- **When**: Before any `batch_design`, if the artboard must be placed at a specific position on the canvas.82- **Actions**: Call `find_empty_space_on_canvas` with desired width/height (e.g. screen width × height from Stitch get_screen). Use returned position when creating the root frame in Phase 1 (x, y on document). No `batch_design` in this phase.8384### 3. Phase 1: Root and main structure (Batch 1)8586**Goal**: Create the root frame, header frame, and main content placeholder so all later content has a parent.8788**Order of operations (≤25):** (1) Insert **root** frame under `document`: layout vertical, width from screen (e.g. 390), **height a fixed value (844 or 884)** so the canvas is not blank—avoid root `fit_content` when children use fill_container. Fill = page background. (2) Insert **header** frame under `root`: layout horizontal, height 56 or 64, width fill_container, padding, fill #fff, optional stroke bottom. (3) Insert **main** frame under `root`: layout vertical, width fill_container, height fit_content(800), padding 16, gap 16, placeholder true.8990**Binding names for later batches:** `root`, `header`, `main`. Style: root fill from `<body>` or wrapper class (bg-*); header/main padding and gap from Tailwind (p-4, space-y-4 → 16).9192### 4. Phase 2: Header content (Batch 2)9394**Goal**: Fill the header with back icon, title text, and optional right actions. **Parent:** `header`. Insert backIcon (icon_font arrow_back), titleText (content = page title), and optionally headerRight frame with actions. Binding names: `backIcon`, `titleText`, `headerRight`.9596### 5. Phase 3: Tabs bar (Batch 3, if present)9798**Goal**: Create the tab row. **Parent:** `root`. Insert **tabsWrap** frame under root (horizontal, height 48), then tab1/tab1Text, tab2/tab2Text, tab3/tab3Text under tabsWrap. If more than 3 tabs, split into Batch 3a/3b or keep under 25 ops total.99100### 6. Phase 4–5: First section / card (Batch 4 + 5)101102**Batch 4** — Parent: `main`. Insert **card1** frame (vertical, fill_container, padding 24, gap 16, fill #fff, cornerRadius 12, stroke 1px); **card1Header** under card1; **card1Title** under card1Header; optional **card1Right**; **card1Body** under card1 (vertical, placeholder true).103104**Batch 5** — Parent: `card1Body`. For each form row: insert row frame, label text, input frame (or ref). If more than ~8 rows, split into Batch 5a, 5b. Binding names: `card1`, `card1Header`, `card1Title`, `card1Body`.105106### 7. Phase 6–7: Second section (Batch 6 + 7)107108Same pattern: **Batch 6** — card2, card2Header, card2Title, card2Body under `main`. **Batch 7** — card2Body children. Repeat for Section 3, 4, … (Batch 8, 9, …). If one section has very many rows, use multiple batches with same parent (e.g. card3Body).109110### 8. Phase N: Footer and final elements111112Insert any footer frame under `main`, or final divider lines. Keep under 25 ops; if many small elements, group into one batch.113114### 9. Batch size and naming rules115116- **Max 25 operations per `batch_design` call.** Split large section bodies (e.g. 15 form rows → Batch 5 first 7, Batch 5b next 8).117- **Binding names:** Unique per batch; use descriptive names (card1, card1Body, inputRow1, labelName). In the **next** batch, reference parents by the binding name from the **previous** batch.118- **Placeholder:** Use `placeholder: true` on frames that will receive many children in the next batch (main, card1Body).119120### 10. Execution order checklist121122Before running Pencil: [ ] Phase 0 optional find_empty_space_on_canvas; [ ] Phase 1 Batch 1 — root, header, main; [ ] Phase 2 Batch 2 — header content; [ ] Phase 3 Batch 3 — tabs if any; [ ] Phase 4–5 Batch 4–5 — card1 + card1Body + body children; [ ] Phase 6–7 Batch 6–7 — card2 + card2Body; [ ] … repeat for remaining sections; [ ] Phase N footer/final; [ ] After all batches: get_screenshot(root) to verify.123124### 11. Example: Minimal page (header + 1 card + 2 rows)125126| Batch | Ops | Content |127|-------|-----|---------|128| 1 | 3 | root, header, main |129| 2 | 2 | backIcon, titleText under header |130| 3 | 6 | card1, card1Header, card1Title, card1Body |131| 4 | 5 | row1, label1, input1; row2, label2, input2 under card1Body |132133Total: 4 batches, 16 operations. Order is fixed: 1 → 2 → 3 → 4.134135## Integration136137- **Stitch screens**: Same pattern as stitch-remotion / stitch-uviewpro-components: list_projects, list_screens, get_screen, download URLs (when user provides Stitch URL/IDs).138- **Pencil**: Same pattern as pencil-ui-designer / pencil-mcp-batch-design: open_document, batch_design (≤25 ops per call), get_screenshot for visual check.139- **Design system**: If .pen has a design system (e.g. uView Pro), prefer refs for Card, Button, Input, Tabs; otherwise use primitive frame + text + icon_font for 100% control over size/margin/shadow.140141## File Structure142143```144skills/pencil-design-from-stitch-html/145├── SKILL.md146├── LICENSE.txt147├── references/148│ ├── html-to-pencil-mapping.md # Element → node + op rule149│ ├── tailwind-to-pencil-styles.md # Generic Tailwind → Pencil; §15–16 framework mapping + refs vs primitives150│ ├── uview-to-pencil-styles.md # uView 2 → Pencil (full style table + §15 refs/constraints)151│ ├── uviewpro-to-pencil-styles.md152│ ├── element-to-pencil-styles.md153│ ├── bootstrap-to-pencil-styles.md154│ ├── layui-to-pencil-styles.md155│ └── vant-to-pencil-styles.md156└── examples/157 ├── usage.md # When to use, steps, MCP flow, example prompts158 ├── sample-batch-ops.md # Minimal page → one batch_design (≤25 ops)159 ├── sample-multi-batch.md # Header + card + form rows → four batches160 ├── sample-with-framework-refs.md # Same page with target framework (refs + tokens)161 └── sample-simple-create-product.md # Simplified Create Product (1–2 batches) for quick validation162```163164## Keywords165166**English:** Stitch, Pencil, batch_design, .pen, HTML to design, Tailwind, layout, fidelity. 167**中文关键词:** Stitch、Pencil、绘图、HTML 转设计稿、批动作。168169## References170171- [Stitch MCP](https://stitch.withgoogle.com/docs/mcp/guide/)172- [Pencil MCP tools](https://github.com/google-labs-code/pencil-skills) / pencil-skills [stitch-html-to-pencil-batch.md](https://github.com/full-stack-skills/pencil-skills/blob/main/docs/stitch-html-to-pencil-batch.md)173- [HTML → Pencil mapping](references/html-to-pencil-mapping.md)174- [Tailwind → Pencil styles](references/tailwind-to-pencil-styles.md) (includes §15–16 framework mapping and refs vs primitives)175- Per-framework style tables (incl. refs/constraints §15): [uview](references/uview-to-pencil-styles.md), [uviewpro](references/uviewpro-to-pencil-styles.md), [element](references/element-to-pencil-styles.md), [bootstrap](references/bootstrap-to-pencil-styles.md), [layui](references/layui-to-pencil-styles.md), [vant](references/vant-to-pencil-styles.md)176- [Examples](examples/usage.md): [usage](examples/usage.md), [single batch](examples/sample-batch-ops.md), [multi-batch](examples/sample-multi-batch.md), [with framework refs](examples/sample-with-framework-refs.md), [simplified Create Product](examples/sample-simple-create-product.md)177178## 能力边界179180### ✅ 适用场景181- 当你需要使用此技能对应的技术栈时182- 当项目需要遵循最佳实践时183- 当需要快速上手或深入理解核心概念时184185### ⚠️ 需要注意186- 复杂业务逻辑需要结合具体场景调整187- 性能优化需要根据实际数据量评估188189### ❌ 不适用场景190- 不相关的技术栈或框架191- 需要完全自定义的特殊场景192193## 常见陷阱 (Gotchas)1941951. **版本兼容性**:注意框架版本与依赖库的兼容性,不同版本 API 可能有差异1962. **配置文件格式**:配置文件格式错误是最常见的问题,建议使用编辑器的语法检查1973. **环境变量**:确保所有必要的环境变量已正确设置,敏感信息不要硬编码1984. **依赖冲突**:多版本共存时注意依赖冲突,使用 lock 文件锁定版本1995. **性能陷阱**:大数据量场景下注意性能优化,避免 N+1 查询等常见问题200201## 使用流程202203### Step 1: 环境准备204确保开发环境已安装必要的依赖和工具。205206### Step 2: 配置初始化207根据项目需求进行基础配置。208209### Step 3: 核心功能使用210按照示例代码实现核心功能。211212### Step 4: 测试验证213运行测试确保功能正常。214215### Step 5: 部署上线216完成开发后进行部署和监控。