Use Case

21 Agents to Untangle a Year of Frontend Drift

I had a pages/reservations.tsx that was past 2,000 lines. I had an api/types.ts that had become a kitchen sink. I'd been promising myself a refactor for two months. Then I tried something dumb: 21 agents, each owns one file, working in phased waves. Three hours later every monster file was split clean.

Brett Ridenour Brett Ridenour · May 19, 2026

0

Distinct subagents

0

Files split

0

Merge conflicts

0

Phased waves

The state of the codebase

Turborepo. apps/web is a Vite + React SPA. After a year of “I’ll clean this up later,” several files had become unreviewable. The product-form component had three thousand lines of conditional rendering. api/types.ts had become a kitchen sink for every type the frontend touched. The reservation page had a charge-dialog, a refund-dialog, a rebook-dialog, and an add-on manager all in one file. The shape of the code wasn’t bad. There was just too much of it living in too few files.

The skill

/refactor-split is a custom skill that does multi-agent file-by-file refactoring. The interface is one command and a target list. Under the hood it runs a strict three-phase wave pattern.

Wave 1 — Analyze
3 agents
One Explore agent per file. Writes a split plan. No code changes.
Analyze api/types.ts Analyze reservation files + create-reservation Analyze products/settings/login structure
Wave 2 — Execute
16 agents
One agent per plan. Owns one file end-to-end. Runs in parallel.
Execute Group A: split api/types.ts B1: ReservationChargeDialog B1 second pass: JSX cards B2: pages/reservations.tsx B3: RebookDialog B4: RefundDialog B5: CustomChargeManager B6: PricingBreakdown B7: AddOnManager D1: enhanced-product-form D2: SchedulePricingManager D3: product-detail-view E1: WaiverSettings E2: settings/index.tsx E3: LocationProfileSettings F1: login.tsx
Wave 3 — Validate
2 agents
Re-analyze the post-split files. Confirm nothing broke.
Re-analyze products/settings/login files Validate refactor orchestration plan

The run

I gave the orchestrator the list of files. Twenty-one distinct subagents got spawned. The recovery row — B1 second pass: extract JSX cards — is the interesting one. The first execute pass on ReservationChargeDialog left some JSX cards inlined that should have been their own files. The orchestrator noticed during the analyze-pass of validation and re-spawned a targeted second-pass agent for just that file. Clean self-healing.

agent network · 3 phased waves · 21 agents · 17 files

File-by-agent ownership

file
A
E
V
api/types.ts
pages/reservations.tsx
ReservationChargeDialog · B1 needed a second pass
ReservationRebookDialog
ReservationRefundDialog
CustomChargeManager
PricingBreakdown
ReservationAddOnManager
enhanced-product-form
SchedulePricingManager
product-detail-view
WaiverSettings
settings/index.tsx
LocationProfileSettings
pages/products
pages/settings
login.tsx
A — Analyze · E — Execute · V — Validate 21 agents · 17 files · 0 merge conflicts

Ownership is the orchestration trick. Everything else is a rounding error.

— Brett Ridenour

What a split plan looks like

The analyze wave doesn’t write code — it writes a plan for the execute agent to follow. One per file. Strict shape.

# File: pages/reservations.tsx (1,900 LOC)

## Proposed split

- pages/reservations.tsx                          → page shell only (~150 LOC)
- components/reservations/ReservationsTable.tsx   → list view
- components/reservations/ReservationsFilters.tsx → filter UI
- components/reservations/ReservationsBulkActions.tsx → bulk ops
- hooks/useReservationsQuery.ts                   → data fetching
- types/reservations.ts                           → local types
- lib/reservations-helpers.ts                     → pure functions

## Ownership rule
One agent owns this file end-to-end. Do not touch any other file
in this PR except imports updated by the agent's own extractions.

## Validation
After split, run `npm run typecheck && npm run lint && npm run build`.
Confirm pages/reservations.tsx is under 250 LOC.
Confirm no orphaned imports.

Why no merge conflicts

Each agent’s blast radius is exactly one file. Two agents never touch the same file. The orchestrator coordinates by a written plan — not by chat between agents. That single rule (one file per agent, plan-mediated coordination) does all the work.

Lessons

  1. Ownership is the orchestration trick. One file per agent → zero merge conflicts. Everything else is a rounding error.
  2. Phased waves beat parallel free-for-all. Analyze first. Execute next. Validate last. Don’t skip a wave.
  3. Recovery is built in. A failed slice doesn’t poison the run — re-spawn one targeted agent for that slice with a sharper prompt.
  4. The orchestrator is a plan doc, not a chat. Agents coordinate by a written plan all of them can read. Not by talking to each other.

I never opened a single one of the files.

References & further reading