opencode vs Codex CLI
Both are alternatives to Claude Code. Here's how they stack up — verified facts, no spin.
Also searched as Codex CLI vs opencode — same comparison, one verdict.
opencode keeps your data local by default and Codex CLI keeps it in the vendor's cloud — for most teams that single fact decides it.
opencode
TOP PICKThe MIT terminal agent that picks up your CLAUDE.md where you left it.
opencode (MIT, maintained by Anomaly) is the open-source agent closest in shape to Claude Code: a terminal UI with a full-access `build` agent, a read-only `plan` agent and a `general` subagent, plus a desktop app in beta. It is provider-agnostic, with 75+ providers through the AI SDK and Models.dev, including Anthropic on an API key and local models via Ollama, LM Studio, llama.cpp or any OpenAI-compatible endpoint. For anyone coming from Claude Code it reads CLAUDE.md, ~/.claude/CLAUDE.md and ~/.claude/skills as fallbacks when no AGENTS.md exists, so an existing repository works on day one. Two optional paid services sit beside the free tool: OpenCode Go, a $10/month subscription to open-source models (Go Plus $40/month), and Zen, a pay-as-you-go gateway of tested models. Your own keys cost nothing extra.
Codex CLI
OpenAI's Apache-2.0 terminal agent, included in the ChatGPT plan you may already pay for.
Codex CLI is OpenAI's coding agent that runs locally on your computer, and unlike Claude Code its client is open source under Apache-2.0. For a subscriber it is the most direct like-for-like swap: sign in with ChatGPT and it draws on your plan (OpenAI's pricing page lists the CLI from Plus at $20/month, with Pro plans at $100, $200 or $500), or use an API key at API rates. It also has a documented local path: pass `--oss` to run against Ollama or LM Studio, and custom OpenAI-compatible providers can be added in its config. The same agent is available as IDE extensions, a desktop app and a cloud agent.
Side by side
6 points of comparison, every one read from a verified field. Green marks the side that wins a row outright. A dash means we do not hold that fact — never that it is zero.
| opencode | Codex CLI | |
|---|---|---|
| Sovereignty ScoreOur transparent 0–100 composite for data ownership and exit cost. | 93 | 79 |
| Open source | Yes | Yes |
| Self-hostable | Yes | Yes |
| Local-first data | Yes | No |
| License | MIT | Apache-2.0 |
| Pricing | Free and open source (MIT); you pay your own model provider. Optional OpenCode Go at $10/month (Go Plus $40/month) for open-source models, or the pay-as-you-go Zen gateway. Verified on opencode.ai 2026-10-03. | Free, open-source client (Apache-2.0). Included with ChatGPT plans, with the CLI listed from Plus ($20/month) and Pro from $100/month; or an API key at API rates. Local models via --oss cost nothing extra. Verified on OpenAI's Codex pricing page 2026-10-03. |
opencode is Macrostack's recommended Claude Code alternative, so it's our pick here.
opencode
Strengths
- +Reads CLAUDE.md, ~/.claude/CLAUDE.md and ~/.claude/skills as fallbacks, the lowest-effort move from Claude Code
- +75+ providers: keep Claude on an API key, switch models per task, or run fully local
- +The same plan-then-build rhythm: a read-only plan agent that denies edits by default and asks before running bash
- +The largest community in the category, about 211k GitHub stars, with commits daily
Trade-offs
- −Keeping Claude models means per-token API billing: opencode's own docs say Anthropic prohibits using Claude Pro/Max plans through it, and it stopped bundling the plugins that did so in version 1.3.0
- −The desktop app is still in beta; the terminal is the mature surface
- −A large configuration surface (providers, models, agents, permissions) is more to learn than one vendor's defaults
- −A local model is a real hardware ask and will trail a frontier model on hard multi-file work
Codex CLI
Strengths
- +An open-source client (Apache-2.0) you can read, audit and fork
- +Uses a ChatGPT plan you may already pay for, so there is no second subscription
- +Documented local mode: `--oss` with Ollama or LM Studio, plus custom OpenAI-compatible providers
- +A similar spread of surfaces to Claude Code: terminal, IDE extensions, desktop app and cloud agent
Trade-offs
- −The client is open but the default models and the plan are OpenAI's, so you trade one vendor's subscription tie for another's
- −Codex shares usage with ChatGPT under OpenAI's plan limits, the same shape of constraint as Claude's plans
- −Project instructions live in AGENTS.md, so CLAUDE.md conventions need moving across
- −Local mode is a supported path rather than the tuned experience; expect a capability gap against OpenAI's hosted models
Which one fits you
The trade-offs above, turned into a decision. Find the line that describes your team.
Choose opencode
if your data should stay on machines you control, and reads CLAUDE.md, ~/.claude/CLAUDE.md and ~/.claude/skills as fallbacks, the lowest-effort move from Claude Code.
Choose Codex CLI
if an open-source client (Apache-2.0) you can read, audit and fork.
Neither, yet
if both carry a real cost you should weigh first — keeping Claude models means per-token API billing: opencode's own docs say Anthropic prohibits using Claude Pro/Max plans through it, and it stopped bundling the plugins that did so in version 1.3.0, and the client is open but the default models and the plan are OpenAI's, so you trade one vendor's subscription tie for another's. If either of those is a dealbreaker for your team, the shortlist is wrong rather than the choice.
opencode vs Codex CLI — common questions
Is opencode a better fit than Codex CLI for ai coding assistants?
It depends on what you are optimising for, and the honest split is this: opencode scores 93 to Codex CLI's 79 on data ownership and exit cost, so it is the safer choice if you care about being able to leave. Codex CLI earns its place on a different axis — an open-source client (Apache-2.0) you can read, audit and fork. Neither is a wrong answer for every team; the table above is the actual comparison.
What happens if we want to switch later?
opencode keeps its data local or in open formats, so leaving is an export rather than a negotiation. Codex CLI is still self-hostable, so the files stay on your server either way — but it is not local-first by design, so check what its export produces before you rely on it.
Can I self-host opencode or Codex CLI?
Both can be self-hosted. The difference is what it costs you in time rather than whether it is possible — see the setup and maintenance rows above.
Are opencode and Codex CLI both alternatives to Claude Code?
Yes — both appear in our Claude Code comparison, which is why they are worth putting side by side. People usually arrive here already having decided to move off Claude Code and now choosing between the two replacements, which is a narrower and much easier question.
More ai coding assistants comparisons
Related alternative guides
Facts verified 2026-10-03. Licenses and pricing change — spotted something out of date? That's a correction we want.