Codex: sandbox and approvals
Two separate settings decide what Codex may do on its own: the sandbox and the approval policy.
The two settings
read-only lets it read and explain but not edit. workspace-write lets it edit inside the project. danger-full-access removes the sandbox. untrusted asks before almost every command, on-request asks when it needs to go beyond the sandbox, never never asks.
Defaults that work day to day
Put them in ~/.codex/config.toml:
toml
sandbox_mode = "workspace-write"approval_policy = "on-request"
A project can override them in .codex/config.toml.
Per run
Flags win over the config file, for one run:
bash
codex --sandbox read-only # explore an unknown repo safelycodex exec --full-auto "Fix the failing test in @src/cart.ts"
--full-auto is shorthand for workspace-write with on-request approvals. codex exec runs once without the interactive UI.