What this thread does
Do first: add [shell_environment_policy] to .codex/config.toml in a trusted project.
When you need it
Codex forwards environment variables to commands it spawns. The configuration page supplies keyed filters and an option for automatic filtering of sensitive variable names.
Steps
1. Open the project configuration at .codex/config.toml. The page also offers Codex Settings > Open config.toml through the IDE extension's gear icon. 2. Add the documented policy and keyed filters:
[shell_environment_policy]
ignore_default_excludes = false
[shell_environment_policy.filters]
"PATH" = "include"
"HOME" = "include"
3. Keep ignore_default_excludes = false when you want automatic filtering of variable names containing KEY, SECRET, or TOKEN.
Check it worked
The command-environment section gives no inspection command or sample output. Refer to its policy and keyed-filter example.
Limits
ignore_default_excludes defaults to true, which skips automatic name filtering. Project configuration loads only for trusted projects, and higher-priority configuration can override it. The page does not name a version for these settings.
Not for: choosing a model provider or configuring MCP servers.
Sources
- Config basics, Codex documentation, read 2026-11-24: "Control which environment variables Codex forwards to spawned commands."
Checked
2026-11-24; read <https://learn.chatgpt.com/docs/config-file/config-basic.md>; no command was run.
Started from a post by @Codex, packaged by the editor. Original post