ZIV LABS
Reference

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

ToolVersionSources
Claude Code2.1.325claude --version, claude --help, official permissions documentation (read November 15, 2026)
Codex CLI0.167.0codex --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 CLI0.64.0gemini --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

  1. What can it do without asking me? Reading files, editing files, running shell commands, using the network.
  2. Where can it act? Which directories, and whether commands run inside a sandbox.
  3. 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 wantClaude CodeCodex CLIGemini CLI
Non-interactive runclaude -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 FILEno such option in --help
Do not save the session--no-session-persistence (with -p)--ephemeralno such option in --help
Spending cap--max-budget-usd (with -p)no such option in --helpno 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

ToolSettingValues
Claude Code--permission-modemanual (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-modedefault: 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

ToolSettingWhat 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

ToolHowWhat the tool itself says
Claude Code--dangerously-skip-permissions, --permission-mode bypassPermissions; --allow-dangerously-skip-permissions makes bypass available without enabling itThe 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-trustThe 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-outputThe 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

ToolMechanismNotes from the documentation and help
Claude CodeAllow, ask, and deny rules in settings; --allowedTools, --disallowedToolsRules 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 CLIConfiguration and execution-policy rulesThe 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 CLIPolicy 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 none denies 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_user is treated as deny in non-interactive mode.
  • Codex CLI: --ask-for-approval never never 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: plan in Claude Code and Gemini CLI, --sandbox read-only in 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 Auto preset (--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 unless sandbox_workspace_write.network_access = true is set. A separate network_proxy feature can restrict traffic by domain, but it does nothing while the network is off.
  • Retired setting. untrusted is no longer a selectable approval policy, and the documentation links a migration guide for configurations that still use it. It suggests sandbox_mode = "read-only" with approval_policy = "on-request" for interactive read-only use.
  • Who reviews approvals. approvals_reviewer chooses between user (you see the prompts) and auto_review (automatic review); the --approve-for-me flag in --help describes 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_roots extends 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 with sandbox_mode="workspace-write" it could. A write to a directory outside the working directory also succeeded with workspace-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 for untrusted says, and not how execution-policy rules are written.
  • Gemini CLI: the policy-engine page contains inconsistencies we noticed (it uses autoEdit where the flag is auto_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 --help

If the output differs from this page, trust your output and tell us so we can update the page.

References

Related notes

Decide

From the build logs