Free resources · Getting started
Codex vs Claude Code: which coding agent should you use?
Codex vs Claude Code in plain words: what each costs, how each asks before it acts, what our small test showed, and how to compare them fairly on your own code.
What are Codex and Claude Code?
Codex is OpenAI's coding agent, and Claude Code is Anthropic's. A coding agent works in a loop: it reads your files, changes them, runs commands such as your tests, and looks at the result before its next step.
Codex runs in the terminal, as an editor extension, in the ChatGPT desktop app, on Codex web, and as Codex Cloud, which runs tasks on OpenAI-managed computers. Claude Code runs in the terminal, in editors, in the Claude desktop app and in the browser. New to it? See how to use Claude Code.
What does a month cost?
Some Codex use comes with every ChatGPT plan, even Free. Plus is $20 a month and Pro starts at $100. Claude Code is not in Claude's Free plan: Pro is $20 a month, Max $100 and Ultra $200.
On the $20 plans, both meter use over a five-hour window, and weekly limits may also apply. A heavy session can stop you until the window resets.
How does each ask before it changes things?
Codex has three ready-made modes, plus a custom one in config.toml:
- Ask for approval asks before it edits files outside your project or uses the internet. In our view, start here.
- Approve for me asks only about actions it judges unsafe.
- Full access gives it your whole computer and the internet.
Claude Code has permission modes. Manual asks before edits and commands. acceptEdits edits freely but still asks before most commands, such as running your tests. Auto runs everything with background safety checks. In our view, the mode matters most, because it decides whether a tool can check its own work.
Can one project serve both tools?
Yes. Codex reads its instructions from a file named AGENTS.md. Claude Code reads CLAUDE.md, and when a project has neither CLAUDE.md nor CLAUDE.local.md, it reads AGENTS.md instead, so one AGENTS.md can serve both.
What happened when we gave both tools the same bug?
Both fixed the bug we named, every time. Our small JavaScript median function uses the default sort, which compares numbers as text, so 10 lands before 9. Each tool got the prompt shown below three times, in fresh folders.
- The visible test the prompt points to: all 3 Claude Code fixes and all 3 Codex fixes passed.
- One extra check we wrote ourselves, after we knew of a second flaw the prompt did not name (the function also reorders the list you pass it): all 3 Claude Code fixes sorted a copy and passed it; all 3 Codex fixes still changed the caller's list and did not pass it.
The test's limits: one task, three runs per tool, one model each. We wrote that check knowing the flaw, so it favors the tool that avoids it, and the flaw is arguably outside the request. Power differed too. Codex ran with codex exec --sandbox workspace-write, which let it run the tests. Claude Code ran in acceptEdits from a script, with nobody to approve commands, so it could not run them; its fixes passed both checks anyway. It does not rank the tools.
How do you compare them fairly?
In our view: your own small task, a fresh copy per tool, the same prompt, the same power to run commands, several runs each, and a hidden check written first.
How do you see a hidden check catch what a visible test misses?
Try a sample fix before any tool runs. You need a Mac or Linux terminal with Node.js 20 or later, which has a test runner built in. The block makes median-test, with the buggy stats.js and visible test in task and a cut-down copy of our hidden check in grader. It applies a fix that only makes the sort compare numbers and runs both checks:
mkdir -p median-test/task median-test/grader && cd median-test/task
cat > package.json <<'EOF'
{ "name": "stats", "type": "module", "scripts": { "test": "node --test" } }
EOF
cat > stats.js <<'EOF'
// Small statistics helpers.
export function median(numbers) {
const sorted = numbers.sort();
const mid = Math.floor(sorted.length / 2);
if (sorted.length % 2 === 0) {
return (sorted[mid - 1] + sorted[mid]) / 2;
}
return sorted[mid];
}
EOF
cat > stats.test.js <<'EOF'
import test from "node:test";
import assert from "node:assert/strict";
import { median } from "./stats.js";
test("median of an odd list", () => assert.equal(median([3, 1, 2]), 2));
test("median of an even list", () => assert.equal(median([4, 1, 3, 2]), 2.5));
test("median of numbers with different digit counts", () => assert.equal(median([10, 9, 100]), 10));
EOF
cat > ../grader/hidden.test.mjs <<'EOF'
import test from "node:test";
import assert from "node:assert/strict";
import { median } from "../task/stats.js";
test("even list with different digit counts", () => assert.equal(median([100, 5, 20, 7]), 13.5));
test("leaves the caller's list unchanged", () => {
const list = [30, 2, 100];
median(list);
assert.deepEqual(list, [30, 2, 100]);
});
EOF
perl -pi -e 's/numbers\.sort\(\)/numbers.sort((a, b) => a - b)/' stats.js
node --test stats.test.js
node --test ../grader/hidden.test.mjsThe visible test passes; the hidden check fails. The fix did what the prompt asked and left an old flaw only your check looked for.
Now repeat it on a small bug from your own code, in a throwaway copy with private values changed, and write the hidden check before either tool sees the task.
Optional: to try a tool, run this block first. Then, inside tool-a, paste the whole first block above again without the perl line. That rebuilds median-test/task and median-test/grader there:
cd ../.. && mkdir tool-a && cd tool-a
Move the grader out, start the tool in tool-a/median-test/task with the prompt below and let it run commands. Then put the grader back and grade:
mv ../grader ../../../grader-a
mv ../../../grader-a ../grader && node --test ../grader/hidden.test.mjs
The function median in stats.js returns wrong answers for some lists. Find the bug and fix it in stats.js so that the tests pass. Run the tests with: npm test
Where is the full answer?
Check your output
The first run reports pass 3, fail 0. The second reports pass 1, fail 1, and the failing test is "leaves the caller's list unchanged": the list came back as 2, 30, 100 instead of 30, 2, 100. If the first run shows a failure, the perl line did not apply.