stitch-loop
Scannednpx machina-cli add skill partme-ai/stitch-skills/stitch-loop --openclawStitch Build Loop
Constraint: Only use this skill when the user explicitly mentions "Stitch" and multi-page or iterative site building.
You are an autonomous frontend builder in an iterative site-building loop. Each iteration: (1) Read the baton (next-prompt.md), (2) Generate a page with Stitch MCP, (3) Integrate into the site, (4) Write the next baton so the loop continues.
Prerequisites
Required:
- Stitch MCP Server (see https://stitch.withgoogle.com/docs/mcp/guide/)
- A Stitch project (create with
stitch-mcp-create-projector MCPcreate_projectif needed) DESIGN.md(generate with stitch-design-md from an existing screen if missing)SITE.md(site vision, Stitch Project ID, sitemap, roadmap)
Optional: Chrome DevTools MCP for visual verification of generated pages.
The Baton System
next-prompt.md is the relay baton between iterations:
---
**DESIGN SYSTEM (REQUIRED):**
[Copy from DESIGN.md Section 6]
**Page Structure:**
1. Header with navigation
2. Explanation of tracking methodology
3. Footer with links
Rules:
- The
pagefrontmatter field determines the output filename (e.g.about.html). - Prompt body must include the design system block from
DESIGN.md. - You MUST update
next-prompt.mdbefore completing so the loop continues.
Execution Protocol
Step 1: Read the Baton
Parse next-prompt.md: extract page from frontmatter and the full prompt from the body.
Step 2: Consult Context Files
| File | Purpose |
|---|---|
SITE.md | Site vision, Stitch Project ID, sitemap (Section 4), roadmap (Section 5), creative freedom (Section 6) |
DESIGN.md | Visual style; copy Section 6 into each baton prompt |
Checks: Do not recreate pages already in Section 4 (Sitemap). Pick next task from Section 5 (Roadmap) or Section 6 (Creative Freedom) if roadmap is empty.
Step 3: Generate with Stitch
Use Stitch MCP (or skills stitch-mcp-create-project, stitch-mcp-generate-screen-from-text, stitch-mcp-get-screen):
- Discover prefix: Run
list_toolsto find the Stitch MCP prefix. - Get or create project: If
stitch.jsonexists, use itsprojectId; else call[prefix]:create_projectand save ID tostitch.json. - Generate screen: Call
[prefix]:generate_screen_from_textwithprojectId,prompt(full baton content including DESIGN SYSTEM),deviceType(e.g. DESKTOP). - Retrieve assets: Call
[prefix]:get_screen; downloadhtmlCode.downloadUrl→queue/{page}.html,screenshot.downloadUrl→queue/{page}.png.
Step 4: Integrate into Site
- Move
queue/{page}.html→site/public/{page}.html. - Fix asset paths to be relative to the public folder.
- Update navigation: wire placeholder links (
href="#") to the new page; add to global nav if appropriate. - Keep headers/footers consistent across pages.
Step 4.5: Visual Verification (Optional)
If Chrome DevTools MCP is available, verify the generated page:
- Run
list_toolsto see ifchrome*tools are present. - Start a local server (e.g.
npx serve site/public). - Use
[chrome_prefix]:navigateto openhttp://localhost:3000/{page}.html. - Use
[chrome_prefix]:screenshotto capture the rendered page. - Compare with the Stitch screenshot (
queue/{page}.png) for fidelity. - Stop the server when done.
If Chrome DevTools MCP is not installed, skip to Step 5.
Step 5: Update Site Documentation
Update SITE.md: add the new page to Section 4 (Sitemap) with [x]; remove consumed ideas from Section 6; update Section 5 if a backlog item was completed.
Step 6: Prepare the Next Baton (Critical)
You MUST update next-prompt.md before completing.
- Choose next page: Section 5 (Roadmap) → Section 6 (Creative Freedom) → or invent one that fits the vision.
- Write
next-prompt.mdwith valid YAML frontmatter (page: <name>) and full prompt body including DESIGN SYSTEM (REQUIRED) copied from DESIGN.md.
File Structure
project/
├── next-prompt.md # Baton — current task
├── stitch.json # Stitch project ID (persist!)
├── DESIGN.md # From stitch-design-md
├── SITE.md # Vision, sitemap, roadmap
├── queue/ # Staging: {page}.html, {page}.png
└── site/public/ # Production: index.html, {page}.html
Orchestration Options
The loop can be driven by different triggers (local exceeds official by documenting all options):
| Method | How it works |
|---|---|
| CI/CD | GitHub Actions or similar runs on next-prompt.md changes. |
| Human-in-loop | Developer reviews each iteration before continuing. |
| Agent chains | One agent dispatches to another (e.g. Jules API). |
| Manual | Developer runs the agent repeatedly with the same repo. |
The skill is orchestration-agnostic; focus on the baton pattern, not the trigger.
Integration with This Repo
- DESIGN.md: Create with stitch-design-md from an existing Stitch screen; copy Section 6 into every baton prompt.
- Prompt quality: Use stitch-ui-prompt-architect to enhance vague baton text or to merge design spec + request into a Stitch-ready prompt.
- MCP tools: Use stitch-mcp-create-project, stitch-mcp-generate-screen-from-text, stitch-mcp-get-screen (or underlying MCP) for create/generate/get.
Common Pitfalls
- ❌ Forgetting to update
next-prompt.md(loop stops) - ❌ Recreating a page already in the sitemap
- ❌ Omitting the design system block from the prompt
- ❌ Leaving
href="#"instead of wiring real links - ❌ Not persisting
stitch.jsonafter creating a project
Troubleshooting
| Issue | Solution |
|---|---|
| Stitch generation fails | Ensure prompt includes DESIGN SYSTEM block from DESIGN.md |
| Inconsistent styles | Keep DESIGN.md up to date; copy Section 6 correctly |
| Loop stalls | Verify next-prompt.md has valid frontmatter and body |
| Broken navigation | Use correct relative paths for internal links |
Keywords
English: stitch-loop, baton, next-prompt, SITE.md, DESIGN.md, multi-page, iterative.
中文关键词: stitch-loop、接力、next-prompt、多页、迭代建站。
References
Source
git clone https://github.com/partme-ai/stitch-skills/blob/main/skills/stitch-loop/SKILL.mdView on GitHub Overview
Automates building a Stitch-based site through a baton-passing loop. Each cycle reads next-prompt.md, generates a new page with Stitch MCP (create_project, generate_screen_from_text, get_screen), then integrates it into SITE.md/site and writes the next baton to continue. Uses stitch-design-md and stitch-ui-prompt-architect for design consistency.
How This Skill Works
The process reads the baton, consults SITE.md and DESIGN.md for context, then invokes Stitch MCP commands to generate a screen from the prompt. It retrieves HTML and assets, moves them into site/public, fixes relative paths, updates navigation, and writes the refreshed next-prompt.md to continue the loop. Optional Chrome DevTools MCP verification can be used for visual checks when available.
When to Use It
- Starting a new multi-page Stitch site workflow from a baton
- Extending an existing Stitch project with additional pages following the Roadmap
- Enforcing design consistency by incorporating DESIGN.md with stitch-design-md
- Keeping SITE.md and next-prompt.md synchronized after each iteration
- When you want optional visual verification with Chrome DevTools MCP
Quick Start
- Step 1: Ensure prerequisites are ready (Stitch MCP Server, a Stitch project, DESIGN.md, SITE.md, and next-prompt.md)
- Step 2: Open next-prompt.md, parse the frontmatter 'page' and the body prompt; confirm DESIGN SYSTEM is included
- Step 3: Run the Stitch MCP sequence (discover prefix, create/load project, generate_screen_from_text with full baton, get_screen), then integrate into site/public and update next-prompt.md
Best Practices
- Always include the DESIGN SYSTEM block from DESIGN.md in the baton prompt
- Ensure the 'page' frontmatter matches the output filename (e.g., about.html)
- Validate asset paths are relative to the site/public folder after integration
- Keep headers and footers consistent across all generated pages
- Use Chrome DevTools MCP for optional visual checks when available
Example Use Cases
- Company landing site with about, services, and contact pages
- Documentation site with a multi-page navigation
- Portfolio site featuring multiple project detail pages
- Product catalog with category and detail pages
- Blog with index and individual article pages