In short.
This guide helps developers using Codex and administrators control which commands Codex may run outside its sandbox, but the feature is experimental and command structure affects matching. It explains exact argument-prefix rules, configuration loading, approval behavior, shell-wrapper handling and rule inspection. Local Codex files and managed Work Cloud configuration have different requirements. No commands were executed; runtime enforcement, version compatibility and costs are not assessed.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage includes the complete selected page at [https://learn.chatgpt.com/docs/agent-configuration/rules.md]. It includes the experimental notice, local and managed configuration distinctions, rule fields, shell handling, setup and inspection examples. Linked pages, including managed configuration, the configuration reference, Team Config, the documentation index and the Starlark specification, are excluded. No commands were executed, and runtime behavior, installation compatibility and security effectiveness were not assessed.
The overview
Resource identity
Rules is a documentation page about controlling which commands Codex can run outside its sandbox. The resource is the guide itself, rather than a separate tool or ready-made policy package. Its source address is [https://learn.chatgpt.com/docs/agent-configuration/rules.md].
Practical assessment
The guide is useful for turning recurring command-approval decisions into explicit rules. Its strongest practical details are argument-order examples, precedence between conflicting decisions and the distinction between simple and complex shell scripts. It supports drafting and inspecting rules, but supplies no execution results establishing enforcement in a particular installation.
Intended users
Developers using local Codex can use this guide to configure repeatable command permissions. Administrators can use its discussion of shared configuration and enforced restrictions. Beginners will need familiarity with command arguments and configuration files; experienced developers get details about prefix matching and shell parsing.
Documented capabilities
A prefix_rule can allow a matching command outside the sandbox without prompting, require approval for each invocation or forbid the request. Patterns accept literal arguments and alternatives at individual argument positions. Optional justifications explain decisions, while match and not_match examples are validated when rules load.
The documented inspection command reports the strictest decision and matching rules as JSON. Multiple --rules flags combine files, and --pretty formats the output.
Using it
Requirements and configuration boundaries
Local Codex loads .rules files from rules/ directories beside active configuration layers. Project rules under <repo>/.codex/rules/ load only when the project's .codex/ layer is trusted. The page does not specify a minimum Codex version or operating-system requirements.
For Local computer access with Work Cloud, the page directs users to the managed rules TOML field in Agent Security and warns against assuming local rule files are read. Those managed rules apply to local executors; Work cloud containers use existing Work Cloud policies. The linked configuration requirements are outside this page.
How matching works
Rules compare a pattern with the beginning of the command's argument list. Argument order therefore matters. The default decision is allow; when multiple rules match, forbidden takes precedence over prompt, which takes precedence over allow.
For supported shell wrappers containing simple command chains, Codex uses tree-sitter to split the script and evaluates the individual commands, taking the strictest result. Scripts with redirection, substitutions, environment assignments, wildcards or control flow are instead evaluated as one complete shell invocation. A rule for an inner command therefore does not receive the same per-command treatment in those cases.
The rules language is Starlark. The page describes its syntax as similar to Python and its execution as having no side effects such as filesystem access.
Documented setup
Create a .rules file in a rules/ directory beside an active configuration layer, such as ~/.codex/rules/default.rules. Add a prefix_rule with a nonempty pattern, choose its decision and include representative match and not_match examples. Restart Codex so it scans the configuration layers.
Adding a command to the allow list through the terminal interface writes to ~/.codex/rules/default.rules. Smart approvals, described as enabled by default, may suggest a prefix_rule during escalation; the guide advises reviewing the proposed prefix carefully.
Command approval example
The page's example uses pattern ["gh", "pr", "view"] with decision "prompt". It matches gh pr view 7888 and gh pr view --repo openai/codex. It does not match gh pr --repo openai/codex view 7888, because the argument sequence no longer starts with the configured prefix.
The documented inspection command is: codex execpolicy check --pretty --rules ~/.codex/rules/default.rules -- gh pr view 7888 --json title,body,comments. The page says this returns JSON describing the strictest decision and matching rules. No output from this command was observed.
Assessment & evidence
Limitations
Rules are explicitly experimental and may change. Exact-prefix matching is sensitive to argument placement, and complex shell scripts are evaluated as whole wrapper invocations. Configuration behavior also differs between local Codex and managed Work Cloud environments.
The page does not establish comprehensive security coverage, compatibility with a specific installed version or performance overhead. Nothing was executed, so configuration loading, example validation and actual command enforcement remain unassessed.
When the guide fits
The documented mechanism fits situations where command prefixes are predictable and the desired approval behavior can be stated explicitly. This follows from its argument-prefix matching model. It requires more care when equivalent commands use different argument orders or shell features that prevent splitting.
The loading examples and inspection command make the guide useful for preparing a configuration. They do not demonstrate that a particular policy covers every way an action could be expressed.
Other documented approaches
Alongside editing local files, the page describes persistent allow-list additions through the terminal interface and administrator-enforced restrictive prefix_rule entries in requirements.toml. For Local computer access with Work Cloud, it points to managed Agent Security configuration. These are different configuration routes; the page does not compare alternative products.
Evidence and source scope
The evidence is the complete Rules page at [https://learn.chatgpt.com/docs/agent-configuration/rules.md], retained as selected-page.txt. Its source revision is sha256:b2c34d7dc85cff73b3706518370f373620713d4acf51c543aa01df958171e350.
The page supplies configuration syntax, examples and descriptions of behavior. Linked documentation, implementation code and runtime results are outside the evidence.
Access & freshness
Costs and access
The page provides no pricing, billing or plan-entitlement information. Costs for Codex access and any managed Work Cloud features are unknown from this evidence.
Usage and redistribution rights
The supplied page states no license or redistribution terms for its documentation or configuration examples. Those rights are unknown from this evidence.
Freshness and version uncertainty
The supplied snapshot was captured on 14 November 2026 at 10:57:01 UTC. The page text gives no publication date, update date or supported Codex version. Its experimental notice means the documented behavior should be checked against the version being configured.
Suggested next steps
Identify whether the target environment uses local Codex files or managed Work Cloud configuration. For local rules, choose narrow command prefixes and add examples covering intended matches and excluded argument orders. Remember that bash -lc, sh -c and similar scripts that use redirection, substitutions, variables, wildcards or control flow are checked as one whole invocation, so a prefix rule for an inner command does not match that wrapper invocation. The page does not say how match and not_match examples or execpolicy check handle shell wrappers.
Use the documented execpolicy check command to inspect decisions before relying on the configuration, then restart Codex to load file changes. Review suggested prefixes before accepting them and recheck behavior after relevant updates.
