Codex vs Claude Code vs OpenCode: Three Terminal Coding Agents, Compared
A detailed feature comparison of OpenAI Codex, Anthropic Claude Code, and OpenCode - the three terminal-based AI coding agents competing to become every developer's default tool.

The terminal AI coding agent has gone from novelty to necessity in under a year. Three tools now dominate the space: OpenAI Codex, Anthropic Claude Code, and OpenCode. All three live in your terminal, understand your codebase, edit files across projects, and run commands on your behalf. But they take fundamentally different architectural approaches, target different workflows, and come with very different cost structures.
This is a feature-by-feature breakdown of what each tool actually does, where it excels, and where it falls short.
The 30-Second Version
| OpenAI Codex | Claude Code | OpenCode | |
|---|---|---|---|
| Maker | OpenAI | Anthropic | Anomaly (YC-backed) |
| License | CLI is open source (Rust) | Proprietary | MIT open source |
| Primary model | GPT-5.3-Codex | Claude Sonnet/Opus 4.6 | Any (75+ providers) |
| Execution | Local + Cloud sandbox | Local | Local |
| Pricing | ChatGPT Plus ($20/mo) or API | Pro ($20/mo), Max ($100-200/mo), or API | Free (BYO API key) |
| SWE-bench Verified | 69.1% | 72.7% | Depends on model |
| GitHub stars | ~40K | ~30K | ~108K |
| Best for | Background tasks, cloud sandbox | Deep codebase work, multi-agent | Model flexibility, cost control |
How They Work

All three tools follow the same basic loop: you describe what you want, the AI reads your codebase, plans an approach, edits files, and optionally runs commands to verify its work. The differences are in the details.
OpenAI Codex
Codex operates in two modes. The CLI runs locally on your machine (Rust binary, open source), with OS-level sandboxing via Seatbelt on macOS and seccomp/Landlock on Linux. Network access is disabled by default. The Cloud mode runs tasks in isolated containers preloaded with your GitHub repository - internet disabled, fully sandboxed, completely separate from your local machine.
This dual architecture is unique. You can fire off a complex refactoring task to the cloud, let it run for 10-30 minutes in the background, and review the results when it finishes. Your local environment stays untouched until you approve the changes.
Codex also ships as a native macOS app (launched February 2026) for managing multiple agents simultaneously, and as a VS Code extension.
npm install -g @openai/codex
codex
Claude Code
Claude Code is terminal-first and local-only by default. It runs commands directly in your shell, reads your filesystem, and makes changes in place. There is no cloud execution layer - everything happens on your machine.
What Claude Code does differently is subagents. It can spawn multiple parallel AI agents, each with its own context window, model selection, tool access, and permissions. A built-in Explore agent (running on Haiku, the fast/cheap model) handles codebase search, while heavier work goes to Sonnet or Opus. Subagents can run in the background, operate in isolated git worktrees, and coordinate through a parent agent.
Docker-based sandboxing is available for full isolation, and DevContainer support exists for teams that want reproducible environments.
curl -fsSL https://claude.ai/install.sh | bash
claude
OpenCode
OpenCode is a fully open-source (MIT) TypeScript backend running on Bun, with a separate Go-based TUI. It follows a client-server architecture where the backend exposes an HTTP API and pushes real-time updates via Server-Sent Events. This means any client can connect to the backend, enabling remote and headless usage patterns.
The defining feature is provider agnosticism. OpenCode works with 75+ model providers out of the box: OpenAI, Anthropic, Google, AWS Bedrock, Azure, Groq, DeepSeek, Ollama, LM Studio, llama.cpp, and dozens more. You can even authenticate with an existing Claude Pro/Max or ChatGPT Plus subscription via OAuth, routing your subscription credits through OpenCode instead of paying for API tokens separately.
curl -fsSL https://opencode.ai/install | bash
opencode
Model Support
This is where the three tools diverge most sharply.
Codex is locked to OpenAI models. The current lineup ranges from GPT-5.3-Codex (the most capable) to GPT-5.1-Codex-Mini (cheapest). You cannot bring a non-OpenAI model. The models are specifically fine-tuned for agentic coding via reinforcement learning, trained on real-world PRs and coding tasks.
Claude Code defaults to Anthropic's Claude models (Opus 4.6, Sonnet 4.6, Haiku) and routes different tasks to different tiers automatically. Third-party models are supported through the VS Code extension and terminal CLI, but the core experience is optimized for Claude.
OpenCode connects to anything. You can use Claude Opus through Anthropic's API, GPT-5 through OpenAI's API, Gemini through Google, or a local Llama model through Ollama - all from the same interface. The OpenCode Zen gateway offers a curated set of 30+ models with pay-per-use pricing, including free-tier options like GLM 5 and Kimi K2.5.
| Feature | Codex | Claude Code | OpenCode |
|---|---|---|---|
| Vendor-locked | Yes (OpenAI only) | Primarily (Claude, some third-party) | No (75+ providers) |
| Local models | No | No | Yes (Ollama, LM Studio, llama.cpp) |
| Model switching | Yes (/model) | Yes (per-subagent) | Yes (config or runtime) |
| OAuth login | ChatGPT subscription | Claude subscription | Both ChatGPT and Claude subscriptions |
Pricing and Cost
Codex bundles into ChatGPT plans. Plus ($20/month) gives you 30-150 messages per 5-hour window. Pro ($200/month) gives 300-1,500. API access is pay-per-token. Users have reported that a single complex prompt can consume 7% of the weekly Plus limit, making the lower tier feel thin for serious work.
Claude Code uses either subscription plans (Pro at $20/month, Max at $100-200/month) or API pay-per-token. Max plans include dedicated Opus hours (15-40 hours/week depending on tier). A dual-layer rate limit governs usage: a 5-hour rolling window for burst activity and a weekly ceiling for total compute hours.
OpenCode is free. The tool itself costs nothing. You bring your own API keys and pay the providers directly. The optional Zen gateway charges per-token with no monthly fee (starting at $0.45/1M input tokens for budget models, up to $10/1M for Opus). An "OpenCode Black" subscription at $200/month was offered but sold out.
For a developer who wants to minimize cost: OpenCode with a local Ollama model is literally free. OpenCode with Zen's free-tier models is near-free. Codex and Claude Code both require at minimum a $20/month subscription.
Codebase Understanding

All three use project-level instruction files to understand your codebase:
| Codex | Claude Code | OpenCode | |
|---|---|---|---|
| Config file | AGENTS.md | CLAUDE.md | AGENTS.md |
| Hierarchical | Yes (walks from root to CWD) | Yes (project + user level) | Loaded once at session start |
| File search | Built-in tools | Glob + Grep (ripgrep) | Glob + Grep (ripgrep) |
| Code intelligence | MCP-based | MCP-based | 30+ built-in LSP servers |
| Semantic search | Web search (cached index) | MCP plugins | No (text search only) |
| Auto-compaction | Not documented | At ~95% context capacity | At ~90% context capacity |
OpenCode's built-in LSP integration is a standout. It ships with 30+ auto-installing Language Server Protocol configurations (TypeScript, Python/Pyright, Rust, Go, Java, C/C++, etc.) that provide real-time diagnostics. After editing a file, OpenCode queries the LSP for compiler errors and feeds them back into the AI's context. This grounds the model in actual type errors and lint violations rather than hallucinated code analysis. Codex and Claude Code can achieve similar results through MCP, but it requires manual server configuration.
Autonomy and Sandboxing
All three tools offer permission systems, but the philosophies differ.
Codex offers three modes: read-only, auto (default, asks before network/out-of-scope access), and full access. Its cloud sandbox is the most isolated option available - tasks run in dedicated containers with no internet, no access to your host system. This makes it uniquely suited for running untrusted or experimental operations.
Claude Code defaults to prompting for approval on every tool use. Its subagent system allows pre-approving specific tools for background agents, and Docker sandboxes provide full isolation. The --dangerously-skip-permissions flag exists for CI/CD but is explicitly discouraged for interactive use.
OpenCode requires user confirmation before command execution. Its snapshotting system is clever: before each agent step, it uses git write-tree to capture the working state without creating actual commits. If something goes wrong, /undo restores cleanly. This is safer than Codex's worktree approach and more granular than Claude Code's git-level operations.
| Feature | Codex | Claude Code | OpenCode |
|---|---|---|---|
| Cloud sandbox | Yes (isolated containers) | No (Docker optional) | No |
| Background tasks | Yes (cloud + local) | Yes (subagents) | Yes (multi-session) |
| Undo/rollback | Git worktree | Git-based | Git write-tree snapshots |
| Network isolation | Default off | Configurable | No built-in |
| Native sandboxing | Seatbelt/seccomp | Docker, Cloudflare | None |
Multi-Agent and Parallelism
Codex supports multi-agent orchestration through the OpenAI Agents SDK and the Codex macOS app. Multiple cloud tasks can run simultaneously in separate containers. The "Automations" system (still being built out) aims to let Codex run continuously for issue triage, CI/CD, and monitoring.
Claude Code has the most sophisticated multi-agent story. Subagents are first-class - you can spawn Explore agents (Haiku, read-only, cheap), Plan agents (read-only analysis), and General-purpose agents (full tool access) in parallel. Each gets its own context window, model selection, and tool permissions. Background subagents auto-deny anything not pre-approved. Agent teams coordinate across separate sessions for sustained parallelism. The isolation: worktree option gives each subagent its own git worktree copy.
OpenCode supports multiple sessions on the same project and a sub-agent "task" tool. Its architecture (HTTP backend + SSE) naturally supports parallel clients. But the multi-agent capabilities are less mature than either competitor.
Git Integration
All three handle git operations, but with different depth:
Codex offers dedicated worktree support where agents work on isolated copies. The macOS app and CLI can commit, push, and create PRs directly. Cloud tasks interact with your GitHub repository and can submit PRs upon completion.
Claude Code has the deepest git integration. It generates commits with meaningful messages (including Co-Authored-By attribution), creates branches, opens PRs via gh, resolves merge conflicts, and uses git worktrees for parallel subagent sessions. The CI/CD integration (GitHub Actions, GitLab CI) enables automated PR review and issue triage.
OpenCode takes a unique approach with its snapshot system. It captures the working tree state before each agent step using git internals (git write-tree) without creating commits or branches, keeping your git history clean. The /undo and /redo commands leverage these snapshots. Actual git commands run through the bash tool.
Extensibility
MCP (Model Context Protocol) is supported by all three, allowing connection to external tools and services. But the implementation varies:
- Codex: MCP configured via
~/.codex/config.tomlorcodex mcpCLI. Stdio-based only (no HTTP endpoints yet). - Claude Code: Native MCP with OAuth handling. Per-subagent MCP configuration. Limitation: not available in background subagents.
- OpenCode: MCP support for extending tool capabilities through external servers.
Beyond MCP:
- Codex: AGENTS.md hierarchical configs, custom slash commands, Automations system.
- Claude Code: CLAUDE.md, custom Skills (slash commands), Hooks (pre/post-tool shell commands), Plugins system for distributing configs.
- OpenCode: AGENTS.md, custom tools via config, plugin hooks for logging/auditing, custom commands and keybinds.
Which One Should You Pick?

There is no single best tool. The right choice depends on how you work.
Pick Codex if:
- You want fire-and-forget background tasks in isolated cloud containers
- You are already paying for ChatGPT Pro and want coding agents bundled in
- You value the security of network-isolated sandboxes
- You want a native macOS app for managing multiple agents
- OpenAI's GPT-5.3-Codex model fits your coding needs
Pick Claude Code if:
- You do complex, multi-file refactoring that benefits from deep codebase understanding
- You want the most advanced multi-agent orchestration (parallel subagents with different models/permissions)
- You rely heavily on Opus for difficult reasoning tasks
- Your workflow involves heavy git operations (commits, PRs, conflict resolution)
- You want a terminal-first, Unix-composable tool that pipes and chains with other CLI tools
Pick OpenCode if:
- You want to use any model from any provider, including local models
- You want to route an existing Claude Max or ChatGPT Plus subscription through a single interface
- Budget matters and you want to use free or cheap models for routine tasks
- You prefer fully open-source tools you can audit, fork, and modify
- You want built-in LSP integration without configuring MCP servers
- You value the snapshot-based undo system for safe experimentation
The Practical Middle Ground
Many developers use more than one. A common pattern: Claude Code for complex multi-file refactoring where Opus 4.6 shines, OpenCode with a cheap model for quick questions and routine edits, and Codex cloud tasks for background work you don't want cluttering your local environment.
The tools are converging on features (all now support MCP, AGENTS.md-style configs, and multi-session work), but the architectural differences - cloud vs. local execution, single-vendor vs. multi-provider, proprietary vs. open source - reflect genuinely different philosophies about how AI-assisted development should work.
Try all three. They are free to install and you can evaluate each on your actual codebase in an afternoon. The one that fits your workflow will be obvious within an hour.
Sources:
- OpenAI Codex Documentation
- OpenAI Codex GitHub
- Claude Code Documentation
- Claude Code GitHub
- OpenCode Website
- OpenCode GitHub
- OpenCode Tools Documentation
- OpenCode Providers Documentation
- Codex vs Claude Code - Builder.io
- Claude Code vs Codex - Northflank
- OpenCode vs Claude Code vs Codex - ByteBridge
- Terminal Agents Comparison - Tembo
