Stitch-kit stitch-loop
Iteratively build multi-page websites using Stitch. Reads next-prompt.md (the baton), generates the next page with Stitch MCP, integrates it into the site, then updates next-prompt.md to continue the loop. Works with stitch-design-md and stitch-ui-prompt-architect for consistent multi-page output.
git clone https://github.com/gabelul/stitch-kit
T=$(mktemp -d) && git clone --depth=1 https://github.com/gabelul/stitch-kit "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/stitch-loop" ~/.claude/skills/gabelul-stitch-kit-stitch-loop && rm -rf "$T"
skills/stitch-loop/SKILL.mdStitch 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, (2) Generate a page with Stitch MCP, (3) Integrate into the site, (4) Write the next baton so the loop continues.
Prerequisites
- Stitch MCP Server (see
skill or https://stitch.withgoogle.com/docs/mcp/guide/)stitch-setup
— generate withDESIGN.md
from an existing screen (required for consistency)stitch-design-system
— site vision, Stitch project ID, sitemap, roadmap (create if missing)SITE.md
The baton system
next-prompt.md is the relay baton between iterations. It tells the loop what page to build next.
Baton format
--- page: about --- **DESIGN SYSTEM (REQUIRED):** [Paste DESIGN.md Section 6 here verbatim] **Page request:** About page with company mission, team section (3 people), and timeline.
Rules:
frontmatter → output filename (page
)about.html- The body must include the design system block from
Section 6DESIGN.md - You must update
at the end of every iteration — the loop stops if this is missingnext-prompt.md
Execution protocol
Step 1 — Read the baton
Parse
next-prompt.md:
- Extract
from YAML frontmatterpage - Extract the full prompt body (including the design system block)
Step 2 — Consult context files
| File | What to look for |
|---|---|
| Stitch project ID (Section 2), sitemap (Section 3), roadmap / next pages (Section 4), creative freedom (Section 5) |
| Section 6 — copy this into every prompt, not just the current one |
Check: Do not rebuild pages already in
SITE.md sitemap. Do not deviate from the visual language in DESIGN.md.
Step 3 — Generate with Stitch
- Run
→ find Stitch MCP prefixlist_tools - If
exists, use storedstitch.json
— do not create a new projectprojectId - If no
, callstitch.json
→ save numeric ID tocreate_projectstitch.json - Call
:generate_screen_from_text
: numeric ID (noprojectId
prefix)projects/
: full baton content including DESIGN SYSTEM blockprompt
: match what's indeviceType
orSITE.mdDESIGN.md
- Call
with numeric projectId + screenIdget_screen - Download HTML:
bash scripts/fetch-stitch.sh "[htmlCode.downloadUrl]" "queue/[page].html" - Download screenshot: save to
queue/[page].png
Step 4 — Integrate into site
- Move
→queue/[page].htmlsite/public/[page].html - Fix asset paths (make relative to
)site/public/ - Wire navigation: replace
placeholders with real paths to existing pageshref="#" - Ensure the header/footer matches other pages in the site
Step 4.5 — Visual verification (if Chrome DevTools MCP available)
If
chrome* tools are in list_tools:
- Start local server:
npx serve site/public -p 3000 - Navigate to
http://localhost:3000/[page].html - Take screenshot, compare against
queue/[page].png - Stop server
Step 5 — Update SITE.md
- Add
to the sitemap[x] [page].html - Remove consumed ideas from creative freedom section
- Update roadmap if a backlog item was completed
Step 6 — Write the next baton (CRITICAL)
You must update
before completing — the loop stalls if you skip this.next-prompt.md
- Pick next page from: sitemap → roadmap → creative freedom → or invent one that fits
- Write
with:next-prompt.md- Valid YAML frontmatter (
)page: <next-page-name>
block copied verbatim from**DESIGN SYSTEM (REQUIRED):**
Section 6DESIGN.md- Clear page description
- Valid YAML frontmatter (
File structure
project/ ├── next-prompt.md ← Baton (current task; updated each iteration) ├── stitch.json ← Stitch project ID (persist between loops!) ├── DESIGN.md ← From stitch-design-system ├── SITE.md ← Vision, sitemap, roadmap ├── queue/ ← Staging: [page].html, [page].png └── site/ └── public/ ← Production: index.html, about.html, etc.
SITE.md template
# Site Vision [One paragraph describing the site's purpose, audience, and overall feeling] ## Stitch Project - **Project ID (numeric):** [ID from stitch-mcp-create-project] ## Sitemap - [ ] index.html — Home - [ ] about.html — About - [ ] contact.html — Contact ## Roadmap 1. index.html — main landing page 2. about.html — company/team info 3. contact.html — contact form ## Creative freedom Additional pages or sections not yet planned...
Common pitfalls
- ❌ Forgetting to update
(loop stops)next-prompt.md - ❌ Rebuilding a page already in SITE.md sitemap
- ❌ Omitting
Section 6 from the prompt (causes visual drift)DESIGN.md - ❌ Using
format instead of numeric inprojects/IDgenerate_screen_from_text - ❌ Leaving
instead of wiring real page linkshref="#" - ❌ Not persisting
(creates new project every iteration)stitch.json
Troubleshooting
| Issue | Fix |
|---|---|
| Inconsistent visual styles across pages | Keep DESIGN.md updated; always copy Section 6 into baton |
| Loop stalls at next iteration | Check has valid frontmatter and non-empty body |
| Stitch generation fails | Ensure baton includes DESIGN SYSTEM block and a specific page request |
| Broken navigation | Use relative paths for internal links; check structure |
References
— Reliable GCS HTML downloaderscripts/fetch-stitch.sh
— Generate DESIGN.md from an existing screenstitch-design-system
— Enhance vague baton text into structured promptsstitch-ui-prompt-architect
— PRD-driven multi-screen workflowdocs/prd-to-stitch-workflow.md