WordPress database error: [Table 'wp_tygart_media.tm_rank_math_redirections_cache' doesn't exist]
SELECT * FROM tm_rank_math_redirections_cache WHERE ( object_id = 10466 and object_type = 'post' ) OR BINARY from_url = 'claude-code-vs-codex' ORDER BY object_id DESC

WordPress database error: [Table 'wp_tygart_media.tm_rank_math_redirections' doesn't exist]
SELECT * FROM tm_rank_math_redirections WHERE status = 'active' AND ( sources like '%a:2:{s:7:\"pattern\";s:20:\"claude-code-vs-codex\";s:10:\"comparison\";s:5:\"exact\";}%' or sources like '%claude%' or sources like '%code%' or sources like '%vs%' or sources like '%codex%' ) ORDER BY updated DESC

WordPress database error: [Table 'wp_tygart_media.tm_rank_math_redirections' doesn't exist]
SELECT * FROM tm_rank_math_redirections WHERE status = 'active' ORDER BY updated DESC

Claude Code vs Codex CLI (2026): A Hands-On Head-to-Head - Tygart Media

Claude Code vs Codex CLI (2026): A Hands-On Head-to-Head

About Will

I run a multi-site content operation on Claude and Notion with autonomous agents — and I write about what we do, including what breaks.

Connect on LinkedIn →

Last verified: June 2026.

Both Claude Code and OpenAI Codex CLI are terminal-native coding agents: you run them inside a repo, they read your files, edit code, run commands, and iterate. I run both daily on real projects. This is the head-to-head I wish existed when I was deciding which one to make my default. No benchmarks-chasing, just install commands, config files, pricing math, and where each one actually earns its keep. For the broader toolchain these slot into, see our AI operator’s stack.

Claude Code vs Codex CLI: the short answer

If you want one sentence: Claude Code is the more mature agentic harness (subagents, hooks, skills, deep MCP, a flat-rate plan that makes heavy use affordable), while Codex CLI is the leaner, cheaper-per-token option with strong raw coding from the GPT-5.x line and a tight sandbox model. Most teams that live in the terminal all day end up on Claude Code for the workflow tooling; people who want a fast, low-cost agent on top of an existing OpenAI subscription reach for Codex.

The honest version: they are closer than tribal arguments suggest. The deciding factors are almost never “which model is smarter this week” and almost always pricing structure, sandbox defaults, and how much workflow scaffolding you need.

How do you install each one?

Claude Code installs from npm and runs as the claude command:

npm install -g @anthropic-ai/claude-code
cd your-project
claude

First run walks you through OAuth login (Pro/Max plan) or an ANTHROPIC_API_KEY. On Windows it runs natively in PowerShell now, though a lot of operators still prefer it under WSL for fewer path headaches.

Codex CLI ships an install script and is also on npm:

# Mac / Linux
curl -fsSL https://chatgpt.com/codex/install.sh | sh

# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

# or via npm
npm install -g @openai/codex

Then codex in your repo. Auth is either a ChatGPT login (Plus/Pro/Business) or an OpenAI API key via codex login. Both tools are open-source clients hitting hosted models, so the install is the easy part; the model access is what you are really buying.

Which models do they run in 2026?

Claude Code defaults to the current Claude flagship. As of June 2026 that is Opus 4.8 for the hardest reasoning, with Sonnet 4.6 as the fast everyday workhorse and Haiku 4.5 for cheap, high-volume calls. You switch in-session with /model. Opus 4.8 also exposes reasoning-effort levels (high is the default; xhigh and max push deeper on gnarly problems at higher token cost).

Codex CLI runs the GPT-5.x coding line. GPT-5.5 is the current recommended default for complex coding and agentic work, GPT-5.4-mini is the faster/cheaper option for light tasks and subagents, and GPT-5.3-Codex remains a strong coding-tuned choice. Pick the model with codex -m gpt-5.5 or set it in your config.

Practical read: on a clean, well-specified function both produce good code. The gap shows up on long, multi-file refactors where the agent has to hold a lot of context and recover from its own mistakes. That is a harness problem as much as a model problem, which is the next section.

What about workflow features: subagents, hooks, and config?

This is where Claude Code is currently ahead, and it is the real reason it tends to win for power users.

  • Subagents – Claude Code spawns isolated sub-sessions with their own context window, tool restrictions, and prompts. Great for “go research this in parallel while the main thread keeps coding.” Codex has a lighter subagent concept (often pointed at GPT-5.4-mini to keep cost down) but it is less fleshed out.
  • Hooks – Claude Code fires deterministic scripts at lifecycle points (PreToolUse, UserPromptSubmit, and more). These run real code, so they cannot hallucinate: you can hard-block a dangerous command, auto-format on every edit, or inject context before the model sees a prompt. Codex leans on its approval/sandbox policy and execpolicy rules instead of a general hook system.
  • Skills and slash commands – In Claude Code, custom slash commands have merged into skills; /your-command still works and skills add reusable, packaged capabilities. Codex uses prompt files and profiles rather than a skills layer.
  • Project memory – Both read a project instruction file. Claude Code uses CLAUDE.md; Codex uses AGENTS.md (checked in a fallback order including AGENTS.override.md and .agents.md). Keep these tight: architecture, conventions, and the few rules the agent keeps forgetting.

Codex’s config story is clean if you like a single file: ~/.codex/config.toml holds your model, approval policy, sandbox mode, MCP servers, and named profiles you switch with codex --profile work. Claude Code spreads config across ~/.claude/ and .claude/settings.json plus per-project files, which is more surface area but more granular control.

How do the sandbox and approval models compare?

This matters more than most comparisons admit, because it governs how much the agent can do without asking.

Codex CLI has an explicit, well-documented sandbox. Sandbox modes run from read-only to workspace-write (edit files in the project, network off by default) up to full access, paired with approval policies like untrusted and on-request. On Windows the native sandbox can run unelevated or elevated. The mental model is clear: pick how much rope, then approve escalations.

Claude Code manages permissions through allow/deny rules and modes (including a plan mode that reasons without touching files, and an auto-accept mode for trusted loops). Combined with PreToolUse hooks you can build a strict policy, but it is more “assemble it yourself” than Codex’s preset sandbox tiers.

If you are dropping an agent onto an unfamiliar or sensitive repo, start read-only in both. Codex makes that posture a one-flag default; Claude Code gives you finer-grained control once you invest in the config.

Do both support MCP?

Yes, and this is a genuine tie that matters. Both speak the Model Context Protocol, so you can wire in the same external tools, databases, and APIs. Codex registers STDIO or streaming-HTTP MCP servers in ~/.codex/config.toml and launches them at session start. Claude Code adds servers via claude mcp add or JSON config. If you have already built MCP integrations, neither tool locks you out. New to MCP, start with our Claude MCP setup guide and the Notion MCP setup walkthrough.

What does each one cost?

Pricing is where the decision often gets made, so here are the real numbers as of June 2026.

Claude Code plans:

  • Pro – $20/mo: Sonnet 4.6 plus some Opus, roughly enough for focused daily sessions, not all-day heavy use.
  • Max 5x – $100/mo: much larger windows, real Opus headroom.
  • Max 20x – $200/mo: the heavy-user tier; effectively flat-rate firehose access.
  • API pay-as-you-go: Opus 4.7 about $5/$15 per million input/output… (current Opus tier runs higher), Sonnet 4.6 $3/$15, Haiku 4.5 $1/$5.

Codex CLI: Included in ChatGPT Plus/Pro/Business plans (usage governed by your plan’s limits), or pay-as-you-go on the API. GPT-5.3-Codex runs about $1.75 per million input / $14 per million output, with cheaper input on cached tokens. The mini model is far cheaper for light work.

The structural difference: Claude Code’s Max plans are flat-rate, which is why heavy users love them. People have tracked billions of tokens that would cost five figures on API metering but ran around a few hundred dollars on Max. Codex’s per-token rates are lower per unit and great if your usage is bursty or already bundled into a ChatGPT subscription, but a true all-day agent habit can run up metered cost faster than a flat plan. Estimate your monthly token volume honestly, then do the arithmetic both ways.

So which coding agent should you actually use?

Pick Claude Code if you want the deepest agentic workflow (subagents, hooks, skills), you are a heavy daily user who benefits from the flat-rate Max plan, or you need fine-grained, scriptable control over what the agent can do. It is the more complete operator’s harness in 2026.

Pick Codex CLI if you want lower per-token cost, you already pay for ChatGPT and want to use that allowance, you like the clean preset sandbox/approval model, or you simply prefer the GPT-5.x output style. It is lean, fast to stand up, and genuinely capable.

The move a lot of us make: run both. They are cheap relative to engineer time, they share MCP servers, and they have different failure modes. When one gets stuck in a loop on a hard bug, handing the same task to the other with fresh context often breaks the logjam. If you are weighing terminal agents against IDE-native ones, our Claude Code vs Cursor breakdown covers that axis.

Frequently asked questions

Is Claude Code or Codex CLI better for large refactors?

Claude Code tends to hold up better on long multi-file refactors, mostly because of subagents and hooks that keep context organized and catch mistakes deterministically. Codex can do it too, especially with GPT-5.5, but you lean harder on tight AGENTS.md instructions and approval gates.

Can I use Codex CLI without a ChatGPT subscription?

Yes. Run codex login with an OpenAI API key and you pay per token instead of through a ChatGPT plan. Same for Claude Code with an ANTHROPIC_API_KEY if you would rather meter than subscribe.

Do they work on Windows natively?

Both do in 2026. Claude Code runs in PowerShell (many operators still prefer WSL for cleaner paths), and Codex CLI has a native Windows installer plus a Windows sandbox with unelevated/elevated modes. Watch out for shells that mangle /tmp or C:\ style paths in arguments.

What is the single biggest difference?

Pricing structure and workflow depth. Claude Code offers flat-rate Max plans and a richer harness (subagents, hooks, skills); Codex offers lower per-token rates and a cleaner preset sandbox. Model quality is close enough that those two factors usually decide it.

Which model do they run by default?

Claude Code defaults to the current Claude flagship (Opus 4.8 as of June 2026, with Sonnet 4.6 for everyday speed). Codex CLI recommends GPT-5.5 for complex work, with GPT-5.4-mini and GPT-5.3-Codex as alternatives. Switch in-session with /model or the -m flag.

How do I get either tool cited or surfaced by AI engines for my own docs?

That is a content question, not a tooling one. The same structure that makes this page answerable, short factual answers, question-shaped headers, and a visible FAQ, is what AI engines reward. See how AI engines cite content for the full playbook.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *