Teaches agents to iteratively build websites using Stitch with an autonomous baton-passing loop pattern
Add this skill
npx mdskills install google-labs-code/stitch-loopComprehensive autonomous site-building loop with clear step-by-step execution protocol and good integration patterns
1---2name: stitch-loop3description: Teaches agents to iteratively build websites using Stitch with an autonomous baton-passing loop pattern4allowed-tools:5 - "stitch*:*"6 - "chrome*:*"7 - "Read"8 - "Write"9 - "Bash"10---1112# Stitch Build Loop1314You 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.1516## Overview1718The Build Loop pattern enables continuous, autonomous website development through a "baton" system. Each iteration:191. Reads the current task from a baton file (`next-prompt.md`)202. Generates a page using Stitch MCP tools213. Integrates the page into the site structure224. Writes the next task to the baton file for the next iteration2324## Prerequisites2526**Required:**27- Access to the Stitch MCP Server28- A Stitch project (existing or will be created)29- A `DESIGN.md` file (generate one using the `design-md` skill if needed)30- A `SITE.md` file documenting the site vision and roadmap3132**Optional:**33- Chrome DevTools MCP Server — enables visual verification of generated pages3435## The Baton System3637The `next-prompt.md` file acts as a relay baton between iterations:3839```markdown40---41page: about42---43A page describing how jules.top tracking works.4445**DESIGN SYSTEM (REQUIRED):**46[Copy from DESIGN.md Section 6]4748**Page Structure:**491. Header with navigation502. Explanation of tracking methodology513. Footer with links52```5354**Critical rules:**55- The `page` field in YAML frontmatter determines the output filename56- The prompt content must include the design system block from `DESIGN.md`57- You MUST update this file before completing your work to continue the loop5859## Execution Protocol6061### Step 1: Read the Baton6263Parse `next-prompt.md` to extract:64- **Page name** from the `page` frontmatter field65- **Prompt content** from the markdown body6667### Step 2: Consult Context Files6869Before generating, read these files:7071| File | Purpose |72|------|---------|73| `SITE.md` | Site vision, **Stitch Project ID**, existing pages (sitemap), roadmap |74| `DESIGN.md` | Required visual style for Stitch prompts |7576**Important checks:**77- Section 4 (Sitemap) — Do NOT recreate pages that already exist78- Section 5 (Roadmap) — Pick tasks from here if backlog exists79- Section 6 (Creative Freedom) — Ideas for new pages if roadmap is empty8081### Step 3: Generate with Stitch8283Use the Stitch MCP tools to generate the page:84851. **Discover namespace**: Run `list_tools` to find the Stitch MCP prefix862. **Get or create project**:87 - If `stitch.json` exists, use the `projectId` from it88 - Otherwise, call `[prefix]:create_project` and save the ID to `stitch.json`893. **Generate screen**: Call `[prefix]:generate_screen_from_text` with:90 - `projectId`: The project ID91 - `prompt`: The full prompt from the baton (including design system block)92 - `deviceType`: `DESKTOP` (or as specified)934. **Retrieve assets**: Call `[prefix]:get_screen` to get:94 - `htmlCode.downloadUrl` — Download and save as `queue/{page}.html`95 - `screenshot.downloadUrl` — Download and save as `queue/{page}.png`9697### Step 4: Integrate into Site98991. Move generated HTML from `queue/{page}.html` to `site/public/{page}.html`1002. Fix any asset paths to be relative to the public folder1013. Update navigation:102 - Find existing placeholder links (e.g., `href="#"`) and wire them to the new page103 - Add the new page to the global navigation if appropriate1044. Ensure consistent headers/footers across all pages105106### Step 4.5: Visual Verification (Optional)107108If the **Chrome DevTools MCP Server** is available, verify the generated page:1091101. **Check availability**: Run `list_tools` to see if `chrome*` tools are present1112. **Start dev server**: Use Bash to start a local server (e.g., `npx serve site/public`)1123. **Navigate to page**: Call `[chrome_prefix]:navigate` to open `http://localhost:3000/{page}.html`1134. **Capture screenshot**: Call `[chrome_prefix]:screenshot` to capture the rendered page1145. **Visual comparison**: Compare against the Stitch screenshot (`queue/{page}.png`) for fidelity1156. **Stop server**: Terminate the dev server process116117> **Note:** This step is optional. If Chrome DevTools MCP is not installed, skip to Step 5.118119### Step 5: Update Site Documentation120121Modify `SITE.md`:122- Add the new page to Section 4 (Sitemap) with `[x]`123- Remove any idea you consumed from Section 6 (Creative Freedom)124- Update Section 5 (Roadmap) if you completed a backlog item125126### Step 6: Prepare the Next Baton (Critical)127128**You MUST update `next-prompt.md` before completing.** This keeps the loop alive.1291301. **Decide the next page**:131 - Check `SITE.md` Section 5 (Roadmap) for pending items132 - If empty, pick from Section 6 (Creative Freedom)133 - Or invent something new that fits the site vision1342. **Write the baton** with proper YAML frontmatter:135136```markdown137---138page: achievements139---140A competitive achievements page showing developer badges and milestones.141142**DESIGN SYSTEM (REQUIRED):**143[Copy the entire design system block from DESIGN.md]144145**Page Structure:**1461. Header with title and navigation1472. Badge grid showing unlocked/locked states1483. Progress bars for milestone tracking149```150151## File Structure Reference152153```154project/155├── next-prompt.md # The baton — current task156├── stitch.json # Stitch project ID (persist this!)157├── DESIGN.md # Visual design system (from design-md skill)158├── SITE.md # Site vision, sitemap, roadmap159├── queue/ # Staging area for Stitch output160│ ├── {page}.html161│ └── {page}.png162└── site/public/ # Production pages163 ├── index.html164 └── {page}.html165```166167## Orchestration Options168169The loop can be driven by different orchestration layers:170171| Method | How it works |172|--------|--------------|173| **CI/CD** | GitHub Actions triggers on `next-prompt.md` changes |174| **Human-in-loop** | Developer reviews each iteration before continuing |175| **Agent chains** | One agent dispatches to another (e.g., Jules API) |176| **Manual** | Developer runs the agent repeatedly with the same repo |177178The skill is orchestration-agnostic — focus on the pattern, not the trigger mechanism.179180## Design System Integration181182This skill works best with the `design-md` skill:1831841. **First time setup**: Generate `DESIGN.md` using the `design-md` skill from an existing Stitch screen1852. **Every iteration**: Copy Section 6 ("Design System Notes for Stitch Generation") into your baton prompt1863. **Consistency**: All generated pages will share the same visual language187188## Common Pitfalls189190- ❌ Forgetting to update `next-prompt.md` (breaks the loop)191- ❌ Recreating a page that already exists in the sitemap192- ❌ Not including the design system block in the prompt193- ❌ Leaving placeholder links (`href="#"`) instead of wiring real navigation194- ❌ Forgetting to persist `stitch.json` after creating a new project195196## Troubleshooting197198| Issue | Solution |199|-------|----------|200| Stitch generation fails | Check that the prompt includes the design system block |201| Inconsistent styles | Ensure DESIGN.md is up-to-date and copied correctly |202| Loop stalls | Verify `next-prompt.md` was updated with valid frontmatter |203| Navigation broken | Check all internal links use correct relative paths |204
Full transparency — inspect the skill content before installing.