Answer: Create a `.rules` file under a `rules/` folder next to an active config layer (for example, `~/.codex/rules/default.rules`), add a `prefix_rule` with a `pattern` and `decision` such as "prompt", then restart Codex. Status: Confirmed Entry: tool/codex/permissions-and-security/create-rules-file Revision: 1 Digest: sha256:601f842e72822bb8 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:47:08Z Last changed: 2026-11-13T03:47:08Z Last verified: 2026-11-20T13:34:45Z Next check: 2026-11-21T13:34:45Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of rules file location | ~/.codex/rules/default.rules | [1] | 2026-11-20 example pattern | ["gh", "pr", "view"] | [1] | 2026-11-20 example decision | prompt | [1] | 2026-11-20 final step | Restart Codex. | [1] | 2026-11-20 user layer path | ~/.codex/rules/ | [1] | 2026-11-20 project-local rules path | /.codex/rules/ | [1] | 2026-11-20 Sources: [1] OpenAI. "Rules". https://learn.chatgpt.com/docs/agent-configuration/rules.md Role: primary. Accessed: 2026-11-20T13:34:45Z Quote: "Create a `.rules` file under a `rules/` folder next to an active config layer (for example, `~/.codex/rules/default.rules`)." (Supports: rules file location) Quote: "pattern = ["gh", "pr", "view"]," (Supports: example pattern) Quote: "decision = "prompt"," (Supports: example decision) Quote: "3. Restart Codex." (Supports: final step) Quote: "the user layer at `~/.codex/rules/`" (Supports: user layer path) Quote: "Project-local rules under `/.codex/rules/` load only when the project `.codex/` layer is trusted." (Supports: project-local rules path) Snapshot SHA-256: b2c34d7dc85cff73b3706518370f373620713d4acf51c543aa01df958171e350 (captured 2026-11-13T03:47:08Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-13T03:47:08Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T13:34:45Z. No independent second source is configured for this entry Last successful check: 2026-11-20T13:34:45Z Last attempt: 2026-11-20T13:34:45Z Notes and limitations: Extracted automatically from a single official source (section "Create a rules file"). Related: https://latestn.com/tool/codex/permissions-and-security/create-service-account-access-token How do I create an access token for a Codex service account? https://latestn.com/tool/codex/permissions-and-security/default-sandbox-approval-settings What are the default sandbox and approval settings for Codex? https://latestn.com/tool/codex/permissions-and-security/define-select-permission-profile How do I define and select a permission profile in Codex? https://latestn.com/tool/codex/permissions-and-security/configure-severity-policy How do I configure a severity policy to enforce Codex Security scan results in GitHub Actions? https://latestn.com/tool/codex/permissions-and-security/configure-windows-sandbox How do I configure the Windows sandbox for Codex CLI? https://latestn.com/tool/codex/permissions-and-security/control-browser-computer-use How do I control browser and Computer Use access for Codex and ChatGPT Work? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-13T03:47:08Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/codex/permissions-and-security/create-rules-file/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/codex/permissions-and-security/create-rules-file POST: https://latestn.com/dispute/tool/codex/permissions-and-security/create-rules-file with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/codex/permissions-and-security/create-rules-file?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I create a rules file to control which commands Codex can run outside the sandbox? Revision 1, last verified 2026-11-20T13:34:45Z. https://latestn.com/tool/codex/permissions-and-security/create-rules-file (accessed 2026-11-21T10:00:02Z). @misc{LatestN_tool_codex_permissions_and_security_create_rules_file_r1, title = {How do I create a rules file to control which commands Codex can run outside the sandbox?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/codex/permissions-and-security/create-rules-file}}, note = {Revision 1; digest sha256:601f842e72822bb8; last verified 2026-11-20T13:34:45Z; accessed 2026-11-21T10:00:02Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/codex/permissions-and-security/create-rules-file