Codex CLI: approval and sandbox modes (and what --yolo does)
How do I make Codex run commands without asking?
Codex combines an approval policy (--ask-for-approval: on-request or never) with a sandbox (--sandbox: read-only, workspace-write or danger-full-access). --dangerously-bypass-approvals-and-sandbox, alias --yolo, removes both. Use /permissions in a session to change them.
Compare: allow all commands in every AI coding agent →
Sandbox modes
- workspace-write (default in version-controlled folders; others start read-only): read files, edit the workspace and run commands; edits outside it and network access need approval.
- read-only: read files and run commands within sandbox limits.
- danger-full-access: no sandbox. Not recommended.
Approval policy
- on-request: you approve actions that go outside the sandbox.
- never: no approval prompts.
~/.codex/config.toml
approval_policy = "on-request" sandbox_mode = "workspace-write"
Hands-off without --yolo
--full-auto has been removed from codex exec. For unattended runs, Codex recommends codex exec with --sandbox workspace-write, which keeps the sandbox while skipping prompts for work inside the workspace.
Sources
More Codex guides
- Configure Codex with config.toml
- Codex AGENTS.md: global, project and override instruction files explained
- Codex MCP servers: codex mcp add and [mcp_servers] in config.toml
- Codex sandbox modes: read-only, workspace-write, danger-full-access and network access
- codex exec: run Codex non-interactively in scripts and CI with JSON output
- Codex skills: create SKILL.md, skill folder locations and $skill invocation
- Codex hooks: hooks.json, PreToolUse allow/deny, exit code 2 and config.toml [hooks]
Reviewed Oct 18, 2026. Settings change often; the linked vendor docs are the source of truth.
Built an MCP server? Get it listed everywhere →
Shipping an Android app? Google Play needs 12 testers for 14 days first. Get them with Tester Exchange →