Claude Code CLI vs Codex CLI vs Gemini CLI vs OpenCode CLI: Which Should You Use?
A practical comparison of the four main terminal AI coding agents — Claude Code, Codex CLI, Gemini CLI, and OpenCode — across install, auth, repo access, sandboxing, models, and cost.
TL;DR. For terminal-based coding, pick by ecosystem: Claude Code if you're Claude-first, Codex CLI if you already pay for ChatGPT, Gemini CLI for a generous free tier (but note it's migrating to Antigravity CLI), and OpenCode if you want open-source, bring-your-own-model freedom. All four run a coding agent directly in your terminal with repo access.
Prices and plan details checked: June 30, 2026. These tools reprice and rename often — see the Sources section and re-check before you commit.
This is the CLI-surface take — which agent to run in your terminal. If you're still deciding between the Claude and OpenAI ecosystems overall (across desktop apps, IDE, and cloud too), start with the pillar comparison: Claude Code vs Codex. For total monthly cost, see the Vibe Coding Cost Comparison.
A CLI coding agent runs in your terminal, reads and edits files in your repository with your permission, runs commands, and iterates — no browser tab required. Here's how the four main options differ.
Quick comparison
| Dimension | Claude Code | Codex CLI | Gemini CLI | OpenCode |
|---|---|---|---|---|
| License / model | Proprietary (Anthropic) | Proprietary (OpenAI) | Open source (Apache 2.0) | Open source (MIT) |
| Cost | Claude Pro $20+/mo (incl. Claude Code) | Included in paid ChatGPT plans | Free tier: 1,000 req/day | Tool free; pay for model usage |
| Auth | Claude subscription login | ChatGPT login or API key | Google account, API key, or Vertex | Provider login or API keys |
| Models | Claude models | OpenAI models | Gemini 3 (1M context) | Any provider (75+) or local |
| Install | installer / brew / winget / npm | npm / brew / installer | npm / brew / MacPorts | curl / npm / brew |
| OS | macOS, Windows, Linux | macOS, Windows, Linux | cross-platform | cross-platform |
Installation
- Claude Code: native installer (
curl -fsSL https://claude.ai/install.sh | bash; Windowsirm https://claude.ai/install.ps1 | iex),brew install --cask claude-code,winget install Anthropic.ClaudeCode, ornpm install -g @anthropic-ai/claude-code. The Claude desktop app also bundles it, so you don't have to install Node separately. - Codex CLI:
npm install -g @openai/codex,brew install --cask codex, or a release binary / install script. - Gemini CLI:
npx @google/gemini-cli,npm install -g @google/gemini-cli,brew install gemini-cli, MacPorts, or conda-forge. - OpenCode:
curl -fsSL https://opencode.ai/install | bash,npm i -g opencode-ai@latest, orbrew install anomalyco/tap/opencode. (Heads-up for searchers: OpenCode is now published under the Anomaly org — the oldsst/opencodeURL redirects there. Same project, renamed home.)
Authentication and account model
- Claude Code authenticates against a Claude subscription (Pro, Max, Team, or Enterprise). No separate seat to buy.
- Codex CLI uses your ChatGPT login (Plus, Pro, Business, Edu, Enterprise) or an OpenAI API key (extra setup; some features differ under API-key auth).
- Gemini CLI offers three paths: Google account OAuth (free tier), a Gemini API key, or Vertex AI for enterprise.
- OpenCode logs in to a provider — e.g. GitHub (to use a Copilot account as a model source) or OpenAI (to use a ChatGPT Plus/Pro account) — or you supply provider API keys directly.
Local repo access, sandbox, and permissions
All four operate on your local repository and run shell commands. The vendor agents (Claude Code, Codex CLI, Gemini CLI) ship explicit permission/sandbox controls so the agent asks before it acts and runs in a constrained environment; Gemini CLI adds sandboxing plus "trusted folders." OpenCode separates a full-access build agent from a read-only plan agent you toggle with Tab — a clean way to keep the model in read-only mode while you scope work.
Model choices
- Claude Code: Claude models (pick the tier for the task).
- Codex CLI: OpenAI models; heavier reasoning draws on plan rate limits.
- Gemini CLI: Gemini 3 models with a 1M-token context window; selectable with
-m. - OpenCode: any model from any provider — Claude, OpenAI, Gemini, 75+ providers via Models.dev, or local models. This is its defining advantage.
MCP and tooling
Claude Code, Codex CLI, and Gemini CLI all support MCP (Model Context Protocol) servers for extending the agent with custom tools, plus shell, file, and web actions; Gemini CLI adds Google Search grounding and a GitHub Action for PR review and issue triage. OpenCode ships a TUI, LSP integration, multi-session with shareable session links, and a @general subagent for complex searches. (We don't claim MCP support for OpenCode here — it wasn't confirmed on the official pages at review time.)
Cost and quota model
- Claude Code: flat Claude Pro $20/mo ($17 annual) includes it; Max from $100/mo for heavy use. You pay the subscription, not per token.
- Codex CLI: included in paid ChatGPT plans (Go $8, Plus $20, Pro from $100, Business $20/$25). Usage draws on published per-window message/credit limits, which is why Pro exists for heavy users.
- Gemini CLI: free for 1,000 requests/day (60/min) on a personal Google account; API key or Vertex for more, billed by usage.
- OpenCode: the tool is free; your bill is whatever the connected model provider charges — potentially $0 with included or local models.
What each is bad at
- Claude Code: no free tier — you must hold a Claude subscription to use it at all.
- Codex CLI: tied to the OpenAI ecosystem and its rate-limit windows; API-key auth limits some features.
- Gemini CLI: on a migration path to Antigravity CLI, so today's setup may shift; the free tier's daily cap can bite on big sessions.
- OpenCode: more assembly required — you choose and configure your own model/provider, so it's less "turnkey" than the vendor agents.
Which should you choose?
- Claude-first developer: Claude Code — strongest if you already prefer Claude's reasoning and want terminal-native repo work.
- OpenAI/ChatGPT user: Codex CLI — it's already included in your plan and shares one account across CLI, app, IDE, web, and cloud.
- Cost-sensitive / experimenting: Gemini CLI's free 1,000/day, with the Antigravity CLI migration in mind.
- Open-source / model-agnostic builder: OpenCode — switch models freely and avoid lock-in.
What I'd use for...
- Daily repo work on a Claude plan: Claude Code.
- You already pay for ChatGPT: Codex CLI — don't pay twice.
- A free, capable agent to learn on: Gemini CLI.
- Running a local or self-hosted model, or avoiding vendor lock-in: OpenCode.
On the Gemini → Antigravity CLI transition specifically, see Cursor vs Google Antigravity for where Google is taking its agent tooling.
Building something with AI? The AI Builder Kits hub collects the rest of these comparisons plus starter kits — including a Voice Agent Starter Kit built on the Vercel AI SDK 7.
Sources
- Claude Code setup — https://code.claude.com/docs/en/setup
- Claude pricing — https://claude.com/pricing
- OpenAI Codex — https://github.com/openai/codex
- OpenAI Codex pricing — https://developers.openai.com/codex/pricing
- Gemini CLI — https://github.com/google-gemini/gemini-cli
- Google I/O 2026 developer highlights — https://blog.google/innovation-and-ai/technology/developers-tools/google-io-2026-developer-highlights/
- OpenCode — https://opencode.ai
- OpenCode repo — https://github.com/anomalyco/opencode
Related: Claude Code vs Codex · Vibe Coding Cost Comparison · Cursor vs Google Antigravity
Curious where AI actually fits your job?
Answer a few questions and get a free, personalized 30-day AI plan for your exact role — the tasks to automate first, and the prompts to do it.
Frequently asked questions
Which CLI coding agent is the cheapest?+
Gemini CLI and OpenCode are the cheapest to start. Gemini CLI is open source (Apache 2.0) with a free tier of 1,000 requests per day on a personal Google account. OpenCode is open source (MIT) and brings your own model, so it's free if you use included or local models and otherwise costs only what your chosen provider charges. Claude Code and Codex CLI are bundled into paid subscriptions ($20/month and up) rather than sold separately.
Do I need a paid subscription to use Claude Code or Codex CLI?+
For Claude Code, yes — it requires a Claude Pro, Max, Team, or Enterprise subscription (Pro is $20/month and includes Claude Code). Codex CLI is included in paid ChatGPT plans (Go, Plus, Pro, Business, Edu, Enterprise) and also has limited access on the ChatGPT Free tier; you sign in with your ChatGPT account or use an OpenAI API key.
Is Gemini CLI being discontinued?+
Not immediately. The Gemini CLI repository is still active, but at Google I/O 2026 (May 19, 2026) Google announced it is transitioning users to the new Antigravity CLI and encouraged migration. Gemini CLI still works today, but treat it as a tool on a migration path when making a long-term commitment.
Which CLI agent is best for bringing your own model?+
OpenCode. It's model-agnostic by design — connect Claude, OpenAI, Gemini, local models, or one of 75+ providers, and switch freely. The other three are tied to their vendor's models (Claude, OpenAI, and Gemini respectively), though each lets you pick among that vendor's model tiers.
Related Guides
Claude Code vs Codex: Which Is Better for Building an App?
An opinionated comparison of Claude Code and OpenAI Codex for building real apps — pricing, surfaces, strengths, weaknesses, and a clear recommendation for which ecosystem to pick.
Claude Desktop vs Codex App for Coding: Which Should You Use?
A practical comparison of the Claude desktop app and the OpenAI Codex app for coding — what each 'app' actually is, which OS they run on, how they relate to the CLI and web, and who each one is for.
Codex App vs Codex CLI: Which Should You Use?
A practical, within-Codex comparison: the Codex desktop app for supervising multiple agents versus the Codex CLI for terminal-first repo work — and when to use each.