Claude Code vs Codex CLI: same job, different guardrails
Both read your repo, edit files and run commands. They differ in how they act without asking, what they cost, and how you point them at other models.
Terminal coding agents converged fast. Both of these read your repository, plan, edit files, run commands, and iterate on failures. Both can now take their project instructions from an AGENTS.md file, so one file can brief either. If you have used one, the other will not feel alien.
The differences that survive daily use are narrower and more specific than the launch posts suggest. This post was revised in October 2026: the first version said Codex CLI could not be pointed at another backend. That was wrong, and correcting it changes most of the comparison.
How they decide what to do without asking
Codex CLI draws a box and works inside it. By default its commands run in an OS-level sandbox (Seatbelt on macOS, bubblewrap on Linux and WSL2, a native sandbox on Windows) that lets it read files, edit inside the workspace and run routine local commands without stopping. It asks when it needs to go beyond that boundary, such as network access. You can widen or narrow the box (read-only, workspace-write, danger-full-access) and choose whether you or a reviewer agent answers the approvals.
Claude Code judges each action. Since v2.1.283 it starts interactive sessions in auto mode, where a second model reviews actions before they run instead of asking you. Manual mode asks before most edits, shell commands and network access, and acceptEdits and plan sit in between. A sandbox for shell commands exists too, but the main control is per-action review.
In practice, Codex is predictable about where it can act, and Claude Code is more selective about what it does. Neither is correct. It maps to whether you would rather define a boundary once or have each step checked.
One catch if you repoint Claude Code: its docs list auto mode as available on Anthropic's API, its own gateway and the major clouds, with recent Claude models. A custom ANTHROPIC_BASE_URL is not on that list, so expect Manual mode, and more prompts, behind a router.
Context handling
Both compact the conversation as it grows, and both load project instructions at the start of a session. Codex reads AGENTS.md. Claude Code reads CLAUDE.md, and since v2.1.277 it reads AGENTS.md instead when the repository has no CLAUDE.md; a CLAUDE.md can also import AGENTS.md. Keep shared conventions in AGENTS.md and both agents start from the same brief.
Whatever either agent reads gets sent again with every later turn. On a metered path that is visible on the invoice. On a subscription it shows up as reaching your usage limit sooner.
The difference that used to matter: repointing
Claude Code reads ANTHROPIC_BASE_URL. You can point it at any endpoint speaking the Anthropic Messages API -- Bedrock, Vertex, an enterprise gateway, or a local router. The agent loop is client-side; the model behind it is configuration.
Codex CLI does the same through ~/.codex/config.toml. openai_base_url sends its built-in OpenAI provider through a proxy, and a [model_providers.<id>] table defines a new provider with its own base URL, wire API and credentials. An API key also works in place of a ChatGPT login, billed at API rates. The full setup is in Codex CLI with any model.
So both agents are separable from the subscription that ships them. What differs is the wire format. Claude Code speaks the Anthropic Messages API and Codex speaks the OpenAI Responses API, so a backend has to speak the right one, or something in between has to translate. Responses API vs Chat Completions covers where that translation tends to break.
Models
| Claude Code | Codex CLI | |
|---|---|---|
| Native models | The Claude line: Opus 5.5, Sonnet 5.5 and Haiku 4.5 are Anthropic's current API models | GPT-6.1 Sol and GPT-6 Luna; GPT-5.5 leaves Codex on October 14, 2026 |
| Wire format | Anthropic Messages | OpenAI Responses |
| Repointable | Yes, via ANTHROPIC_BASE_URL | Yes, via [model_providers.<id>] or openai_base_url |
| Also served elsewhere | Claude models through GitHub Copilot and Kiro | GPT models through GitHub Copilot |
That last row is worth noting: GitHub Copilot serves models from both families. If you hold a Copilot subscription, you have a path to either agent's model class without a second subscription.
Cost, in practice
The entry price is the same. Claude Code comes with Claude Pro ($20 a month, or $17 a month billed annually) and Max (from $100 a month). Codex in the CLI comes with ChatGPT Plus ($20 a month) and Pro (from $100 a month). Either one also runs on an API key at per-token rates.
Because both are repointable, the plan is not the only way to run either one. Compare each agent on a backend you already have, not plan against plan. On that basis the decision comes back to how you want the agent to ask for permission, not to price.
Choosing
Take Claude Code if you want each action reviewed rather than a fixed boundary, you work mostly in the Claude model line, or you already hold access it can use.
Take Codex CLI if you would rather define a sandbox once and let it run inside it, you already pay for ChatGPT Plus or Pro, or your work suits the GPT line.
Take both if you have subscriptions covering both -- they coexist fine, share an AGENTS.md, and different tasks genuinely suit different guardrails.
Running either on what you already pay for
npm install -g @sifxprime/krouter
krouter -tConnect what you hold, then open the dashboard's CLI Tools page. For Claude Code it writes the base URL and a key into ~/.claude/settings.json. By hand, that is:
export ANTHROPIC_BASE_URL=http://localhost:20128/v1
export ANTHROPIC_AUTH_TOKEN=<your-krouter-key>For Codex it adds a krouter provider to ~/.codex/config.toml and leaves your ChatGPT login alone:
model = "<provider/model>"
model_provider = "krouter"
[model_providers.krouter]
name = "kRouter"
base_url = "http://localhost:20128/v1"
wire_api = "responses"
http_headers = { Authorization = "Bearer <your-krouter-key>" }The model can be anything kRouter serves: Codex-family models at the cx/ (your ChatGPT login) and gh/ (Copilot) prefixes, or a Claude, GLM or Kimi model, translated to and from the Responses API. Connecting a Claude, ChatGPT or Copilot subscription shows a risk notice first, because those subscriptions are not licensed for proxy use. The Codex integration page has the rest.
Common questions
Which is better at large refactors?
Neither harness wins by default. On a large refactor the result depends mostly on the model behind it and on how well the task is specified. Claude Code's per-action review suits long runs you check as they go; Codex's sandbox suits letting it work unattended inside one workspace. Either way, the more of the repository it reads, the more tokens every later turn costs.
Can I use Claude Code without an Anthropic subscription?
Yes. It reads ANTHROPIC_BASE_URL, so any endpoint speaking the Anthropic Messages API works -- an Anthropic API key, Bedrock or Vertex, or a local router in front of free tiers or a Copilot subscription.
Can I point Codex CLI somewhere else?
Yes. Set openai_base_url to send the built-in OpenAI provider through a proxy, or define a [model_providers.<id>] table with its own base URL, wire_api and credentials. Put these in ~/.codex/config.toml: Codex ignores provider keys in a project's .codex/config.toml. The backend has to speak the Responses API, or sit behind something that translates.
Do MCP servers work in both?
Yes. MCP is negotiated between the client and the server on your machine, so it is unaffected by which model answers.
Is gpt-5.3-codex better than the general GPT-5 line for coding?
It is an older model now. Codex's current models are GPT-6.1 Sol and GPT-6 Luna, and GPT-5.5 leaves Codex on October 14, 2026. gpt-5.3-codex is still on OpenAI's API at $1.75 per million input tokens and $14 per million output tokens, and GitHub Copilot still serves it, so it remains an option behind either agent. Codex itself has moved on to the newer line.
Related
Published by Kodelyth, the team that builds kRouter. Posts are drafted with AI assistance and reviewed by a person before they go out. kRouter is free and MIT licensed.
Install kRouterRelated posts
- ComparisonsGrok in Claude Code and Codex: three ways to pay for itGrok 4.5 to 4.7 in Claude Code or Codex through Grok Build, OpenCode Go or the xAI API: what each costs, which API it speaks, and the setup.
- ComparisonsGemini CLI vs Claude Code: what changed in 2026Gemini CLI lost its free tier in June, and both tools now run 1M-token models. What still separates them, and how to use Gemini models inside Claude Code.
- ComparisonsClaude Code with GLM, Kimi or DeepSeek: setup and trade-offsGLM-5.3, Kimi K3 and DeepSeek V4 can all drive Claude Code. What each costs, which slot each suits, what breaks, and when you need a router.
Relevant docs
- Getting StartedInstall kRouter, connect a first provider, and point Claude Code, Codex or any OpenAI-compatible tool at it. Takes about five minutes.
- Core conceptsProviders, combos, account routing, token savers, MITM mode, quota tracking, the response cache and remote access: the eight ideas behind kRouter.
- ProvidersConnect 95+ AI providers to kRouter: OAuth subscriptions, free services, free-tier and pay-per-token API keys, and browser-cookie logins.