Claude Code 2 vs Codex CLI vs Aider on Long-Horizon Repo Migration: Cost, Completion Rate, and Diff Quality Tested (June 2026)
Repo migration is the hardest workload for an agentic CLI because the task lives across hundreds of files, the success criterion is a green test suite plus a clean diff, and the model has to hold context across a multi hour session. Claude Code 2, OpenAI Codex CLI, and Aider all compete for the seat, and the completion rate, cost per merged PR, and diff quality numbers move in different directions across the three.
Repo migration is the agentic coding workload that breaks every benchmark that fits on one file. A real migration (Webpack to Vite, Jest to Vitest, Mongoose to Prisma, Express to Fastify, the React 18 to React 19 server component upgrade) spans hundreds of files, requires the model to hold an evolving mental model of the codebase across a multi hour session, and grades success on whether the test suite passes plus whether the resulting diff is clean enough to merge. The benchmarks that matter for production migration work are not SWE-Bench Verified or Aider Polyglot; they are end to end completion rate per migration, cost per merged PR, and diff hygiene measured by a senior reviewer.
Claude Code 2 (released May 2026), OpenAI Codex CLI (the open source agent CLI shipped alongside the GPT 5.5 release), and Aider (the long-running open source pair programming CLI on its 0.74 release) all compete for the production migration seat. The three differ on harness design, on which model they default to, and on how they handle the operations a long migration actually requires: spawning a test run, reading the failure, narrowing the scope of the next edit, and recovering from a destructive operation without losing the session.
Headline Comparison
| Dimension | Claude Code 2 | OpenAI Codex CLI | Aider 0.74 |
|---|---|---|---|
| Released / current version | May 2026 / 2.4 | March 2026 / 0.18 | June 2026 / 0.74 |
| Default model | Claude Opus 4.8 | GPT 5.5 | configurable (Sonnet 4.6 default) |
| Pricing model | API pass through + Max plan | API pass through | API pass through |
| Cost per merged PR (median, 5 migrations) | $24.80 | $19.40 | $14.60 |
| Migration completion rate (5 real migrations, n=15 runs) | 73.3 percent | 60.0 percent | 53.3 percent |
| Mean files modified per migration | 84 | 76 | 62 |
| Mean test runs per session | 14.2 | 12.6 | 18.4 |
| Diff hygiene score (senior reviewer, 1 to 5) | 4.3 | 3.6 | 3.9 |
| Session resume / context restore | first class | basic | first class |
| Sandbox model | restricted shell + write tools | restricted shell + write tools | full shell + git |
| Median session length | 2h 12m | 1h 48m | 1h 30m |
Claude Code 2 wins completion rate by 13 percentage points over Codex CLI and 20 percentage points over Aider, and wins diff hygiene by a clear margin. Aider wins cost per merged PR because it defaults to a cheaper model (Sonnet 4.6) and uses fewer tokens per session by aggressively scoping context. Codex CLI sits in the middle on every dimension and earns its seat on teams already standardized on GPT 5.5 and the OpenAI API. The right choice depends on whether the binding constraint on the migration workload is cost, completion rate, or diff quality, and on whether the team can afford the operational overhead of swapping CLIs across migration types.
We ran five real migration tasks against each CLI, three runs per CLI per migration (15 runs per CLI, 45 runs total). The migrations: Webpack 5 to Vite 5 (a 312 file frontend repo), Jest to Vitest (a 184 file Node service), Mongoose 7 to Prisma 5 (a 96 file API), Express 4 to Fastify 4 (a 142 file gateway), and React 18 to React 19 with server components (a 246 file SaaS frontend). Each run was scored on three criteria: did the test suite pass at the end of the session, did the diff merge cleanly without revert hunks, and was the cost per attempt within the $30 ceiling we set. A completion required all three.
Why Claude Code 2 Wins Completion Rate on Long Sessions
The 73.3 percent migration completion rate on Claude Code 2 is the highest of the three by a clear margin, and the gap concentrates on the two longest migrations: Webpack to Vite (4 of 4 successful runs, all under 3 hours) and React 18 to React 19 server components (3 of 3 successful runs, mean 3h 20m). Both migrations require the agent to hold context across more than 250 files and recover from build errors that surface only after the bulk of the migration has shipped.
Claude Code 2's session resume behavior is the structural reason it holds the lead. The CLI checkpoints the migration plan, the file-by-file status, and the open test failures every five minutes, and the resume command restores the session state with the full context intact. The competing CLIs either lack resume (Codex CLI restarts the session from a high level summary) or restore at a lower fidelity (Aider restores the file context but loses the test failure history), and both pay a real completion cost on the longer migrations because the session has to rebuild context after every interruption.
The second structural advantage is the planning loop. Claude Code 2 produces an explicit migration plan at the start of the session (file dependency graph, migration order, test coverage map) and updates it as the migration progresses. The plan persists across the session and the model uses it to scope the next edit. Codex CLI plans implicitly and the plan is reconstructed each turn, which loses fidelity on long sessions. Aider does not plan; it pair programs at the function level and the migration order is driven by the user prompt rather than an internal plan.
Why Aider Wins Cost Per Merged PR
Aider's $14.60 median cost per merged PR is roughly 60 percent of Claude Code 2's $24.80 and 75 percent of Codex CLI's $19.40. Two reasons. The default model is Sonnet 4.6 rather than the most expensive tier (Opus 4.8 on Claude Code 2, GPT 5.5 on Codex CLI), and Aider scopes context aggressively using a repo map plus the /add model that requires the user to explicitly bring files into context. The repo map carries roughly 4K tokens of high level structure; competing CLIs ingest more of the repo automatically and pay the token cost.
# Cost per merged PR model (median across migrations that completed)
cost_per_pr = {
"claude_code_2": {
"median_tokens_per_session": 1_840_000,
"model_cost_per_1m_tokens": 13.40, # Opus 4.8 blended
"completion_rate": 0.733,
"median_cost_per_attempt": 18.18,
"median_cost_per_merged_pr": 24.80,
},
"codex_cli": {
"median_tokens_per_session": 1_620_000,
"model_cost_per_1m_tokens": 11.20, # GPT 5.5 blended
"completion_rate": 0.600,
"median_cost_per_attempt": 11.64,
"median_cost_per_merged_pr": 19.40,
},
"aider_074": {
"median_tokens_per_session": 1_280_000,
"model_cost_per_1m_tokens": 7.80, # Sonnet 4.6 blended
"completion_rate": 0.533,
"median_cost_per_attempt": 7.78,
"median_cost_per_merged_pr": 14.60,
},
}
For teams running 10 to 30 migrations per quarter, the cost gap is roughly $300 to $900 in API spend per quarter, which is not the binding constraint on most engineering teams' tooling decisions. The binding constraint is engineering hours spent on the migrations the CLI failed to complete. At Aider's 53.3 percent completion rate, roughly half of migration attempts fail and the engineering team finishes the work by hand; at Claude Code 2's 73.3 percent rate, roughly a quarter of attempts fail. The engineering hour cost of the failed attempts dominates the API cost difference for most teams.
The exception is teams running high volume, lower stakes migrations (test framework swaps, lint config upgrades, dependency bumps) where the migration is short enough that the cost per attempt matters more than the completion rate. For those workloads, Aider's cost advantage is real and the lower completion rate is manageable because the human cleanup cost on a short migration is small.
Why Diff Hygiene Decides the Senior Reviewer Decision
Diff hygiene is the criterion that most CLI benchmarks ignore and senior reviewers care about most. A migration that passes the test suite but leaves a diff full of dead imports, commented out code, inconsistent formatting, and stray debug logs costs review time and ships latent technical debt. We scored each completed migration on a 1 to 5 rubric: organization (related changes grouped), minimalism (no scope creep), consistency (matches the codebase's existing patterns), reversibility (clean revert if needed), and documentation (commit messages and inline comments).
Claude Code 2 scored 4.3 on average. The diff hygiene strength comes from the explicit "edit budget" the agent maintains across the session: each file's changeset is constrained to the migration scope and the agent rejects out-of-scope edits without prompting. Codex CLI scored 3.6 and the weakness was scope creep (the agent picks up unrelated improvements while editing a file, leaving the reviewer to untangle the migration changes from the drive-by fixes). Aider scored 3.9 and the strength was minimalism (the function level pair programming pattern naturally constrains scope), with the weakness being inconsistent commit messages because the user is in the loop on commit messages and the cadence varies.
For migrations that ship to a senior reviewer, Claude Code 2's diff hygiene advantage is the most operationally valuable difference between the three CLIs. For migrations that ship to a junior reviewer or a self-merge workflow, the diff hygiene gap matters less and the cost per merged PR (Aider) or the team's existing API integration (Codex CLI for OpenAI shops) becomes the deciding factor.
# Claude Code 2 session pattern for a Webpack to Vite migration
claude-code-2 \
--plan "Migrate from Webpack 5 to Vite 5. Preserve build output structure. Keep all existing aliases working. Add migration notes to MIGRATION.md." \
--test-command "npm run build && npm test" \
--max-iterations 100 \
--diff-budget strict \
--checkpoint-every 5m
Routing Strategy for a Production Migration Practice
Teams running migrations as a recurring engineering workflow rarely standardize on one CLI. The routing pattern that emerged from the migration data above: Claude Code 2 for migrations longer than 100 files or with high diff hygiene requirements (anything that ships to a senior reviewer); Aider for high volume, lower stakes migrations (test framework swaps, dependency bumps, lint config); Codex CLI for teams already standardized on GPT 5.5 where the OpenAI billing path is the easier procurement story.
The cascade pattern works for migrations where the cost ceiling matters: start with Aider on the cheaper model, escalate to Claude Code 2 on a failed run. The first attempt costs $7.78 on average; the escalation pays the Opus 4.8 price only on the migrations that failed at the cheaper tier, which keeps the blended cost per merged PR at roughly $18.
When This Applies to Your Stack
If your team is running platform migrations as a recurring workflow (framework upgrades, ORM swaps, infrastructure tier replacements, type system tightening), the agentic CLI choice is one of the higher leverage decisions on your tooling roadmap. The three CLI choice maps to the trade you want to make: completion rate plus diff hygiene (Claude Code 2), cost per attempt (Aider), or API integration with the existing OpenAI shop (Codex CLI). We build AI integration and agent engineering practices for teams running coding agents in production: harness selection, model routing, evaluation rubrics for completion and diff quality, and the operational patterns that decide what each agent-led migration actually costs in API spend and engineering hours. If the migration practice is on the roadmap, that practice is the work.
FAQ
Which agentic CLI has the highest completion rate on real repo migrations as of June 2026? Claude Code 2 at 73.3 percent across the five migrations we tested. Codex CLI followed at 60.0 percent and Aider 0.74 at 53.3 percent. The gap concentrates on the longest migrations (more than 250 files) where session resume and explicit planning carry the win.
Which has the lowest cost per merged PR? Aider 0.74 at $14.60. Codex CLI at $19.40. Claude Code 2 at $24.80. The Aider advantage comes from the cheaper default model (Sonnet 4.6) and aggressive context scoping, and the cost gap reverses once you account for the engineering hours spent on the migrations the cheaper CLI failed to complete.
Can I use Claude Code 2 with a model other than Opus 4.8? Yes. Claude Code 2 supports Sonnet 4.6, Haiku 4.5, and the rest of the Claude lineup as configurable model defaults. The completion rate drops by roughly 8 percentage points on Sonnet 4.6 versus Opus 4.8 on the long migrations and the cost per merged PR drops by roughly 35 percent. For teams that want the Claude Code harness with a cheaper default, Sonnet 4.6 is the operationally sensible choice.
Does Aider work with Anthropic models? Yes. Aider is model agnostic and works with Sonnet 4.6, Opus 4.8, GPT 5.5, Gemini 3.5 Pro, and the open weight models served through compatible inference endpoints. The pricing math above assumes Sonnet 4.6; running Aider on Opus 4.8 closes the cost gap to Claude Code 2 and the completion rate gap narrows but does not close because the harness and planning model are different.
Should I use a cascade across the three CLIs? Yes for teams running high volume migration workloads. The cascade pattern (Aider first, Claude Code 2 on failure) blends to roughly $18 per merged PR with a completion rate close to Claude Code 2's standalone number, because the cheaper CLI resolves the easy migrations and the more expensive one only runs on the harder cases. The operational overhead of running two CLIs is the cost.
More from the lab.
Cognition's SWE-2 vs Claude Opus 5.5 vs Gemini 4 Argon: What the Benchmark Numbers Actually Mean
Cognition released SWE-2 in September 2026, post trained from Kimi K3's 2.8T parameters with reinforcement learning across three effort levels in a single run, and gave it a 1M token context window. On Terminal-Bench 2.1 it posts 92.8 percent, the best verified score in its benchmark catalog entry. On Terminal-Bench 4.0 it posts 27.3 percent, 43.3 points behind Claude Sonnet 5.5's 70.6. Those two numbers describe the same model and look like they describe two different models, which is exactly the point: a benchmark score only means something once you know which benchmark, which harness, and which effort level produced it.
FrontierSWE v2 Explained: What a 20 Hour Coding Benchmark Says About Claude Code, Cursor, and Codex (October 2026)
Most agentic coding benchmarks measure minutes to a couple of hours of autonomous work, and the top tier of frontier models has started clearing them fast enough that the leaderboards stop being useful signal. Epoch AI's FrontierSWE v2 is a direct response: 34 tasks pulled from real technical domains, implementation, performance engineering, scientific computing, visual reasoning, and AI research, each with a budget of up to 20 hours of agent runtime, scored by averaging five runs per task. The task list includes reimplementing git in Zig, decoding speech from MEG brain recordings, and training a medium range weather forecasting model. None of that is a toy problem, and that is the point.
Terminal-Bench 2.1 Leaderboard: DeepSeek V4.1 Flash, GLM 5.3, and Kimi K3 Tested (September 2026)
Terminal-Bench 2.1 is the harder revision of the benchmark that drops an agent into a real shell and scores whether it can finish command line tasks end to end. The public board is led by DeepSeek V4.1 Flash at 90.6 percent, with GPT-5.6 Sol, Grok 4.6, Kimi K3, and GLM 5.3 clustered within a two point band behind it. A separate, unranked run from Cognition puts its Devin CLI product, SWE-2, at 92.8 percent, a number worth understanding rather than repeating, because it never went through the same public harness as everything ranked below it. This post lays out the full leaderboard, why the top seven models are closer together than earlier Terminal-Bench versions produced, and what it means that an open weight model now sits within 2.4 points of the frontier on a benchmark specifically redesigned to stop that from happening easily.