Cubicles
Cubicles

Claude Code vs Codex vs OpenCode: which coding agent should you use?

Three terminal coding agents, three different bets. Here's how they differ, and how to pick one without a month of trials.

Blog ·

Claude Code, Codex and OpenCode all do the same basic thing: you describe a change in plain English, and the agent reads your code, edits files, runs commands and tests, and keeps going until the job is done. All three run in a terminal. All three can work for an hour on a well-scoped task.

The differences are in who makes them, which models they run on, how you pay, and how much they let you customise. Those differences decide which one fits you.

The short answer

  • Choose Claude Code if you want Anthropic's Claude models and the most configurable agent: hooks, subagents, skills and fine-grained permissions.
  • Choose Codex if you already pay for ChatGPT, want an open-source agent from a major lab, or want sandboxing switched on by default.
  • Choose OpenCode if you want to pick any model from any provider, including open-weight and local ones, and switch between them freely.
  • Still not sure? Give all three the same real task from your backlog. It takes an afternoon and tells you more than any review.

At a glance

Claude CodeCodex CLIOpenCode
Made byAnthropicOpenAIAnomaly, the team behind SST
SourceClosed sourceOpen source (Apache 2.0)Open source (MIT)
ModelsClaudeOpenAI's models; others through its configDozens of providers, including local models
How you payA Claude plan or an API keyA ChatGPT plan or an API keyYour chosen provider's API key or plan
Project instructionsCLAUDE.mdAGENTS.mdAGENTS.md
Run from a scriptclaude -pcodex execopencode run
Stands out forHooks, subagents, skills, permission modesDefault sandbox, speed, ChatGPT plansModel freedom, open source, a polished terminal UI

All three move fast and ship new features most weeks. This table reflects them as of November 2026, so check each project's docs for the latest.

Claude Code: the most configurable

Claude Code is Anthropic's agent. It runs in the terminal, and also in IDE extensions, a desktop app and the browser. It's built around Claude models and tuned closely to them.

  • Deep customisation. Hooks run your own scripts before or after the agent's actions, subagents take on side tasks with their own context, and skills package know-how it loads when needed.
  • Permission modes. You choose what it may do without asking, from read-only planning to editing files freely, with rules for specific commands.
  • MCP support. It connects to MCP servers for tools beyond your repo, like issue trackers, databases or a remote computer.
  • Long tasks. It's widely used for multi-file refactors and migrations that take many steps.

The trade-off: it's closed source and tied to Claude models. If you want to run it on another provider's model, it's the wrong tool.

Codex: open source, sandboxed by default

Codex CLI is OpenAI's open-source coding agent, written in Rust. You sign in with a ChatGPT account or use an API key.

  • Included with ChatGPT plans. If you already pay for ChatGPT, you can start without a separate API bill, within your plan's limits.
  • Sandboxed commands. By default it runs commands in a sandbox and asks before stepping outside it, such as reaching the network.
  • Built for scripts and CI. codex exec runs a task with no interactive screen and can write structured output, which suits pipelines.
  • Open source. You can read the code, file issues and see exactly what it does.

The trade-off: it's designed around OpenAI's models. It can be pointed at other providers through its config, but that's not its main path.

OpenCode: any model, your choice

OpenCode is an open-source agent from the team behind SST. Its big idea is model freedom: it works with dozens of providers, from Anthropic and OpenAI to OpenRouter, DeepSeek and models running on your own hardware.

  • Switch models freely. Use a strong model for planning and a cheaper one for routine edits, or try a new model the day it's released.
  • Open source and MIT licensed. No lock-in to a vendor's agent or its pricing.
  • A polished terminal UI, with built-in agents for planning and for making changes, and language-server support so it understands your code's structure.
  • Client and server. The agent runs as a server, so other clients can drive it.

The trade-off: quality depends on the model you pick. With a weak model it's a weak agent, and you're the one who has to find a good combination.

What matters more than the agent

Teams that switch agents often find the results barely change. These matter more:

  1. The model. A strong coding model in any of the three beats a weak model in the best agent. See choosing a model for your agent.
  2. The task. “Fix the failing tests in the billing package and explain the cause” works. “Improve the codebase” doesn't.
  3. Tests it can run. An agent that can check its own work fixes its own mistakes. Without tests, you're the test suite.
  4. Project instructions. A short CLAUDE.md or AGENTS.md with how to build, test and lint saves every session ten wrong guesses.
  5. Where it runs. On your laptop it stops when you do and can reach all your keys. On its own computer it can work overnight with only the access you gave it.

How to choose

If you…Pick
Use Claude models and want maximum controlClaude Code
Already pay for ChatGPTCodex
Need to run in CI with structured outputCodex, or Claude Code with claude -p
Want to use open-weight or local modelsOpenCode
Want to compare models on the same agentOpenCode
Care most about an open-source agent from a major labCodex

Plenty of developers use two: one as the daily driver and another for a second opinion on a tricky change. They read the same repo and don't interfere, as long as each works on its own branch.

Try all three on one computer

The fairest test is the same task, the same repo and the same machine. On Cubicles, Claude Code, Codex and OpenCode come installed on every cloud computer, alongside Git, Python, Node.js, Docker and a real browser for testing web apps.

One worktree per agent, so they don't trip over each other
cd ~/code/my-app
git worktree add ../try-claude -b try-claude
git worktree add ../try-codex -b try-codex
git worktree add ../try-opencode -b try-opencode

# Then, in three terminals:
cd ~/code/try-claude && claude
cd ~/code/try-codex && codex
cd ~/code/try-opencode && opencode

Give each the same prompt, let them finish, and compare the diffs, the test results and how often each needed you. For keeping a coding agent running unattended, with a token scoped to one repo, see how to run Claude Code, Codex or OpenCode in the cloud.

The bottom line

Claude Code is the most configurable, Codex is the open-source choice from a major lab with sandboxing built in, and OpenCode gives you the widest choice of models. All three are good. Pick by the models you want to use and how you want to pay, then spend your effort on clear tasks, good tests and a safe place for the agent to work. Create a free Cubicles computer to try them side by side.

Frequently asked questions

Is Claude Code better than Codex?

Neither is better for everyone. Claude Code is more configurable and built for Claude models. Codex is open source, sandboxed by default and included with ChatGPT plans. The model you use and how you scope tasks usually matter more.

Is OpenCode free?

Yes. OpenCode is open source under the MIT licence. You pay for the model you connect, through your provider's API key or plan.

Can I use Claude models in OpenCode?

Yes. OpenCode supports Anthropic as a provider through an API key, along with OpenAI, Google, OpenRouter and many others.

Can I use Codex with my ChatGPT subscription?

Yes. Codex CLI can sign in with a ChatGPT account and use your plan's allowance, or use an OpenAI API key instead.

Can I run Claude Code, Codex and OpenCode on the same machine?

Yes. They're separate programs. Give each its own Git worktree or branch so they don't edit the same files at once.

Which coding agent works best for running overnight?

All three can run unattended on a computer that stays on. Run them in tmux, give them a token scoped to one repository, and ask for a pull request rather than a merge.

Give your agent a computer