Short answer. Claude Code is the stronger choice when you want a composable Unix-style agent with hooks, subagents and a mature set of CI integrations. Codex CLI is the stronger choice when your team already pays for ChatGPT and wants explicit permission profiles, sandboxing and a direct path to Codex Cloud. Both are capable; the deciding factors are your repository, your billing model and how much autonomy you are willing to grant.
Side by side
| Dimension | Claude Code | Codex CLI |
|---|---|---|
| Vendor | Anthropic | OpenAI |
| Surfaces | Terminal, IDE, desktop, web | Terminal, IDE, desktop, cloud |
| Included plan | Claude Pro and above | ChatGPT Free, Go, Plus, Pro, Business, Enterprise |
| Models | Claude Opus, Sonnet, Haiku and newer tiers | GPT-6.1 Sol, GPT-6 Astra, GPT-6 Sol and Luna, GPT-5.6 |
| Context | Up to 1M, varies by model | Model-dependent; 256K–400K on ChatGPT reasoning tiers |
| Permissions | Permission modes, hooks, sandboxed execution | Permission profiles, sandbox and approval settings |
| Scripting | claude -p, GitHub Actions, Agent SDK | codex exec, CI, SDK |
| Project memory | CLAUDE.md or AGENTS.md, auto memory | AGENTS.md, skills and plugins |
| Best for | Teams that live in the terminal and CI | Teams standardised on ChatGPT |
Sources: Claude Code docs, Claude pricing, OpenAI Codex CLI docs and Codex pricing, checked 20 November 2026. Model names and limits change; confirm in the docs.
What each agent is
Claude Code began as a terminal tool and expanded to VS Code, JetBrains, desktop and web. It reads the codebase, plans a change, edits files, runs commands and works with git. The other surfaces share the same engine, project instructions and MCP servers, and a paid Claude plan includes Claude Code.
Codex CLI is OpenAI's terminal agent. The install is a single script, and codex starts an interactive session with a model picker, a permission picker and a review command. /init creates an AGENTS.md file, codex exec runs non-interactively, and the CLI can hand work to Codex Cloud. It is included in ChatGPT plans rather than sold as a separate seat.
Permissions and sandboxing
Claude Code exposes permission modes, allows or denies specific tools, and supports hooks before or after actions. A hook can format a file, run a linter or block a command that touches production credentials. Permissions can be scoped per project and kept in version control.
Codex CLI exposes permission profiles and a sandbox. The /permissions command shows what the agent may do and which directories are writable. You can require approval for commands, allow edits inside the workspace, or run with broader access when the task demands it. The sandbox is an OS-level boundary, not just a prompt instruction.
For both, default to workspace-only writes, approval for network and shell commands, and a disposable VM for unattended runs.
Context and model access
Claude Code advertises up to 1M tokens depending on model and plan. Using all of it is rarely optimal: a focused retrieval step plus the failing test and the interface contract usually beats dumping the whole tree into the prompt.
Codex CLI's context depends on the model. ChatGPT plan pages list 256K for reasoning on Plus and 400K on Pro; API models may differ. The CLI lets you choose model and reasoning effort per session, which is useful for trading cost against depth. Codex also supports image inputs and live web search when a task depends on current documentation.
Claude Code is Claude-first; Codex CLI is OpenAI-first. Both can reach other providers through supported configurations, but the default experience is tied to the vendor's models.
Pricing
Claude Code is included in Claude Pro at $20 per month ($17 annual), Max at $100 and Ultra at $200. Higher tiers raise usage limits and add API credits. Heavy use can hit the five-hour or weekly cap, so the effective cost is the tier that gets the team through a normal week.
Codex is included in ChatGPT Free, Go, Plus, Pro, Business and Enterprise plans, with usage allowances that vary by model and plan. API-key usage is billed per token. If your team already has ChatGPT Business seats, the marginal cost of trying Codex is close to zero; that is a real advantage over adding a new vendor.
CI and automation
Both tools are scriptable. Claude Code's print mode runs non-interactively; Codex CLI's codex exec is built for pipelines. The pattern is the same: checkout, install, authenticate with a scoped token, run a bounded task, run tests, and open a pull request.
# Claude Code: non-interactive review of changed files
git diff --name-only origin/main...HEAD | claude -p "Review these files for security issues. Return JSON."
# Codex CLI: non-interactive task with a workspace sandbox
codex exec --sandbox workspace-write \
"Run the test suite, fix only the failing unit tests, and summarise the changes."
# Both: fail the job if the agent changed files outside the expected paths.
git status --porcelain | awk '{print $2}' | grep -v '^src/' && exit 1
Migration path. Keep one AGENTS.md for both tools; generate it from CLAUDE.md if you have one. Port hooks, permission rules, MCP servers and CI commands, then run both agents on low-risk tasks for a sprint before cutting over.
A reproducible task benchmark
A useful comparison fixes the commit, the task set and the acceptance tests, then runs each agent more than once. We do not publish a winner score because the result depends on language, framework, model version and context.
Use 12 tasks across three categories: a bug fix with a failing test, a small feature with a new test, and a refactor with no behaviour change. Run each task three times from a clean checkout. Score pass@1 against the acceptance tests, count human interventions, record wall-clock time and tokens, and note whether the agent touched files outside the task scope.
| Metric | How to measure | Why it matters |
|---|---|---|
| Pass rate | Acceptance tests green after the run | Correctness, not eloquence |
| Interventions | Human approvals or corrections per task | Supervision cost |
| Scope | Files changed outside the task boundary | Review risk |
| Time | Wall-clock from prompt to green tests | Developer throughput |
| Tokens | Input plus output per completed task | Cost per task |
Publish the harness and raw logs; a benchmark without the repository and prompts is marketing.
FAQ
Is Claude Code or Codex CLI better?
Neither wins universally. Claude Code is more mature in terminal composability, hooks and subagents; Codex CLI is tightly integrated with ChatGPT plans and offers explicit permission profiles and sandboxing. Run the same task set on your repository before choosing.
Do I need an API key to use either tool?
No. Claude Code is included on Claude Pro and above, and Codex is included in ChatGPT plans. Both also support API-key billing, which is useful for CI and for teams that want usage-based cost instead of seat-based limits.
Which has larger context?
Claude Code advertises up to 1M tokens depending on model and plan. Codex context depends on the selected model; ChatGPT plan pages list 256K for reasoning on Plus and 400K on Pro. Confirm the API limit for the exact model you deploy.
Can both run in CI?
Yes. Claude Code supports non-interactive print mode and GitHub Actions; Codex CLI supports codex exec for scripts and pipelines. Both need a scoped token, a clean checkout and a review step before merges.
How should I benchmark them?
Use a fixed repository commit, 10–20 tasks with acceptance tests, three runs per task, and measure pass rate, human interventions, wall-clock time and token cost. Publish the harness and the raw results so someone else can reproduce them.
Reviewed 20 November 2026. Claude Code features were checked against the Claude Code docs and Claude pricing; Codex features were checked against the Codex CLI docs and Codex pricing. Benchmark design is editorial; we publish no vendor-sourced scores.