stitch-loop
This skill enables an agent to autonomously build a website by iteratively passing a "baton" to itself, using Stitch to generate, review, and refine code in a loop until completion.
How to Install
git clone --depth 1 https://github.com/google-labs-code/stitch-skills.git && cp stitch-skills/plugins/stitch-utilities/skills/stitch-loop ~/.claude/skills/stitch-loop -rStitch Build Loop
You are an autonomous frontend builder participating in an iterative site-building loop. Your goal is to generate a page using Stitch, integrate it into the site, and prepare instructions for the next iteration.
When to Use
- You are iteratively building a website with Stitch using a baton-based loop across runs or agents.
- Each pass should read the next prompt, generate or integrate a page, and hand off the next task.
- You need a disciplined autonomous loop for multi-step frontend site construction.
Overview
The Build Loop pattern enables continuous, autonomous website development through a "baton" system. Each iteration:
1. Reads the current task from a baton file (.stitch/next-prompt.md)
2. Generates a page using Stitch MCP tools
3. Integrates the page into the site structure
4. Writes the next task to the baton file for the next iteration
Prerequisites
Required:
- Access to the Stitch MCP Server
- A Stitch project (existing or will be created)
- A .stitch/DESIGN.md file (generate one using the design-md skill if needed)
- A .stitch/SITE.md file documenting the site vision and roadmap
Optional: - Chrome DevTools MCP Server — enables visual verification of generated pages
The Baton System
The .stitch/next-prompt.md file acts as a relay baton between iterations:
---
page: about
---
A page describing how jules.top tracking works.
**DESIGN SYSTEM (REQUIRED):**
[Copy from .stitch/DESIGN.md Section 6]
**Page Structure:**
1. Header with navigation
2. Explanation of tracking methodology
3. Footer with links
Critical rules:
- The page field in YAML frontmatter determines the output filename
- The prompt content must include the design system block from .stitch/DESIGN.md
- You MUST update this file before completing your work to continue the loop
Execution Protocol
Step 1: Read the Baton
Parse .stitch/next-prompt.md to extract:
- Page name from the page frontmatter field
- Prompt content from the markdown body
Step 2: Consult Context Files
Before generating, read these files:
| File | Purpose |
|---|---|
.stitch/SITE.md |
Site vision, Stitch Project ID, existing pages (sitemap), roadmap |
.stitch/DESIGN.md |
Required visual style for Stitch prompts |
Important checks: - Section 4 (Sitemap) — Do NOT recreate pages that already exist - Section 5 (Roadmap) — Pick tasks from here if backlog exists - Section 6 (Creative Freedom) — Ideas for new pages if roadmap is empty
Step 3: Generate with Stitch
Use the Stitch MCP tools to generate the page:
- Discover namespace: Run
list_toolsto find the Stitch MCP prefix - Get or create project:
- If
.stitch/metadata.jsonexists, use theprojectIdfrom it - Otherwise, call
[prefix]:create_project, then call[prefix]:get_projectto retrieve full project details, and save them to.stitch/metadata.json(see schema below) - After generating each screen, call
[prefix]:get_projectagain and update thescreensmap in.stitch/metadata.jsonwith each screen's full metadata (id, sourceScreen, dimensions, canvas position) - Generate screen: Call
[prefix]:generate_screen_from_textwith: projectId: The project IDprompt: The full prompt from the baton (including design system block)deviceType:DESKTOP(or as specified)- Retrieve assets: Before downloading, check if
.stitch/designs/{page}.htmland.stitch/designs/{page}.pngalready exist: - If files exist: Ask the user whether to refresh the designs from the Stitch project or reuse the existing local files. Only re-download if the user confirms.
- If files do not exist: Proceed with download:
htmlCode.downloadUrl— Download and save as.stitch/designs/{page}.htmlscreenshot.downloadUrl— Append=w{width}to the URL before downloading, where{width}is thewidthvalue from the screen metadata (Google CDN serves low-res thumbnails by default). Save as.stitch/designs/{page}.png
Step 4: Integrate into Site
- Move generated HTML from
.stitch/designs/{page}.htmltosite/public/{page}.html - Fix any asset paths to be relative to the public folder
- Update navigation:
- Find existing placeholder links (e.g.,
href="#") and wire them to the new page - Add the new page to the global navigation if appropriate
- Ensure consistent headers/footers across all pages
Step 4.5: Visual Verification (Optional)
If the Chrome DevTools MCP Server is available, verify the generated page:
- Check availability: Run
list_toolsto see ifchrome*tools are present - Start dev server: Use Bash to start a local server (e.g.,
npx serve site/public) - Navigate to page: Call
[chrome_prefix]:navigateto openhttp://localhost:3000/{page}.html - Capture screenshot: Call
[chrome_prefix]:screenshotto capture the rendered page - **Visual compa
Details
| Category | AI/ML → agents |
| Source | google-labs-code/stitch-skills |
| SKILL.md | View on GitHub → |
| Repo Stars | ★ 6.1K |
| Est. per Skill | 438 (shared across 14 skills from this repo) |
| Difficulty | Intermediate |
| Risk Level | Safe |
Related Skills
Works Well With
Skills from the same repository — often designed to work together