config-advanced.md +38 −4
84 84
85In addition to your user config, Codex reads project-scoped overrides from `.codex/config.toml` files inside your repo. Codex walks from the project root to your current working directory and loads every `.codex/config.toml` it finds. If multiple files define the same key, the closest file to your working directory wins.85In addition to your user config, Codex reads project-scoped overrides from `.codex/config.toml` files inside your repo. Codex walks from the project root to your current working directory and loads every `.codex/config.toml` it finds. If multiple files define the same key, the closest file to your working directory wins.
86 86
8787For security, Codex loads project-scoped config files only when the project is trusted. If the project is untrusted, Codex ignores `.codex/config.toml` files in the project.For security, Codex loads project-scoped config files only when the project is trusted. If the project is untrusted, Codex ignores project `.codex/` layers, including `.codex/config.toml`, project-local hooks, and project-local rules. User and system layers remain separate and still load.
88 88
89Relative paths inside a project config (for example, `model_instructions_file`) are resolved relative to the `.codex/` folder that contains the `config.toml`.89Relative paths inside a project config (for example, `model_instructions_file`) are resolved relative to the `.codex/` folder that contains the `config.toml`.
90 90
91## Hooks (experimental)91## Hooks (experimental)
92 92
9393Codex can also load lifecycle hooks from `hooks.json` files that sit next toCodex can also load lifecycle hooks from either `hooks.json` files or inline
9494active config layers.`[hooks]` tables in `config.toml` files that sit next to active config layers.
95 95
96In practice, the two most useful locations are:96In practice, the two most useful locations are:
97 97
98- `~/.codex/hooks.json`98- `~/.codex/hooks.json`
99- `~/.codex/config.toml`
99- `<repo>/.codex/hooks.json`100- `<repo>/.codex/hooks.json`
101- `<repo>/.codex/config.toml`
102
103Project-local hooks load only when the project `.codex/` layer is trusted.
104User-level hooks remain independent of project trust.
100 105
101Turn hooks on with:106Turn hooks on with:
102 107
105codex_hooks = true110codex_hooks = true
106```111```
107 112
113Inline TOML hooks use the same event structure as `hooks.json`:
114
115```toml
116[[hooks.PreToolUse]]
117matcher = "^Bash$"
118
119[[hooks.PreToolUse.hooks]]
120type = "command"
121command = '/usr/bin/python3 "$(git rev-parse --show-toplevel)/.codex/hooks/pre_tool_use_policy.py"'
122timeout = 30
123statusMessage = "Checking Bash command"
124```
125
126If a single layer contains both `hooks.json` and inline `[hooks]`, Codex loads
127both and warns. Prefer one representation per layer.
128
108For the current event list, input fields, output behavior, and limitations, see129For the current event list, input fields, output behavior, and limitations, see
109[Hooks](https://developers.openai.com/codex/hooks).130[Hooks](https://developers.openai.com/codex/hooks).
110 131
230 251
231You can also use a granular approval policy (`approval_policy = { granular = { ... } }`) to allow or auto-reject individual prompt categories. This is useful when you want normal interactive approvals for some cases but want others, such as `request_permissions` or skill-script prompts, to fail closed automatically.252You can also use a granular approval policy (`approval_policy = { granular = { ... } }`) to allow or auto-reject individual prompt categories. This is useful when you want normal interactive approvals for some cases but want others, such as `request_permissions` or skill-script prompts, to fail closed automatically.
232 253
233254```Set `approvals_reviewer = "auto_review"` to route eligible interactive approval
255requests through automatic review. This changes the reviewer, not the sandbox
256boundary.
257
258Use `[auto_review].policy` for local reviewer policy instructions. Managed
259`guardian_policy_config` takes precedence.
260
261```toml
234approval_policy = "untrusted" # Other options: on-request, never, or { granular = { ... } }262approval_policy = "untrusted" # Other options: on-request, never, or { granular = { ... } }
263approvals_reviewer = "user" # Or "auto_review" for automatic review
235sandbox_mode = "workspace-write"264sandbox_mode = "workspace-write"
236allow_login_shell = false # Optional hardening: disallow login shells for shell tools265allow_login_shell = false # Optional hardening: disallow login shells for shell tools
237 266
249exclude_slash_tmp = false # Allow /tmp278exclude_slash_tmp = false # Allow /tmp
250writable_roots = ["/Users/YOU/.pyenv/shims"]279writable_roots = ["/Users/YOU/.pyenv/shims"]
251network_access = false # Opt in to outbound network280network_access = false # Opt in to outbound network
281
282[auto_review]
283policy = """
284Use your organization's automatic review policy.
285"""
252```286```
253 287
254Need the complete key list (including profile-scoped overrides and requirements constraints)? See [Configuration Reference](https://developers.openai.com/codex/config-reference) and [Managed configuration](https://developers.openai.com/codex/enterprise/managed-configuration).288Need the complete key list (including profile-scoped overrides and requirements constraints)? See [Configuration Reference](https://developers.openai.com/codex/config-reference) and [Managed configuration](https://developers.openai.com/codex/enterprise/managed-configuration).