Codex CLI approvals and sandbox modes explained
Updated 17 November 2026
Codex CLI has two separate controls. 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. The default is workspace-write with on-request.
Codex CLI splits safety into two settings that are easy to mix up. The sandbox is enforced by the operating system and limits what a command can reach. The approval policy decides when Codex pauses and asks you. You choose one of each.
The names and examples below are from the Codex docs on approvals and security.
What are the sandbox modes?
| Mode | What Codex can do |
|---|---|
read-only |
Read files and run commands inside a read-only sandbox |
workspace-write |
Read, edit and run commands in the workspace. Network access is off by default |
danger-full-access |
No sandbox. Read, edit and use the network without approval prompts |
On a Mac the sandbox uses Seatbelt: commands run through sandbox-exec with a profile that matches the mode you chose.
Even in workspace-write, a few paths inside the workspace stay read-only: .git, and .agents, .codex and .aws when they exist as directories.
What are the approval policies?
| Policy | When Codex asks |
|---|---|
on-request |
Before acting outside what the sandbox allows, such as editing outside the workspace or using the network |
never |
Never. It works within the limits of the sandbox mode |
granular |
Keeps chosen categories of prompt interactive and rejects the rest automatically |
You may see untrusted in older posts and configs. The docs now list it as retired and say it can stop Codex starting, so remove it if you still have it.
What is the default?
With no flags, Codex uses the Auto preset: workspace-write with on-request. Edits and commands run inside your project without a prompt, and Codex asks before it edits outside the workspace or uses the network.
Codex asks fairly rarely as a result. The sandbox contains the work, so approval is only needed at its edge.
Which flags set them?
codex --sandbox workspace-write --ask-for-approval on-request
codex --sandbox read-only --ask-for-approval on-request
codex --sandbox read-only --ask-for-approval never
codex -a never
-a is short for --ask-for-approval. For a non-interactive run, use codex exec --sandbox workspace-write.
The combinations the docs call out:
| What you want | Flags | Effect |
|---|---|---|
| Auto (the preset) | none, or --sandbox workspace-write --ask-for-approval on-request |
Works in the workspace; asks to go outside it or use the network |
| Safe read-only browsing | --sandbox read-only --ask-for-approval on-request |
Stays in the read-only sandbox; outside actions can require approval |
| Read-only for CI | --sandbox read-only --ask-for-approval never |
Stays in the read-only sandbox and never prompts |
| Dangerous full access | --dangerously-bypass-approvals-and-sandbox |
No sandbox and no approvals |
Inside a session, /permissions switches modes. Dropping to read-only is a quick way to talk through a plan without any edits.
How do I set them in config.toml?
Codex reads ~/.codex/config.toml. To keep prompts on with a read-only sandbox:
approval_policy = "on-request"
sandbox_mode = "read-only"
To let commands in the workspace sandbox reach the network:
[sandbox_workspace_write]
network_access = true
A granular policy looks like this. Categories set to true stay interactive and the others are rejected:
approval_policy = { granular = {
sandbox_approval = true,
rules = true,
mcp_elicitations = true,
request_permissions = false,
skill_approval = false
} }
There is also approvals_reviewer. It defaults to "user". Set it to "auto_review" and eligible requests go to an automatic reviewer, inside the same sandbox boundary.
What does —yolo do?
--yolo is an alias for --dangerously-bypass-approvals-and-sandbox. It turns off both the sandbox and the approvals, so nothing limits what a command can touch and nothing asks you first. The docs advise against using it.
If your reason for reaching for it is “the prompts are annoying”, try the smaller changes first:
- Stay on the default. In
workspace-writemost work inside the project already runs without asking. - If the prompts are all about network access, turn on
network_accessfor the workspace sandbox and leave the rest alone. - For unattended runs, use
--ask-for-approval neverwith a sandbox still on. Codex then works within the sandbox and never waits. - Keep full access for a container or VM you can throw away.
Can something other than the terminal answer an approval?
Yes. Codex has lifecycle hooks, configured in ~/.codex/hooks.json or inline in config.toml. A PermissionRequest hook runs when Codex is about to ask you, and it can answer:
{
"hookSpecificOutput": {
"hookEventName": "PermissionRequest",
"decision": { "behavior": "allow" }
}
}
If any matching hook denies, the request is denied. If a hook allows, the prompt is skipped. If no hook decides, the normal prompt appears. New hooks have to be reviewed and trusted before they run; use /hooks in the CLI to do that.
A hook that allows everything is --yolo with extra steps, so keep any auto-approving hook narrow.
Where does NotchDaddy fit?
NotchDaddy connects to Codex CLI through that same PermissionRequest hook. When Codex would have prompted, the request appears in the MacBook notch with the command and Allow and Deny buttons, and your answer goes back as the hook’s decision. If you do not answer in time it returns no decision, so Codex shows its own prompt as usual. Nothing is approved for you. You connect it from Settings › Agents and then trust the hooks once through Codex’s /hooks.
You do not need it if you sit in the Codex terminal while it works. With the default sandbox, Codex asks rarely enough that the terminal prompt is fine. It is more useful when you run Codex next to other agents or in a window you are not watching. The same flow for Claude Code is in approving Claude Code from the notch, and the two tools are set side by side in Claude Code vs Codex CLI on approvals.
Start a 3-day trial for $0. It is $19 once for 2 Macs.