AI coding agents: permission and safety settings
An AI coding agent can read your files, run commands, and change your code. The settings below decide how much of that it may do without asking. This page compares how three command-line agents handle approval, where they can act, and how to switch safety off. It was compiled from each tool's own --help output and, where we could read it, official documentation. It does not rank the tools. ZIV LABS is not affiliated with Anthropic, OpenAI, or Google, and the product names belong to their owners.
What we checked
| Tool | Version | Sources |
|---|---|---|
| Claude Code | 2.1.325 | claude --version, claude --help, official permissions documentation (read November 15, 2026) |
| Codex CLI | 0.167.0 | codex --version, codex --help, codex exec --help, codex sandbox (a local write test, below), and the official Agent approvals & security, Sandboxing and Permissions pages (read November 15, 2026; they show no version, so we did not tie them to 0.167.0) |
| Gemini CLI | 0.64.0 | gemini --version, gemini --help (rechecked November 15, 2026), official policy-engine documentation (read October 21, 2026, not reread) |
First compiled on October 21, 2026 and rechecked on November 15, 2026 with the versions installed that day. Claude Code 2.1.325 was the latest on npm; Codex CLI (0.169.0) and Gemini CLI (0.68.0) had newer releases that we did not install for this check. Flags and defaults change between releases, so treat this page as a map and confirm with --help on your own version. Wording in quotation marks is the tool's own; everything else is our paraphrase.
1. Three questions for any agent
- What can it do without asking me? Reading files, editing files, running shell commands, using the network.
- Where can it act? Which directories, and whether commands run inside a sandbox.
- How do I turn the safety off, and when is that acceptable? Every tool has a way; each one's own help says it is for isolated environments.
2. Running without a person at the keyboard
| You want | Claude Code | Codex CLI | Gemini CLI |
|---|---|---|---|
| Non-interactive run | claude -p (--print) | codex exec (alias e) | gemini -p (--prompt) |
| Machine-readable output | --output-format json or stream-json | --json (events as JSON lines) | --output-format json or stream-json |
| Fix the shape of the final answer | --json-schema | --output-schema FILE | no such option in --help |
| Do not save the session | --no-session-persistence (with -p) | --ephemeral | no such option in --help |
| Spending cap | --max-budget-usd (with -p) | no such option in --help | no such option in --help |
Two details matter for safety. Claude Code's help says that in non-interactive mode the workspace trust dialog is skipped, so it should only be used in directories you trust, and that settings files that fail validation are silently ignored in that mode. Gemini CLI has --skip-trust, which trusts the current workspace for the session.
3. Approval: what happens before an action runs
| Tool | Setting | Values |
|---|---|---|
| Claude Code | --permission-mode | manual (the documentation names this mode default and accepts manual as an alias): asks on first use of each tool. acceptEdits: accepts file edits and common filesystem commands such as mkdir and mv in the working directories. plan: reads and runs read-only commands, does not edit source files. auto: runs without routine prompts while a background classifier checks actions against your request. dontAsk: automatically denies anything that would otherwise prompt. bypassPermissions: skips prompts except for a short list of actions that no mode auto-approves. |
| Codex CLI | --ask-for-approval (-a) | The help lists on-request (the model decides when to ask) and never (never ask; execution failures are returned to the model). --approve-for-me routes approval requests through automatic review using the workspace-write sandbox. |
| Gemini CLI | --approval-mode | default: prompts for approval. auto_edit: auto-approves edit tools. plan: read-only. yolo: auto-approves all tools. |
One naming trap: Gemini CLI's documentation page for its policy engine writes autoEdit, while the command-line flag in --help accepts auto_edit. Use the spelling your version's help prints.
4. Where the agent can act
| Tool | Setting | What it does |
|---|---|---|
| Claude Code | --add-dir, --restricted | --add-dir extends tool access to more directories. --restricted removes the built-in tools that run commands or code and the web-fetch tool unless --tools names them, ignores user, project, and local settings files (managed settings and --settings still apply), confines file tools to the working directories, and refuses bypassPermissions. The documentation also describes a setting, permissions.blockReadsOutsideWorkingDirectories, that makes the file tools refuse paths outside the working directories. |
| Codex CLI | --sandbox (-s), --add-dir, --search | --sandbox selects the policy for model-generated shell commands: read-only, workspace-write, or danger-full-access. --add-dir adds directories that are writable alongside the workspace. --search enables live web search, with no per-call approval according to the help. codex sandbox runs a command inside the Codex-provided sandbox. |
| Gemini CLI | --sandbox (-s), --include-directories | --sandbox is a boolean ("Run in sandbox?"). --include-directories adds directories to the workspace. |
5. Switching safety off
| Tool | How | What the tool itself says |
|---|---|---|
| Claude Code | --dangerously-skip-permissions, --permission-mode bypassPermissions; --allow-dangerously-skip-permissions makes bypass available without enabling it | The help recommends it only for sandboxes with no internet access. The documentation says bypass mode also skips prompts for writes to protected paths such as .git and .claude, and to use it only in isolated environments such as containers or virtual machines. Setting permissions.disableBypassPermissionsMode to "disable" prevents it. |
| Codex CLI | --dangerously-bypass-approvals-and-sandbox; --dangerously-bypass-hook-trust | The first is described as skipping all confirmation prompts and running commands without sandboxing, "EXTREMELY DANGEROUS", intended solely for environments that are externally sandboxed. The second runs enabled hooks without persisted hook trust and is "DANGEROUS". |
| Gemini CLI | --yolo (-y), --approval-mode yolo; --raw-output | The first two auto-approve all actions. --raw-output disables sanitization of model output, for example allowing ANSI escape sequences, and the help warns it can be a security risk if the model output is untrusted. --accept-raw-output-risk suppresses that warning. |
The --raw-output warning is the same lesson as our note on treating model output as untrusted input: what the model returns can be shaped by text it read, so what consumes it must not assume it is clean.
6. Rules and policies
| Tool | Mechanism | Notes from the documentation and help |
|---|---|---|
| Claude Code | Allow, ask, and deny rules in settings; --allowedTools, --disallowedTools | Rules are evaluated in the order deny, ask, allow, and the first match decides, so a broad deny rule cannot be carved out by a narrower allow rule. Rules live in ~/.claude/settings.json (user), .claude/settings.json (project), and .claude/settings.local.json (local), and managed settings rank highest: no other level, including command-line arguments, overrides a managed permission rule. The documentation states that permission rules are enforced by the tool, not by the model, and that a Bash deny or ask rule covers the form of the command the model usually writes and is not a security boundary around the program. |
| Codex CLI | Configuration and execution-policy rules | The help describes a user configuration file at ~/.codex/config.toml (under $CODEX_HOME), -c key=value overrides, --strict-config to reject unrecognized fields, and user or project execution-policy .rules files that codex exec --ignore-rules skips. In 0.167.0, codex exec --ignore-user-config skips $CODEX_HOME/config.toml (authentication still uses CODEX_HOME), and -p (--profile) layers $CODEX_HOME/<name>.config.toml on top of the user configuration. We could not read the documentation that explains how execution-policy rules are written. |
| Gemini CLI | Policy engine (TOML files) | Each rule sets conditions, a decision of allow, deny, or ask_user, and a priority from 0 to 999; the highest-priority match wins. In non-interactive mode, ask_user is treated as deny. User policies are read from ~/.gemini/policies/*.toml; admin policies come from a system directory (on macOS, /Library/Application Support/GeminiCli/policies) or from --admin-policy, and admin rules override user rules. Workspace policies are described as currently disabled. --policy loads extra policy files, and --allowed-tools is marked deprecated in favor of the policy engine. |
7. What happens when nobody can answer a prompt
Unattended runs need a decision for actions that would normally prompt. The three tools differ, and the difference is easy to miss:
- Claude Code: with
-p,--permission-prompts nonedenies anything that would prompt; the default,host, leaves the answer to the SDK host or a permission-prompt tool. - Gemini CLI: a policy rule with
ask_useris treated asdenyin non-interactive mode. - Codex CLI:
--ask-for-approval nevernever asks, and the help says execution failures are returned to the model instead of prompting you.
8. How we would start (our opinion, not tested)
- Begin with the narrowest mode that does the job:
planin Claude Code and Gemini CLI,--sandbox read-onlyin Codex CLI. Widen only when you need to. - Treat every flag in section 5 as unsuitable outside an isolated environment. That is what the tools' own descriptions say.
- For unattended runs, choose the "nobody answers" behavior deliberately (section 7) and keep the working directory to what the task needs.
- Use rules and sandboxes together. The tools' rules decide what they will try; a sandbox or container limits what an action can do if a rule is wrong.
What Codex's documentation adds
Codex's documentation moved to learn.chatgpt.com; the older developers.openai.com/codex/security address now redirects to a page about Codex Security, a different product, which is why an earlier version of this page could not use it. The pages below describe the Codex clients, including the CLI. They carry no date or version, so treat them as the current text on November 15, 2026, not as a statement about version 0.167.0.
- Two layers. A sandbox mode decides what Codex can do technically, such as where it can write and whether it can reach the network. An approval policy decides when it must ask you first.
- Defaults. The agent runs with network access turned off. In the CLI and IDE extension the defaults are no network access and writes limited to the active workspace. The
Autopreset (--sandbox workspace-write --ask-for-approval on-request) lets Codex read files, edit, and run commands in the working directory without asking, and it asks before editing outside the workspace or running commands that need the network. - Turning the network on. With
workspace-write, network stays off unlesssandbox_workspace_write.network_access = trueis set. A separatenetwork_proxyfeature can restrict traffic by domain, but it does nothing while the network is off. - Retired setting.
untrustedis no longer a selectable approval policy, and the documentation links a migration guide for configurations that still use it. It suggestssandbox_mode = "read-only"withapproval_policy = "on-request"for interactive read-only use. - Who reviews approvals.
approvals_reviewerchooses betweenuser(you see the prompts) andauto_review(automatic review); the--approve-for-meflag in--helpdescribes the same automatic review. - Switching safety off.
--dangerously-bypass-approvals-and-sandbox(alias--yolo) is listed as dangerous full access: no sandbox and no approvals. With it, or another full-access setting, web search defaults to live results. - How the sandbox is enforced. On macOS it uses the built-in Seatbelt framework. On Linux it needs
bubblewrap.sandbox_workspace_write.writable_rootsextends what the agent may modify without removing the sandbox.
What we did not verify
- We did not run an agent session for this page, because a session sends the prompt to the provider. Apart from the local Codex sandbox test below, behavior is described from help output and documentation, not observed.
- Codex sandbox, tested locally with 0.167.0 on macOS:
codex sandbox -c sandbox_mode="read-only" -- sh -c ...could not write a file in the working directory, and withsandbox_mode="workspace-write"it could. A write to a directory outside the working directory also succeeded withworkspace-write, but that directory was under the system temporary directory, which the sandbox may treat as writable; we did not test a directory outside both. - Codex CLI: the table above comes from
--help; the section on Codex's documentation comes from its official pages, which are not versioned. Apart from the local write test above, we did not test it: not the network defaults, not what the migration guide foruntrustedsays, and not how execution-policy rules are written. - Gemini CLI: the policy-engine page contains inconsistencies we noticed (it uses
autoEditwhere the flag isauto_edit, and its tier numbers differ between its table and its examples). We did not test the policy engine. - We checked on macOS with the installed command-line tools. We did not check Linux, Windows, IDE extensions, or desktop apps, and we did not cover slash commands, hooks, or MCP server settings.
How to reproduce the check
On your machine, with your versions:
claude --version && claude --help
codex --version && codex --help && codex exec --help
gemini --version && gemini --helpIf the output differs from this page, trust your output and tell us so we can update the page.
References
- Claude Code documentation: Configure permissions
- Gemini CLI documentation: Policy engine
- Codex documentation: Agent approvals & security (read November 15, 2026)
- Codex documentation: Sandboxing (read November 15, 2026)
- Codex documentation: Permissions (read November 15, 2026)
Related notes
- When the data an AI agent reads can give orders — Planted instructions in data coding agents read: a June 2026 research note, a local simulation, and an allow-list gate tested under a worst-case assumption.
- Treat model output as untrusted input — Four consumers that use an LLM's output directly (shell, file path, HTML, SQL), an attack string for each, and the fixes, reproduced with runnable Node.js code.
Decide
- Claude Code or Codex: which permission setup fits the task? — Four harmless steps run through Claude Code and Codex in two setups each: what was done, stopped or refused, with the test's limits stated and no ranking.
From the build logs
- Proving each acceptance criterion was checked took 23 review rounds — We built a command that shows, for each acceptance criterion of an Issue, whether it was Verified, Failed or Unknown. It took 8 pull requests and 23 Codex review rounds, and the design bent twice: record before the pull request's code runs, and read GitHub's rendered HTML.
- Where we stop reviewing an AI agent's pull request, and three times our auto-revert was wrong — Review rounds stopped by the weight of a finding, three pull requests that still hit the limit, a final review that found what two approvals missed, and three automatic reverts that were wrong.
- A month of AI-agent development in numbers: October 2026 — Counted from GitHub records by a script, not from memory: 203 merged pull requests, 70 agent runs, 693 CI runs, what Codex and Claude reviews found and how much of it was fixed, where the time went, and what we could not measure.