How to use it
- Choose the sandbox mode and the approval policy.
workspace-writewithon-requestis the everyday setup. - Choose whether commands can reach the network. If they can, list the hosts instead of opening everything.
- Press Copy with header and save it as
~/.codex/config.toml, or as.codex/config.tomlin a project you trust. Pick Copy without header if you don't want the comment lines. - If you turned the rules on, save that file as
~/.codex/rules/default.rulesand restart Codex. You can test a rule withcodex execpolicy check. - Commit it with the suggested message so the next person knows where it came from.
Every key was checked against the official OpenAI docs on December 5, 2026: configuration reference, agent approvals and security, advanced configuration and rules. TOML allows comments, so the header goes in as comment lines. The rules file uses Starlark, which allows them too.
What it writes
sandbox_modeisread-onlyorworkspace-write.danger-full-accessis not offered.approval_policyison-requestornever. The retireduntrustedvalue is never written, and the docs say it can stop the client starting.sandbox_workspace_write.network_accessturns command networking on or off. With a host list,features.network_proxyholds the allowed hosts and keeps everything else out.web_searchiscached,disabledorlive.shell_environment_policysetsinherit = "core", turns on the automatic KEY, SECRET and TOKEN exclusions withignore_default_excludes = false, and drops a few named variables.- The rules file uses
prefix_rulewithdecision = "forbidden"or"prompt", and amatchexample the docs say Codex checks when it loads the file.
Honest limits
- Rules only decide commands Codex asks to run outside the sandbox. A command that runs inside it is limited by the sandbox, and the docs mark rules as experimental.
- The host allowlist filters commands Codex runs. The docs say it does not filter web search, apps or MCP servers, and the proxy feature is experimental.
- The sandbox limits what commands can do. It does not hide your files from reads inside the allowed area, so keep secrets out of the workspace.
approval_policy = "never"means Codex never stops to ask, so the sandbox is the only guard.- Settings change between Codex versions. Check the keys against the docs for your version. Educational, not a guarantee.
