Architecture Orchestrator
Overview
Turn a raw product brief into a consistent, implementation-ready spec pack under specs/ by coordinating specialist agents and enforcing a project's preferred stack (frontend, backend, and AI).
When to Use
- User provides a software brief and wants full project architecture/spec docs
- User wants "screen-by-screen + backend + API + AI" markdown files
- User says "create architecture", "generate specs", "turn my brief into documentation"
- User wants an opinionated stack (design system + deployment platform) applied consistently across the whole spec pack
When NOT to Use
- Simple one-off questions about architecture patterns
- When user already has spec files and just needs edits
- Code implementation tasks (use after specs are approved)
Preference System (SOURCE OF TRUTH)
1) Preference File Search Order
specs/preferences.yaml (recommended)
specs/preferences.json
.arch-orchestrator/preferences.yaml
.arch-orchestrator/preferences.json
If none exist, create specs/preferences.yaml using the default template (see templates/preferences.example.yaml), and record this in specs/decisions.md.
2) Design System Sources Search Order
design-system/ folder (any of: README.md, tokens.*, components.*, patterns.*, a11y.*)
specs/design-system-source.md
docs/design-system.md
If none exist, generate specs/design-system.md as a "Design system not provided" doc.
3) How Preferences Are Applied
- Treat preferences as hard constraints unless explicitly marked as optional
- Every generated spec must include:
- The chosen packages/libraries and why they exist in the architecture
- How they are wired into the repo
- Any constraints they impose (build/deploy/runtime limits)
- Subagents must be instructed to read and comply with
specs/preferences.yaml first, then the brief
Output Contract (MUST)
Create (or update) these files in specs/:
| File |
Purpose |
specs/index.md |
Navigation hub with links to all specs |
specs/brief-normalized.md |
Structured extraction of the product brief |
specs/preferences.yaml |
Stack preferences (create if missing) |
specs/design-system.md |
Design tokens, components, a11y rules |
specs/frontend-specs.md |
Screen-by-screen UI specifications |
specs/backend-specs.md |
Domain model, services, database schema |
specs/api-docs.md |
Endpoint documentation with schemas |
specs/ai-services.md |
AI/LLM features (or "Not in scope") |
specs/decisions.md |
Architectural decisions and rationale |
specs/open-questions.md |
Uncertainties needing clarification |
Workflow
Phase 0: Load Preferences + Design System
Load preferences
- Find and parse a preference file using the search order above
- If missing, create
specs/preferences.yaml using the default template
- Normalize into a short "Stack Summary" section for all specs
Load design system sources
- If
design-system/ exists, summarize it into specs/design-system.md
- If only a doc exists, consolidate it
- If nothing exists, produce a default DS doc matching chosen UI libraries
Propagate constraints
- Every Task prompt must include: "Follow
specs/preferences.yaml as hard constraints."
Phase 1: Normalize the Brief
Locate the brief
- Look for:
brief.md, spec.md, requirements.md, product-brief.md
- If not found, ask user where it is
Extract and structure
- Project name and purpose
- Goals and non-goals
- User roles and personas
- Key workflows and user journeys
- Technical constraints (merge with preferences; preferences win)
- Required integrations
- Success metrics
Write specs/brief-normalized.md
Phase 2: Define Shared Foundations (Backend First)
Write specs/backend-specs.md first with:
Canonical domain model (SOURCE OF TRUTH)
- Core entities with fields, types, constraints
- Relationships between entities
Platform blueprint (from preferences)
- Compute layer selection rationale
- Storage selection (D1 vs KV vs R2 vs Durable Objects)
- Deployment model and environment separation
Auth/authz model (from preferences)
- Authentication approach (JWT, session, OAuth)
- Authorization model (RBAC, ABAC)
- Multi-tenancy strategy
Error conventions
- Standard error envelope format
- HTTP status code usage
- Error code taxonomy
Observability + operations (from preferences)
- Logging, error tracking, metrics
- Analytics approach
Complete the backend spec
- Services architecture
- Database schema with indexes
- Background jobs and queues
- Security and rate limiting
Phase 3: Spawn Specialist Agents (Preference-Aware)
Use the Task tool to spawn agents in parallel:
API Documentation Agent:
Task tool with:
- subagent_type: "general-purpose"
- prompt: "Create comprehensive API documentation in specs/api-docs.md.
HARD CONSTRAINTS: Follow specs/preferences.yaml.
Reference the canonical domain model from specs/backend-specs.md.
Include all endpoints with request/response schemas, auth requirements,
error handling, and pagination conventions."
Frontend Specs Agent:
Task tool with:
- subagent_type: "general-purpose"
- prompt: "Create granular frontend specifications in specs/frontend-specs.md.
HARD CONSTRAINTS: Follow specs/preferences.yaml and specs/design-system.md.
Use the preferred UI component source and icon strategy.
Reference entities from specs/backend-specs.md and endpoints from specs/api-docs.md.
Provide screen-by-screen breakdown with component-level detail."
AI Services Agent (ONLY if AI features mentioned or ai.enabled=true):
Task tool with:
- subagent_type: "general-purpose"
- prompt: "Create AI services architecture in specs/ai-services.md.
HARD CONSTRAINTS: Follow specs/preferences.yaml.
Include AI feature inventory, model gateway, prompt management, RAG strategy,
safety guardrails, evaluation framework, and cost controls."
Phase 4: Create Index and Decision Logs
Index (specs/index.md)
- Navigation hub with links to all specs
- One-paragraph summary per document
- "Stack Summary" pulled from preferences
Decisions (specs/decisions.md)
- All assumptions made
- Rationale for key architectural choices
- Stack choices (must match preferences)
Open questions (specs/open-questions.md)
- Uncertainties needing clarification
- Trade-offs to discuss with team
Phase 5: Consistency Validation
Before finishing, verify:
Assumptions + Questions
Ask at most 5 critical questions only if blockers exist:
- Must choose between fundamentally different approaches (e.g., session vs jwt)
- Must know tenancy model for multi-tenant apps
- Must clarify data residency / compliance requirements
Otherwise, proceed with explicit assumptions and document in specs/decisions.md.
Error Handling
| Condition |
Action |
| Preferences missing |
Create defaults, record in decisions.md |
| Design system missing |
Generate default DS doc, record assumptions |
| Brief missing |
Ask user where it is |
| Brief vague |
Proceed with assumptions, document in decisions.md |
| AI features unclear |
Default to ai.enabled preference; otherwise "not in scope" |
| Agent fails |
Document issue in open-questions.md, continue with other specs |
1---2name: arch-orchestrator3description: Turn a raw product brief into a consistent, implementation-ready spec pack under specs/ (frontend, backend, API, AI) by coordinating specialist agents and enforcing a project's preferred stack. USE WHEN the user says "create architecture plan/specs", "turn this brief into docs", "generate frontend/backend/api specs", or "write the spec markdown files" — wants end-to-end software architecture documentation from a product brief.4---56# Architecture Orchestrator78## Overview910Turn a raw product brief into a consistent, implementation-ready spec pack under `specs/` by coordinating specialist agents **and** enforcing a project's preferred stack (frontend, backend, and AI).1112## When to Use1314- User provides a software brief and wants full project architecture/spec docs15- User wants "screen-by-screen + backend + API + AI" markdown files16- User says "create architecture", "generate specs", "turn my brief into documentation"17- User wants an **opinionated** stack (design system + deployment platform) applied consistently across the whole spec pack1819## When NOT to Use2021- Simple one-off questions about architecture patterns22- When user already has spec files and just needs edits23- Code implementation tasks (use after specs are approved)2425---2627## Preference System (SOURCE OF TRUTH)2829### 1) Preference File Search Order30311. `specs/preferences.yaml` (recommended)322. `specs/preferences.json`333. `.arch-orchestrator/preferences.yaml`344. `.arch-orchestrator/preferences.json`3536If none exist, **create** `specs/preferences.yaml` using the default template (see `templates/preferences.example.yaml`), and record this in `specs/decisions.md`.3738### 2) Design System Sources Search Order39401. `design-system/` folder (any of: `README.md`, `tokens.*`, `components.*`, `patterns.*`, `a11y.*`)412. `specs/design-system-source.md`423. `docs/design-system.md`4344If none exist, generate `specs/design-system.md` as a "Design system not provided" doc.4546### 3) How Preferences Are Applied4748- Treat preferences as **hard constraints** unless explicitly marked as optional49- Every generated spec must include:50 - The chosen packages/libraries and *why* they exist in the architecture51 - How they are wired into the repo52 - Any constraints they impose (build/deploy/runtime limits)53- Subagents must be instructed to **read and comply** with `specs/preferences.yaml` first, then the brief5455---5657## Output Contract (MUST)5859Create (or update) these files in `specs/`:6061| File | Purpose |62|------|---------|63| `specs/index.md` | Navigation hub with links to all specs |64| `specs/brief-normalized.md` | Structured extraction of the product brief |65| `specs/preferences.yaml` | Stack preferences (create if missing) |66| `specs/design-system.md` | Design tokens, components, a11y rules |67| `specs/frontend-specs.md` | Screen-by-screen UI specifications |68| `specs/backend-specs.md` | Domain model, services, database schema |69| `specs/api-docs.md` | Endpoint documentation with schemas |70| `specs/ai-services.md` | AI/LLM features (or "Not in scope") |71| `specs/decisions.md` | Architectural decisions and rationale |72| `specs/open-questions.md` | Uncertainties needing clarification |7374---7576## Workflow7778### Phase 0: Load Preferences + Design System79801. **Load preferences**81 - Find and parse a preference file using the search order above82 - If missing, create `specs/preferences.yaml` using the default template83 - Normalize into a short "Stack Summary" section for all specs84852. **Load design system sources**86 - If `design-system/` exists, summarize it into `specs/design-system.md`87 - If only a doc exists, consolidate it88 - If nothing exists, produce a default DS doc matching chosen UI libraries89903. **Propagate constraints**91 - Every Task prompt must include: "Follow `specs/preferences.yaml` as hard constraints."9293### Phase 1: Normalize the Brief94951. **Locate the brief**96 - Look for: `brief.md`, `spec.md`, `requirements.md`, `product-brief.md`97 - If not found, ask user where it is98992. **Extract and structure**100 - Project name and purpose101 - Goals and non-goals102 - User roles and personas103 - Key workflows and user journeys104 - Technical constraints (merge with preferences; preferences win)105 - Required integrations106 - Success metrics1071083. **Write `specs/brief-normalized.md`**109110### Phase 2: Define Shared Foundations (Backend First)111112Write `specs/backend-specs.md` first with:1131141. **Canonical domain model** (SOURCE OF TRUTH)115 - Core entities with fields, types, constraints116 - Relationships between entities1171182. **Platform blueprint** (from preferences)119 - Compute layer selection rationale120 - Storage selection (D1 vs KV vs R2 vs Durable Objects)121 - Deployment model and environment separation1221233. **Auth/authz model** (from preferences)124 - Authentication approach (JWT, session, OAuth)125 - Authorization model (RBAC, ABAC)126 - Multi-tenancy strategy1271284. **Error conventions**129 - Standard error envelope format130 - HTTP status code usage131 - Error code taxonomy1321335. **Observability + operations** (from preferences)134 - Logging, error tracking, metrics135 - Analytics approach1361376. **Complete the backend spec**138 - Services architecture139 - Database schema with indexes140 - Background jobs and queues141 - Security and rate limiting142143### Phase 3: Spawn Specialist Agents (Preference-Aware)144145Use the Task tool to spawn agents in parallel:146147**API Documentation Agent:**148```149Task tool with:150- subagent_type: "general-purpose"151- prompt: "Create comprehensive API documentation in specs/api-docs.md.152 HARD CONSTRAINTS: Follow specs/preferences.yaml.153 Reference the canonical domain model from specs/backend-specs.md.154 Include all endpoints with request/response schemas, auth requirements,155 error handling, and pagination conventions."156```157158**Frontend Specs Agent:**159```160Task tool with:161- subagent_type: "general-purpose"162- prompt: "Create granular frontend specifications in specs/frontend-specs.md.163 HARD CONSTRAINTS: Follow specs/preferences.yaml and specs/design-system.md.164 Use the preferred UI component source and icon strategy.165 Reference entities from specs/backend-specs.md and endpoints from specs/api-docs.md.166 Provide screen-by-screen breakdown with component-level detail."167```168169**AI Services Agent** (ONLY if AI features mentioned or ai.enabled=true):170```171Task tool with:172- subagent_type: "general-purpose"173- prompt: "Create AI services architecture in specs/ai-services.md.174 HARD CONSTRAINTS: Follow specs/preferences.yaml.175 Include AI feature inventory, model gateway, prompt management, RAG strategy,176 safety guardrails, evaluation framework, and cost controls."177```178179### Phase 4: Create Index and Decision Logs1801811. **Index** (`specs/index.md`)182 - Navigation hub with links to all specs183 - One-paragraph summary per document184 - "Stack Summary" pulled from preferences1851862. **Decisions** (`specs/decisions.md`)187 - All assumptions made188 - Rationale for key architectural choices189 - Stack choices (must match preferences)1901913. **Open questions** (`specs/open-questions.md`)192 - Uncertainties needing clarification193 - Trade-offs to discuss with team194195### Phase 5: Consistency Validation196197Before finishing, verify:198199- [ ] Preferences applied across FE/BE/API/AI specs200- [ ] Entity names identical across all specs201- [ ] API routes in frontend-specs.md exist in api-docs.md202- [ ] Permissions consistent (screen access = endpoint access)203- [ ] Data schemas match between FE/BE/API204- [ ] All agent tasks completed successfully205- [ ] All open questions captured206207---208209## Assumptions + Questions210211Ask at most **5 critical questions** only if blockers exist:212- Must choose between fundamentally different approaches (e.g., session vs jwt)213- Must know tenancy model for multi-tenant apps214- Must clarify data residency / compliance requirements215216Otherwise, proceed with explicit assumptions and document in `specs/decisions.md`.217218---219220## Error Handling221222| Condition | Action |223|-----------|--------|224| Preferences missing | Create defaults, record in decisions.md |225| Design system missing | Generate default DS doc, record assumptions |226| Brief missing | Ask user where it is |227| Brief vague | Proceed with assumptions, document in decisions.md |228| AI features unclear | Default to ai.enabled preference; otherwise "not in scope" |229| Agent fails | Document issue in open-questions.md, continue with other specs |