Claude Code, Codex CLI and Gemini CLI are all terminal coding agents that read your repo, edit files, run commands, speak MCP and run headless in CI. They differ in three ways. Licensing: Codex CLI and Gemini CLI are Apache-2.0 open source, while Claude Code is proprietary. Billing: Claude Code and Codex are included in their vendors' consumer and team subscriptions. Gemini CLI, since June 18, 2026, is aimed at Google Cloud's Gemini Code Assist customers and paid API keys, and free and Google AI Pro/Ultra users were moved to Antigravity CLI. Safety model: each tool combines a sandbox and an approval policy differently, and that's what decides how much you can safely automate.
Everything below was checked against each vendor's official docs and repositories as of November 2026. The versions checked were Claude Code 2.1.326, Codex CLI 0.169.0 and Gemini CLI 0.68.0. All three ship weekly or faster, so treat any flag as "verify against --help".
At a glance
| Claude Code | Codex CLI | Gemini CLI | |
|---|---|---|---|
| Vendor | Anthropic | OpenAI | |
| License | Proprietary (LICENSE.md) | Apache-2.0 | Apache-2.0 |
| Written in | Native binary (closed source) | Rust | TypeScript / Node.js |
| Pay with | Claude Pro/Max/Ultra/Team/Enterprise, or API key, Bedrock, Google Cloud, Foundry | ChatGPT Free/Go/Plus/Pro/Business/Edu/Enterprise, or API key | Gemini Code Assist Standard/Enterprise, or paid Gemini API / Vertex AI key |
| Instruction file | CLAUDE.md (reads AGENTS.md if no CLAUDE.md) |
AGENTS.md |
GEMINI.md (filename configurable) |
| Sandbox default | Off (opt-in, Bash only) | On (workspace-write interactively, read-only for exec) |
Off (opt-in, process or container) |
| Headless | claude -p |
codex exec |
gemini -p |
| MCP | Yes | Yes | Yes |
| Hooks | Yes | Yes (on by default, must be trusted) | Yes |
| GitHub Action | anthropics/claude-code-action@v1 |
openai/codex-action@v1 |
google-github-actions/run-gemini-cli |
Installation
All three install in one line. Claude Code and Codex now favor native installers, while Gemini CLI remains an npm package.
# Claude Code (native installer; also: brew install --cask claude-code, winget, npm)
curl -fsSL https://claude.ai/install.sh | bash
# Codex CLI (also: npm install -g @openai/codex, brew install --cask codex)
curl -fsSL https://chatgpt.com/codex/install.sh | sh
# Gemini CLI (also: brew install gemini-cli, or npx @google/gemini-cli)
npm install -g @google/gemini-cli
Per the Claude Code setup docs, native installs auto-update while Homebrew and WinGet don't. Codex's README also offers codex app for its desktop app, and Gemini CLI ships stable releases weekly per its README.
Licensing and openness
- Codex CLI is Apache-2.0 and written in Rust. You can read every line of the sandbox and approval logic, build it yourself, and pin a binary in your repo.
- Gemini CLI is also Apache-2.0. Its README says it is "fully open source," and the repo includes the docs, sandbox profiles and policy engine.
- Claude Code's repository is public, but the license file reads "© Anthropic PBC. All rights reserved," with use under Anthropic's Commercial Terms. Anthropic has open-sourced the sandbox runtime that Claude Code's Bash sandbox is built on, but not the agent itself.
If your security team requires source review of the agent harness, Claude Code is the one that fails that test.
How you pay (as of November 2026)
Claude Code
Claude Code needs a Pro, Max, Ultra, Team, Enterprise or Console (API) account. The setup docs say the free claude.ai plan doesn't include it. List prices on claude.com/pricing: Pro $20/month ($17/month billed annually), Max $100, Ultra $200, Team Standard $20/seat annually ($25 monthly), Team Premium $100/seat annually ($125 monthly), and Enterprise at $20/seat/month plus usage at API rates. You can also bill through an Anthropic API key, Amazon Bedrock, Google Cloud's Agent Platform or Microsoft Foundry.
Codex CLI
The Codex pricing page says Codex is included in ChatGPT Free, Go ($8), Plus ($20), Pro (from $100, with $100/$200/$500 tiers), Business ($20/user/month annually, $25 monthly), Edu and Enterprise. Limits are shown as rough message ranges per five hours, and they vary by model and task size. With an API key you pay standard API rates. Sign in with codex and choose Sign in with ChatGPT, or use an API key.
Gemini CLI
This changed in 2026. A Google Developers Blog post from May 19, 2026 announced that from June 18, 2026, Gemini CLI stops serving requests for Google AI Pro and Ultra subscribers and for the free Gemini Code Assist for individuals tier. Those users move to Antigravity CLI (agy), a new Go-based terminal agent. Gemini CLI remains supported for Gemini Code Assist Standard and Enterprise customers, Code Assist for GitHub through Google Cloud, and paid Gemini API or Vertex AI keys. The current README also warns that Gemini CLI is "not optimized for Gemini 4+" models.
So the old pitch, "Gemini CLI has the most generous free tier," no longer applies. Some pages in the repo's docs still describe a free tier, but the README and Google's announcement are the newer sources.
Default models
Only what each vendor documents:
- Claude Code: the model configuration docs say
defaultresolves to Opus 5.5 on Pro, Max, Ultra, Team, Enterprise and the Anthropic API. Aliases such assonnet,opus,haikuandopusplanswitch models, set with--model,/modelor themodelsetting. - Codex CLI: the models page says Codex uses "a recommended model" if you don't pick one, and lists Astra (
gpt-6-astra), 6.1 Sol (gpt-6.1-sol), 6.1 Terra (gpt-6.1-terra) and 6 Luna (gpt-6-luna). Set one with-mormodel = "..."inconfig.toml. - Gemini CLI: the CLI reference lists
autoas the default--modelvalue. It routes between Pro and Flash models, and the/modeldialog offers Gemini 3 and Gemini 2.5 Auto options.
No benchmark scores here: model quality changes with every release.
Permission and sandbox models
This is the most important difference. There are two separate questions: what the OS lets the agent's commands touch (the sandbox), and when the agent must ask you (the approval policy).
Claude Code: rules and modes first, sandbox optional
Claude Code's permission system uses allow/ask/deny rules plus a session-wide mode:
| Mode | Behavior |
|---|---|
default (Manual) |
Prompts on first use of each tool |
acceptEdits |
Auto-accepts file edits and common filesystem commands |
plan |
Read and explore only, no source edits |
auto |
A background classifier reviews actions instead of prompting |
dontAsk |
Denies anything that would prompt; allow rules still apply |
bypassPermissions |
Skips prompts; docs say use only in isolated containers or VMs |
Deny rules win at every level. A managed-settings deny can't be overridden by --allowedTools. The Bash sandbox is off by default. When enabled, it uses Seatbelt on macOS and bubblewrap on Linux and WSL2, restricts writes to the working directory, and routes network traffic through a proxy with an allowedDomains list that starts empty. It covers only shell commands. It doesn't cover built-in file tools, MCP servers or hooks, and it isn't supported on native Windows.
{
"permissions": {
"defaultMode": "acceptEdits",
"allow": ["Bash(npm run *)", "Bash(git commit *)"],
"deny": ["Bash(git push *)", "Read(./.env)"]
},
"sandbox": {
"enabled": true,
"network": { "allowedDomains": ["registry.npmjs.org"] }
}
}
Save that as .claude/settings.json to share it with the team.
Codex CLI: sandbox on by default
Codex pairs a sandbox mode with an approval policy. Per its sandboxing docs, the modes are read-only, workspace-write (the default low-friction mode for local work) and danger-full-access. The approval policies are on-request and never. The older untrusted policy is no longer selectable, and config.toml also accepts a granular policy table. The sandbox uses Seatbelt on macOS, bubblewrap on Linux and WSL2 (you install bwrap yourself), and a native Windows sandbox under PowerShell.
# ~/.codex/config.toml (or .codex/config.toml in a trusted project)
approval_policy = "on-request"
sandbox_mode = "workspace-write"
[sandbox_workspace_write]
network_access = false # the default; set true only if tasks need the network
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
On the command line, --sandbox (-s) and --ask-for-approval (-a) set the same options. --dangerously-bypass-approvals-and-sandbox (alias --yolo) turns both off and is "intended solely for running in environments that are externally sandboxed." In 0.169.0 there's also --approve-for-me, which routes approval requests through automatic review inside workspace-write.
Gemini CLI: approval modes plus a policy engine, sandbox optional
Gemini CLI has four approval modes: default (prompt), auto_edit (auto-approve edit tools), plan (read-only) and yolo (auto-approve everything). yolo can only be enabled from the command line with --approval-mode=yolo. Finer control comes from the policy engine: TOML rules in ~/.gemini/policies/ with allow, deny or ask_user decisions and priorities. In non-interactive mode, ask_user is treated as deny.
# ~/.gemini/policies/ci.toml
[[rule]]
toolName = "run_shell_command"
commandPrefix = "npm test"
decision = "allow"
priority = 100
[[rule]]
toolName = "run_shell_command"
commandPrefix = "git push"
decision = "deny"
priority = 200
The sandbox is off by default. Turn it on with -s, GEMINI_SANDBOX=docker|podman|sandbox-exec|runsc|lxc, or "tools": {"sandbox": "docker"} in settings.json. On macOS it uses Seatbelt profiles (default permissive-open: writes confined to the project, network allowed). Elsewhere it runs the CLI inside a container. The configuration reference notes that YOLO mode enables the sandbox by default.
Project instruction files
| File | Hierarchy | Cross-compatibility | |
|---|---|---|---|
| Claude Code | CLAUDE.md, .claude/CLAUDE.md, CLAUDE.local.md, ~/.claude/CLAUDE.md, .claude/rules/ |
Project, user, org | Reads AGENTS.md natively when no CLAUDE.md exists (v2.1.277+), or import it with @AGENTS.md |
| Codex CLI | AGENTS.md, AGENTS.override.md |
Global and per-directory | Extra filenames via project_doc_fallback_filenames |
| Gemini CLI | GEMINI.md |
Global, workspace and ancestors, plus just-in-time per directory | context.fileName accepts a list, e.g. ["AGENTS.md", "GEMINI.md"] |
The practical choice for a mixed team: put shared rules in AGENTS.md. Codex reads it natively. Claude Code reads it when there's no CLAUDE.md, per its memory docs. Gemini CLI reads it once you add it to context.fileName. Keep tool-specific extras in thin CLAUDE.md or GEMINI.md files that import or reference the shared one.
MCP, hooks and extensions
All three are MCP clients that support both local stdio and remote HTTP servers:
- Claude Code:
claude mcp add, a project-scoped.mcp.json, or--mcp-configfor headless runs. - Codex:
codex mcp add context7 -- npx -y @upstash/context7-mcp, or[mcp_servers.*]tables inconfig.toml. - Gemini CLI:
gemini mcp add, ormcpServersinsettings.json.
Our MCP servers roundup covers common servers.
All three also have lifecycle hooks. Claude Code's PreToolUse hooks can block calls, but they can't override deny rules. Codex has a large event set (PreToolUse, PermissionRequest, PostToolUse, SessionStart, Stop and more), and its hooks docs say hooks are on by default but each non-managed hook must be reviewed and trusted by hash before it runs. Gemini CLI's hooks run synchronously at events such as SessionStart and can block tool calls. Codex's trust-by-hash rule is a sensible default if you clone untrusted repos.
Headless and CI usage
The non-interactive entry points look alike but have different safety defaults:
claude -p: from v2.1.302, if nothing sets a permission mode,-pruns start in Manual mode, and anything that would prompt is denied. Add--allowedToolsor--permission-mode. The headless docs recommend--barefor CI, which skips local hooks, plugins, MCP servers andCLAUDE.md, and requiresANTHROPIC_API_KEY. Use--output-format json(orstream-json) and--json-schemafor structured output.codex exec: runs in a read-only sandbox by default, per the non-interactive docs. Pass--sandbox workspace-writeto allow edits,--jsonfor a JSONL event stream, and-oto save the final message.--output-schematakes a JSON Schema file and asks for a final message that conforms to it. Authenticate withCODEX_API_KEY, scoped to that one step.gemini -p:--output-format jsonorstream-json. Documented exit codes are0,1,42(bad input) and53(turn limit). If folder trust is enabled, an untrusted folder exits withFatalUntrustedWorkspaceErrorunless you pass--skip-trustor setGEMINI_CLI_TRUST_WORKSPACE=true.
Here's one GitHub Actions workflow running the same task with each tool. Install dependencies in a prior step, because network access is restricted or off in the sandboxes:
name: agent-fix-tests
on: workflow_dispatch
jobs:
claude:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- run: npm ci && npm install -g @anthropic-ai/claude-code@latest
- run: |
claude --bare -p "Run npm test and fix failing tests" \
--allowedTools "Read,Edit,Bash(npm test *)" \
--max-turns 20 --output-format json > claude.json
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
codex:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- run: npm ci && npm install -g @openai/codex
- run: |
codex exec --sandbox workspace-write --json \
-o codex-summary.md "Run npm test and fix failing tests" > codex.jsonl
env:
CODEX_API_KEY: ${{ secrets.OPENAI_API_KEY }}
gemini:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- run: npm ci && npm install -g @google/gemini-cli
- run: |
mkdir -p ~/.gemini/policies
printf '[[rule]]\ntoolName = "run_shell_command"\ncommandPrefix = "npm test"\ndecision = "allow"\npriority = 100\n' \
> ~/.gemini/policies/ci.toml
gemini -p "Run npm test and fix failing tests" \
--approval-mode auto_edit --skip-trust --output-format json > gemini.json
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
On Ubuntu runners, Codex's Linux sandbox needs bubblewrap on the PATH. If it's missing, add sudo apt-get install -y bubblewrap first. For anything beyond a demo, prefer each vendor's GitHub Action. Codex's docs recommend openai/codex-action@v1 because it keeps the API key behind a proxy. Claude's action handles @claude mentions and PR review. Pipe the JSON outputs through a JSON formatter when you debug them.
IDE integration
- Claude Code: VS Code extension, JetBrains plugin and a desktop app, all sharing
~/.claudeconfiguration. - Codex: an IDE extension for VS Code, Cursor and Windsurf, plus the desktop app (
codex app) and Codex Web. MCP config is shared across them. - Gemini CLI: a "Gemini CLI Companion" extension for VS Code-compatible editors, and the Agent Client Protocol (ACP) for JetBrains and Zed.
For how Claude Code compares with IDE-first tools, see Claude Code vs Cursor and, for another open-source terminal agent, Claude Code vs Aider.
Which one fits which team
| If you... | Lean toward | Why |
|---|---|---|
| Need an auditable, open-source harness | Codex CLI or Gemini CLI | Apache-2.0; Claude Code is closed source |
| Want a sandbox on by default with minimal setup | Codex CLI | workspace-write locally, read-only in exec, network off by default |
| Want fine-grained per-command rules shared via git | Claude Code or Gemini CLI | allow/ask/deny rules in .claude/settings.json; TOML policy engine |
| Already pay for ChatGPT Plus/Pro/Business | Codex CLI | Included in the plan |
| Already pay for Claude Pro/Max/Team | Claude Code | Included in the plan |
| Are a Google Cloud shop on Gemini Code Assist Standard/Enterprise | Gemini CLI | Google says it continues to support Gemini CLI for these customers |
| Are an individual wanting Google's free or AI Pro tier | Antigravity CLI, not Gemini CLI | Free and AI Pro/Ultra access moved there on June 18, 2026 |
| Need native Windows with sandboxing | Codex CLI or Gemini CLI | Codex documents a native Windows sandbox under PowerShell, and Gemini lists a windows-native sandbox option; Claude Code's sandbox needs WSL2 |
Frequently Asked Questions
Is Gemini CLI still free?
Not for most individuals. As of June 18, 2026, Google stopped serving Gemini CLI requests for the free Gemini Code Assist for individuals tier and for Google AI Pro and Ultra subscribers, and moved them to Antigravity CLI. Gemini CLI now targets Gemini Code Assist Standard/Enterprise and paid Gemini API or Vertex AI keys.
Is Claude Code open source?
No. The anthropics/claude-code repository is public, but its license states all rights reserved, with use under Anthropic's Commercial Terms. The sandbox runtime Claude Code uses is open source. Codex CLI and Gemini CLI are both Apache-2.0.
Can one AGENTS.md file work for all three tools?
Mostly. Codex reads AGENTS.md natively. Claude Code reads it when the repo has no CLAUDE.md (v2.1.277 or later). Gemini CLI reads it if you add it to the context.fileName setting. Keep tool-specific details in small per-tool files.
Which tool is safest to run unattended in CI?
All three can be locked down, but their defaults differ. codex exec starts in a read-only sandbox, recent claude -p versions deny anything that would prompt unless you allow it, and gemini -p treats ask_user as deny. Whichever you choose, run it in an ephemeral container and grant the narrowest tool list you can.
Do I need an API key, or can I use my subscription in CI?
Claude Code can use a subscription OAuth token (claude setup-token) or an API key. In --bare mode it needs ANTHROPIC_API_KEY. Codex's docs show CODEX_API_KEY for codex exec in CI. Gemini CLI uses GEMINI_API_KEY, Vertex AI credentials or a Code Assist login.
Bottom Line
No single winner exists. The right choice follows what you already pay for and how much control you need. Codex CLI has the strongest out-of-the-box isolation and an open-source Rust codebase, and it comes with ChatGPT plans. Claude Code has the richest permission-rule system and CI tooling, but it's closed source and its sandbox is opt-in. Gemini CLI is open source with a capable policy engine, but since June 2026 it makes sense mainly for Google Cloud Code Assist customers and paid API users. Individuals on Google's free or AI Pro plans should look at Antigravity CLI instead. Whichever you choose, put shared rules in AGENTS.md, script the headless mode with explicit tool allowlists, and re-check flags against the current docs, because all three change weekly.