Coding · Head-to-Head

Claude Code vs. Codex CLI for Terminal-Based AI Coding

Two terminal-native coding agents most working engineers are now choosing between. We ran both on the same repos for two weeks and graded the outputs, not the marketing.

Tested by Marcus Feld · August 9, 2026 · 4 rounds
Claude Code
Anthropic
2rounds
89 / 100 overall
vs
Codex CLI
OpenAI
2rounds
85 / 100 overall
The verdict

If most of your day is multi-file refactors, unfamiliar-codebase archaeology, or long agentic sessions where you actually want to trust the output, Claude Code is the better daily driver. Its reasoning depth on large-context work, and its layered customization (CLAUDE.md, hooks, subagents), hold up under sustained use in a way Codex CLI's simpler configuration model does not. If your team already pays for ChatGPT, needs an open-source client you can audit or fork, cares about kernel-level sandboxing, or wants to dispatch parallel tasks to a cloud sandbox and come back to finished diffs, Codex CLI is the safer pick and rides on a subscription you already have. Either tool will cover most of what a working engineer needs in 2026. The edge cases pull them apart, and running both for a week on real tickets is cheaper than guessing.

Most working developers are picking between these two right now. Terminal-based AI coding agents have gone from novelty to default, and the two dominant players, Anthropic's Claude Code and OpenAI's Codex CLI, have converged on the same broad shape (a coding agent that reads your codebase, edits files, runs commands, and iterates in a loop) while making very different bets about how it should work.

We ran both tools side by side for two weeks across three real repositories: a TypeScript/Next.js frontend, a Python service, and a Rust CLI. We scored four rounds: how each one handles multi-file refactors on a real ticket, how each one behaves in long, less-supervised agent runs, how each one fits the ecosystem and tooling a team already uses, and how the pricing and sandboxing story shakes out once you factor in the billing changes both companies shipped over the past year. Each round below names the procedure we used, then the result.

Round by round

Multi-file refactors and long-context reasoning
WinnerClaude Code

How we testedWe assigned the same three refactors to each agent on the same three repos: rename a domain concept across ~35 files in a TypeScript codebase, migrate a Python service from one HTTP client to another, and extract a shared crate from a Rust workspace. We graded each attempt on whether the build passed, whether the test suite passed, and how many files we had to hand-correct afterward.

Claude Code finished all three refactors with fewer hand-corrections in our testing. That also lines up with what independent reviewers have found on this class of work: in blind evaluations where developers rated code without knowing which tool produced it, Claude Code won 67% of comparisons against Codex CLI's 25%, with 8% ties. The 1M token context on Opus (available at standard pricing on paid plans) let it hold most of a mid-sized project in-session, and its agentic search meant it read broadly before writing rather than making us hand-pick files. Codex CLI shipped working code faster and used materially fewer tokens on the same tasks, but on the two larger refactors it left more stragglers we had to clean up by hand.

Long-running agent sessions and multi-agent orchestration
WinnerClaude Code

How we testedWe took four open tickets from our test repos (two bug fixes, a small feature, a dependency upgrade) and handed each one to both tools' longest-running mode: Claude Code with subagents on, Codex CLI with a cloud task dispatched from chatgpt.com/codex. We scored whether the run produced a diff we would merge, how many follow-up prompts it needed, and how well each tool handled a session that ran past an hour.

Both tools now offer some form of longer-horizon work, and both close the loop with a diff you review before it lands. In our testing, Claude Code's subagents and hooks kept context across the longer sessions better, and its CLAUDE.md configuration compounds: the setup gets more capable the longer a team uses it, because CLAUDE.md, memory, skills, and hooks stack together. Codex CLI has a real answer here in Codex Web (the cloud-based agent at chatgpt.com/codex), which is genuinely useful for dispatching tasks in parallel to isolated sandboxes and returning to reviewable diffs, and its Symphony orchestration spec (published April 27, 2026) is a credible bet on multi-agent coordination. But on our longest tickets Codex lost context across sessions in a way Claude Code did not, which tracked with what heavy users report. Claude handled context, large outputs, and long-session memory better; Codex has the nicer sandbox, but for the long, tool-heavy sessions we actually build, Claude wins.

Ecosystem, openness, and editor fit
WinnerCodex CLI

How we testedWe installed each tool the way our test team actually works: from the terminal, and inside VS Code, JetBrains, and (for Codex) Cursor and Windsurf. We scored coverage across editors, how each tool handled MCP servers and repo-level configuration, and how cleanly each fit a GitHub-based workflow with PR reviews and issue assignment.

Codex CLI is open source under Apache 2.0 and lives at github.com/openai/codex, with a codebase that is roughly 95% Rust. For a security team that wants to audit what the agent does before it touches a repo, or a platform team that wants to fork the client and embed it in CI, that alone can decide the question. Claude Code is closed source. Codex CLI also reads AGENTS.md, the open standard used across Codex, Cursor, Aider, and others, so a team that has already written an AGENTS.md gets that configuration for free. Claude Code uses CLAUDE.md, which supports a more detailed setup including layered settings, policy enforcement, hooks that run before or after actions, and MCP integration, but it only works within Anthropic's tools and nothing else reads it. Editor coverage was closer than we expected: Anthropic ships native extensions for VS Code and JetBrains, and Codex ships an IDE extension for VS Code, Cursor, and Windsurf. Codex's broader third-party surface and open license tipped this round.

Price, billing, and sandboxing
WinnerCodex CLI

How we testedWe compared current published pricing at every tier for individual and team use, modeled a month of heavy agent use for a five-person engineering team, and read the sandboxing docs for each tool end to end. We also factored in the billing-model changes both companies shipped over the past year.

Codex CLI is included with any paid ChatGPT plan (Plus, Pro, Business, Edu, or Enterprise), so for a team that already pays for ChatGPT there is no separate line item. Claude Code is included with Anthropic's Pro plan at $20/month, Max at $100 or $200/month, and Team Premium at $100 per seat billed annually ($125/month monthly), with usage pooled across Claude chat, Claude Code, and Cowork on a rolling five-hour session window plus weekly caps. Neither company publishes a token count for those sessions, and community estimates put the Pro allocation in the tens of thousands of tokens per window before you hit a limit. On sandboxing, Codex has the more rigorous story out of the box: it uses Apple Seatbelt on macOS and Landlock plus seccomp on Linux, so commands can read broadly but cannot write or reach the network unless your policy allows it. Claude Code enforces safety at the application layer through programmable hook events, which gives finer-grained control but weaker default boundaries. If your work involves reviewing untrusted code, or you need kernel-enforced isolation, Codex is the safer default. If your work is enforcing organizational conventions on trusted code, Claude Code's hooks do things a sandbox cannot.

Most working developers are picking between these two right now. Both agents have converged on the same broad shape, a terminal-native tool that reads your codebase, edits files, runs commands, and iterates in a loop, and the question is no longer “which one has an agent” but “which one does the work you actually do, on the ecosystem you already live in, at a price you can defend.”

Where Claude Code wins

Claude Code is the better tool when the work is heavier than a single-file change. In our testing, its multi-file refactors needed fewer hand-corrections, and its long-running sessions kept context across turns better than Codex’s did. That matches the broader signal from developers running both: in blind evaluations where developers rated code without knowing which tool produced it, Claude Code won 67% of comparisons against Codex CLI’s 25%, the most significant quality gap in the data. Claude Code produces code that human developers consistently judge as cleaner, more idiomatic, and better structured.

The customization layer is the other half of why it wins on sustained work. CLAUDE.md, auto memory, skills, and hooks stack together, so a team’s Claude Code setup gets more capable the longer it is used, not just faster. That compounds in a way Codex’s flatter configuration model does not.

The catch is the billing and the ceiling. Claude Code is included with paid plans, but usage pools across products, so Claude Code usage counts against the same limits as Claude chat usage, a morning of chatting and an afternoon of Claude Code both eat into the same five-hour session and weekly caps . On a Pro plan, that ceiling shows up faster than you’d expect. The team tier isn’t cheap either: Team Standard is $25/user/month billed monthly or $20/user/month billed annually, and Team Premium is $125/user/month monthly or $100/user/month billed annually , and Team Premium is the only Team tier that includes Claude Code.

Where Codex CLI wins

Codex CLI wins on fit and openness. OpenAI Codex is an open-source CLI coding agent, available at github.com/openai/codex, built primarily in Rust (96.3% of the codebase) and licensed Apache 2.0 . If your security team wants to read the client before it touches a repo, or your platform team wants to fork it and embed it in a pipeline, that’s the whole answer.

It also plugs into the ecosystem most teams already pay for. You run codex, select Sign in with ChatGPT, and use Codex as part of your Plus, Pro, Business, Edu, or Enterprise plan . There’s no separate agent subscription to buy or defend. For teams that want to move long tasks off a local machine, the cloud path is real too: you delegate a longer task and return when it is ready, run tasks in parallel without tying up your local machine, and use integrations to hand off work without leaving the pull request, issue, channel, or thread .

The sandboxing is the quiet advantage. The sandbox uses Apple Seatbelt on macOS and Landlock plus seccomp on Linux, which means commands can read broadly but cannot write or access the network unless your policy allows it . For reviewing untrusted code, or running an agent in CI, that default matters.

Who should pick which

Pick Claude Code if your day is multi-file refactors, unfamiliar-codebase archaeology, or long agentic runs where the diff needs to be right the first time, and you’re willing to invest in a CLAUDE.md and a hooks setup that will compound over months. Pick Codex CLI if your team already pays for ChatGPT, you need an open-source client you can audit or fork, kernel-level sandboxing is a hard requirement, or you want to dispatch parallel work to a cloud sandbox and come back to finished diffs.

The honest advice we’d give a team choosing between them is the same one heavy users keep giving: run both for a week on a real task, and pick the one that matches how you work . Subscriptions are cheap next to engineer time, and two weeks of real tickets tells you more than any benchmark. On the work we cared about, Claude Code’s edge on reasoning and long-session memory outweighed Codex’s edge on speed and cost. Your codebase might vote differently.

Sources