CODEX

Codex CLI approval modes, the approval policy and sandbox explained

How Codex CLI approval policies and sandbox modes work, the exact flags and config.toml keys, what each combination allows, and setups to use.

Short answer

Codex CLI controls what the agent may do with two settings that work together. The sandbox mode (read-only, workspace-write or danger-full-access) sets what commands can technically touch, and the approval policy (on-request or never) sets when Codex stops to ask you. The default Auto preset is workspace-write with on-request.

Codex CLI does not have a single "approval mode" switch. It has two settings that combine: a sandbox mode, which limits what a command can physically do on your machine, and an approval policy, which decides when Codex pauses and asks you. Most confusion about Codex permissions comes from treating these as one thing.

This guide gives the exact names of both settings, the flags and config.toml keys that set them, what each combination allows in practice, and the setups that make sense for daily work, CI and untrusted code. Everything here was checked against the official Codex documentation on approvals, security and the configuration reference.

What is the difference between the sandbox and the approval policy in Codex?

In Codex, the sandbox is a technical boundary enforced by the operating system, and the approval policy is a rule about when to ask a human. The sandbox says "this command cannot write outside the workspace or reach the network". The approval policy says "if the agent wants to go beyond that boundary, ask me first" or "never ask, just work inside it".

On macOS, Codex runs commands through Seatbelt (sandbox-exec) with a profile that matches the selected sandbox mode. On Linux it uses bwrap plus seccomp by default. Because the boundary is enforced below the model, a command that tries to write outside the allowed paths fails, whatever the model intended.

What sandbox modes does Codex CLI support?

Codex CLI supports three sandbox modes, set with --sandbox (short form -s) or the sandbox_mode key:

Sandbox modeWhat commands can do
read-onlyRead files and run commands, but not write to disk
workspace-writeRead, edit and run commands inside the workspace; network access is off by default
danger-full-accessNo sandbox at all; commands run with your user's full access

workspace-write is the mode most people end up using. It lets Codex edit your project and run tests, but keeps it out of the rest of your home folder and off the network unless you allow it.

Even inside a writable root, some paths stay read-only. The docs list .git (including the resolved Git directory when .git is a gitdir: pointer file), and the .agents, .codex and .aws directories when they exist. This stops the agent from rewriting your Git history or its own configuration through a shell command.

What approval policies does Codex CLI support?

Codex CLI currently documents two approval policies, set with --ask-for-approval (short form -a) or the approval_policy key:

  • on-request: commands the sandbox permits run without asking. Anything outside the sandbox, or anything that needs network access, prompts you.
  • never: Codex never prompts. It does its best inside the sandbox constraints, and actions the sandbox blocks simply fail.

There is also a granular form for finer control, written as a table:

approval_policy = { granular = { sandbox_approval = true, rules = true, mcp_elicitations = true, request_permissions = true, skill_approval = false } }

Each boolean decides whether one category of prompt can surface: sandbox escalations, prompt rules from execpolicy, MCP elicitations, the request_permissions tool, and skill script approvals.

If you have older configs or scripts, check them. The docs say untrusted is retired and can prevent Codex from starting, and on-failure is deprecated in favor of on-request. Remove both from config.toml, profiles and shell aliases.

What does each combination allow?

Each combination of sandbox and approval policy gives a different level of autonomy. The official docs describe these setups:

IntentFlagsEffect
Auto (default preset)--sandbox workspace-write --ask-for-approval on-requestReads, edits and runs commands in the workspace; asks before going outside it or using the network
Safe read-only--sandbox read-only --ask-for-approval on-requestReads and runs commands read-only; asks for anything beyond that
Read-only CI--sandbox read-only --ask-for-approval neverReads and runs commands read-only and never asks
Full access--dangerously-bypass-approvals-and-sandbox (alias --yolo)No sandbox and no approvals

The CLI reference describes the last flag as running every command without approvals or sandboxing and says to use it only inside an externally hardened environment, such as a disposable container or VM. On your laptop, with your SSH keys and cloud credentials in reach, it removes every safety net at once. The same reasoning applies to Claude Code, as covered in the guide to dangerously skip permissions.

Combinations not in the table are possible but rarely useful. danger-full-access with on-request mostly means prompts never fire, since nothing is outside the sandbox. workspace-write with never is reasonable for unattended jobs where you accept that blocked actions just fail.

How do I set the approval mode in config.toml?

Put both keys at the top level of ~/.codex/config.toml to make them your defaults:

sandbox_mode = "workspace-write"
approval_policy = "on-request"

[sandbox_workspace_write]
network_access = false
writable_roots = ["/Users/me/code/shared-fixtures"]

The [sandbox_workspace_write] table only applies when the sandbox mode is workspace-write. The configuration reference lists four keys there:

  • network_access: allow outbound network access inside the sandbox.
  • writable_roots: extra directories Codex may write to, beyond the workspace.
  • exclude_slash_tmp: remove /tmp from the writable roots.
  • exclude_tmpdir_env_var: remove $TMPDIR from the writable roots.

Turning network_access on is the most common change, because package installs and API tests need it. Weigh that carefully: network access is also how a prompt injection would exfiltrate data. The glossary entry on prompt injection explains the risk in a few paragraphs.

How do I change the approval mode for one run?

Flags on the command line override config.toml for that run:

# Explore an unfamiliar repo without letting Codex write anything
codex --sandbox read-only --ask-for-approval on-request

# Normal work in a Git repo
codex -s workspace-write -a on-request

# Override a single key inline
codex -c 'sandbox_workspace_write.network_access=true'

The -c (--config) flag overrides any configuration value and parses it as TOML when it can. For setups you switch between often, use profile files: the docs place them next to config.toml as $CODEX_HOME/profile-name.config.toml, selected with --profile profile-name (short form -p).

Inside a running session, the /permissions slash command changes what Codex can do without asking, for example switching between Auto and Read Only. /status shows the active approval policy and writable roots, which is the quickest way to confirm what you are actually running with.

What happened to --full-auto?

Older blog posts and READMEs often recommend codex --full-auto. The current CLI reference does not list that flag. The documented shortcut is --approve-for-me (alias --not-so-yolo), which uses automatic approval review with on-request approvals and the workspace-write sandbox. If an old alias stops working, run codex --help to see what your installed version accepts.

Automatic approval review is a separate setting, approvals_reviewer. With approvals_reviewer = "auto_review", eligible approval requests go to a reviewer agent instead of you. The /approve command retries a recent auto-review denial. This is a model deciding on your behalf, so treat it as a convenience, not a security boundary.

How does Codex decide the starting mode for a folder?

Codex looks at whether the folder is trusted and version controlled. The docs recommend Auto (workspace-write with on-request) for folders under version control and read-only for folders that are not, and note that Codex may start in read-only until you trust the working directory. Running codex with no flags accepts these defaults.

Trust is stored per project. In config.toml you can mark a path explicitly:

[projects."/Users/me/code/client-repo"]
trust_level = "untrusted"

Untrusted projects skip project-scoped .codex/ layers, including project-local config, hooks and rules. That matters when you clone a repository you did not write: its .codex/config.toml cannot quietly widen your sandbox.

Which setup should I use?

Pick the setup by how much you trust the code and how closely you are watching:

  1. Daily work in your own Git repo: workspace-write with on-request. You review the occasional network or out-of-workspace request, Git protects the rest.
  2. Reading an unknown codebase: read-only with on-request. Nothing changes on disk.
  3. CI or scripted analysis: read-only with never, or workspace-write with never when the job must produce files. Nobody is there to answer prompts, so do not wait on them.
  4. Throwaway container: --dangerously-bypass-approvals-and-sandbox only when the container itself is the boundary and holds no credentials you care about.

The trade-off with on-request is that prompts appear in the terminal, and if you are in another window they wait there. That is the problem the rest of this site is about: keeping a human in the loop without staring at a terminal. The human in the loop article covers the thinking, and if you also use Claude Code, compare with the Claude Code permission modes.

Answering Codex approvals from the menu bar

Allowbar is a macOS menu bar app that shows Codex and Claude Code approval requests where you will see them. It connects through Codex's own hooks by adding an entry to ~/.codex/hooks.json and leaves your other hooks and settings alone. Codex asks you to trust that hook the first time, and Allowbar never skips that step.

When Codex wants to run something your approval policy does not already allow, a panel slides down from the top of the screen with the project, the tool and the exact command. You answer Allow, Block, or Terminal to send the question back to the terminal. A ring counts down, and if it runs out the question returns to the terminal. Allowbar never approves anything on its own, and a missing answer is never treated as approval. Commands your sandbox and rules already allow do not show up, so on-request stays quiet until there is a real decision to make.

Allowbar is Mac only (macOS 14 or later) and supports Claude Code and Codex. It is in private beta: join the waitlist, the launch price is $9.99 instead of $29.90.

Sources

Frequently asked questions

What is the default approval mode in Codex CLI?

In a trusted, version-controlled folder the recommended default is the Auto preset: workspace-write sandbox with the on-request approval policy. In folders that are not under version control, Codex recommends read-only, and it may start read-only until you trust the directory. Run /status to see what your session is using.

How do I stop Codex from asking for approval?

Set approval_policy = "never" in ~/.codex/config.toml or pass --ask-for-approval never. Codex then works inside the sandbox and actions the sandbox blocks fail instead of prompting. Keep the sandbox on; removing both with --yolo is only meant for hardened, disposable environments.

Does --full-auto still work in Codex?

The current Codex CLI reference does not list --full-auto. It documents --approve-for-me (alias --not-so-yolo), which combines workspace-write, on-request and automatic approval review. Run codex --help to check what your installed version accepts.

How do I let Codex use the network in workspace-write mode?

Set network_access = true under [sandbox_workspace_write] in config.toml, or pass -c 'sandbox_workspace_write.network_access=true' for one run. Network access is off by default in workspace-write, which is a deliberate protection against data leaving your machine.

Can Codex modify my .git folder?

Not through sandboxed commands. In workspace-write, .git inside a writable root stays read-only, as do .codex, .agents and .aws when they exist. Only danger-full-access or the full bypass flag removes that protection.

ALLOWBAR FOR MAC

Answer your agents from the menu bar.

Permission requests from Claude Code and Codex slide down from the top of your screen. Allow, Block or send back to the terminal. Allowbar never approves anything on its own.

Launch price $9.99 instead of $29.90, one-time purchase, lifetime license.