Run a fleet of coding agents like a teaching hospital

Two Cockroach Labs engineers turned GitHub issues into 'patients' handled by agent roles (triage nurse, fellow, reviewing attending, discharge nurse) and shipped production code for five months.

Difficulty
AdvancedOur rating
Time to build
Months (iterated over 5 months)From the source
Monthly cost
Sourced: ~$135K total over ~5 months, ~$84 per issueFrom the source
Revenue
Not reportedWe only show revenue the source states
Result
Sourced: Db2 support '164x faster, and 38x cheaper' than the earlier Oracle effort

What they did

Adam Storm and Rafi Shamim built a GitHub Actions pipeline where each label hands an issue to the next agent role. A fellow agent must reproduce the bug and write a treatment plan, a separate reviewer agent approves or rejects the plan, and a discharge agent audits that the review actually happened before merge. A human 'Chief' handles escalations and records precedents agents must check first.

How it went

The source reports well over a million lines of code landed between April 21 and September 11, with IBM Db2 support for their MOLT migration tool built in under two days for a $4,172 token bill (versus about 9 months and roughly $160K for the earlier Oracle work). Total spend was just over $135,000 in Claude tokens, about $84 per issue.

Worth knowing

The agents got bureaucratic: a one-line copy edit went through five rework rounds, so they added a circuit-breaker after repeated review rounds. Their skill files grew to 100,000+ words and about 23% turned out to be redundant. They also switched on mandatory human approval for merges after the first week.

Builder recipe

Our own starting point, written from the source. Adapt it to your setup.

Stack

  • Claude (Opus/Sonnet-class models)
  • GitHub Actions
  • GitHub labels as state
  • Markdown skill files per role

Steps

  1. Define 4-6 roles (triage, planner, plan reviewer, implementer, code reviewer, merge auditor) as separate skill files.
  2. Use issue labels as the state machine: each label triggers one workflow and the agent applies the next label when done.
  3. Require a written plan and an independent plan review before any code is written.
  4. Forbid weakening tests; reviews start by reverting the change and confirming the new tests fail.
  5. Add a circuit-breaker: escalate to a human after a fixed number of rework rounds.
  6. Keep an append-only precedent log of human decisions that agents must read before escalating.

Starter prompt

You are the PLAN REVIEWER, a different agent from the one who wrote this plan. Your only job is to find what is wrong with it: missing reproduction, wrong root cause, untested paths, scope creep, security or data risks. Reply APPROVE, REJECT (with numbered reasons) or ESCALATE (with the exact question for a human). Do not write code.

Tags

Read the original

Related use cases

The Daily 5.

Five real AI agent use cases each morning, each with a recipe and a source. Plus a Sunday roundup. Free.