Web Architecture
by @michaelmonetized
Multi-agent orchestration for complex TypeScript/Next.js/Convex projects. Phased builds, functional verification, the full playbook for delegating to sub-agents without chaos.
clawhub install web-architectureπ About This Skill
name: web-architecture description: Multi-agent orchestration for complex TypeScript/Next.js/Convex projects. Phased builds, functional verification, the full playbook for delegating to sub-agents without chaos.
Web Architecture
Multi-agent development workflow for TypeScript/Next.js/Convex projects.
*Born from: 29 agents, 50K lines, 212 errors, 1 hard lesson*
β οΈ SUB-AGENT POLICY (READ FIRST)
No Timeouts
Sub-agents MUST run without timeout limits. A 10-minute timeout that cuts off an agent mid-implementation leaves broken, partial code. Let agents finish.Completion Means Working, Not Compiling
"Build passes" is necessary but NOT sufficient.Before marking ANY phase complete, verify: 1. Functions actually work β Call them, verify data flows 2. UI actually renders data β Not just loading spinners forever 3. User flows complete end-to-end β Click through, verify state changes persist 4. Error states are handled β Not just happy path
The Lesson
An agent produced 15K lines of "working" code that:bun run buildSelf-grade: 5/10 β A prototype, not a product.
The Core Lesson
> Single agent with full context > Many agents with partial context
29 parallel agents wrote 50K lines of code that didn't compile. Why?
user.role, backend returned profile.plannpx convex dev never ran, no generated typesThe fix: One agent with full context rewrote the entire Convex backend in 11 minutes.
When to Use Multi-Agent
β Good for parallel work:
β Bad for parallel work:
The Workflow
Phase 0: Bootstrap (SEQUENTIAL β One Agent)
Must complete before spawning ANY other agents.
1. Initialize project structure
2. Initialize Convex: npx convex dev --once
3. Create complete schema.ts (ALL tables)
4. Run npx convex dev to generate types
5. Create CONTRACTS.md (all data shapes)
6. Create shared types in lib/types.ts
7. Verify: bun run build passes
Deliverables:
convex/schema.ts β Complete, no TODOsconvex/_generated/ β Types generatedCONTRACTS.md β API shapes documentedlib/types.ts β Shared frontend typesbun run build β Passes with 0 errorsPhase 1: Foundation Documents (CAN BE PARALLEL)
Only spawn AFTER Phase 0 completes.
| Agent | Output | Dependencies |
|-------|--------|--------------|
| Tech Requirements | TECH-REQ.md | None |
| Compliance | COMPLIANCE.md | None |
| Design Principles | DESIGN.md | None |
| Coding Standards | STANDARDS.md | None |
Rule: These agents READ the schema. They do NOT modify it.
Phase 2: Backend Implementation (SEQUENTIAL or CAREFUL PARALLEL)
Option A: Single Backend Agent (Recommended)
Option B: Parallel with File Locks
Functional Requirements: 1. Test CRUD operations β Create, read, update, delete 2. Verify queries return data β Not empty arrays 3. Check mutations persist β Data survives refresh 4. Test auth guards β Protected functions reject unauthorized 5. Verify indexes work β Queries return correct filtered data
Phase 3: Component Library (SEQUENTIAL)
Single agent builds the component library.
Why? Components reference each other. Parallel work creates duplicate components with different APIs.
Functional Requirements: 1. Interactive states work β Buttons trigger onClick 2. Form components submit β Not just styled divs 3. Loading/error states exist 4. Accessibility basics β Labels, ARIA, keyboard nav 5. Consistent API β All components follow same patterns
Phase 4: Features & Pages (CAN BE PARALLEL)
Now safe to parallelize because schema is locked, types exist, components exist.
| Agent | Scope | Can Modify |
|-------|-------|------------|
| Admin Suite | /app/(admin)/** | Own files only |
| Support Portal | /app/(support)/** | Own files only |
| Marketing Pages | /app/(marketing)/** | Own files only |
| User Flows | /app/(app)/** | Own files only |
Rules: 1. Read schema, types, contracts β don't modify 2. Use existing components β don't recreate 3. Write to assigned directories only
Functional Requirements:
Red flags (NOT complete):
// TODO comments in business logicPhase 5: Integration & QA (SEQUENTIAL)
1. bun run build (must pass)
2. npx convex dev --once (must pass)
3. Generate sitemap from routes
4. Route crawl & 404 check
5. Browser smoke test (all routes return 200)
6. End-to-end flow verification
E2E Verification Checklist:
Auth Flow:
Core CRUD Flow:
Directory Structure
project/
βββ convex/
β βββ schema.ts # π Phase 0 only
β βββ _generated/ # π Auto-generated
β βββ [domain].ts
βββ lib/
β βββ types.ts # π Phase 0 only
β βββ utils.ts
βββ components/
β βββ ui/ # Component library agent
β βββ [domain]/ # Feature agents
βββ app/
β βββ (admin)/ # Admin agent
β βββ (app)/ # App agent
β βββ (marketing)/ # Marketing agents
βββ CONTRACTS.md # π Phase 0 only
π = Locked after Phase 0. Agents read, don't modify.
Agent Spawn Order
1. Bootstrap Agent (MUST COMPLETE FIRST)
βββ schema.ts, types, contracts
2. Doc Agents (parallel)
βββ TECH-REQ.md
βββ COMPLIANCE.md
βββ DESIGN.md
3. Backend Agent (single)
βββ All convex/*.ts functions
4. Component Agent (single)
βββ All components/ui/*
5. Feature Agents (parallel, isolated directories)
βββ Admin Suite
βββ Support Portal
βββ Marketing Pages
βββ User Flows
6. Integration Agent (single)
βββ Final build, fixes, QA
Anti-Patterns
β Spawn all agents at once β No coordination, duplicate work
β Let agents invent types β Use CONTRACTS.md, not imagination
β Skip Phase 0 β "We'll figure out the schema later" = disaster
β Parallel schema writes β One owner only
β Frontend before backend types β Generates type mismatches
β No build checkpoints β Errors compound