# Multi-Agent Coding Workflow

Adapted from @elvissun's system (Feb 23, 2026 -- 4M views on X) and our own OpenClaw setup.

## Architecture: Two-Tier Context Separation

The core insight: **context windows are zero-sum**. Fill with code = no room for business context. Fill with business context = no room for codebase.

**Orchestrator (Max/OpenClaw):** Holds business context -- customer data, meeting notes, past decisions, what worked/failed. Translates into precise prompts.

**Coding Agents (Claude Code/Codex):** See only code + task-specific context. Stay focused on implementation.

## Our Current Setup vs Elvis's

| Component | Elvis (Zoe) | Us (Max) |
|-----------|------------|----------|
| Orchestrator | OpenClaw agent "Zoe" | OpenClaw agent "Max" |
| Coding agents | Codex (gpt-5.3) + Claude Code | Claude Code via coding-agent skill |
| Isolation | Git worktrees per feature | Sub-agent sessions |
| Monitoring | Cron every 10min + tmux | Sub-agent auto-announce |
| Review | 3x AI review (Codex + Gemini + Claude) | Manual |
| Notification | Telegram | Telegram |
| Tracking | JSON registry (.clawdbot/active-tasks.json) | Memory files |

## What We Should Adopt

### 1. Dual/Triple AI Code Review (HIGH VALUE)
Every PR reviewed by multiple models. They catch different things:
- **Codex/Claude Code:** Edge cases, logic errors, race conditions
- **Gemini Code Assist:** Security issues, scalability (FREE via GitHub)
- **Third reviewer:** Validates what others flag

Install Gemini Code Assist on GitHub repos -- it's free and catches things others miss.

### 2. Agent Task Registry (MEDIUM VALUE)
Track spawned agents in a JSON file:
```json
{
  "id": "feat-name",
  "agent": "claude-code",
  "description": "What it's doing",
  "branch": "feat/name",
  "status": "running|done|failed",
  "startedAt": timestamp,
  "pr": null,
  "checks": {}
}
```
We partially do this via sub-agent sessions, but a persistent JSON would survive restarts.

### 3. Definition of Done (HIGH VALUE)
PR isn't done until ALL pass:
- PR created
- Branch synced to main (no conflicts)
- CI passing (lint, types, tests)
- AI reviews passed
- Screenshots included (if UI changes)

### 4. Failure Loop with Context (ALREADY DOING)
When agent fails, don't just retry -- diagnose with business context and rewrite the prompt. We already do this via sub-agent steering.

### 5. Proactive Task Discovery (PARTIALLY DOING)
- Morning: Scan error logs, spawn fix agents
- After meetings: Extract action items, spawn agents
- Evening: Update docs/changelog
We do this via heartbeats but could be more aggressive.

### 6. Git Worktrees for Parallel Work (FUTURE -- needs more RAM)
Each agent gets isolated branch + node_modules. Elvis hitting 16GB limit with 4-5 agents.
Our Intel Mac can't do this. If Rob gets the Mac Mini M4, this becomes viable.

## Agent Selection Guide (Elvis's Rules)
- **Codex (gpt-5.3):** Backend logic, complex bugs, multi-file refactors. 90% of tasks.
- **Claude Code:** Frontend work, git operations. Faster but less thorough.
- **Gemini:** Design sensibility. Generate HTML/CSS spec first, hand to Claude Code to implement.

**Our equivalent:**
- **Claude Code:** Everything coding (we don't have Codex yet)
- **Sonnet sub-agents:** Research, content, batch work
- **Opus (Max):** Strategy, coordination, complex reasoning

## Cost Reference
Elvis spends ~$190/month ($100 Claude + $90 Codex). We're on subscription model currently.

## Key Quote
"My git history looks like I just hired a dev team. In reality it's just me managing an OpenClaw agent that manages a fleet of other agents."

---
Source: x.com/elvissun/status/2025920521871716562
Saved: 2026-02-25
