Claude Code vs OpenAI Codex CLI: how to choose

Claude Code vs OpenAI Codex CLI compared from their official docs, November 2026. Plans and usage limits, CLAUDE.md vs AGENTS.md, sandbox and permissions, hooks, subagents, skills and MCP, and how to use both.

· 7 min read

Claude Code and OpenAI's Codex CLI are the same kind of tool: an agent in your terminal that reads your repository, edits files and runs commands, with IDE extensions, a desktop app and a cloud version around it. They've converged a lot in 2026. Both have project instruction files, hooks, subagents, skills and MCP. The differences that matter are in billing, how each one keeps the agent inside a boundary, and which models it runs. Every fact below comes from Anthropic's Claude Code docs and pricing, and OpenAI's Codex docs, read on November 28, 2026. Both change often, so check the linked pages before you decide.

#How do they compare side by side?

Claude CodeCodex CLI
ModelsClaudeOpenAI's GPT models
Comes withClaude Pro, Max, Ultra, Team or Enterprise; not the free planChatGPT Free, Go, Plus, Pro, Business, Edu or Enterprise (CLI listed from Plus)
API billingAnthropic Console, per tokenAn OpenAI API key, at API pricing
Usage limitsA 5-hour session limit and a weekly limit on subscriptionsEstimated messages per 5 hours on Plus and Business; weekly limits may apply
Project instructionsCLAUDE.md (reads AGENTS.md when there's no CLAUDE.md)AGENTS.md
SettingsJSON: ~/.claude/settings.json, .claude/settings.jsonTOML: ~/.codex/config.toml, .codex/config.toml
Default boundaryPermission prompts; the OS sandbox is off until you turn it onOS sandbox on: workspace writes, network on approval
HooksYesYes, on by default
SubagentsMarkdown files in .claude/agents/TOML files in .codex/agents/
SkillsSKILL.md in .claude/skills/SKILL.md in .agents/skills/
MCPYes, claude mcp addYes, codex mcp add
Scriptingclaude -pcodex exec
SourceAll rights reservedApache-2.0

#What does each one cost?

Claude Code comes with the paid Claude plans. Its setup page says it "requires a Pro, Max, Ultra, Team, Enterprise, or Console account. The free claude.ai plan does not include Claude Code access." On claude.com/pricing today: Pro is $20 a month ($17 a month billed yearly), Max is $100 a month with "5x Pro usage every 5 hours and every week", and Ultra is $200 a month with "no 5-hour limit" for verified accounts and "10x Pro usage every week". With a Console account instead, usage is billed per token to your organization.

Codex comes with ChatGPT. OpenAI's pricing page says Codex is "included in your ChatGPT Free, Go, Plus, Pro, Business, Edu, or Enterprise plan". The CLI and IDE extension are listed from Plus ($20 a month); Free ($0) and Go ($8) list the desktop app. Pro starts at $100, with plans at $100, $200 or $500 a month, and Business is $20 per user per month billed yearly for two users or more. With an API key, Codex runs in the CLI, SDK or IDE extension, without the cloud features, and "API-key sessions use separate API pricing, not your ChatGPT allowance."

If you already pay for one of the two subscriptions, that's usually the cheapest way to start with its agent.

#How do the usage limits work?

Both meter subscriptions in windows, and neither publishes a fixed token count.

  • Claude Code: the docs describe two messages, "You've hit your session limit" and "You've hit your weekly limit", for a usage window "shared across all models". On Team and Enterprise, each member's usage "resets on a rolling five-hour window and a weekly window." Plans differ by multiples of Pro's usage. More in Claude Code usage limits.
  • Codex: the pricing page gives estimates of local messages per five-hour period for Plus and Business, per model, and adds that "These estimates are not fixed message limits" and "Weekly limits may also apply." Pro "currently" has no five-hour limit. Local and cloud work share the same allowance. If you hit the limit mid-turn, the agent can finish that turn.

In both, a long session on a large repository uses the window faster than short questions, so the only real measure is your own work on your own code.

#CLAUDE.md or AGENTS.md?

Claude Code reads CLAUDE.md: ~/.claude/CLAUDE.md for you, ./CLAUDE.md or ./.claude/CLAUDE.md for the project, CLAUDE.local.md for what you don't commit, plus files in subdirectories, loaded once Claude works there. A CLAUDE.md can pull in other files with @path/to/file, and .claude/rules/ holds rules scoped to paths. It also reads AGENTS.md, but "only when you have no CLAUDE.md in your working directory or above it" (Claude Code v2.1.277 or later).

Codex reads AGENTS.md. First from your Codex home (~/.codex), where an AGENTS.override.md wins over AGENTS.md. Then, from the project root down to your current folder, at most one file per directory, joined so that files closer to where you work override earlier ones. It stops adding files once they reach project_doc_max_bytes, 32 KiB by default.

If a repository serves both, keep the shared instructions in AGENTS.md and make CLAUDE.md import it with a line @AGENTS.md, adding Claude-only notes below. See How to write a CLAUDE.md that Claude Code actually follows.

#How do sandbox and permissions differ?

This is the biggest difference in day-to-day use.

Codex starts sandboxed. Its default preset is --sandbox workspace-write --ask-for-approval on-request: "Codex can read files, make edits, and run commands in the workspace. Codex requires approval to edit outside the workspace or to access network." The sandbox modes are read-only, workspace-write and danger-full-access; the approval policies are on-request and never (untrusted is retired). On macOS it uses Seatbelt, on Linux and WSL2 bubblewrap, and in PowerShell the native Windows sandbox. An "Auto-review" option sends eligible approval requests to a model instead of to you. --yolo removes both sandbox and approvals. codex exec runs read-only unless you say otherwise.

Claude Code starts with prompts. You write rules in permissions.allow, ask and deny (evaluated deny, then ask, then allow), like Bash(npm run build) or Read(./.env), and pick a mode: default, acceptEdits, plan, auto, dontAsk or bypassPermissions. In auto, "A separate classifier model reviews actions before they run." The OS sandbox exists too, but "The sandbox is off by default. To turn it on, run /sandbox in a session." It uses Seatbelt on macOS and bubblewrap on Linux and WSL2, sends network traffic through a proxy that allows only the domains you list, and doesn't run on native Windows. See Claude Code permission modes.

In practice: Codex out of the box blocks network and writes outside the repository at the OS level. Claude Code out of the box asks you, and gets the same OS-level isolation once you run /sandbox.

#Hooks, subagents, skills and MCP

Both have all four, and they look alike.

  • Hooks. Claude Code's run shell commands, HTTP endpoints, MCP tools, prompts or subagents on 34 events, from SessionStart and PreToolUse to WorktreeCreate and SessionEnd. Codex's are "enabled by default", cover events such as PreToolUse, PermissionRequest, PostToolUse and Stop, and hooks that aren't managed by an admin "must be reviewed and trusted before they run." See Claude Code hooks.
  • Subagents. Claude Code's are Markdown files with YAML front matter in .claude/agents/ or ~/.claude/agents/. Codex enables subagents by default, ships default, worker and explorer, and takes custom agents as TOML files in .codex/agents/ or ~/.codex/agents/. See Claude Code subagents.
  • Skills. Both use a SKILL.md folder: .claude/skills/<name>/ for Claude Code, .agents/skills/ (scanned from your folder up to the repository root) for Codex. A skill written for one often works in the other with a copy. See Claude Code skills.
  • MCP. claude mcp add writes to local, project (.mcp.json) or user scope. codex mcp add writes [mcp_servers.<name>] tables to ~/.codex/config.toml, or to .codex/config.toml in a trusted project.

Claude Code also has plugins that bundle skills, agents, hooks and MCP servers, installed from marketplaces with /plugin.

#Which one should you pick?

Pick Claude Code if you already pay for Claude, want Claude models, or want fine-grained permission rules and the larger set of hook events. Pick Codex if you already pay for ChatGPT, want GPT models, want the OS sandbox on from the first command, or want to read and change the agent's source (Apache-2.0).

Better than reading tables: take a one-hour task, run it in each on a fresh branch, and compare the diffs, how often you had to step in, and what each took from your plan. The same test is laid out in Claude Code vs Cursor, and for GitHub's agent in Claude Code vs GitHub Copilot.

#Can you use both?

Yes. Many people do: one writes, the other reviews the diff. They don't conflict in one repository, since Claude Code keeps its files in .claude/ and Codex in .codex/ and .agents/. Share instructions through AGENTS.md as above. To move settings across, Claude Code has claude import codex --dry-run, which shows what it would bring over without writing anything. Run them in separate git worktrees if both edit at the same time.

#In Relais

Relais is a Mac app that runs Claude Code on the Claude plan you're already signed in to, with no API key. It doesn't run Codex. If Claude Code is your agent, it keeps every repository of a project together, shows which sessions wait for you, switches to your next Claude account at a limit, and adds agents and routines for the work that isn't code. Relais is made by an independent company, not affiliated with Anthropic or OpenAI. More on features and Compare.

Your AI team,
on your Claude plan.

$14.99 a month, everything included. On your Mac or on Linux, on your Claude Pro or Max plan. Cancel any time.