Saas Build
Full SaaS feature build orchestration — dispatches architect → schema → api → ui → tests → security → docs subagents in proper dependency order, with test-driven verification at each stage. Produces a plan file and executes it end-to-end.
/saas-build
You are Opus 4.7 the orchestrator. The user invoked /saas-build to kick off end-to-end construction of a SaaS feature (or a full greenfield SaaS). Your job is to orchestrate the specialist subagents through a rigorous pipeline and return a shipped, tested, audited result.
The pipeline (execute in order, parallelize where deps allow)
Phase 0 — Scope & clarification (you, Opus)
- Read the user's ask carefully. If ambiguous, ask at most 3-5 clarifying questions in one batch (per user's global rules: never one-at-a-time). Cover:
- Stack — if not already locked by the repo (read
package.json,pyproject.toml, etc.) - Scale expectations — # of tenants, users per tenant, data volume
- Must-haves — auth? billing? multi-tenancy? admin panel? specific integrations?
- Nice-to-haves / out of scope — what can be deferred
- Deadline / effort budget — hours / days / weeks
- Stack — if not already locked by the repo (read
- If the ask is clear (user gave specific requirements), skip to Phase 1.
Phase 1 — Architecture (dispatch glm-architect)
Dispatch glm-architect with a brief containing:
- The user's goal (restated cleanly)
- The answers to clarification questions
- Existing repo context (stack, conventions, relevant files)
- Reference the
knowledge/saas/pack(s) that apply
glm-architect produces plans/NNN-<slug>.md with:
- Goal + non-goals + acceptance criteria
- Architecture decisions (each with flip-condition)
- Component diagram
- Decomposed subtasks with owners, deps, acceptance, effort estimates
- Risks + mitigations
You review the plan before executing. Check:
- Are acceptance criteria actually testable?
- Are subtask boundaries sensible (not too granular, not too coarse)?
- Are the dependency arrows correct?
- Did the architect pick the right tech for the team size / scale?
- Any decision you'd make differently? If so, ask architect to revise OR override explicitly (document the override in the plan).
If the plan looks right → proceed. If not → dispatch glm-architect again with specific fixes, OR revise inline if the change is small.
Phase 2 — Schema + data layer (dispatch glm-schema-designer if it exists; else glm-worker)
For each subtask tagged [schema] in the plan, dispatch a worker. Each produces:
- Migration SQL (reversible — up + down)
- Model / ORM definitions
- Seed data / factories for testing
Acceptance per subtask: migration idempotent, models type-check, factories produce valid data.
Dispatch parallel where deps allow.
Phase 3 — Tests FIRST (dispatch glm-test-generator)
Before writing any API or UI code, dispatch glm-test-generator to write the test cases for each planned endpoint and component. These are the specs the implementations must satisfy.
This is strict TDD — the tests will fail at first, implementations make them pass.
Phase 4 — API layer (dispatch glm-api-designer)
For each API subtask, dispatch glm-api-designer with:
- Plan file path
- Relevant schema files (from Phase 2)
- Pre-written tests (from Phase 3) — so the designer knows the contract
- Knowledge pack references (auth-flows, stripe-billing if relevant)
Parallelize endpoints that don't share state.
After each, run the tests. If they fail, dispatch glm-worker (or re-dispatch glm-api-designer) with a focused fix brief.
Phase 5 — UI layer (dispatch glm-ui-builder)
For each UI subtask, dispatch glm-ui-builder with:
- Plan file path
- API schema / OpenAPI (from Phase 4)
- Design tokens / existing components to match
- Pre-written component tests (from Phase 3)
Parallelize components that don't share state.
Phase 6 — Integration tests (dispatch glm-test-generator again, or glm-worker)
Write E2E tests that exercise the full user journey. Use Playwright / Cypress for web.
Phase 7 — Security audit (dispatch glm-security-auditor)
Read-only pass across all code produced in phases 2-6. Returns a severity-tagged report.
If verdict is CRITICAL-ESCALATE → you (Opus) personally review and fix. Do not hand any CRITICAL finding back to GLM for fix without your verification.
For HIGH / MEDIUM findings → dispatch glm-worker with focused fix briefs, then re-run Phase 7.
Phase 8 — Review (dispatch glm-reviewer against the final diff)
Final routine review across the 10 categories (correctness, plan conformance, edge cases, tests, style, perf, security, scope, backwards compat, design quality).
Adjudicate findings. Fix blockers, defer nits.
Phase 9 — Docs (dispatch glm-docs-writer if it exists; else glm-worker)
Update README, API docs (OpenAPI → redoc/swagger), and any user-facing docs. Generate a CHANGELOG entry under [Unreleased].
Phase 10 — You (Opus) integration + verification
Final steps you do yourself:
- Run full test suite (
npm test/pytest/ etc.) - If UI: start dev server, exercise the feature in a browser
- Resolve any merge conflicts with existing code
- Write the commit message or PR description
- Report back to the user
Parallelism rules
- Within a phase, dispatch independent subtasks in parallel (single message, multiple Agent tool calls)
- Across phases, serialize — Phase 3 waits for Phase 2, etc.
- If a subtask fails, don't block unrelated subtasks in the same phase — let independent work proceed, fix the failure in parallel
Escalation rules (hand back to the user)
Pause and ask the user before proceeding when:
- Scope creep — what was promised to be small turned out to require 10x the work. Give the user the new estimate.
- Irreversible decision — database migration that drops tables, production deployment, paid API calls at scale.
- Quality gate — a security audit finding that looks like it requires design-level changes, not just code fixes.
- Ambiguous tradeoff — two valid paths with different implications; user should choose.
Output format (what you return to the user)
## Shipped: <feature name>
### What was built
- <bullet list of concrete outputs>
### Plan file
plans/NNN-<slug>.md
### Test coverage
- Unit: <N passing>
- Integration: <N passing>
- E2E: <N passing>
### Security audit
Verdict: APPROVE | REQUEST_CHANGES
- <any outstanding findings>
### Files changed
<git diff --stat>
### How to verify
<commands to run: test suite, dev server, manual flow>
### Known limitations / followups
- <things explicitly deferred>
### Stripe / billing / auth notes (if relevant)
<any subtle behaviors the user should know about>
Anti-patterns (catch yourself)
- Skipping Phase 1 (architecture) because "it's obvious" — then realizing mid-build you need to refactor the schema. Always plan first for non-trivial features.
- Writing implementation before tests — defeats the purpose of test-driven dispatch. Tests first, always.
- Parallel dispatch of dependent subtasks — "let's do schema and API at the same time" produces drift when the API uses a schema that's about to change. Serialize dependencies.
- Skipping security audit for "internal" or "simple" features — every feature with user input needs it. Ten minutes now saves a week after a breach.
- Accepting GLM's CRITICAL security findings without personal review — violates the global rule. Always read those yourself.
When NOT to use /saas-build
- Tiny one-file changes → just dispatch
glm-workerdirectly - Bug fixes → just dispatch
glm-workerwith a reproduction and fix brief - Pure refactors with no behavior change →
glm-workerwith specific rename/extract briefs - Exploration / "tell me how X works" →
glm-explorer - Non-code reasoning (picking a DB, architecture tradeoffs without implementation) →
glm-analyst+ maybeglm-architect
/saas-build is for end-to-end feature construction where multiple specialists must coordinate. If the scope is a single subagent's job, dispatch that subagent directly.
Execute the pipeline now. User's feature request follows.