Sub topic 11
Configuring each tool with settings files
This chapter assumes you can edit JSON and TOML files, and that you know what permission prompts and sandboxes are from the previous chapters. Settings files make those choices repeatable. Instead of answering the same prompt every session, you write the decision down once.
Why settings files matter
Every tool starts with defaults that ask often. That is safe, but slow for routine work such as running tests. A settings file lets you pre-approve low-risk actions, block sensitive ones, and share the result with your team.
Each tool has its own format and location. The ideas are similar, but the key names are not interchangeable.
Claude Code: .claude/settings.json
Claude Code reads JSON settings. A file inside the project's .claude/ directory applies to that repository, so it can be committed and shared.
{
"permissions": {
"allow": [
"Bash(npm run test:*)"
],
"deny": [
"Read(./.env)"
]
}
}The allow list runs matching commands without asking. Here, any npm run test variant is approved. The deny list blocks matching actions entirely, so the agent cannot read .env even if you would otherwise approve the request.
Rules take the form Tool(pattern). Keep patterns narrow. Bash(npm run test:*) is safe. A broad rule such as allowing all Bash commands removes the safety check.
Codex CLI: ~/.codex/config.toml
Codex CLI reads TOML from your home directory. Two settings do most of the work.
# ~/.codex/config.toml
approval_policy = "on-request"
sandbox_mode = "workspace-write"approval_policycontrols when the agent must stop and ask you.on-requestlets the agent decide when to ask.sandbox_modelimits what commands can touch.workspace-writeallows writes inside the project folder and blocks them elsewhere.
These two settings are independent. The sandbox sets the boundary, and the approval policy sets when the agent asks to step outside it.
Copilot CLI
Copilot CLI also keeps settings and permission choices in configuration files. Its key names and file locations differ from the two tools above and can change between releases. Check copilot --help and the official documentation for your installed version before copying settings from another tool.
Comparing the three
| Tool | Format | Typical location | What you control |
|---|---|---|---|
| Claude Code | JSON | `.claude/settings.json` | Allow and deny rules per tool |
| Codex CLI | TOML | `~/.codex/config.toml` | Approval policy and sandbox mode |
| Copilot CLI | See documentation | See documentation | Permissions for tools and paths |
Common mistakes
- Putting secrets in a committed settings file. Settings should hold rules, not keys.
- Writing wide allow rules for convenience. Start narrow and add rules as you see repeated prompts.
- Assuming a setting from one tool works in another. Unknown keys are often ignored without a warning, so you may think a protection is active when it is not.
- Relying on
denyalone for secrets. Also keep secrets out of the repository.
Exercise
In the Claude Code example, what happens if the agent tries to read ./.env, and why does a matching allow rule not change that?
Show answer
The read is blocked. Deny rules are checked first, so a matching deny rule stops the action even if an allow rule would also match.
Exercise
In Codex CLI, which setting decides where commands can write files, and which decides when the agent asks you?
Show answer
sandbox_mode decides where commands can write (for example, only in the workspace). approval_policy decides when the agent asks you.