--- name: scaffold description: "Autonomous project bootstrapper. Use when starting a new project from scratch ('new project', 'bootstrap', 'create a new app/API/library'). Generates structure, code, tests, docs, and config by orchestrating ba, plan, design, fix, test, docs, and git in one pipeline." metadata: author: runedev version: "0.1.0" layer: L1 model: sonnet group: orchestrator tools: "Read, Write, Edit, Bash, Glob, Grep, WebFetch, WebSearch" --- # scaffold ## Purpose The "zero to production-ready" orchestrator. Takes a project description and autonomously generates a complete, working project — directory structure, code, tests, documentation, git setup, and verification. Orchestrates 8+ skills in sequence to produce output that builds, passes tests, and is ready for development. Generated projects MUST build and pass tests. A scaffold that produces broken code is WORSE than no scaffold. Phase 9 (VERIFY) is mandatory — if verification fails, fix before presenting to user. ## Triggers - `/rune scaffold ` — Interactive mode (asks questions) - `/rune scaffold express ` — Express mode (autonomous) - Called by `team` when task is greenfield project creation - Auto-trigger: when user says "new project", "start from scratch", "bootstrap", "create a new [app/api/lib]" ## Calls (outbound) - `ba` (L2): Phase 1 — requirement elicitation (always, even in Express mode) - `sentinel-env` (L3): Phase 1.5 — environment pre-flight (validate runtime versions, ports, required tools before generating code) - `research` (L3): Phase 2 — best practices, starter templates, library comparison - `plan` (L2): Phase 3 — architecture and implementation plan - `design` (L2): Phase 4 — design system (frontend projects only) - `skill-forge` (L2): when scaffolded project includes custom skills or plugin structure - `fix` (L2): Phase 5 — code generation (implements the plan) - `team` (L1): Phase 5 — parallel implementation when 3+ independent modules - `test` (L2): Phase 6 — test suite generation - `docs` (L2): Phase 7 — README, API docs, architecture doc - `git` (L3): Phase 8 — initial commit with semantic message - `verification` (L3): Phase 9 — lint + types + tests + build - `sentinel` (L2): Phase 9 — security scan on generated code ## Called By (inbound) - User: `/rune scaffold` direct invocation - `team` (L1): when decomposed task is a new project - `cook` (L1): when task is classified as greenfield (rare — cook usually handles features, not projects) ## Modes ### Interactive Mode (default) Full phase-gate workflow. User reviews and approves at each major phase: 1. BA asks 5 questions → user answers 2. Plan presented → user approves 3. Design system presented → user approves (if frontend) 4. Implementation proceeds 5. Results presented with full report ### Express Mode Autonomous mode for detailed descriptions. User provides enough context upfront: 1. BA extracts requirements from description (no questions asked) 2. Plan auto-approved (user gave enough detail) 3. Implementation proceeds autonomously 4. User reviews only the final output Express mode MUST still validate. Auto-approve doesn't mean skip quality checks. BA still extracts requirements — it just doesn't ask questions. Verification (Phase 9) is NEVER skipped in any mode. ## Project Templates Auto-detected from BA output. Template selection informs Phase 3 (Plan) architecture decisions. | Template | Stack | Key Generation Targets | |----------|-------|----------------------| | REST API | Node.js/Python + DB + Auth | Routes, models, middleware, migrations, Docker, CI | | Web App (Full-stack) | Next.js/SvelteKit + DB | Pages, components, API routes, auth, DB setup | | CLI Tool | Node.js/Python/Rust | Commands, arg parsing, config, tests | | Library/Package | TypeScript/Python | Src, tests, build config, npm/pypi publish setup | | MCP Server | TypeScript/Python | Tools, resources, handlers, tests (delegates to mcp-builder) | | Chrome Extension | React/Vanilla | Manifest, popup, content script, background, tests | | Mobile App | React Native/Expo | Screens, navigation, auth, API client | ## Executable Steps ### Phase 1 — BA (Requirement Elicitation) Invoke `rune:ba` with the user's project description. **Interactive Mode**: BA asks 5 questions, discovers hidden requirements, produces Requirements Document. **Express Mode**: BA extracts requirements from the detailed description without asking questions. Still produces Requirements Document with scope, user stories, and acceptance criteria. Output: `.rune/features//requirements.md` Gate: In Interactive mode, user must approve requirements before proceeding. ### Phase 2 — RESEARCH (Best Practices & Templates) Invoke `rune:research` to find: - Best practices for the detected project type - Recommended libraries (compare 2-3 options for each concern) - Starter templates or skeleton projects to reference - Common pitfalls for this stack Do NOT clone templates blindly. Use them as REFERENCE for architecture decisions in Phase 3. ### Phase 3 — PLAN (Architecture & Implementation) Invoke `rune:plan` with the Requirements Document from Phase 1 and research from Phase 2. Plan must include: - Directory structure (exact paths) - File list with purpose of each file - Implementation order (dependency-aware) - Technology choices with rationale - Test strategy (what to test, coverage target) Gate: In Interactive mode, user must approve plan before proceeding. ### Phase 4 — DESIGN (Design System — Frontend Only) If project has frontend (Web App, Mobile App, Chrome Extension): - Invoke `rune:design` to generate design system - Output: `.rune/design-system.md` with tokens, components, patterns If backend-only or CLI → skip this phase. ### Phase 5 — IMPLEMENT (Code Generation) Execute the plan from Phase 3. For each planned file: 1. Create directory structure first 2. Generate shared types/interfaces 3. Generate core modules (models, services, utilities) 4. Generate API layer (routes, controllers, handlers) 5. Generate UI layer (pages, components) if applicable 6. Generate configuration (env, docker, CI) **Parallelization**: If plan has 3+ independent modules → invoke `rune:team` to implement in parallel using worktrees. **Quality during generation**: - Follow project conventions from research - Include proper error handling - Use environment variables for config (never hardcode) - Add TypeScript strict types / Python type hints - Follow file size limits (< 500 LOC per file) ### Phase 6 — TEST (Test Suite Generation) Invoke `rune:test` to generate tests based on acceptance criteria from Phase 1: - Unit tests for each module/function - Integration tests for API endpoints - E2E test template for critical flows - Target: 80%+ coverage on generated code Each acceptance criterion from BA → at least one test case. ### Phase 7 — DOCS (Documentation) Invoke `rune:docs init` to generate: - `README.md` — Quick Start, Features, Tech Stack, Commands - `ARCHITECTURE.md` — if project has 10+ files - `docs/API.md` — if project has API endpoints - `.env.example` — all required environment variables with descriptions ### Phase 8 — GIT (Initial Commit) Invoke `rune:git commit` to create initial commit: - Stage all generated files (except .env, node_modules, __pycache__) - Commit message: `feat: scaffold with