Skip to content

Claude Code vs Gemini CLI: sandbox, approvals and security compared

Claude Code and Google's Gemini CLI side by side on sandboxing, approval modes, network access, hooks, admin policy and public advisories, with a source for every fact.

Checked

Claude Code

Made by
Anthropic
Out of the box
From v2.1.283, interactive terminal and VS Code sessions start in auto mode, where a classifier reviews actions. Without a supported model it starts in Manual. claude -p and Agent SDK runs start in Manual, which asks before edits, shell commands and network access.
Sandbox
Yes, off by default. Turn on with /sandbox or sandbox.enabled. macOS uses Seatbelt, Linux and WSL2 use bubblewrap. Not supported on native Windows. Covers Bash, PowerShell and Monitor commands only. File tools, MCP servers and hooks run outside it.
Public advisories
8 with a CVE or GHSA id, 6 rated critical or high

Gemini CLI

Made by
Google
Out of the box
Mode default asks before write tools and before every shell command. Choices are allow once, allow always for the session, or deny. Read-only tools do not ask.
Sandbox
Optional. macOS uses Seatbelt (sandbox-exec) with six profiles, default permissive-open. Docker, Podman, gVisor and LXC also work. Turn on with -s, GEMINI_SANDBOX or tools.sandbox. The docs do not state a default.
Public advisories
1 with a CVE or GHSA id, 1 rated critical or high

Short answer

Both are terminal agents with an optional macOS Seatbelt sandbox, hooks that can block a tool call, and admin settings users cannot override. Gemini CLI asks before every shell command by default. Claude Code's interactive sessions start in auto mode, where a classifier reviews actions. One change matters before you choose: since June 18, 2026, Google moved free and Google AI Pro or Ultra users to Antigravity CLI. Gemini CLI now serves Gemini Code Assist Standard and Enterprise and paid API keys.

At a glance

Every answer links to the page that says it. Both agents change often, so their own docs win where they differ from this page.

Safety controls, side by side
QuestionClaude CodeGemini CLI
Sandbox on from the first runNoOpt-in with /sandbox3NoOpt-in with -s or tools.sandbox27
OS-level sandbox availableYesSeatbelt on macOS, bubblewrap on Linux3YesSeatbelt, Docker, Podman, gVisor or LXC27
No network in commands by defaultPartlyAsks in Manual mode; with the sandbox, an allowlist that starts empty34NoThe default Seatbelt profile allows network27
Asks you before shell commands by defaultPartlyAuto mode lets a classifier approve; Manual mode asks2YesAsks before every shell command410
Deny rules you writeYesdeny arrays, checked first4YesPolicy engine deny rules4
A hook can block a tool callYesPreToolUse with exit code 2 or a deny5YesBeforeTool can deny5
Admin policy users cannot overrideYesManaged settings file, MDM or admin console8YesSystem settings and admin policies47
Admins can turn off the skip-approvals modeYesAdmins can disable bypassPermissions2Yessecurity.disableYoloMode46
Open sourceNoThe sandbox runtime is open source93YesApache-2.01

The basics

QuestionClaude CodeGemini CLI
Runs in
Terminal CLI, VS Code and JetBrains extensions, desktop app, web at claude.ai/code, mobile app, GitHub Actions and GitLab CI/CD, and an Agent SDK.1
Open-source terminal agent (gemini). Since June 18, 2026 free individual and Google AI Pro or Ultra access moved to Antigravity CLI (agy). This repo now targets Code Assist Standard or Enterprise users.1
Platforms
macOS, Linux, WSL and native Windows. Installs with a script, Homebrew, WinGet, apt, dnf or apk.1
Installs by npx, npm, Homebrew, MacPorts or Anaconda. Sandbox methods are documented for macOS, Linux and Windows. The README does not list supported platforms.12
Open source
No. The anthropics/claude-code repo holds issues, plugins and examples, and its license file is "All rights reserved" under Anthropic's Commercial Terms. The sandbox runtime is a separate open source package.93
Yes, Apache License 2.0.1
Models
Claude models from Anthropic, or third-party providers such as Amazon Bedrock, Google Cloud and Microsoft Foundry. Auto mode needs Opus 4.6 or later, Sonnet 4.6 or later, Haiku 5.5 or a Fable model on the Anthropic API.12
Choose a model with -m, for example gemini-2.5-flash. The README says the CLI is not tuned for the Gemini 4 series.1
Pricing
Included with Claude Pro, Max, Ultra, Team and Enterprise plans, not Free. Pro is $20 a month, or $17 a month billed annually. Also usable with an Anthropic Console API account at API rates.101
No free tier or Google AI plans. Meant for Gemini Code Assist Standard or Enterprise licenses, Code Assist for GitHub, and legacy paid API or Vertex keys with usage-based billing.1

Safety controls

QuestionClaude CodeGemini CLI
Out of the box
From v2.1.283, interactive terminal and VS Code sessions start in auto mode, where a classifier reviews actions. Without a supported model it starts in Manual. claude -p and Agent SDK runs start in Manual, which asks before edits, shell commands and network access.2
Mode default asks before write tools and before every shell command. Choices are allow once, allow always for the session, or deny. Read-only tools do not ask.410
Sandbox
Yes, off by default. Turn on with /sandbox or sandbox.enabled. macOS uses Seatbelt, Linux and WSL2 use bubblewrap. Not supported on native Windows. Covers Bash, PowerShell and Monitor commands only. File tools, MCP servers and hooks run outside it.3
Optional. macOS uses Seatbelt (sandbox-exec) with six profiles, default permissive-open. Docker, Podman, gVisor and LXC also work. Turn on with -s, GEMINI_SANDBOX or tools.sandbox. The docs do not state a default.27
Network in commands
Without the sandbox, network commands and WebFetch ask in Manual mode, apart from preapproved documentation domains. With it, traffic goes through a local proxy that checks sandbox.network.allowedDomains, which starts empty.34
Open by default. The default Seatbelt profile allows network access. *-proxied profiles route traffic through a proxy. tools.sandboxNetworkAccess is off by default for the legacy sandbox.27
Turning approvals off
--dangerously-skip-permissions, same as --permission-mode bypassPermissions. Skips prompts and safety checks. Deny rules and explicit ask rules still apply. Docs say to use it only in containers or VMs. Admins can disable it.2
--yolo or --approval-mode=yolo auto-approves all tools. It is command line only. security.disableYoloMode blocks it.46
Permission rules
permissions.allow, ask and deny arrays in settings.json, for example Bash(npm run test *) and Read(./.env). Deny is checked first, then ask, then allow. /permissions lists them.4
Policy engine TOML files. Each [[rule]] sets toolName, argsPattern or commandPrefix, a decision of allow, deny or ask_user, and a priority. User files live in ~/.gemini/policies/*.toml.4
Hooks before a tool runs
Yes. PreToolUse hooks run before a tool call and can block it with exit code 2 or a deny decision. Types are command, http, mcp_tool, prompt and agent. A crashed hook does not block unless onFailure is block.5
Yes. Hooks in settings.json fire on events such as BeforeTool, AfterTool and SessionStart. BeforeTool can block a call with a JSON deny or exit code 2.5
Project instructions
CLAUDE.md in the project and in ~/.claude/, plus CLAUDE.local.md and .claude/rules/. Can read AGENTS.md in place of CLAUDE.md. These are guidance, not enforced.61
Reads GEMINI.md context files. The context.fileName setting can name other files.17
MCP servers
Yes. HTTP, SSE (deprecated), stdio and WebSocket. Servers live in .mcp.json (project) or ~/.claude.json (local and user scope). Admins can set managed-mcp.json or managedMcpServers.78
Yes. Servers are set under mcpServers in ~/.gemini/settings.json using command, url or httpUrl. Tools get an mcp_ name prefix.17
Session history
Plaintext JSONL transcripts at ~/.claude/projects/<project>/<session>.jsonl, prompt history in ~/.claude/history.jsonl. Transcripts are deleted after 30 days by default (cleanupPeriodDays)6
Sessions are saved to ~/.gemini/tmp/<project_hash>/chats/ and kept 30 days by default. Checkpoints, when on, use ~/.gemini/history/<project_hash> and the same tmp tree.89
Admin policy
Yes. /Library/Application Support/ClaudeCode/managed-settings.json on macOS, a com.anthropic.claudecode MDM profile, or server-managed settings from the claude.ai admin console. Users and project files cannot override them.8
System settings at /Library/Application Support/GeminiCli/settings.json outrank user and project settings. Admin policies go in /Library/Application Support/GeminiCli/policies and outrank user rules. macOS paths must be root-owned.47

The differences that matter

Who Gemini CLI is for now

Since June 18, 2026, free individual access and Google AI Pro and Ultra plans use Antigravity CLI (agy). Gemini CLI has no free tier and is meant for Gemini Code Assist Standard or Enterprise licenses and paid API or Vertex keys. If you are an individual on a Google AI plan, compare Claude Code with Antigravity CLI.

What runs without asking

Gemini CLI's default mode asks before write tools and before every shell command, and read-only tools run. Claude Code's interactive sessions start in auto mode, where a classifier approves routine actions. Its scripted runs start in Manual mode, which asks.

The sandbox and the network

Both sandboxes are optional on macOS and use Seatbelt. Gemini CLI has six Seatbelt profiles, and the default one allows network access. It also runs in Docker, Podman, gVisor or LXC. Claude Code's sandbox covers shell commands and sends their traffic through a proxy whose list of allowed domains starts empty.

Rules and hooks

Gemini CLI's policy engine reads TOML rules that allow, deny or ask, with priorities and an admin tier users cannot override. Claude Code keeps allow, ask and deny arrays in settings.json. Both have a hook before each tool call that can block it: BeforeTool in Gemini CLI, PreToolUse in Claude Code.

Turning approvals off

Gemini CLI's --yolo approves every tool, works only from the command line, and admins can block it with security.disableYoloMode. Claude Code's --dangerously-skip-permissions skips prompts while deny rules still apply, and admins can disable it.

Public advisories

Gemini CLI has one GitHub advisory, rated critical, fixed in 0.39.1 in April 2026, and a July 2025 prompt-injection issue reported by Tracebit, fixed in 0.1.14. Claude Code's repository lists eight since June 2026, six rated high. All were fixed in releases.

Approval modes

Each agent's modes, from the one that asks most to the one that asks least, with the mode each starts in marked.

Claude Code

  1. planAsks for some actions
  2. default (Manual)Asks before each action
  3. dontAskNever asks
  4. acceptEditsAsks for some actions
  5. autoAsks for some actionsStarts here
  6. bypassPermissionsNever asks

Gemini CLI

  1. planAsks for some actions
  2. defaultAsks before each actionStarts here
  3. auto_editAsks for some actions
  4. yoloNever asks

Claude Code modes in detail

ModeHow to turn it onAsks youWhat it allows
plan
Shift+Tab, --permission-mode plan or /plan
For some actions
Reads and proposes changes without editing source until you approve the plan.
default (Manual)
--permission-mode default or permissions.defaultMode
Before each action
Prompts for most edits, shell commands and network access. Reads in the working directory run without asking.
dontAsk
--permission-mode dontAsk (not in the Shift+Tab cycle)
Never
Denies every call that would prompt. Only reads and pre-approved tools run.
acceptEdits
Shift+Tab, --permission-mode acceptEdits
For some actions
Auto-approves edits and common filesystem commands in the working directory. Other Bash commands still prompt.
auto
Shift+Tab, --permission-mode auto or defaultMode in user settings
For some actions
A classifier model blocks risky actions such as curl | bash and force pushes. Pauses and prompts after 3 blocks in a row or 20 in total.
bypassPermissions
--dangerously-skip-permissions or --permission-mode bypassPermissions
Never
Skips prompts and safety checks. Deny rules and explicit ask rules still apply. Docs say it offers no protection against prompt injection.

Gemini CLI modes in detail

ModeHow to turn it onAsks youWhat it allows
plan
general.defaultApprovalMode or --approval-mode=plan
For some actions
Strict read-only mode for research and design.
default
Out of the box, or --approval-mode=default
Before each action
Most write tools and every shell command need confirmation.
auto_edit
general.defaultApprovalMode or --approval-mode=auto_edit
For some actions
Edit tools are auto-approved. Other tools still ask.
yolo
--yolo or --approval-mode=yolo (command line only)
Never
All tools are auto-approved. Policy rules can still deny.

Where their settings live

Claude Code

PathWhat it holds
~/.claude/settings.json
User settings, permissions and hooks
.claude/settings.json
Project settings, shared in git
.claude/settings.local.json
Personal project settings, gitignored
/Library/Application Support/ClaudeCode/managed-settings.json
Admin-managed policy on macOS
~/.claude.json
Account state, trust decisions, local and user MCP servers
.mcp.json
Project MCP servers
~/.claude/projects/
Session transcripts and auto memory
~/.claude/history.jsonl
Prompt history
~/.claude/file-history/
Pre-edit file snapshots for checkpoint restore
CLAUDE.md
Project instructions

Gemini CLI

PathWhat it holds
~/.gemini/settings.json
User settings, MCP servers, hooks
.gemini/settings.json
Project settings, override user settings
/Library/Application Support/GeminiCli/settings.json
System settings that outrank user and project
~/.gemini/policies/*.toml
User policy rules
/Library/Application Support/GeminiCli/policies
Admin policy rules
~/.gemini/trustedFolders.json
Saved folder trust choices
~/.gemini/tmp/<project_hash>/chats/
Saved sessions
~/.gemini/history/<project_hash>
Shadow Git repo for checkpoints
GEMINI.md
Project context and instructions

Security advisories

Public advisories and well-documented reported issues since 2025. A longer list can mean more people are looking, so read each one rather than the count.

Claude Code

8Listed here
8With a CVE or GHSA id
8Name a fix

Gemini CLI

2Listed here
1With a CVE or GHSA id
2Name a fix

Both, newest first

  1. Claude CodeGHSA-5xjx-9qx6-jcrvHigh

    A race in the Edit tool's path check let a process in the Bash sandbox swap a parent directory for a symlink, so the unsandboxed Edit tool could overwrite a file outside the workspace on macOS. CVE-2026-88968.

    Fixed in 2.1.251
  2. Claude CodeGHSA-4p2j-qj3c-6x84High

    Uncontrolled search path let a malicious git executable run arbitrary code. Affects Claude Desktop, listed in the Claude Code repo. CVE-2026-88066.

    Fixed in Claude Desktop 1.8089.0
  3. Claude CodeGHSA-pq7j-f95f-qfcvHigh

    A plugin commit SHA pin could be bypassed, allowing installation of attacker-controlled code. CVE-2026-86063.

    Fixed in 2.1.179
  4. Claude CodeGHSA-5j29-h97v-84chHigh

    Arbitrary file write through write-time symlink following (a time-of-check to time-of-use race). CVE-2026-103435.

    Fixed in 2.1.129
  5. Claude CodeGHSA-gfvf-j8jh-jxxwLow

    Managed settings were not applied when a stored API key was preferred over enterprise sign-in. CVE-2026-103012.

    Fixed in 2.1.260
  6. Claude CodeGHSA-v234-4jrq-mgg6High

    Claude Desktop on macOS: opening a malicious file from a Cowork folder could run commands on the host. Listed in the Claude Code repo.

    Fixed in Claude Desktop 1.15962.0
  7. Claude CodeGHSA-7835-87q9-rgvvHigh

    Git worktree path confusion allowed a sandbox escape and unsandboxed code execution. CVE-2026-55607.

    Fixed in 2.1.163
  8. Claude CodeGHSA-4vp2-6q8c-pvq2Medium

    An insecure temporary file in the /copy command allowed response disclosure and a symlink-based file write. CVE-2026-46406.

    Fixed in 2.1.128
  9. Gemini CLIGHSA-wpqr-6v78-jr5gCritical

    CVE-2026-12537. In headless mode workspace folders were auto-trusted, so a malicious .env or .gemini/ config in an untrusted pull request could run code. Under --yolo, fine-grained tool allowlists were ignored.

    Fixed in 0.39.1
  10. Gemini CLITracebit research write-up

    Tracebit showed prompt injection in a README plus a weak command allowlist check could run a command that began with an approved one, with whitespace padding hiding it from the terminal. Reported June 27, 2025. Google reclassified it P1, S1.

    Fixed in 0.1.14

Strengths and things to watch

Claude Code

What it does well

  • Permission rules and hooks are enforced by Claude Code, not by the model, and deny rules apply in every mode.
  • Managed settings rank above user, project and command-line values, and admins can disable bypass and auto modes.
  • An OS-level sandbox with a domain allowlist and credential and filesystem controls is available, built on an open source runtime.
  • PreToolUse hooks can block a call before it runs, and onFailure: "block" makes a failed hook fail closed.
  • Transcripts and pre-edit file snapshots are kept locally, with claude purge and cleanupPeriodDays to control retention.

What to watch for

  • The sandbox is off by default and covers Bash, PowerShell and Monitor commands only. Edit, Read, Write, WebFetch, MCP servers and hooks run outside it.
  • Sandboxed reads cover most of the machine by default, including ~/.ssh, unless denyRead or similar settings narrow them.
  • A failed sandboxed command can be retried unsandboxed with dangerouslyDisableSandbox unless allowUnsandboxedCommands is false.
  • Bash rules match command text, so Bash(rm *) does not match /bin/rm or bash -c 'rm ...'. The docs point to the sandbox for stronger enforcement.
  • Transcripts are plaintext, so a value read from a .env file or printed by a command is written to ~/.claude/projects/.

Gemini CLI

What it does well

  • Default mode asks before every shell command and before most write tools.
  • The policy engine supports deny rules and admin-tier policies that users cannot override, with root ownership checks on macOS.
  • System settings in /Library/Application Support/GeminiCli/ outrank user and project settings.
  • BeforeTool hooks can block a tool call, and security.disableYoloMode can turn the yolo mode off.
  • The CLI is Apache-2.0, so the sandbox and policy code can be read.

What to watch for

  • The sandbox is opt-in. The docs do not state it is on by default, and the default Seatbelt profile allows network access.
  • Folder trust docs disagree. The trusted folders page says it is off by default and the settings reference says on. Check security.folderTrust.enabled.
  • In CI, untrusted folders fail unless --skip-trust or GEMINI_CLI_TRUST_WORKSPACE=true is set.
  • Workspace policy files in .gemini/policies are documented as currently disabled.
  • Checkpointing is off by default, and session files sit under ~/.gemini/tmp and are pruned after 30 days.

Which should you pick

Pick Claude Code if

  • You want Claude models and an agent that also runs in your IDE, the desktop app and CI.
  • You want a sandbox whose network starts closed, opened one domain at a time.
  • You want a classifier to handle routine approvals.
  • You are an individual developer: Gemini CLI no longer has a free or Google AI plan tier.

Pick Gemini CLI if

  • Your company has Gemini Code Assist Standard or Enterprise licenses.
  • You want to be asked before every shell command by default.
  • You want sandbox choices beyond Seatbelt, such as Docker, Podman or gVisor.
  • You want to read the source: Gemini CLI is Apache-2.0.

Running both

Gemini CLI reads GEMINI.md, and its context.fileName setting can point it at AGENTS.md or CLAUDE.md too, so one instruction file can reach both. Their enforced settings are separate: Claude Code's in settings.json, Gemini CLI's in ~/.gemini/settings.json and its policy files.

Where Excellent fits

What Excellent doesClaude CodeGemini CLI
Reads its session logs (free scan)
Yes
Yes
Key finder reads its key files
Yes
Yes
Live check before risky actions (Pro)
Yes, in its own hook settings
Yes, in its own hook settings
Before a force push to main
Claude Code asks you first
Refuses and tells Gemini CLI to ask you
Excellent's sandbox (Pro)
Yes, in its own sandbox settings
No
Rule sharing
Yes
No

Excellent reads the session logs of both Claude Code and Gemini CLI on your Mac. The free scan shows what each did: your email in request commands or form inputs, keys sitting in logs, secrets files read, history overwritten, checks skipped. Each finding says which agent and where.

With Pro, Excellent adds its live check to each one's own hook settings, after listing what it will change. The same rules apply to both: it blocks your email on its way to a website, an API key typed into a command, and deleting a folder you marked never-delete.

Excellent's sandbox and rule sharing are for Claude Code and Codex only, so here they apply to Claude Code. The check reads what a command says, so it isn't a wall around your Mac.

Questions

Is Gemini CLI still free?

No. Since June 18, 2026, free and Google AI Pro or Ultra access moved to Antigravity CLI. Gemini CLI now serves Gemini Code Assist Standard and Enterprise and paid API or Vertex keys.

Does Gemini CLI have a sandbox?

Yes, optional. On macOS it uses Seatbelt with six profiles, and it also runs in Docker, Podman, gVisor or LXC. Turn it on with -s, GEMINI_SANDBOX or tools.sandbox.

Does Claude Code have a sandbox?

Yes, off by default. It uses Seatbelt on macOS and bubblewrap on Linux, and covers shell commands.

Which one asks more?

Gemini CLI's default mode asks before every shell command and write tool. Claude Code's interactive default, auto mode, lets a classifier approve routine actions, and its Manual mode asks like Gemini CLI does.

Read more

Sources

More agent comparisons

All comparisons →

Check what Claude Code and Gemini CLI did on your Mac

Get the Mac app