Overview
Codify "safe actions the user has already explicitly approved" into Codex's approval configuration, so that the next time the same type of action is executed itno longer repeatedly prompts for confirmation, while avoiding expanding permissions into an uncontrollable scope.
Core idea:Only persist "actions that are confirmed safe and high-frequency", and use a minimal allowlist (reversible, auditable).
What counts as “approved”?
Refers only to: in the current session, the user has explicitly said "yes / authorize all / don't ask again / add to allowlist" for a certain type of operation.
Does not include:
- High-risk actions without explicit user authorization (deletion, executing unknown binaries, accessing sensitive directories, etc.)
- One-off temporary actions (unless the user requests persistence)
Where Codex stores approvals (this environment)
Usually two places need to be checked together:
-
Project trust level(project trust level)
- File:
~/.codex/config.toml - Key:
[projects."<path>"] trust_level = "trusted" | "untrusted"
- File:
-
Command allow rules(command allowlist)
- File:
~/.codex/rules/default.rules - Format:
prefix_rule(pattern=[...], decision="allow") - Meaning: when the command argv has
patternas its prefix, allow it directly
- File:
Note: this is a security boundary configuration on the user's machine. Any write must be explainable, revocable, and minimal.
Collaboration Rules (collaboration rules / security discipline)
Before writing the approval configuration, you must:
-
Propose first, then write to disk
- List the "candidate allowlist items" (each containing: purpose, risk, scope)
- Have the user confirm each item (YES/NO)
-
Minimize authorization
- Prefer allowlisting fixed scripts in the repository(for example
scripts/run_*.sh|ps1), do not directly allowlist/bin/bash -lc <任意命令> - Do not allowlist dangerous commands that take user input parameters (for example
rm -rf <path>), unless the path is fixed and safe - Avoid global paths (for example, setting
/mnt/e/developmentas trusted would cover too many repositories; prefer the repo root)
- Prefer allowlisting fixed scripts in the repository(for example
-
Reversible
- Back up before modifying:
cp ~/.codex/rules/default.rules ~/.codex/rules/default.rules.bakcp ~/.codex/config.toml ~/.codex/config.toml.bak
- Add only a small number of rules each time (1–5), and verify them before continuing
- Back up before modifying:
-
Verifiable
- After writing, immediately execute once an action that "would originally trigger approval" and confirm it now passes silently
-
Do not fabricate
- Do not guess what the user wants to authorize; only derive rules from behaviors "the user has explicitly approved"
How to extract “already approved actions” (practical workflow)
Step 1 — Build a candidate list during the session
When an approval prompt appears and the user approves, immediately record a candidate item:
- Action name: for example "Run headless Godot tests"
- Exact command argv(or more preferably: guide them to change it to a fixed script and then allowlist the script)
- Scope: Only allow in this repository? Only allow a certain fixed parameter combination?
- Why safe: Why is this safe/controllable/high-frequency
Step 2 — Normalize to a stable allow pattern
Priority (from safe to dangerous):
- allowlist:
scripts/<fixed entrypoint>(strongly recommended) - allowlist:
git push/git statuslow-risk fixed subcommands like these - allowlist: fixed binary + fixed parameter prefix (requires caution)
- Forbidden:
/bin/bash -lc "<anything>"(scope too large)
Step 3 — Present proposal + get confirmation
Use a table to have the user confirm each item (YES/NO), example:
| Candidate | Pattern | Why | Risk | Persist? |
|---|---|---|---|---|
| Run tests | ["scripts/run_godot_tests.ps1"] |
CI-equivalent | low | YES |
Step 4 — Write config + verify
- Append
prefix_rule(...)to~/.codex/rules/default.rules - If the repository needs to be trusted, write the
~/.codex/config.tomlof[projects."<repo-root>"] trust_level="trusted" - Run a verification command once (it should no longer prompt for approval)
Checklist (execution checklist)
- List in this sessionRepeated occurrencesof approval points (commands/actions)
- For each candidate, write: purpose / risk / minimal pattern / whether it can be changed to a fixed script
- Have the user confirm each item one by one with YES/NO
- Backup:
-
cp ~/.codex/rules/default.rules ~/.codex/rules/default.rules.bak -
cp ~/.codex/config.toml ~/.codex/config.toml.bak
-
- Small-step writes (1–5 rules)
- Immediately verify once an action that "would originally trigger approval"
- If unexpected permission granting/mismatch occurs: roll back immediately
.bakand re-converge the pattern
Red Flags (stop when you see them)
- "Just set everything to trusted / allow all, to save trouble"
- "Create a wildcard allowlist for /bin/bash -lc"
- "Add a rule for rm -rf *"
- "Write to disk without having the user confirm each item one by one"
Example: Safe patterns for this repo (Reference)
It is recommended to prioritize allowlisting fixed scripts rather than the Godot binary itself:
- Windows:
scripts\\run_godot_tests.ps1
- WSL/Linux:
- First wrap a
scripts/run_godot_tests_linux.sh(fixedGODOT_LINUX_EXE), then allowlist this script
- First wrap a
Outcome
What you ultimately deliver is:
- Fewer repeated approval pop-ups
- A permission boundary that is not amplified (minimal allowlist + rollback-capable + verifiable)
- A reproducible collaboration process (proposal → item-by-item confirmation → write to disk → verification)