Claude Code vs Codex CLI: Which Terminal Coding Agent Wins in 2026?

Claude Code vs Codex CLI: Which Terminal Coding Agent Wins in 2026? — illustration

Two terminal coding agents, one decision: Claude Code from Anthropic, Codex CLI from OpenAI. The short answer in 2026 is that the feature gap has mostly closed, so pick the one whose bill you already pay, unless you specifically need an open-source agent, in which case it’s Codex CLI.

Last verified: 26 September 2026.

A correction first. When this page went up in May, it said Codex CLI had no hooks, subagents or plugin layer, and built most of its recommendation on that. That’s no longer true. OpenAI’s current docs list all three, plus MCP support and slash commands, and the sections below have been rewritten to match.

Scope, quickly. Both of these run in your terminal, read your codebase, edit files, and run commands. If what you actually want is AI inside an editor, that’s a different question, and our best AI code editors roundup covers it.

The short version

Pick Claude Code if you’re already on a Claude Pro or Max plan, or you want Claude models doing the work. Pick Codex CLI if you’re already on a ChatGPT or OpenAI API plan and don’t want a second AI subscription, or if you want a tool whose source you can audit and fork. The extensibility argument that used to push teams toward Claude Code doesn’t hold up now. Both have MCP, subagents, hooks, plugins and slash commands.

If you’re trying a terminal agent for the first time on a side project, start with whichever ecosystem you already pay for. Honestly, that’s the answer for most people.

What each one actually is

Claude Code is Anthropic’s agentic CLI. You run it inside a repo, describe a task, and it plans, edits files across the project, runs your build and tests, and iterates. It runs on Claude models. Anthropic’s own model docs now say to start with Claude Opus 5.5 for most workloads; it launched on 22 September. You sign in with an Anthropic API key or a paid Claude plan. Pro is $20 a month ($17 billed annually), Max starts at $100, and Team and Enterprise include Claude Code too. The free Claude plan doesn’t. One thing people miss: on paid plans, Claude Code and chat draw from one shared usage pool, so a long agent session eats into your chat allowance.

Around the core loop you get MCP support for connecting Model Context Protocol servers, subagents, hooks at lifecycle points, and slash commands you check into the repo. If you’ve never gone past the basics, our Claude Code tips and tricks post is a decent next stop. (New to MCP entirely? Start with how MCP servers work.)

Codex CLI is OpenAI’s open-source terminal coding agent, licensed Apache-2.0. Same core loop: it reads and edits your repo and runs commands. You authenticate with an OpenAI API key or a ChatGPT plan. OpenAI’s pricing page lists “Codex on the web, in the CLI, in the IDE extension, and on iOS” starting with Plus; the Free and Go plans get Codex only in the desktop app.

Around that loop, Codex now has the same kind of tooling. Subagents are switched on by default in current releases; you define them in TOML under ~/.codex/agents/ or .codex/agents/ and flip between running threads with /agent. Hooks cover twelve lifecycle events, including PreToolUse, PostToolUse, SessionStart and SubagentStop, managed with /hooks. /plugins opens a plugin browser, and a plugin can bundle skills, MCP servers and hooks. MCP servers go in ~/.codex/config.toml and you inspect them with /mcp.

(OpenAI has used the name “Codex” for several things. There’s now a Codex desktop app and Codex Web alongside the CLI. This post is about the command-line tool. Also, if your bookmarks point at developers.openai.com/codex, they now redirect to learn.chatgpt.com.)

Side by side

Claude CodeCodex CLI
PricingClaude Pro ($20/mo), Max (from $100/mo), Team, Enterprise, or Anthropic API key; not on the free Claude planOpenAI API key (usage-based), or ChatGPT Plus and up
ModelsClaude family; Anthropic recommends Opus 5.5 for most workloadsOpenAI models, switchable with /model
Open source?No, closed clientYes, Apache-2.0
Where it runsTerminal, plus VS Code and JetBrains extensions, a desktop app and the webTerminal, plus an IDE extension and desktop app
ExtensibilityMCP, subagents, hooks, slash commands, plugins, skillsMCP, subagents, hooks, slash commands, plugins, skills
Sandboxing / approvalPermission modes, plus a Bash sandbox (/sandbox) that limits which files and network domains commands can touchSandbox modes (read-only, workspace-write, danger-full-access) plus separate approval settings
Best forPeople already paying Anthropic, or who prefer Claude modelsPeople already paying OpenAI, or who need to audit the source

Where Claude Code pulls ahead

If you already pay for Claude Pro or Max, Claude Code costs you nothing extra, and that’s a real advantage. The flip side is the shared pool. A heavy refactor session in the terminal and a long chat in the browser come out of the same allowance, which is easy to forget until you run short.

The other reason is the model. If you’ve found you get better results from Claude models on your codebase, Claude Code is the direct way to use them, and Opus 5.5 is what Anthropic now points people at first. That’s a preference about output quality, and it’s mine as much as anyone’s. I still reach for Claude Code for the big, messy changes. That’s my habit, not a benchmark, and you should test it on your own repo.

What you give up: it’s closed source. The public anthropics/claude-code repo holds plugins, example hooks and settings, and the changelog. It doesn’t hold the CLI itself, and the license is “All rights reserved”. You can’t inspect or fork the client.

Where Codex CLI pulls ahead

It’s open source, and for some people that settles it. The openai/codex repo has the real thing, including a Rust implementation, under Apache-2.0. You can see how it sandboxes commands, audit it for a security review, contribute fixes, or fork it for an internal build. For teams with compliance requirements, or anyone who doesn’t love a black box running loose in their repo, that counts for a lot.

It’s also one account, one bill. If you’re already paying OpenAI for ChatGPT or running on an OpenAI API key, Codex CLI slots in with no new billing relationship. For a lot of people that’s the whole decision.

The permission model is explicit, too, and it’s two settings rather than one. OpenAI’s docs put it this way: “The sandbox defines which files and network resources ChatGPT can access. Approvals determine when ChatGPT pauses before an action”. The sandbox modes are read-only, workspace-write (the default for local work) and danger-full-access. The permission choices in the UI are “Ask for approval”, “Approve for me” (called Auto-review in settings), “Full access” and “Custom (config.toml)”, and in the CLI you change them with /permissions. Don’t read the two lists as the same thing renamed: “Ask for approval” still lets Codex edit files in your workspace and run routine local commands. I like that the riskiest sandbox mode has “danger” in its name.

What you give up: you’re tied to OpenAI’s models and roadmap. On which model is actually in use, OpenAI’s CLI docs show “gpt-6-sol” in an example screen, but I couldn’t confirm that’s the default every new user gets, so check /model on your own install. Usage on a ChatGPT plan is metered in messages per five-hour window, and OpenAI’s Codex pricing page publishes ranges per plan and model. On Plus it’s 15 to 150 local messages on GPT-6 Sol and 350 to 3,000 on GPT-6 Luna; the Pro tiers scale those up. OpenAI adds that “These estimates are not fixed message limits; check your usage dashboard for current limits and reset times.”

If you want to widen the field beyond these two, Aider is another terminal-leaning agent worth a look, and our roundup of AI tools developers actually use in 2026 puts all of them in context.

So which should you pick?

Match yourself to the situation.

You already pay for Claude Pro, Max, Team or Enterprise: Claude Code. It’s included in what you already pay.

You already pay for ChatGPT Plus or higher, or run on an OpenAI API key: Codex CLI. No new subscription.

You want an open-source agent you can audit, contribute to, or fork: Codex CLI. It’s the only one of the two whose source you can actually read.

You’re a team that wants hooks, MCP and subagent workflows: either. Pick on billing and model preference instead.

You’re trying terminal agents for the first time: whichever ecosystem you already live in. Your hooks, agent definitions and config won’t carry across if you switch later, so don’t over-invest in either before you’ve decided.

If you forced me to give one blanket answer, I’d tell you to stop looking for a feature winner; on the checklist, I don’t see one this month. Decide on who you already pay and which model’s output you trust, then spend a week with it.

Can you run both?

Sure. They’re both just CLIs you run inside a repo, and nothing stops you keeping both installed and picking per task. If you point both at the same repo, give each its own branch or worktree, because two agents editing one working tree can overwrite each other. If you want a second opinion on a tricky change, running the same task through both and diffing the results is useful. And since both speak MCP now, an MCP server you rely on can be wired into either one.


Still weighing terminal agents against editor-based tools like Cursor and Copilot? Our best AI code editors roundup has the current free tiers and prices. More head-to-heads in the AI Tools category.

Frequently Asked Questions

Is Codex CLI free?

The tool itself is free and open source under the Apache-2.0 license. Model usage comes from an OpenAI API key or a ChatGPT plan; OpenAI's pricing page lists Codex in the CLI from ChatGPT Plus upward.

Is Codex CLI open source?

Yes. The openai/codex repo is Apache-2.0 and contains the CLI's actual source, so you can read it, file issues, and fork it. Claude Code is a closed client from Anthropic.

Is Claude Code better than Codex CLI?

Not on the feature checklist any more: both now have MCP servers, subagents, hooks, plugins, skills and slash commands. How deep each implementation goes is something to test on your own work. Pick Claude Code if you already pay Anthropic or want Claude models; pick Codex CLI if you already pay OpenAI or need an agent you can read and audit.

Does Codex CLI have hooks and subagents?

Yes. OpenAI's docs say current Codex releases enable subagent workflows by default, and list a lifecycle hooks system with events like PreToolUse and PostToolUse, and a plugin browser under /plugins.

Can Codex CLI edit multiple files?

Yes. It reads your repo, edits files within its workspace, and runs commands, asking for approval when it needs to go beyond what your sandbox and permission settings allow.

Which one costs less?

Depends on your usage and which plan you're already on. On a subscription, Claude Code starts at Claude Pro, $20 a month, and ChatGPT Plus is the first plan OpenAI lists with Codex in the CLI. Both can also run usage-based off an API key. Run a real week of work through each and compare your actual bill.

Written by Hirak Banerjee

Indie dev and maker. I build AI-powered apps and write about the tools I actually use. Follow on X · GitHub

Get told when these numbers change

Every figure here is re-checked against the vendor's own docs. Leave your email and we'll tell you when one moves — only when something actually changes.

Join builders who ship faster. No spam.

Comments