Claude Code CLI vs Codex: Which AI Coding Tool to Use

Updated November 12, 2026. I rewrote this post. The earlier version showed commands that do not exist, such as claude edit, codex ask and an @openai/codex-cli package. Everything below comes from the two tools on my Mac and from their official docs.

Claude Code CLI vs Codex comes down to scope and setup, not capability. Both read your repo, edit files and run tests from the terminal. In my same-task test, both fixed a failing test with the same one-line change. The difference showed up when a bug was already lying around: Claude Code stuck to the task and asked, while Codex fixed the extra bug and said so.

I ran Claude Code 2.1.322 and Codex CLI 0.167.0, one run per task, on a tiny Python repo. That is a sketch, not a benchmark.

Claude Code CLI vs Codex: What Is the Difference?

The commands and modes below are from --help on each installed tool, plus the official docs.

Claude Code Codex CLI
Made by Anthropic OpenAI
Start a session claude codex
Run once, non-interactively claude -p "prompt" codex exec "prompt"
Instruction file CLAUDE.md AGENTS.md
Permission control --permission-mode: plan, acceptEdits, auto, manual, dontAsk, bypassPermissions --sandbox: read-only, workspace-write, danger-full-access; --ask-for-approval: on-request, never
MCP servers claude mcp codex mcp
Resume a session claude --continue or --resume codex resume
Code review command claude ultrareview, a cloud multi-agent review codex review
Config settings.json files ~/.codex/config.toml

How Do You Install Each One?

Claude Code’s setup docs list three routes:

curl -fsSL https://claude.ai/install.sh | bash
brew install --cask claude-code
npm install -g @anthropic-ai/claude-code

The first is the native installer for macOS, Linux and WSL. The npm package needs Node.js 22 or later. To sign in, run claude and follow the browser prompts. You need a Pro, Max, Ultra, Team, Enterprise or Console account, because the free claude.ai plan doesn’t include Claude Code.

The Codex CLI docs give a standalone installer. Homebrew and npm also work:

curl -fsSL https://chatgpt.com/codex/install.sh | sh
brew install --cask codex
npm install -g @openai/codex

On first run, choose “Sign in with ChatGPT” or another available method. The npm package is @openai/codex. The @openai/codex-cli name from the old version of this post returns a 404.

Claude Code CLI vs Codex: I Gave Both the Same Two Tasks

I built a repo with cart.py and a unittest file. The total() function treated discount_percent as a fraction, so a 10% discount subtracted ten times the subtotal. Each tool got a fresh copy and the same prompt.

claude -p "<task>" --permission-mode acceptEdits --allowedTools "Bash(python3 -m unittest:*) Bash(python3:*)"
codex exec -s workspace-write "<task>"

Task A was “fix the failing test without changing the test file”. Task B was “add shipping(total), free at 50 or more, otherwise 4.99, with tests, and confirm everything passes”.

Claude Code Codex CLI
Task A 12 seconds, one-line fix, test file untouched, tests pass 21 seconds, the same one-line fix, test file untouched, tests pass
Task B 14 seconds, function plus 3 tests, 1 older test still failing 22 seconds, function plus 3 tests, also fixed the discount bug, all 5 tests pass

Task B is the interesting row. My fresh copy still had the discount bug, so “everything passes” was impossible without touching it. Claude Code added what I asked for, then explained the bug and its fix, and asked before changing code outside the request. Codex fixed the bug and said so: “Also corrected an existing percentage-discount bug so the existing test passes.”

Claude Code’s way is safer in a shared codebase, but Codex’s way gave me a green suite faster. Either way, read the diff, because only one tool touched code I hadn’t mentioned.

Two practical notes. Run from a script, Claude Code printed Warning: no stdin data received in 3s, proceeding without it, and adding < /dev/null silences it. Codex printed tokens used after each run (23,242 and 5,948). Claude Code’s print mode showed no usage, so I can’t compare cost.

How Do Permissions and Sandboxes Compare?

Claude Code controls what it may do through --permission-mode and --allowedTools. In my runs, acceptEdits let it edit files, and the allowed-tools list let it run only the test command and Python.

Codex separates two ideas. The sandbox says what it can touch, and the approval policy says when it must ask. workspace-write let it edit inside the repo and run tests.

Both tools ship a flag that skips all checks: --dangerously-skip-permissions for Claude Code and --dangerously-bypass-approvals-and-sandbox for Codex. Each help text says to use it only in an environment that is already sandboxed. For the Claude side of this, see our guide to securing Claude Code.

Which Instruction File Does Each Tool Read?

Claude Code reads CLAUDE.md, and Codex reads AGENTS.md. If you use both, keep the shared rules in AGENTS.md and add a CLAUDE.md that imports it. I tested which file Claude Code loads in CLAUDE.md vs AGENTS.md, including the CLAUDE.local.md catch. For installing and configuring Claude Code, start with our setup guide or the quick-start guide.

Claude Code CLI vs Codex: Which Should You Pick?

  • Pick Claude Code if you want it to stay inside the task and ask before it widens the change, or you already pay for a Claude plan.
  • Pick Codex CLI if you want a sandbox-first model with explicit levels, or you sign in with ChatGPT.
  • Use both on one repo if your team is split. A shared AGENTS.md keeps them aligned.

Claude Code finished first in both runs. With two runs on a tiny repo, that says nothing about large projects.

What I Did Not Test

I used one machine, one small repo and one run per task. I did not compare models, measure cost, test Windows, or try large refactors. I did not run the installers, so the install commands come from the docs, brew info and npm view. I also skipped Claude Code’s plan mode, Codex Cloud, the desktop apps, MCP servers and the review commands.

Frequently Asked Questions

Q: Is the old claude edit command real?
A: No. The older version of this post listed claude edit, claude plan, codex ask and codex fix. None appear in either tool’s command list, so use claude or claude -p and codex or codex exec.

Q: Do I need a paid plan to use Claude Code?
A: Yes. The setup docs say it needs a Pro, Max, Ultra, Team, Enterprise or Console account, and the free claude.ai plan doesn’t include it.

Q: How do I run each tool in a script?
A: Use claude -p "prompt" for Claude Code and codex exec "prompt" for Codex. Add --permission-mode acceptEdits or -s workspace-write if the run needs to edit files.

Q: Can both tools share one instruction file?
A: Yes. Put the rules in AGENTS.md, which Codex reads, and import it from CLAUDE.md with @AGENTS.md.

Quick Summary:
– Both tools fixed the same bug with the same one-line change
– Claude Code asked before touching an unrelated bug, and Codex fixed it and said so
– Install commands: @anthropic-ai/claude-code and @openai/codex
– Use claude -p and codex exec for scripts
– Read every diff, whichever tool you choose

Claude Code CLI vs Codex is a close call, so pick the one whose defaults match how much you want it to decide on its own.

Related guides