Claude Code vs OpenAI Codex CLI: Our Verdict
Two terminal-native coding agents from the two frontier labs. One wins the long, tool-heavy refactor. The other wins the daily bill. We tested both to decide which one working engineers should actually put in their shell.
We recommend Claude Code for engineers whose day is spent on long, multi-file refactors and architecture work in a single codebase, where its context handling and hooks earn back their price. Codex CLI is the pick for developers who want a cheaper, more predictable terminal agent, wider cross-editor reach, and stronger shell-task performance, and for anyone who already lives inside a ChatGPT subscription.
These two products answer the same question from opposite ends of the same frontier lab. Both are terminal-native coding agents, both run on the vendor's flagship models, and both edit files, run tests, and open pull requests without leaving the shell. The differences that matter sit in the harness around the model, in how each tool handles a long session, and in what the bill actually looks like at the end of the month.
We ran each tool through the same production work over several weeks in June and early July 2026: a mix of multi-file refactors, terminal-heavy DevOps tasks, and long agentic sessions on a real repository. Each round below names a winner and states the concrete procedure we used to decide it.
Claude Code produced diffs our blind reviewers preferred on four of the five tasks, and the pattern lines up with published data. In a documented Express.js refactor comparison, blind reviewers rated Claude Code's output cleaner 67% of the time versus 25% for Codex, and on the harder SWE-bench Pro benchmark Opus 4.7 leads GPT-5.5 by roughly 5.7 points (64.3% to 58.6%). The gap is smallest on single-file work; it widens the moment the change has to span the repo.
How we tested itWe ran the same five multi-file refactors on a 60K-line codebase in each tool (a framework migration, an API-contract update, a shared-type change, a test-suite rewrite, and a lift-and-shift of a shared component). Two reviewers scored each resulting diff blind on correctness, idiomaticness, and whether it caught the non-obvious edge cases, then we compared to third-party head-to-head data.
Claude Code exposes a 1M-token context on Opus at standard pricing, and its compaction preserved architectural memory across a long session we could not reproduce in Codex, where the middle of a large tool response was truncated and the reasoning behind an earlier decision was lost. Codex defaults to a 272K window with a 1.05M long-context mode that must be explicitly enabled and is billed at 2x input / 1.5x output over the threshold. For long, tool-heavy sessions, Claude's harness is the one that remembers.
How we tested itWe ran multi-hour agentic sessions in each tool on the same codebase, deliberately pushing past the default context window, then asked each agent about a decision made early in the session after a /compact-style summarisation. We also observed how each tool handled a large MCP tool response mid-session.
Codex needed fewer interventions on shell-native work, and its sandboxing behaved more predictably on destructive commands. GPT-5.5 currently leads Terminal-Bench 2.0 (82.7% versus Claude's 69.4%), and the gap showed up in practice: for CI, deploys, and one-shot scripts, Codex is the tool that finishes first.
How we tested itWe assigned each tool the same set of DevOps and scripting jobs (writing a deploy script, patching a CI workflow, diagnosing a failing container build, and automating a release note) and measured how many required human correction before completing, drawing on Terminal-Bench 2.0 leaderboard results for context.
Codex operates across a cloud web agent, the open-source Rust CLI, IDE extensions for VS Code and Cursor, and a macOS desktop app, and it reads AGENTS.md, an open configuration standard adopted by 60,000+ open-source projects and supported natively by Cursor, GitHub Copilot, Gemini CLI, Windsurf, Aider, Zed, Warp, and RooCode. Claude Code ships native extensions for VS Code (plus Cursor and Devin Desktop) and JetBrains, but its CLAUDE.md is Anthropic-only. If a team already runs any of the AGENTS.md-native tools, Codex inherits that configuration for free.
How we tested itWe installed each tool on every surface it ships (CLI, IDE extensions, desktop app, cloud) and confirmed the feature set on each. We also checked configuration portability across tools.
Claude Code exposes 26 programmable lifecycle hook events for deep governance customization, plus layered settings, MCP integration, and skill sub-agents. Codex enforces safety at the kernel layer with Seatbelt, Landlock, and seccomp but offers coarser application-level control. For teams that want to encode a coding standard, an audit hook, or a pre-commit reviewer as part of the harness itself, Claude Code has the finer instrument.
How we tested itWe built the same guardrails in each tool (pre-tool permission prompts, a policy that blocks certain shell commands, and a post-run hook that runs a linter) and counted the customization points each exposed for organizational policy.
Both tools start at essentially the same subscription price (Claude Pro at $20/month, or $17 on annual billing, and ChatGPT Plus at $20/month), but Claude Pro's five-hour rolling window and weekly caps hit fast under agentic load, with the community reporting Max at $100/month or Max 20x at $200/month as the realistic tier for daily professional use. Codex Plus rarely triggered a limit on the same workload. Starting June 15, 2026, Anthropic further splits interactive Claude Code usage from programmatic Agent SDK usage into a separate metered credit pool at API rates, which teams scripting Claude Code into CI need to budget for. For a developer whose day is heavy autocomplete and moderate agent work, Codex is the lower and more predictable bill.
How we tested itWe ran each tool on its entry-tier paid plan for a normal working week, then priced a heavy agentic week where sessions ran multi-hour with Opus/GPT-5.5 as the primary model, and read the actual bill through each tool's /cost command and the vendor console.
Where the verdict turned
Claude Code and Codex CLI are the two credible answers to the same question, a coding agent that lives in your shell rather than in an IDE, and they diverge on almost every axis that matters. Claude Code took the rounds about the work itself: code quality on repository-scale refactors, context handling in long sessions, and governance depth. Codex took the rounds about the surrounding footprint: terminal-task accuracy, surface and editor coverage, and the monthly bill. That split isn’t a coincidence. Anthropic built a harness optimized for long, tool-heavy engineering sessions; OpenAI built one optimized for reach, throughput, and price predictability across a much larger ChatGPT subscriber base.
The benchmarks are consistent with what we saw. On the contamination-resistant SWE-bench Pro, Claude leads. On Terminal-Bench 2.0, Codex leads. On SWE-bench Verified the two are essentially tied at 88.7% and 87.6%. Treating any one of those numbers as the whole story is exactly what the two companies are hoping you’ll do. In practice, most teams we spoke to end up installing both and routing work between them: Codex for cost-sensitive bulk work and autonomous PRs, Claude Code for high-stakes refactors and architecture. That’s a defensible answer, but it isn’t a verdict, and this is a ratings site.
What changed in mid-2026
Both products are being repriced in real time, and anyone choosing between them is choosing across a moving target. Anthropic doubled the per-session Claude Code rate limits on May 6, 2026 for Pro, Max, Team, and seat-based Enterprise plans, and permanently removed the peak-hour throttling that used to burn Pro and Max budgets faster on weekday mornings. That materially improves the entry-tier experience. It does not close the gap on heavy agentic work: the $20 Pro plan still hits its weekly cap fast under real refactor load, and community write-ups continue to report Max at $100/month or Max 20x at $200/month as the practical tier for daily professional use.
The harder change lands on June 15, 2026, when Anthropic splits subscription usage into two pools. Interactive Claude Code in the terminal or an IDE stays on the plan’s session and weekly limits. Programmatic use (claude -p, the Agent SDK, the Claude Code GitHub Actions integration, ACP-based third-party tools) moves to a separate metered credit pool billed at full API list prices, with monthly credit allotments of roughly the plan price ($20 on Pro, $100 on Max 5x, $200 on Max 20x). If you script Claude Code into CI or build an internal agent on the Agent SDK, that automation is now a separate line item, and it isn’t covered by the flat subscription in the way it used to be.
Codex is on a comparable but simpler trajectory: token-metered under a credit system already, with GPT-5.5 costing roughly 125 credits per 1M input tokens and 750 per 1M output, and per-message costs averaging 5-45 credits. Plus and Pro users can top up. Neither product is a flat-rate, unlimited-agent tool in July 2026. Budget the heavy work.
Who should buy which
Choose Claude Code if repository-scale refactors, long agentic sessions, and organizational governance are the bulk of your day, and if you’re willing to pay $100 or $200 a month for headroom you will actually use. The 1M-token context on Opus at standard pricing, the depth of the hooks system, and the quality of the diffs on multi-file work are worth the price for engineers whose output is measured in landed refactors rather than lines of code. Budget on a Max tier from day one; the $20 Pro plan is a starter subscription, not a professional one, and the Agent SDK credit change means CI usage has to be planned separately.
Choose Codex CLI if you want the cheapest predictable entry point into a competent terminal agent, if your work is scripting- and shell-heavy, if your team already runs an AGENTS.md-native stack (Cursor, Aider, Copilot, Gemini CLI, Windsurf, Zed, Warp, or RooCode), or if you’re already paying for ChatGPT and want the coding agent bundled in. It’s the more autonomous long-horizon runner in our tests, and it’s measurably the more affordable one at the entry tier.
For teams that can afford both, running both isn’t unreasonable, and that’s the pattern we heard most often from senior engineers. But if forced to one terminal agent, our recommendation for working engineers doing serious multi-file work is Claude Code. For everyone else (cost-sensitive individuals, script-heavy workflows, and teams anchored to editors Claude Code doesn’t natively cover as deeply) the pick is Codex.