Purpose: Autonomous infrastructure provisioning system for enterprise-grade SaaS scaffolding.
This isn't a boilerplate. It's an autonomous scaffolding system with:
- Configuration Layer — Customize before execution (auth provider, payments, features)
- State Persistence — Resume from any point, track progress across sessions
- Self-Healing — Automatic detection and repair of common issues
- Visual Dashboard — See progress at a glance
- Smoke Testing — End-to-end validation that everything works together
- Guided Handoff — Personalized next steps after completion
You are reading this because a user wants you to scaffold a new SaaS project.
# 1. Check current state
node Masterguide/scaffolding/scripts/scaffold-state.js status
# 2. Get resume instructions
node Masterguide/scaffolding/scripts/resume-scaffold.js prompt
# 3. Execute the indicated phase document
# 4. After each phase, verify and update state
node Masterguide/scaffolding/scripts/verify-phase.js XX
node Masterguide/scaffolding/scripts/scaffold-state.js complete XX-
Run pre-flight checks — Open PREFLIGHT.md and verify all tools are installed.
-
Check for existing state — Run
node Masterguide/scaffolding/scripts/scaffold-state.js status -
Check for config — If
scaffold-config.jsonexists in project root, use those settings.
-
Check state first — Always run
scaffold-state.js statusto see where you are. -
Get instructions — Run
resume-scaffold.js promptfor exactly what to do next. -
Execute one phase at a time — Open the indicated phase document and follow it exactly.
-
Update state after each phase:
# Before starting a phase node Masterguide/scaffolding/scripts/scaffold-state.js start XX # After verification passes node Masterguide/scaffolding/scripts/scaffold-state.js complete XX # If phase fails node Masterguide/scaffolding/scripts/scaffold-state.js fail XX "error message"
-
If something fails — Run the repair script:
node Masterguide/scaffolding/scripts/repair-phase.js XX
- Run repair —
node Masterguide/scaffolding/scripts/repair-phase.js XX - Check troubleshooting — TROUBLESHOOTING.md
- Re-run verification — See exactly what's missing
- Don't guess — If stuck, ask the user rather than improvising
| File | Purpose |
|---|---|
scaffold-config.json |
User configuration (auth, payments, features) |
scaffold-config.schema.json |
Configuration schema with validation |
scaffold-config.example.json |
Example configuration to copy |
scaffold-state.json |
Progress tracking (auto-generated) |
scaffold-dashboard.html |
Visual progress dashboard |
PREFLIGHT.md |
Pre-flight checklist |
TROUBLESHOOTING.md |
Error fixes |
NEXT_STEPS.md |
Post-scaffold guidance (auto-generated) |
| Script | Purpose |
|---|---|
scripts/scaffold-state.js |
State management (status, start, complete, fail) |
scripts/resume-scaffold.js |
Generate resume instructions |
scripts/verify-phase.js |
Verify phase completion |
scripts/repair-phase.js |
Auto-fix common issues |
scripts/smoke-test.js |
End-to-end validation |
scripts/generate-next-steps.js |
Generate NEXT_STEPS.md |
| Phase | Document | Time | Produces |
|---|---|---|---|
| 01 | 01-WORKSPACE | 10m | Monorepo structure, tooling, git |
| 02 | 02-ENVIRONMENT | 5m | Env validation, config management |
| 03 | 03-TYPES | 10m | Shared types, exceptions, error codes |
| 04 | 04-DATABASE | 10m | Schema foundation, migrations, RLS |
| 05 | 05-AUTH | 15m | Auth infrastructure, middleware, JWT |
| 06 | 06-RESILIENCE | 15m | Circuit breakers, retries, locks |
| 07 | 07-WORKERS | 15m | Job system, state machine, DLQ |
| 08 | 08-API | 10m | API foundation, middleware, rate limiting |
| 09 | 09-OBSERVABILITY | 10m | Logging, metrics, health checks |
| 10 | 10-INTEGRATIONS | 10m | Stripe, webhooks, email stubs |
| 11 | 11-FRONTEND | 15m | Design tokens, components, PWA |
| 12 | 12-SECURITY | 15m | CSP headers, audit logging, input sanitization |
| 13 | 13-FILE-STORAGE | 15m | Storage buckets, file validation, upload components |
| 14 | 14-CACHING | 15m | Redis client, cache patterns, session storage |
| 15 | 15-DEPLOYMENT | 20m | Docker Compose, Dockerfiles, health checks, scripts |
Total Time: ~3 hours for complete enterprise foundation
01-WORKSPACE (required for all)
└── 02-ENVIRONMENT
└── 03-TYPES
├── 04-DATABASE
├── 05-AUTH (requires 04)
├── 06-RESILIENCE
├── 07-WORKERS (requires 06)
├── 08-API (requires 05, 06)
├── 09-OBSERVABILITY
├── 10-INTEGRATIONS (requires 05, 07)
├── 11-FRONTEND (requires 02)
├── 12-SECURITY (requires 05, 11)
├── 13-FILE-STORAGE (requires 04, 12)
├── 14-CACHING (requires 06)
└── 15-DEPLOYMENT (requires all above)
# Copy example config
cp Masterguide/scaffolding/scaffold-config.example.json scaffold-config.json
# Edit to customize (auth provider, payments, features, etc.)
# The scaffolding will adapt based on your choices# Check status
node Masterguide/scaffolding/scripts/scaffold-state.js status
# Get next phase instructions
node Masterguide/scaffolding/scripts/resume-scaffold.js prompt
# Execute phase (agent reads and follows the phase document)
# Verify
node Masterguide/scaffolding/scripts/verify-phase.js XX
# Update state
node Masterguide/scaffolding/scripts/scaffold-state.js complete XX
# Repeat until all phases complete# Run smoke test
node Masterguide/scaffolding/scripts/smoke-test.js
# Generate next steps guide
node Masterguide/scaffolding/scripts/generate-next-steps.js
# Open dashboard to see final status
# Open scaffold-dashboard.html in browserAfter scaffolding completes:
- Read
NEXT_STEPS.mdfor personalized setup instructions - Configure environment variables
- Start development with
pnpm dev - Begin building your specific SaaS features
For the human directing the AI agents:
"Copy scaffold-config.example.json to scaffold-config.json in the project root.
Edit it to match your preferences (auth provider, payment provider, etc.).
Then run the pre-flight checks in PREFLIGHT.md."
"Read the scaffolding manifest at Masterguide/scaffolding/00-MANIFEST.md.
Check the scaffold state, then execute the next phase."
"Run: node Masterguide/scaffolding/scripts/resume-scaffold.js prompt
Then execute whatever it tells you."
"Run: node Masterguide/scaffolding/scripts/scaffold-state.js status
Show me the current state of scaffolding."
"Run the repair script: node Masterguide/scaffolding/scripts/repair-phase.js XX
Then re-run verification."
"Run the smoke test: node Masterguide/scaffolding/scripts/smoke-test.js
Then generate next steps: node Masterguide/scaffolding/scripts/generate-next-steps.js"
For optimal context management, batch phases like this:
| Session | Phases | Why |
|---|---|---|
| 1 | 01-02 | Foundation + config (low complexity) |
| 2 | 03-04 | Types + database (related, schema-heavy) |
| 3 | 05 | Auth alone (complex, many files) |
| 4 | 06-07 | Resilience + workers (related patterns) |
| 5 | 08-09 | API + observability (related, middleware) |
| 6 | 10-11 | Integrations + frontend (finishing touches) |
| 7 | 12-13 | Security + file storage (related, security-focused) |
| 8 | 14-15 | Caching + deployment (infrastructure finalization) |
Open scaffold-dashboard.html in a browser to see:
- Overall progress with percentage
- Status of each phase (completed, failed, pending)
- Error history
- Time metrics
- Next action to take
To update the dashboard:
- Run
scaffold-state.js statusto ensure state is current - Open
scaffold-dashboard.html - Click "Load scaffold-state.json" and select the file
After all 15 phases complete:
- All phases show "completed" in state
- Smoke test passes
- NEXT_STEPS.md generated
- Environment variables documented
- Docker stack starts successfully
- Ready for domain-specific development
- PREFLIGHT.md - Pre-flight checklist
- TROUBLESHOOTING.md - Common errors and fixes
- scaffold-config.schema.json - Configuration schema
- ../INDEX.md - Full pattern index
- ../00-foundations/ - Foundation patterns
- ../03-resilience/ - Resilience patterns
- ../04-workers/ - Worker patterns