Beyond Single Prompts: Autonomous AI Coding Agent Teams in CommandMate
Running 4 or 5 coding agents in parallel feels productive for the first hour—until every worktree finishes at once. Suddenly, you are spending your entire evening reading unverified diffs, catching out-of-scope edits, an
Running 4 or 5 coding agents in parallel feels productive for the first hour—until every worktree finishes at once. Suddenly, you are spending your entire evening reading unverified diffs, catching out-of-scope edits, and re-running tests manually.
Parallel coding without automated verification and role boundaries does not scale output; it scales review bottlenecks.
In this third part of the series (as of CommandMate v0.55.0), I explain how CommandMate moves from solo prompting to a 5-role Milestone-driven agent team—and share real measurements from shipping CommandMate itself on a 468k-LOC codebase with 59,177 unit/integration tests and Playwright E2E CI.
Series: Building CommandMate
- What is CommandMate?
- Mobile Workflow with Tailscale & Cloudflare Tunnel
- Autonomous AI Coding Agent Team (This post)
- Persistent Memory & Automated Retrospectives (Coming soon)
Want to try CommandMate in 1 minute? Run
npx commandmate@latestor visit Kewton/CommandMate.
Scope, Prerequisites, and When Not to Use Teams
This guide applies when a single session or manual parallel workflow hits a review ceiling.
Prerequisites:
- Automated checks in your repository: Lint, type checks, and unit/integration tests must already exist and return accurate exit codes
- GitHub Issues / Milestones and PR workflow: Work items need clear acceptance criteria
-
git worktreeworkflow: Separate working directories per active Issue
What this post does not cover, and when NOT to use multi-agent teams:
- Repositories without tests: Without deterministic checks, agents will cheerfully mark broken changes as complete
- Small, isolated 10-minute fixes: Handing a one-file typo through a PM and Dev Lead adds unnecessary coordination overhead—use Level 1 directly
- Vendor benchmark rankings: I allocate roles based on my own observed workflows and subscription budgets, not universal model rankings
Designing a 5-Role Team Across Vendors
Instead of talking to five workers directly, CommandMate supports a 5-role team configured via commandmate roles and enforced at send time (as of v0.55.0):
- PM: Talks to you, turns requests into briefs, manages the GitHub Milestone scope, monitors blockers, and escalates only decisions and approvals.
- Development Lead: Breaks work into non-overlapping file tracks, dispatches isolated worker worktrees, and verifies acceptance evidence before opening PRs.
- Worker: Implements a single bounded Issue inside its own Git worktree.
- Reviewer: Reviews diffs read-only against acceptance criteria and security invariants.
-
Judge: Independent sessions (never the worker that wrote the code) that run User Acceptance Testing (UAT) on the integrated
developbranch before release.
Role Boundaries (exit 32)
# Define roles once per workspace
commandmate roles add pm --file ./roles/pm.md
commandmate roles add reviewer --file ./roles/reviewer.md
# Enforce role matching before typing into a session
commandmate send <worktree-id> "Review PR #4550" --instance codex --role reviewer
# If instance `codex` is running with role `worker`, CommandMate refuses before typing (exit 32)
Note: A role is startup instruction text, not an OS permission sandbox. Actual write boundaries are enforced by each CLI's permission settings and the post-work scope check in the verification gate.
Cross-Model Review and Cost Optimization
Mixing vendors across roles gives two immediate practical advantages:
- Raising quality through cross-model review: Having a different vendor's model review an implementation (for example, Codex reviewing code written by Claude Code or Command Code, or vice versa) catches blind spots and unstated assumptions that a single model family tends to overlook.
- Reducing cost by separating judgment seats from execution seats: Instead of burning top-tier reasoning quotas on every worker, I reserve higher-tier subscriptions/models for judgment-heavy seats (PM, Dev Lead, Judge, and high-risk design/review) while routing well-specified, test-backed implementation Issues to lower-cost plans or models.
You can set up this entire 5-role topology across 1 to 3 vendors by pasting a single prompt into your coding CLI:
Read https://kewton.github.io/CommandMate/team-setup.md and set up a CommandMate team for my repository with me. Explain each step before you run it, and ask me before you install anything, change files in my repository, create an instance or a role, change a permission, run `commandmate sync`, use a GitHub repository, turn on Auto Yes, or merge.
Guardrails: Task Contracts and Verification Gates
Roles alone cannot prevent an agent from editing unrelated files or declaring victory before tests pass. CommandMate pairs roles with Task Contracts and Verification Gates.
Task Contracts (.commandmate/tasks/*.yaml)
Before a worker starts, its brief is accompanied by a YAML contract declaring the goal, allowed/denied file globs, required gates, and cleanup rules:
version: 1
title: "Fix relay target resolution"
goal: |
Resolve the relay target once before checking tool policy and hold delivery on failure.
Acceptance: unit tests cover unresolved targets and fallback prevention.
scope:
allow:
- "src/lib/relay/**"
- "tests/unit/relay/**"
deny: []
verify:
gates: [lint, typecheck, unit-related]
success:
requireWorkEvidence: true
requireScopeClean: true
CommandMate snapshots the contract at commandmate send --contract time—editing the file mid-run does not retroactively loosen the contract.
Verification Gates (.commandmate/verify.yaml)
When a worker finishes, the Development Lead runs commandmate wait <id> --instance <inst> --verify (or commandmate verify). The repository's own .commandmate/verify.yaml executes and returns a deterministic exit code:
-
exit 0(SUCCESS): All declared gates plus built-inwork-evidence(commits or uncommitted changes exist) andscope(changed files matchscope.allow/deny) passed. -
exit 20(VERIFY_FAILED): One or more gates or scope checks failed. -
exit 21(NOT_STARTED): No commits and no uncommitted changes exist at all.
The agent does not decide when work is done; the exit code does. And because .commandmate/verify.yaml lives in the repo outside the worker's scope.allow, workers cannot weaken gates to pass.
Case Study: Shipping CommandMate on a 468k-LOC Codebase
It is easy to ship fast on a greenfield 2,000-line prototype. To test whether this team structure holds up as complexity grows, here are the actual numbers from building CommandMate with CommandMate itself (v0.55.0, measured 2026-11-22):
Codebase Scale and the CI Bottleneck
| Metric | Measured Value (v0.55.0) |
|---|---|
| Tracked files in repo |
7,263 files (3,781 commits) |
Source code (src/*.ts, src/**/*.ts(x)) |
1,788 files / 468,652 lines |
Test files (tests/) |
3,440 files (59,177 unit + integration tests recorded in v0.54.0) |
PR CI workflow (.github/workflows/ci-pr.yml) |
Unit Tests (4 shards), Integration Tests, Playwright E2E (2 shards), ESLint + shellcheck, Type Check, Build (next + CLI + server), Security Audit, and static guard scripts |
At this scale, testing and CI are the real throughput bottleneck—not typing code. Even locally, the unit-related verification gate averages ~43 minutes per run (measured in our Sprint 9 retrospective), and running full Unit + Integration + 2-shard Playwright E2E in CI determines how quickly PRs can merge safely.
Milestone-Driven Results Across Three Releases (Nov 19–22)
Instead of hand-picking Issues one by one, we drive sprints by GitHub Milestones (Sprint 7, Sprint 8, Sprint 9):
| Release / Sprint | Planned / Scope | Closed in Sprint | Rolled to Next Milestone | Integrated UAT (2 Parallel Judges) |
|---|---|---|---|---|
| v0.53.0 (Sprint 7, Nov 19) | 12 active Issues | 9 closed (10 PRs merged) | 3 rolled (#4430, #4432, #4433) |
34 / 36 passed (~2h 34m) |
| v0.54.0 (Sprint 8, Nov 21) | 14 impl + 3 design + urgent adds | 15 closed + 3 design docs | 2 impl rolled (#4418, #4433) |
44 / 46 passed, 0 failed (~2h 47m) |
| v0.55.0 (Sprint 9, Nov 22) | 22 planned Issues | 9 closed + 3 partial PRs (10 PRs merged) | 9 rolled to Sprint 10 | 40 / 40 passed, 0 new regressions (~1.5h) |
Across those 4 days, 33 Issues closed across three production releases with zero forced merges.
Adjusting to Test-Gate Capacity
Notice what happened in Sprint 9 (v0.55.0): planning 22 Issues at once overloaded the local unit-related mutex (causing 15 queued SKIPs and occupying ~89% of the 16.9-hour dev window). Because we operate on Milestones rather than forcing every task into the current branch, unfinished work rolled cleanly to Sprint 10—and starting with Sprint 10, we now cap each sprint plan to ~1 day of verification-gate capacity (~16 unit-related runs/day, ~6 PR merges/day) before dispatching workers.
Two Real Catches Before Merge
-
Cross-model review (
#4548): While updating our shared role definitions, a Claude-authored draft instructed workers to runcommandmate verify --gates lint,typecheckas a self-check. Codex reviewed the draft against the source code and caught 12 issues (including 3P1blockers—all 12 accepted): runningverify --gateswithout--taskstill resolves the active worktree task and marks itsucceededonce those narrow gates pass, which causes the Dev Lead's subsequent fullverify --taskverdict to be rejected by the task state machine. -
Verification gates and
STOPescalation (#4527->#4553): Across 63 verify runs in Sprint 9, top failures came from dirty environments (env-clean: 10) and contract boundary checks (scope: 3) rather than syntax errors. When Issue#4527hit repeated stops under our two-failureSTOPrule, the team halted instead of forcing a noisy branch in—splitting only the verified clean commits into PR#4553while rolling the rest cleanly to Sprint 10.
Next Steps
If you already have CI and tests on a non-trivial codebase, try Level 2 before jumping to a full 5-role team:
- Create
.commandmate/verify.yamlwrapping your existing lint, typecheck, and fast test commands. - Wrap one well-scoped Issue in
.commandmate/tasks/issue-N.yamland runcommandmate send <wt> --contract ...followed bycommandmate wait <wt> --verify. - Once that loop feels reliable, add a second vendor session as a read-only reviewer.
In Part 4, we look at how CommandMate prevents context rot across frequent session restarts using typed memory (mem)—and what comes next with Dreaming and automated retrospectives.
Meta note: All metrics, file counts, and release outcomes in this draft were pulled directly from the CommandMate repository logs (v0.55.0) using AI-assisted verification, then reviewed and edited by hand.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.