On this page
AI Agents for Large-Scale Refactoring: What Works in 2026
tl;dr
Only 5.4% of frontier-model runs complete whole-repository refactors without breakage, per SWE Refactor Bench data. Success depends far more on automated behavior-level verification and AST-aware tooling than on the underlying AI model selected.
Only 5.4% of frontier-model runs can complete a whole-repository migration without breaking something — and yet teams are merging thousand-agent refactors into production codebases. That tension defines AI agents for large-scale refactoring right now: the ceiling is real, the floor is low, and the difference between the two has almost nothing to do with which model you pick.
September 2026 made this impossible to ignore. In a single week, Sourcegraph, Cursor, Devin, and Anthropic all shipped orchestration products aimed at codebase-wide change. The industry has moved from autocomplete to what I’d call fleet orchestration — coordinators directing swarms of subagents across hundreds of repositories. Here’s what the evidence says about where that works, where it falls apart, and what it costs.
Why did every vendor ship orchestration in the same week?
The short answer: single-agent sessions hit a wall on work that spans repositories, and every major vendor arrived at the same architectural fix — a coordinator that delegates rather than codes.
On September 14, Sourcegraph announced general availability of Agentic Batch Changes for Sourcegraph Cloud customers. One prompt plans, executes, and tracks a change across hundreds or thousands of repositories, with pricing based on changesets merged. The pedigree matters here: Sourcegraph’s existing Batch Changes product already merges roughly half a million changesets per year for its largest enterprise customers, and the agentic version merged nearly a thousand changesets during beta. This isn’t a startup’s demo — it’s an orchestration layer bolted onto change-management infrastructure that’s been running for years.
Four days earlier, Cursor launched Projects, a persistent coordinator that delegates to thousands of subagents across cloud and local machines, maintains shared context files between them, and watches Slack or PR queues without being prompted. Cursor reports that users who primarily use Projects merge six times as many PRs as before, while new users merge 30% more. Treat those as vendor-reported internal figures, not independent measurements — but the direction is consistent with what early adopters describe elsewhere.
Then Devin shipped Code Scans on September 16, using an “Agentic MapReduce” pattern — plan, shard, map across parallel agents, reduce into a report — to turn goals like “reduce build time” into pull requests. And on September 17, Anthropic relaunched Claude Code Projects, running parallel cloud sessions on branched repo copies with conflicts resolved through the ordinary PR merge flow. That last design choice is telling: instead of inventing new coordination primitives, Anthropic mapped multi-agent work onto git workflows your team already knows. The tools that win long-term integrate transparently into existing workflows rather than demanding rewrites, and this is that instinct showing up in product design.
What do the flagship refactoring runs actually prove?
The headline case studies are real, but they share a hidden ingredient that has nothing to do with model intelligence: exhaustive, automated verification.
Nous Research ran 1,393 subagents on Claude Fable 5.1 against its own million-line Python repository, cutting non-test code by 34.4% (from 1,063,826 to 698,363 lines) at a model cost of about $19,300 over roughly 19 active hours. The PR merged — but only after a crash, a resumed session, and two rounds of community review that caught real regressions. Human review time isn’t in the cost figure.
Bun’s rewrite of 535,496 lines of Zig to Rust is the more instructive case. It finished in four months — a quarter of the estimated human timeline — using orchestrated Claude agents across roughly 50 dynamic workflows. But read why it worked: Bun’s test suite is written in TypeScript with over a million assertions, so it validates behavior independent of the implementation language. The team also maintained a porting guide and a lifetimes table as shared agent context, and ran adversarial reviewer agents against every diff. The orchestration infrastructure and the verification harness did the heavy lifting. The model was almost interchangeable.
The counterexample is just as useful. Wisedocs consolidated more than ten repositories and hit 15 of 17 requirements after a six-month gated refactor — but when the team first handed a frontier model the whole goal in one shot, it returned 2,000 lines of scaffolding in ten minutes with no implemented models and no deployment path. The same source is blunt about current requirements: explicit specification, source traceability, sandboxed execution, and human PR approval. If you’re designing your own setup, our guide on configuring AI coding agents for large codebases covers why harness configuration matters more than model choice — the Wisedocs story is that thesis in production.
Where do agents still fail at scale?
The benchmark data is sobering, and it’s the strongest argument against unattended autonomy for high-stakes migrations.
SWE Refactor Bench, which tests whole-repository stack migrations across 520 runs from 8 frontier models and 26 configurations, found that only 5.4% of runs pass all three stages — migration audit, behavioral tests, and agentic verification. Thirteen of 20 tasks received no accepted solution at all, and the best model scored 47.0 out of 100. That’s the signature of subtle breakage — the kind that survives casual review and detonates in production.
The more encouraging finding is that architecture choices move the needle more than model upgrades. RefactorPlatform, an open-source evaluation harness, found that AST-aware chunking — splitting code along syntax-tree boundaries rather than arbitrary token windows — outperforms naive chunking by 25–30% across prompt modes. More surprising: a lean retrieval-augmented single agent hit 86% accuracy versus 66% for the sub-agent configuration they evaluated, and retrieval’s accuracy gains absorbed its token overhead, leaving cost per successful refactor unchanged. More agents isn’t automatically better. Better context is better.
JetBrains has the cleanest cost data on this point. When Rider exposed its refactoring engine to agents via a bundled skill, median C# refactoring task time dropped 83% (157.9s to 26.6s) and cost per solved task fell 64% ($0.52 to $0.19) across fifteen tasks. The baseline agent made 2,513 tool calls — including 163 builds just to discover what its own edits had done — and performed zero structural refactoring operations, because it had none to call. Giving agents deterministic, compiler-grade tools beat giving them more tokens. This is also why model routing matters more than model prestige — the spend is in context churn, not raw intelligence.
What does fleet-scale refactoring tooling actually cost?
Pricing is splitting into two camps: per-seat subscriptions and outcome-based models, and the gap between them is now wide enough to drive real decisions.
| Tool | Pricing | Orchestration model | Best fit |
|---|---|---|---|
| Cursor Teams | $40/user/mo Standard, $120/user/mo Premium | Projects coordinator + subagents | Teams already in Cursor wanting fleet features |
| Sourcegraph Cody Enterprise | ~$59/user/mo; platform from ~$16,000/yr | Agentic Batch Changes, per-changeset-merged billing | Multi-repo enterprises with existing Sourcegraph |
| Gemini Code Assist | $19/user/mo Standard (annual) | Agent mode, no fleet coordinator | Budget-constrained teams, Google Cloud shops |
| Augment Code Business | $100/mo flat, up to 50 seats | Coordinator/implementor/verifier agents | Mid-size teams with large monorepos |
| Replicas | $120/seat/mo Developer, $300/seat/mo Team | Nine harnesses in isolated cloud VMs | Teams wanting harness-neutral cloud execution |
A few things stand out. Cursor’s org plans add a Token Rate of $0.25 per million tokens on third-party model requests — a line item individual plans don’t have, and one that compounds fast at fleet scale. Augment’s flat $100 covers up to 50 seats but overage bills at provider list price plus a 40% service fee. Replicas is the outlier: harness-neutral, running Claude Code, Codex, Cursor, and six others in isolated VMs, so you’re renting orchestration infrastructure rather than committing to one vendor’s agent.
For a 50-developer team, the subscription math from these published rates looks like this: Cursor Teams Standard comes to $24,000 per year (50 × $40 × 12, per Continuum’s pricing guide). Sourcegraph Cody Enterprise runs approximately $35,400 per year (50 × $59 × 12, per AI Agent Square). Gemini Code Assist Standard totals $11,400 per year (50 × $19 × 12, per AgentCode). Those are seat costs only — token overages, service fees, and review headcount sit on top, and at fleet scale the review burden can dwarf the subscription.
How should you decide what to adopt?
Match the tool to your verification infrastructure, not your ambition. The pattern across every success story — Bun, Nous, Sourcegraph’s enterprise base — is that automated, behavior-level validation existed before the agents arrived. If your test suite can’t independently confirm a refactor preserved behavior, a fleet will generate plausible breakage faster than you can catch it.
A practical decision order:
- Audit your verification layer first. Language-independent test suites, type checking, and CI gates are prerequisites, not nice-to-haves.
- Start with deterministic tooling. IDE-grade refactoring engines and AST-aware retrieval deliver measured gains at trivial cost before you spend anything on fleets.
- Pilot outcome-based pricing where possible. Per-changeset-merged models align vendor incentives with your merge rate; flat seats don’t.
- Budget review capacity honestly. A coordinator producing dozens of PRs daily needs humans reading them — that headcount is part of TCO.
My recommendation: if you’re an enterprise team with a real multi-repo estate, pilot Sourcegraph’s Agentic Batch Changes or a harness-neutral runner like Replicas on one bounded migration with a strong test suite, and measure merge rate plus reviewer hours before scaling. If you’re a smaller team, the evidence says you’ll get more from AST-aware retrieval and IDE refactoring skills than from any fleet product.
Recommended Reading
-
Refactoring Prompt Templates: What Actually Works
Out-of-the-box LLMs produce correct refactors only 40% of the time on complex tasks, per 2026 independent testing. Scoped prompt templates with embedded guardrails fix this failure mode, with top tools like Continue.dev hitting 89% accuracy on the Refactoring Benchmark Suite v2.1.
-
CrewAI vs OpenAI Agents SDK: The 2026 Production Decision
CrewAI and OpenAI Agents SDK are converging in capability, but serve different production constraints. CrewAI wins on governance and speed, while OpenAI offers leaner token overhead and first-party tooling. The real barrier to production is evaluation infrastructure, not framework choice.
-
AGENTS.md vs Cursor Rules
This post compares AGENTS.md, the open cross-tool agent configuration standard, and Cursor's proprietary .cursor/rules/*.mdc format for project rules. It breaks down feature tradeoffs, instruction budget impacts, and cost implications, recommending a layered architecture with AGENTS.md as the canonical source of truth paired with thin tool-specific adapter files.