Codex vs Claude Code vs OpenCode: which one to choose ?

Codex CLI (OpenAI) and Claude Code (Anthropic) are two terminal coding agents you can use with a subscription or an API key from their vendor: starting with ChatGPT Plus at $20 per month for Codex, and Claude Pro at $20 per month for Claude Code (official pricing as of November 18, 2026). OpenCode is free and open source (MIT). For a local model, Codex (--oss option) and OpenCode officially support Ollama; Claude Code can do it via Ollama, without support from Anthropic.
Claude Code, Codex CLI, and OpenCode all do the same job: they read your repository, edit files, and run commands from the terminal. They differ on three points that drive the choice: the required subscription, the software license, and whether you can connect a model running on your own machine. This comparison is based on official pages consulted on November 18, 2026, and ends with a "your use case, your tool" table.
#Codex or Claude Code: what are the differences in November 2026?
Codex CLI and Claude Code feel similar in use, but Codex CLI is open-source software under the Apache-2.0 license that you can use with a ChatGPT account or an API key, whereas Claude Code is proprietary Anthropic software limited to paid Claude plans and Console (API) accounts. So the choice comes down first to the subscription you already have.
- Code agent
- A coding agent is a program that takes a natural-language instruction, reads a project's files, proposes or applies changes, and runs commands (tests, builds), asking for your approval depending on the permissions you've configured.
- Claude Code
- Claude Code is Anthropic's agentic coding tool: it reads your codebase, edits files, runs commands, and is available in the terminal, in editors, as a desktop app, and in the browser.
- Codex CLI
- Codex CLI is OpenAI's coding agent that runs on your computer, in the terminal. The same name, Codex, also refers to the cloud agent and the editor extension.
- OpenCode
- OpenCode is an open-source coding agent, available as a terminal interface, a desktop app, and a web app, that connects to many model providers.
| Criterion | Claude Code | Codex CLI | OpenCode |
|---|---|---|---|
| Editor | Anthropic | OpenAI | Open-source project (anomalyco/opencode repository) |
| License | Proprietary (Anthropic's own license) | Apache-2.0 | MIT |
| Version checked | 2.1.327 (changelog) | 0.170.0 (npm) | 2.3.2 (npm @opencode/cli, V2 branch) |
| Minimal access | Claude Pro, Max, Ultra, Team, Enterprise, or a Console account | ChatGPT Plus or higher, or an OpenAI API key | No account: free software |
| Official starting price | Claude Pro: $20 per month ($17 billed annually) | ChatGPT Plus: $20 per month | $0; optional Go plan at $10 per month |
| Local model | Possible via Ollama, not supported by Anthropic | Official: --oss option with Ollama or LM Studio | Native: detects Ollama, LM Studio, and vLLM |
| Instructions file | CLAUDE.md or AGENTS.md | AGENTS.md | AGENTS.md |
None of these official pages publishes a benchmark comparing the quality of the code produced by Claude Code and Codex CLI. It depends mainly on the model behind the agent (Claude, OpenAI's GPT-6 family, or the model selected in OpenCode) and on your tasks: a ranking that specifies no model, version, or task proves nothing.
#Claude Code, Codex CLI, or OpenCode: which one supports a local model?
Benefit from our experience and a guided path to build your local copilot and get comfortable with your coding assistant.
- Lifetime online access
- PDF + files
- Refunded within 30 days
OpenCode and Codex CLI officially support a local model: OpenCode detects Ollama on its own, and Codex CLI has an --oss mode documented by OpenAI for Ollama and LM Studio. Claude Code also works with Ollama, but Anthropic does not support this use with non-Claude models.
According to OpenCode's providers page, OpenCode queries the http://127.0.0.1:11434 address, discovers the Ollama models, and adds them to its /models list without signing in to an account. The same page lists the default addresses for LM Studio (port 1234) and vLLM (port 8000). That makes OpenCode the most direct option for a fully local agent.
Codex CLI can work with a local "open source" provider, Ollama or LM Studio, when you pass it the --oss option, according to the advanced configuration published by OpenAI. Ollama also documents the ollama launch codex command, which sets up a dedicated Codex profile.
Claude Code connects to Ollama through Ollama's Anthropic-compatible API, using the ollama launch claude command or the ANTHROPIC_BASE_URL variable pointed at http://localhost:11434. The Claude Code documentation states that Anthropic does not support routing Claude Code to non-Claude models through a gateway: this setup is at your own risk.
On the model side, the site's catalog gives rough memory figures at Q4, weights only: about 13 GB for gpt-oss 20B, 14 GB for Devstral Small 2 24B, and 19 GB for Qwen3-Coder 30B-A3B. Add the memory for the 64k context, which depends on the model. The chosen model must support tool calling; otherwise the agent can neither read nor modify your files.
#How much do Claude Code, Codex CLI, and OpenCode cost?
According to the official pricing pages checked on November 18, 2026, Claude Code starts with Claude Pro at $20 per month, Codex CLI with ChatGPT Plus at $20 per month, and OpenCode is free: you only pay the model provider you choose, or nothing with a local model.
| Formule | Official monthly price | What applies to the agent |
|---|---|---|
| Claude Pro | $20 ($17 per month billed annually, $200 upfront) | Claude Code included, limits shared with chat |
| Claude Max | 100 $ | Claude Code included, higher usage |
| Claude Ultra | 200 $ | Claude Code included, no 5-hour limit (verified accounts) |
| ChatGPT Free and Go | $0 and $8 | The page mentions GPT-6 Luna in the desktop app, in gradual rollout; the CLI isn't listed |
| ChatGPT Plus | 20 $ | Codex on the web, in the CLI, in the editor extension, and on iOS |
| ChatGPT Pro | $100, $200, or $500 | Everything in Plus, with more usage |
| OpenAI API key | In practice | Codex in the CLI billed at API rates |
| OpenCode | 0 $ | Free software; optional Go plan at $10 per month for hosted open models |
Both subscriptions work on quotas rather than a fixed number of messages. At Anthropic, Claude Code shares usage limits with the rest of the plan: your terminal sessions and your conversations draw from the same pool. At OpenAI, local messages and cloud tasks also share the plan's allocation, and weekly limits may apply.
According to its providers page, OpenCode can also use a ChatGPT Plus or Pro plan instead of an OpenAI API key: a ChatGPT subscriber can therefore choose between Codex CLI and OpenCode without paying twice.
#Claude Code vs. OpenCode: what do you gain with an open-source agent?
OpenCode offers three things Claude Code doesn't: readable source code under the MIT license, free choice of model provider, and use without any account with a local model. In return, Claude Code offers a tool designed and maintained by the publisher of the Claude model.
Open source matters if you need to know what the tool runs on your machine: a security team can read the code of OpenCode (MIT) or Codex CLI (Apache-2.0), but not that of Claude Code, whose npm package points to a proprietary license rather than an open-source one. Open source says nothing, however, about what the model provider does with your requests.
OpenCode includes two agents you switch between with the Tab key: build, the default agent with full permissions for development, and plan, a read-only agent that denies file edits by default and asks for permission before every shell command. Plan mode is a good fit for exploring an unfamiliar repository before you let the agent write.
All three tools read the same instructions file. Codex reads AGENTS.md files before doing any work, OpenCode loads the project's AGENTS.md files, and Claude Code accepts CLAUDE.md or AGENTS.md. A single AGENTS.md file at the root of the repository is therefore enough to give all three agents the same build and style instructions, which makes it easier to compare them on your own project.
#What data do Claude Code, Codex, and OpenCode send online?
With a hosted model, each agent sends your prompt and the code snippets it reads to its provider; only a model running on your machine keeps that content on your side. Retention and training policies then depend on the account used, not on the agent.
For Claude Code, Anthropic's data usage page states that Free, Pro, Max, and Ultra accounts are used to train new models when the corresponding setting is enabled, including in Claude Code. Data is retained for 30 days if you opt out and for 5 years if you opt in. Commercial plans (Team, Enterprise, API) keep a no-training-by-default policy.
For Codex, OpenAI's authentication documentation states that the sign-in method you choose determines the rules: with a ChatGPT account, the settings of the ChatGPT workspace apply; with an API key, the retention and sharing settings of the API organization apply. The Business plan states that, by default, it does not train on business data.
#Which coding agent should you choose for your use case?
Pick the agent that matches the subscription or constraint you already have: Claude Code if you pay for Claude, Codex CLI if you pay for ChatGPT, OpenCode if you want a free and open-source or fully local tool.
| Your situation | Recommended agent | Why |
|---|---|---|
| You already have Claude Pro, Max, or Ultra | Claude Code | Included in the plan, maintained by Anthropic |
| You already have ChatGPT Plus or Pro | Codex CLI, or OpenCode connected to ChatGPT | The CLI is included in Plus; OpenCode accepts the same plan |
| No subscription, code that must not leave your machine | OpenCode + Ollama | Free, automatic Ollama detection, no account |
| You want to stay with a single vendor for local use | Codex CLI with --oss | Local mode documented by OpenAI |
| Tool to be audited by a security team | OpenCode or Codex CLI | MIT and Apache-2.0 licenses, readable code |
| Multiple model providers in a single tool | OpenCode | Catalog of providers and local models |
| You prefer a graphical editor to the terminal | Claude Code or Codex extension in the editor | Both install in VS Code and its derivatives |
For a business, the contract matters more than the tool: a Team, Enterprise, or API account with Anthropic, or a Business workspace with OpenAI, governs training and data retention. An open-source agent on a local model removes the third-party processor, at the cost of the hardware and maintenance.
#How do you try Claude Code, Codex, and OpenCode with Ollama?
The simplest approach is to install Ollama, download a coding model that supports tool calling, then start each agent with the ollama launch command followed by its name. The commands below come from the official documentation consulted on November 18, 2026.
- 01Set up Ollama and a modelInstall Ollama, then download a coding model that supports tool calling and set a context of at least 64k tokens, as the Ollama documentation requires for all three agents.
- 02Install the agent you want to compareInstall Codex CLI, Claude Code, or OpenCode with the official command for your system. On Windows, Codex and Claude Code have a PowerShell installer, and OpenCode has a desktop app in beta.
- 03Launch the agent via OllamaGo to the project folder and run ollama launch codex, ollama launch claude, or ollama launch opencode. Ollama prepares the configuration and starts the agent on the chosen model. For Claude Code, the manual configuration documented by Ollama replaces the Anthropic key with the variable ANTHROPIC_AUTH_TOKEN=ollama; for Codex, OpenAI documents that a local provider without credentials works without authentication.
- 04Verify that the local model respondsIn Codex, type /model to see the available Ollama models; in OpenCode, type /models. Then ask the agent to summarize a file in the project: a response that quotes the file's actual contents proves that file reading and tool calling work.
- 05Compare on the same taskPut an AGENTS.md file at the project root, give all three agents the same prompt on a copy of the repo, then compare the changes with git diff before keeping anything.
Codex or Claude Code: which one codes better?+
Cursor or Claude Code: what's the difference?+
Is OpenCode really free?+
Does Codex CLI work without a ChatGPT subscription?+
Which local model should you use with these agents?+
Do Claude Code, Codex, and OpenCode work on Windows?+
#Sources and verification as of November 18, 2026
Prices, plans, licenses, versions, and compatibility with local models were collected on November 18, 2026, from the official pages of Anthropic, OpenAI, OpenCode, and Ollama. Subscription prices and quotas change often, so check them before you subscribe.
- Source: Claude plan pricing (Anthropic)
- Source: Claude Code and model gateways (Anthropic)
- Source: Codex pricing (OpenAI)
- Source: Codex --oss local mode (OpenAI)
- Source: OpenCode providers and local models
- Source: Codex with Ollama (Ollama)
Feedback, an error, or a clarification? Let us know—it improves the guide for everyone.