Gemini CLI vs Claude Code vs Codex CLI: The Terminal Agents Compared
Three vendors, three agents that live in your terminal. How Gemini CLI, Claude Code and Codex CLI differ on install, sign-in, instruction files, approvals and sandboxing, MCP, subagents, scripting and open source, and who each one suits.
7 min read
Gemini CLI, Claude Code and Codex CLI do the same job from the same place: you type a goal in a terminal, and the agent reads the repository, edits files, runs commands and keeps going until it is done. The differences are in the frame around that job. Gemini CLI and Codex CLI are open source; Claude Code is not. Codex contains commands in a sandbox from the first run; Gemini CLI and Claude Code ask before risky actions and offer a sandbox you switch on. Each reads its own instruction file, and each signs in with its own vendor’s account. Choose by those, not by which one sounds cleverer this month.
The matrix
Gemini CLI Claude Code Codex CLI
Install npm i -g @google/gemini-cli install script (sh, PowerShell) install script (sh, PowerShell)
brew install gemini-cli brew install --cask claude-code npm i -g @openai/codex
(Node.js 20+) WinGet, apt, dnf, apk, npm brew install --cask codex
Sign-in Gemini API key, Vertex AI, Claude Pro/Max/Team/Enterprise, ChatGPT account or
or Code Assist Standard/ Console, Bedrock, Google Cloud, API key
Enterprise via Google login Microsoft Foundry
Context file GEMINI.md (AGENTS.md via CLAUDE.md, falls back to AGENTS.md
context.fileName) AGENTS.md
Approvals default, auto_edit, plan, Manual, acceptEdits, plan, approval policy, e.g.
yolo auto, dontAsk, bypassPermissions on-request
Sandbox off until -s / --sandbox off until /sandbox on by default:
(Seatbelt, Docker, Podman, (macOS, Linux, WSL2) workspace-write,
gVisor, Windows native) no network
MCP mcpServers in settings.json claude mcp add, .mcp.json [mcp_servers] in
gemini mcp add config.toml, codex mcp add
Subagents .gemini/agents/*.md, .claude/agents/*.md, plugins .codex/agents/*.toml,
extensions skills, plugins
Headless gemini -p claude -p codex exec
Open source Yes, Apache 2.0 No, all rights reserved Yes, Apache-2.0The rest of this page explains the rows that change how you work. The two-way detail between Claude Code and Codex, including their editors, desktop apps and cloud agents, is in Claude Code vs Codex; here that pair stays short.
Install and sign-in
All three install in one line. Gemini CLI is an npm package that needs Node.js 20 or later, and Google’s Gemini CLI repository (opens in a new tab) lists three ways to authenticate: sign in with a Google account in the browser, set a Gemini API key from AI Studio, or use Vertex AI for enterprise controls. A personal Google account no longer gets you in: since 18 June 2026, Login with Google has stopped working for Gemini Code Assist for individuals and the Google AI Pro and Ultra tiers, so on a personal account you need an API key. Code Assist Standard and Enterprise licences are unchanged, and Google points individual users to Antigravity; the details are in Gemini CLI vs Gemini Code Assist and Antigravity vs Claude Code.
Claude Code ships as a native binary. Anthropic’s setup guide (opens in a new tab) gives a shell installer for macOS, Linux and WSL, a PowerShell installer for Windows, and Homebrew, WinGet and Linux package repositories. It needs a Pro, Max, Team, Enterprise or Console account, since the free Claude plan does not include it, or an Amazon Bedrock, Google Cloud or Microsoft Foundry account.
Codex CLI installs with a script, npm or Homebrew, and the Codex repository (opens in a new tab) says to sign in with a ChatGPT account on a paid plan or to use an API key. Each is billed differently; check each vendor’s current plans rather than a comparison table.
Context files
- Gemini CLI reads
GEMINI.mdfrom~/.gemini, your workspace and its parents, and folders it opens later. Thecontext.fileNamesetting takes a list, so["AGENTS.md", "GEMINI.md"]lets it read a file other agents share. - Claude Code reads
CLAUDE.mdfrom the working directory and above, and readsAGENTS.mdonly when there is noCLAUDE.md. ACLAUDE.mdcan import one with@AGENTS.md. - Codex reads
AGENTS.md, orAGENTS.override.md, from~/.codexand each directory down to where you are.project_doc_fallback_filenamesadds other names such asCLAUDE.md.
So one AGENTS.md can serve all three, with a line of configuration in Gemini CLI and none in the other two. The full precedence rules are in AI context files compared.
Approvals and sandbox
This is the row that differs most. Gemini CLI has four approval modes: default asks before tools that change things, auto_edit approves file edits, plan is read-only until you approve a plan, and yolo approves everything. Its sandbox is a separate switch. The sandbox documentation (opens in a new tab) lists gemini --sandbox, the GEMINI_SANDBOX variable or tools.sandbox in settings, and backends from macOS Seatbelt and Docker or Podman to gVisor and a native Windows sandbox. Plan mode itself is covered in Gemini CLI plan mode.
Claude Code frames the same choice as permission modes, from Manual, which asks before most edits and commands, to auto, where a classifier reviews actions, with plan for read-only work. Its Bash sandbox, opened with /sandbox, runs on macOS, Linux and WSL2 but not native Windows. Codex starts from the other end: the sandbox is on by default, writes stay inside the workspace, the network is off, and the approval policy decides when it may step outside. How far to loosen Claude Code is in Claude Code auto-approve.
gemini --approval-mode=plan claude --permission-mode plan codex --sandbox read-only --ask-for-approval on-request
Subagents and extensions
All three can hand part of a task to a subagent with its own context. In Gemini CLI, the subagents page (opens in a new tab) says they are on by default, with built-ins such as a codebase investigator, a generalist and a browser agent; your own are Markdown files with YAML frontmatter in .gemini/agents/ or ~/.gemini/agents/. Claude Code uses the same shape in .claude/agents/, and Codex uses TOML files in .codex/agents/.
Packaging differs. A Gemini CLI extension bundles prompts, MCP servers, custom commands, themes, hooks, subagents and skills, and installs from a GitHub URL with gemini extensions install. Claude Code’s equivalent is plugins, covered in Claude Code plugins; Codex has skills and plugins of its own.
Headless mode
For scripts and CI, Gemini CLI takes -p with --output-format json or stream-json. Claude Code takes -p too, and its programmatic mode (opens in a new tab) adds --bare so a CI run skips hooks, plugins, MCP servers and CLAUDE.md it would otherwise pick up from the machine. Codex uses a separate command, codex exec. In all three, set the permissions you want explicitly; an unattended run cannot answer a prompt. Claude Code’s -p starts in Manual mode on every plan, so pass --allowedTools or a permission mode; Gemini CLI takes --approval-mode; Codex takes its sandbox and approval flags. Treat a CI run as a stranger on your machine: give it the narrowest set that finishes the job.
gemini -p "List the TODOs in src/" --output-format json claude -p "List the TODOs in src/" --output-format json codex exec "List the TODOs in src/"
Open source
Gemini CLI is published under Apache 2.0 and Codex CLI under Apache-2.0, so you can read the code that decides what runs on your machine, fork it, or patch it. Claude Code is distributed as a binary; its public repository holds plugins, examples and the issue tracker, and its licence reserves all rights under Anthropic’s commercial terms. If you need to audit or modify the agent itself, that settles it. If you need a vendor to answer for it, it may settle it the other way.
Who each suits
- You want to pay per use with an API key rather than buy a subscription, or you work in Google Cloud: Gemini CLI, with a Gemini API key or Vertex AI. Google stopped personal Google sign-in (opens in a new tab) on 18 June 2026, so a free or Google AI subscription account is no longer a way in.
- You want the agent’s source in front of you: Gemini CLI or Codex CLI.
- You want every command contained from the first run, network off: Codex CLI. The other two can do it once you turn their sandbox on.
- You want to tune how often you are asked, down to a classifier that reviews actions for you: Claude Code’s permission modes are built around that.
- Your team already has Claude, ChatGPT or Google accounts: the agent that signs in with them is usually the one that gets used.
Many people keep two. A second agent is a cheap second opinion on a plan or a diff, and the shared AGENTS.md keeps both on the same rules. Running several at once is covered in orchestrating coding agents, and the wider field in the best AI coding agents.
One board for all three
Each agent keeps its own session history, and none of them can see the others’. All three speak MCP, so they can work the same fenbs board instead. Each connects to https://fenbs.ai/api/mcp with a browser sign-in, you tick what it may do, and every task it creates, moves or comments on is recorded in History under the assistant’s name, on your behalf. Switch agents next month and the tasks, plans and decisions stay where they are.
gemini mcp add fenbs https://fenbs.ai/api/mcp --transport http claude mcp add --transport http fenbs https://fenbs.ai/api/mcp codex mcp add fenbs --url https://fenbs.ai/api/mcp
Related
Set-up pages: Gemini CLI, Claude Code and Codex CLI. The tools behind them: the MCP docs. More comparisons: Cline, Roo Code and Kilo Code vs Claude Code and OpenCode vs Claude Code.