What Codex --approve-for-me Does (and Why --sandbox Breaks It)
Verified
Contents
--approve-for-me turns on three settings at once: approval requests go to automatic review, the approval policy is on-request, and the session runs in the workspace-write sandbox. Because it already sets the sandbox, you can’t combine it with --sandbox. Codex exits with error: the argument '--sandbox <SANDBOX_MODE>' cannot be used with '--approve-for-me'. Run codex --approve-for-me on its own.
Separate the approval reviewer from the sandbox
Approval review and sandboxing answer different questions, but --approve-for-me sets both:
| Control | Question it answers | Safe way to reason about it |
|---|---|---|
--sandbox workspace-write | What sandbox should the session use? | Use it for an explicit workspace-write policy without --approve-for-me. |
--ask-for-approval on-request | When should Codex request approval? | Use it without --approve-for-me for human-reviewed requests. |
--approve-for-me | Should approval requests go to automatic review inside a workspace-write sandbox? | Sets approvals_reviewer=auto_review, approval_policy=on-request, and sandbox_mode=workspace-write together. Conflicts with --sandbox and --dangerously-bypass-approvals-and-sandbox. |
--dangerously-bypass-approvals-and-sandbox | Should both guardrails be bypassed? | Treat it as a separate, high-risk mode. |
The flag changes the reviewer path and fixes the sandbox mode at workspace-write. If a prompt or script needs access outside the workspace, automatic review does not make that request harmless; it changes how an eligible request is evaluated. The settings and argument conflicts are defined in the source change that added the flag (PR #36373).
The official Codex sandboxing documentation describes the approval policies and sandbox modes. Read those settings together instead of treating “approve” and “sandbox” as synonyms.
Verify that the installed CLI supports the flag
Release availability and the binary installed on a machine can differ. Check the local help and version before adding the flag to a shared script:
codex --versioncodex --help | rg -- '--approve-for-me|--sandbox|--ask-for-approval'If --approve-for-me is absent, update the CLI through the package or distribution channel used by that environment. Do not silently replace it with an unrestricted bypass flag just to make the command start.
For a human-reviewed session, omit the new flag and keep the approval policy visible:
codex --sandbox workspace-write --ask-for-approval on-requestThe exact default policy can depend on the invocation context and configuration, so a team script should state the intended mode rather than rely on an inherited setting.
Handle non-interactive commands separately
The Codex 0.147.0 release also removes the deprecated codex exec --full-auto path. For a scripted exec task, use the documented sandbox option instead of carrying the old alias forward:
codex exec --sandbox workspace-write "Run the repository's read-only checks and summarize failures."That command still needs a task-appropriate policy. workspace-write permits the kind of repository edits many coding tasks require, but it does not mean that a script should be allowed to modify deployment credentials, system files, or unrelated directories. Keep destructive operations out of unattended prompts and review the exact command before adding automatic approval.
Add a small safety check to team workflows
Before enabling automatic review in CI or a shared development script, keep the task scope explicit in the prompt. The flag already applies workspace-write:
set -euo pipefail
codex --approve-for-me \ "Inspect the current workspace, make only the requested source changes, and run the listed tests."The wrapper should also define the working directory, avoid passing secrets in the prompt, and keep generated output inside a disposable checkout when the task is not fully trusted. Automatic review is a convenience for predictable work; it is not a substitute for narrowing the prompt or protecting the repository.
FAQ
Does --approve-for-me disable Codex’s sandbox?
No. It applies the workspace-write sandbox itself. Run codex --approve-for-me without adding --sandbox; it also conflicts with --dangerously-bypass-approvals-and-sandbox.
Why does Codex say --sandbox cannot be used with --approve-for-me?
The error comes from the CLI argument parser. Its clap declaration uses conflicts_with_all to prevent combining --approve-for-me with --sandbox or --dangerously-bypass-approvals-and-sandbox, because the flag already sets the workspace-write sandbox. Drop --sandbox and run codex --approve-for-me.
Is --approve-for-me the replacement for codex exec --full-auto?
Not exactly. The release removes the deprecated exec --full-auto path and documents codex exec --sandbox workspace-write for that workflow. --approve-for-me applies automatic review, on-request approvals, and the workspace-write sandbox together. Do not combine it with --sandbox.
Why does the flag work on one machine but not another?
The installed CLI versions or configuration may differ. Run codex --version and search the local help output before assuming that a shared wrapper is portable.
References: