Get the FREE Ultimate OpenClaw Setup Guide →

stitch-loop

Scanned
npx machina-cli add skill partme-ai/stitch-skills/stitch-loop --openclaw
Files (1)
SKILL.md
6.7 KB

Stitch 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-project or MCP create_project if 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 page frontmatter 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.md before 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

FilePurpose
SITE.mdSite vision, Stitch Project ID, sitemap (Section 4), roadmap (Section 5), creative freedom (Section 6)
DESIGN.mdVisual 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):

  1. Discover prefix: Run list_tools to find the Stitch MCP prefix.
  2. Get or create project: If stitch.json exists, use its projectId; else call [prefix]:create_project and save ID to stitch.json.
  3. Generate screen: Call [prefix]:generate_screen_from_text with projectId, prompt (full baton content including DESIGN SYSTEM), deviceType (e.g. DESKTOP).
  4. Retrieve assets: Call [prefix]:get_screen; download htmlCode.downloadUrlqueue/{page}.html, screenshot.downloadUrlqueue/{page}.png.

Step 4: Integrate into Site

  1. Move queue/{page}.htmlsite/public/{page}.html.
  2. Fix asset paths to be relative to the public folder.
  3. Update navigation: wire placeholder links (href="#") to the new page; add to global nav if appropriate.
  4. Keep headers/footers consistent across pages.

Step 4.5: Visual Verification (Optional)

If Chrome DevTools MCP is available, verify the generated page:

  1. Run list_tools to see if chrome* tools are present.
  2. Start a local server (e.g. npx serve site/public).
  3. Use [chrome_prefix]:navigate to open http://localhost:3000/{page}.html.
  4. Use [chrome_prefix]:screenshot to capture the rendered page.
  5. Compare with the Stitch screenshot (queue/{page}.png) for fidelity.
  6. 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.

  1. Choose next page: Section 5 (Roadmap) → Section 6 (Creative Freedom) → or invent one that fits the vision.
  2. Write next-prompt.md with 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):

MethodHow it works
CI/CDGitHub Actions or similar runs on next-prompt.md changes.
Human-in-loopDeveloper reviews each iteration before continuing.
Agent chainsOne agent dispatches to another (e.g. Jules API).
ManualDeveloper 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.json after creating a project

Troubleshooting

IssueSolution
Stitch generation failsEnsure prompt includes DESIGN SYSTEM block from DESIGN.md
Inconsistent stylesKeep DESIGN.md up to date; copy Section 6 correctly
Loop stallsVerify next-prompt.md has valid frontmatter and body
Broken navigationUse 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

  1. Step 1: Ensure prerequisites are ready (Stitch MCP Server, a Stitch project, DESIGN.md, SITE.md, and next-prompt.md)
  2. Step 2: Open next-prompt.md, parse the frontmatter 'page' and the body prompt; confirm DESIGN SYSTEM is included
  3. 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

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers