Codex: Manage Sandbox, exec, Review, and Worktrees
The approval policy answers when Codex must stop, sandbox mode limits the process's access, and a worktree isolates the Git checkout. For CI the non-interactive codex exec is used with predefined rights.
Documented flag combinations set the level of autonomy for the task.
Task · Combination · Meaning
- Research - --sandbox read-only --ask-for-approval on-request; Reading; a change or step beyond the boundary needs a decision
- A normal local task - --sandbox workspace-write --ask-for-approval on-request; Writes to the workspace, network off until explicitly configured
- Read-only CI - --sandbox read-only --ask-for-approval never; No interactive prompts and no writes
- A changing non-interactive run - codex exec --sandbox workspace-write; Explicitly allowed writes for automation
One detail is worth stressing: the current official documentation marks the old codex exec --full-auto as a deprecated compatibility path and recommends the explicit --sandbox workspace-write. Network for workspace-write is off by default, and enabling it is a separate decision, not a side effect.
Review is a separate command. /review runs a focused code review without changing the worktree and can check the current changes, a base branch, or a commit; team-specific criteria are kept in the repository and referenced from AGENTS.md. Review should get the diff and the acceptance contract, not just "find problems." A worktree gives the task its own files and branch state - useful for parallel tasks and risky refactors - but it doesn't limit network, credentials, or external services, so sandbox and permission policy remain.
Full access - only inside another verified boundary. The flag--dangerously-bypass-approvals-and-sandboxand the alias--yoloturn off both protections; the docs mark the mode as dangerous. Use it only if an external container or VM already gives the needed isolation and the scope is fully understood.
Codex is covered. The next product is built around the explore, plan, implement, commit loop - that's Claude Code.