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 are, from the chapter on permissions and approval modes. Here you will learn where each tool keeps its settings, which file wins when two disagree, and how to commit safe defaults to a repository.
Why settings files matter
Permission prompts are tiring. If you answer "yes" to npm test fifty times a day, you will eventually stop reading the prompts. Settings files let you decide once which actions are always allowed, which are always blocked, and which need a question. They also make the rules reviewable, because a file in a repository can be read in a pull request and a clicked button cannot.
Keep two ideas apart:
- Instruction files (CLAUDE.md, AGENTS.md) tell the model what to do. The model can ignore or misread them.
- Settings files tell the tool what it may do. The tool enforces them, regardless of what the model wants.
Claude Code: layered JSON
Claude Code reads JSON settings from several scopes:
| Scope | Typical location | Shared with the team? |
|---|---|---|
| User | `~/.claude/settings.json` | No, applies to all your projects |
| Project | `.claude/settings.json` | Yes, committed to git |
| Local project | `.claude/settings.local.json` | No, for your own overrides in this repository |
| Managed | A system path set by an administrator | Enforced by the organization |
The permission rules go under a permissions key. Rules have the form Tool(pattern).
{
"permissions": {
"allow": [
"Bash(npm run test:*)"
],
"deny": [
"Read(./.env)"
]
}
}The allow rule lets any command starting with npm run test: run without a prompt. The deny rule blocks reads of .env. Deny rules take priority over allow rules, so you can allow a broad pattern and carve out exceptions. Claude Code also supports an ask list for actions that should always prompt.
When scopes disagree, the more specific or more authoritative one wins. Managed settings override everything, command-line flags come next, then local project, shared project, and user settings.
Put team rules in .claude/settings.json and commit it. Put personal tweaks in .claude/settings.local.json, and add that file to .gitignore so it stays out of the repository. Claude Code normally does this for you when it creates the file, but check.
Codex CLI: one TOML file with profiles
Codex CLI keeps its settings in ~/.codex/config.toml. Two keys control safety:
# ~/.codex/config.toml
approval_policy = "on-request"
sandbox_mode = "workspace-write"approval_policydecides when Codex stops to ask. Common values areuntrusted(ask before running anything not known to be safe),on-request(the model decides when to ask),on-failure(ask only after a sandboxed command fails), andnever.sandbox_modedecides what the operating system lets the process touch. The values areread-only,workspace-write, anddanger-full-access.
The two settings are independent. approval_policy is a question the tool asks you. sandbox_mode is a wall the operating system enforces. A combination such as never with workspace-write runs without prompts but still cannot write outside the workspace. never with danger-full-access removes both protections, so reserve it for disposable environments.
Codex also supports named profiles, so you can switch between a cautious setup and a faster one:
approval_policy = "on-request"
sandbox_mode = "workspace-write"
[profiles.review]
approval_policy = "untrusted"
sandbox_mode = "read-only"Start the cautious profile with codex --profile review. You can also override a single key for one run with -c, for example codex -c sandbox_mode=read-only. Command-line values beat the file.
Codex reads project guidance from AGENTS.md. The TOML file does not hold instructions, only behavior.
Copilot CLI: a user config directory and per-run flags
Copilot CLI stores its user-level settings under ~/.copilot/. A config.json file there holds preferences such as the model and the folders you have chosen to trust, and MCP servers are configured in a separate file in the same directory. The set of keys has changed between releases, so check the current documentation or the in-session /help output before copying a configuration from a blog post.
Copilot CLI leans more on flags for tool permissions than on a committed file. You can pre-approve or block tools for a run with --allow-tool and --deny-tool, which makes the permission choice visible in the script or alias that launches it. Repository instructions come from .github/copilot-instructions.md, and Copilot CLI also reads AGENTS.md.
Comparing the three approaches
| Question | Claude Code | Codex CLI | Copilot CLI |
|---|---|---|---|
| Format | JSON | TOML | JSON |
| Project-level committed file | `.claude/settings.json` | Mainly AGENTS.md plus user config | Instruction file plus flags |
| Personal override file | `.claude/settings.local.json` | Profiles and `-c` overrides | Flags and user config |
| Fine-grained command rules | `allow` / `ask` / `deny` patterns | Approval policy and sandbox mode | `--allow-tool` / `--deny-tool` |
Claude Code gives you pattern-level rules per tool. Codex gives you two coarse dials, approval and sandbox, that the operating system backs up.
Common errors
- Putting secrets in a committed settings file. Environment values and tokens belong in your shell or a secret store, not in
.claude/settings.json. - Relying on
denyto hide secrets while allowing broad shell access. A deniedRead(./.env)does not stop an allowed shell command from printing the file withcat. Pair deny rules with a sandbox or with narrow shell allow rules. - Over-broad allow patterns.
Bash(npm:*)also allowsnpm publish. Allownpm run test:*instead. - Editing the wrong scope. If a rule seems ignored, check whether a higher-precedence file or a command-line flag overrides it.
- Assuming a setting is enforced when it is advice. Only the tool and the operating system enforce settings. Text in an instruction file does not.
Workflow for a new repository
- Start with the defaults and note which prompts you answer "yes" to every time.
- Add those exact commands, such as the test and lint commands, to the allow list in the shared project settings.
- Add a deny rule for secrets and for generated directories.
- Commit the settings file and review it like code.
- Keep experiments in your local or profile-level override.
Exercise
Your team's .claude/settings.json allows Bash(npm run test:*). You want Claude Code to skip prompts for a longer script that only you use, without changing what your teammates get. Where do you put the rule, and why?
Show answer
Put it in .claude/settings.local.json, or in your user-level ~/.claude/settings.json if it applies to all projects. The shared project file is committed, so a change there affects the whole team. The local file stays out of git, and the tool merges it with the shared rules.
Exercise
A Codex CLI config has approval_policy = "never" and sandbox_mode = "workspace-write". Can the agent delete files in your home directory outside the project? Explain.
Show answer
No, in the normal case. never removes the approval prompts, but the workspace-write sandbox is enforced by the operating system and limits writes to the workspace. Changing sandbox_mode to danger-full-access would remove that limit.