Stitch Build Loop
You are an autonomous website builder that generates a multi-page Symbiote.js SPA through iterative Stitch screen generation.
Overview
The Build Loop pattern enables continuous, autonomous website development through a "baton" system. Each iteration:
- Reads the current task from a baton file (
next-prompt.md) - Generates a page using Stitch MCP tools
- Converts HTML to a Symbiote.js page component
- Integrates the page into the SPA with AppRouter
- Writes the next task to the baton file for the next iteration
Prerequisites
Required:
- Access to the Stitch MCP Server
- Access to the Project Graph MCP Server
- A Stitch project (existing or will be created)
- A
DESIGN.mdfile (generate one using thedesign-mdskill if needed) - A
SITE.mdfile documenting the site vision and roadmap
Optional:
- Browser tool — enables visual verification of generated pages
The Baton System
The next-prompt.md file acts as a relay baton between iterations:
---
page: about
route: /about
---
An about page describing the team and mission.
**DESIGN SYSTEM (REQUIRED):**
[Copy from DESIGN.md Section 5]
**Page Structure:**
1. Header with navigation
2. Team member grid with avatar cards
3. Mission statement section
4. Footer with links
Critical rules:
- The
pagefield determines the component and file name - The
routefield sets the AppRouter path pattern - The prompt must include the design system block from
DESIGN.md - You MUST update this file before completing to continue the loop
Execution Protocol
Step 1: Read the Baton
Parse next-prompt.md to extract:
- Page name from
pagefrontmatter - Route path from
routefrontmatter - Prompt content from the markdown body
Step 2: Consult Context Files
Before generating, read these files:
| File | Purpose |
|---|---|
SITE.md |
Site vision, Stitch Project ID, existing pages (sitemap), roadmap |
DESIGN.md |
Required visual style and CSS custom properties 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
- Discover namespace: Run
list_toolsto find the Stitch MCP prefix - Get or create project:
- If
stitch.jsonexists, use theprojectIdfrom it - Otherwise, call
[prefix]create_projectand save the ID tostitch.json
- If
- 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: Call
[prefix]get_screento get:htmlCode.downloadUrl— Download and save asqueue/{page}.htmlscreenshot.downloadUrl— Download and save asqueue/{page}.png
Step 4: Convert to Symbiote Component
Transform the Stitch HTML into a Symbiote.js page component:
Create triple-file structure:
src/pages/{PageName}/ ├── {PageName}.js ├── {PageName}.tpl.js └── {PageName}.css.jsExtract colors and values → map to CSS custom properties from
DESIGN.mdConvert inline styles and framework classes to native CSS using custom properties
Use custom element tag names:
page-about,page-home, etc.
Step 5: Integrate into SPA
- Register the page component in the AppRouter routing map:
import { AppRouter } from '@symbiotejs/symbiote/core/AppRouter.js';
const routerCtx = AppRouter.initRoutingCtx('R', {
home: { pattern: '/', title: 'Home', default: true },
about: { pattern: '/about', title: 'About' },
// Add new page route here
});
- Add lazy loading for the new page:
{pageName}: {
pattern: '/{route}',
title: '{Page Title}',
load: () => import('./pages/{PageName}/{PageName}.js'),
},
- Update navigation links across all pages
- Ensure consistent headers/footers
- If this is the first page, set up
index.htmlusingresources/global-styles-template.md(at project root) — includes CSS reset, font loading, importmap, and design tokens
Step 6: Validate with Project Graph MCP
Run the full validation sequence (see resources/project-graph-workflow.md at project root):
get_skeleton(path)— verify page component appears with correct structureget_full_analysis(path)— target Health Score ≥ 80check_custom_rules(path)— auto-detects Symbiote, validates conventionsget_undocumented(path)— ensure JSDoc on interactive methods- Add
@test/@expectannotations to interactive handlers get_pending_tests(path)→ execute each test →mark_test_passed(id)- Optionally, open in browser to compare against Stitch screenshot
Step 7: Update Site Documentation
Modify SITE.md:
- Add the new page to Section 4 (Sitemap) with
[x] - Update Section 5 (Roadmap) if you completed a backlog item
Step 8: Prepare the Next Baton (CRITICAL)
You MUST update next-prompt.md before completing. This keeps the loop alive.
- Decide the next page:
- Check
SITE.mdSection 5 (Roadmap) for pending items - If empty, pick from Section 6 (Creative Freedom)
- Or invent something new that fits the site vision
- Check
- Write the baton with proper YAML frontmatter:
---
page: achievements
route: /achievements
---
A competitive achievements page showing developer badges and milestones.
**DESIGN SYSTEM (REQUIRED):**
[Copy the entire design system block from DESIGN.md]
**Page Structure:**
1. Header with title and navigation
2. Badge grid showing unlocked/locked states
3. Progress bars for milestone tracking
File Structure Reference
project/
├── stitch.json # Stitch project ID and metadata
├── DESIGN.md # Design system (CSS custom properties)
├── SITE.md # Site vision, sitemap, roadmap
├── next-prompt.md # Current baton for the build loop
├── queue/ # Raw Stitch HTML files (staging area)
│ ├── home.html
│ └── home.png
├── src/
│ ├── app-root.js # Root component with AppRouter
│ ├── components/ # Shared components (nav, footer)
│ │ ├── AppNav/
│ │ └── AppFooter/
│ └── pages/ # Page components (one per route)
│ ├── Home/
│ │ ├── Home.js
│ │ ├── Home.tpl.js
│ │ └── Home.css.js
│ └── About/
│ ├── About.js
│ ├── About.tpl.js
│ └── About.css.js
└── index.html # Entry point (see resources/global-styles-template.md)
Common Pitfalls
- ❌ Forgetting to update
next-prompt.md— breaks the loop - ❌ Not including the design system block in prompts — inconsistent designs
- ❌ Creating duplicate pages — always check SITE.md sitemap first
- ❌ Using framework CSS classes in converted components — use native CSS with custom properties
- ❌ Hardcoding routes — use AppRouter with
patternfor path-based routing