Make the list of auto-approved commands configurable via `execpolicy`
Resolved 💬 8 comments Opened Jun 6, 2025 by bolinfest Closed Jan 11, 2026
💡 Likely answer: A maintainer (polyrand, contributor)
responded on this thread — see the highlighted reply below.
This is a highly requested feature. https://github.com/openai/codex/blob/main/codex-rs/execpolicy/README.md explains the bones of what we have today, though this logic needs to be polished and wrapped up in a way that is easy for end-users to take advantage of.
8 Comments
I believe this is a much-needed feature. While this gets polished and made available to users, maybe allowing to pass custom Starlark
.policyfiles when runningcodexcould be a good starting point?Cursor CLI has a nice UI for choosing which tools to allow:
<img width="823" height="145" alt="Image" src="https://github.com/user-attachments/assets/78138cd1-4d1d-4908-a352-4ebc28567561" />
How can one create an allowed tools list as in claude code?
Thought I would use Codex CLI to migrate some tests to use Testcontainers. Really want to be able to let the sandbox interact with docker!
Would love to have this implemented!
The recent PR #7033 by @zhao-oai adds a version of prefix allowance during TUI execution, it would be awesome to configure a pre-approved list of prefix commands before execution. Anyone is working on this?
Recently noticed that:
it's getting the wrong prefix selection. I would like to set everything before the first quotes to be auto-approved. @zhao-oai was this intentional?
(p)is also harder to reach than(a)(it was "always approve this command (a)" before)Thanks for the work on the rules feature! I think this issue can be closed - no
config.tomlchanges are needed since prefix-based auto-approval already works via rules files.Here's docs for future people who stumble upon this issue thread:
How to use prefix-based auto-approval today
The feature exists via rules files (landed in PR #6641, refined in #7888 and #8453).
Setup
Place
.rulesfiles in one of:~/.codex/rules/*.rules(global).codex/rules/*.rules(project-level)Example rule
This auto-approves any command starting with
git add(e.g.,git add .,git add -p file.txt).How matching works
patternmust match a command argument in ordercodex execpolicy check --rules <path> <command>to test rulesCommon patterns
Parser caveat: environment variables
Bare env assignments like
PGPASSWORD=... psql ...are parsed as a single token, not separate arguments. This causes prefix matching to capture the whole command as one "word".Workaround 1: Use
envexplicitlyWorkaround 2: Set environment in config, approve command only
Testing your rules
Related issues
Notes on my proposal in #9006
My simpler config-based approach (
[execpolicy].auto_allow_prefixes = [...]) was proposed but not merged due to the above. Use the rules files.Thank you for your time.