Intermediate 13 minAgents

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

BestLLMfor — Claude Code vs — Codex CLI · OpenCode
Direct response

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.

By Mohamed Meguedmi·Update 2026-11-30·Tested on Windows, macOS, and Linux

#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.
Claude Code, Codex CLI, and OpenCode: fact sheet as of November 18, 2026
CriterionClaude CodeCodex CLIOpenCode
EditorAnthropicOpenAIOpen-source project (anomalyco/opencode repository)
LicenseProprietary (Anthropic's own license)Apache-2.0MIT
Version checked2.1.327 (changelog)0.170.0 (npm)2.3.2 (npm @opencode/cli, V2 branch)
Minimal accessClaude Pro, Max, Ultra, Team, Enterprise, or a Console accountChatGPT Plus or higher, or an OpenAI API keyNo account: free software
Official starting priceClaude Pro: $20 per month ($17 billed annually)ChatGPT Plus: $20 per month$0; optional Go plan at $10 per month
Local modelPossible via Ollama, not supported by AnthropicOfficial: --oss option with Ollama or LM StudioNative: detects Ollama, LM Studio, and vLLM
Instructions fileCLAUDE.md or AGENTS.mdAGENTS.mdAGENTS.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?

The complete kit for building your own AI copilot.

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.

!
64k-token context minimum
The Ollama documentation requires a context of at least 64k tokens for Codex and OpenCode, and recommends it for Claude Code. This context uses memory on top of the model weights, so leave headroom beyond the size of the model alone.

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.

Official plans that give access to each agent (public prices in dollars, November 18, 2026)
FormuleOfficial monthly priceWhat applies to the agent
Claude Pro$20 ($17 per month billed annually, $200 upfront)Claude Code included, limits shared with chat
Claude Max100 $Claude Code included, higher usage
Claude Ultra200 $Claude Code included, no 5-hour limit (verified accounts)
ChatGPT Free and Go$0 and $8The page mentions GPT-6 Luna in the desktop app, in gradual rollout; the CLI isn't listed
ChatGPT Plus20 $Codex on the web, in the CLI, in the editor extension, and on iOS
ChatGPT Pro$100, $200, or $500Everything in Plus, with more usage
OpenAI API keyIn practiceCodex in the CLI billed at API rates
OpenCode0 $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.

i
Local does not mean offline
With Codex's Ollama profile, web searches requested by the agent are run by the Ollama service, which requires signing in with ollama signin. Turn off web search if your code or questions must never leave your machine. According to Anthropic's documentation, Claude Code, even when connected to Ollama, sends api.anthropic.com the domain name of every page it fetches with its WebFetch tool for a security check: only the domain is sent, not the full URL or the content.

#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.

Decision table: your situation and the agent to try first
Your situationRecommended agentWhy
You already have Claude Pro, Max, or UltraClaude CodeIncluded in the plan, maintained by Anthropic
You already have ChatGPT Plus or ProCodex CLI, or OpenCode connected to ChatGPTThe CLI is included in Plus; OpenCode accepts the same plan
No subscription, code that must not leave your machineOpenCode + OllamaFree, automatic Ollama detection, no account
You want to stay with a single vendor for local useCodex CLI with --ossLocal mode documented by OpenAI
Tool to be audited by a security teamOpenCode or Codex CLIMIT and Apache-2.0 licenses, readable code
Multiple model providers in a single toolOpenCodeCatalog of providers and local models
You prefer a graphical editor to the terminalClaude Code or Codex extension in the editorBoth 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.

  1. 01
    Set up Ollama and a model
    Install 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.
  2. 02
    Install the agent you want to compare
    Install 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.
  3. 03
    Launch the agent via Ollama
    Go 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.
  4. 04
    Verify that the local model responds
    In 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.
  5. 05
    Compare on the same task
    Put 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.
macOS and Linux: install Codex CLI (OpenAI documentation)
curl -fsSL https://chatgpt.com/codex/install.sh | sh
macOS, Linux, and WSL: install Claude Code (Anthropic documentation)
curl -fsSL https://claude.ai/install.sh | bash
macOS and Linux: install OpenCode (official repository)
curl -fsSL https://opencode.ai/v2/install | bash
Terminal (macOS, Linux, or Windows), Ollama installed: launch each agent (Ollama documentation)
ollama launch codex
ollama launch claude
ollama launch opencode
Frequently asked questions
Codex or Claude Code: which one codes better?+
OpenAI's and Anthropic's official pages don't publish a neutral comparison between Codex and Claude Code. Quality depends on the model used, its version, and the task. The most reliable approach is to give both agents the same prompt on a copy of your project, with the same AGENTS.md file, then compare the changes and the tests.
Cursor or Claude Code: what's the difference?+
Cursor is a code editor that also has a CLI for driving its agents from the terminal, whereas Claude Code is primarily a terminal agent. The two aren't mutually exclusive: Anthropic provides an install link for the Claude Code extension for Cursor. The guide to Ollama in Claude Code and Cursor explains how to connect local models.
Is OpenCode really free?+
Yes, OpenCode is free software released under the MIT license, and its documentation states that the $10/month Go subscription is optional. The cost comes from the model: nothing with a local model served by Ollama, the provider's rates with a hosted model, or your ChatGPT Plus or Pro plan if you connect it.
Does Codex CLI work without a ChatGPT subscription?+
Yes, in two documented ways. Codex CLI accepts an OpenAI API key, billed at API rates, and offers a local mode with the --oss option, which relies on Ollama or LM Studio. According to OpenAI's pricing page, the Free ($0) and Go ($8) plans mention the desktop app, not the CLI.
Which local model should you use with these agents?+
Choose a coding model that supports tool calling and fits in memory with a 64k-token context. In the site's catalog, gpt-oss 20B, Devstral Small 2 24B, and Qwen3-Coder 30B-A3B require roughly 13, 14, and 19 GB at Q4 for the weights alone. The guide to the best local LLMs for coding compares them in detail.
Do Claude Code, Codex, and OpenCode work on Windows?+
Yes, all three do. Claude Code supports Windows 10 version 1809 or later, Codex CLI provides a PowerShell installer for Windows, and OpenCode offers a Windows desktop app in beta. The commands differ from those for macOS and Linux: use the one that matches your system in the official documentation.

#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.

Did this guide help you?

Feedback, an error, or a clarification? Let us know—it improves the guide for everyone.