Claude Code settings.json and Permissions: Locations, Precedence, allow/ask/deny and a Safe Team Default
Claude Code's settings.json decides which model a session starts with, which commands run without asking, which files are off limits, and which API endpoint it talks to. As of 2026-11-25 (Claude Code 2.1.3xx), settings live in four scopes: user, shared project, project local and managed. Precedence runs managed > command line > project local > shared project > user. Permission rules are checked in the order deny → ask → allow, and the first match wins. This guide checks each key against Anthropic's official docs and ends with a team default you can commit today. QCode is an independent third-party API service and is not affiliated with Anthropic.
Updated 2026-11-26
Key facts
- Four settings files:
~/.claude/settings.json(user),.claude/settings.json(shared project, committed),.claude/settings.local.json(project local, not committed) andmanaged-settings.json(organization). - List keys such as
permissions.allowmerge across files instead of overriding. A deny rule at any level can't be overridden by an allow anywhere else. defaultModeacceptsdefault(shown as Manual),acceptEdits,plan,auto,dontAskandbypassPermissions.autoandbypassPermissionsdon't take effect from project or local files.- In a project's
.claude/settings.json,permissions.allow,additionalDirectoriesand mostenvvalues wait until each teammate trusts the folder.denyandaskrules apply right away. - When you set
ANTHROPIC_BASE_URLin theenvblock, keep the key in user or local settings only, never in the committed project file.
Where the four settings files live
| Scope | File | Who it affects | Use it for |
|---|---|---|---|
| User | ~/.claude/settings.json |
You, in every project on this machine | Default model, theme, your own rules, API endpoint |
| Shared project | .claude/settings.json |
Everyone in the folder, once committed | Team permissions, hooks, plugins, project env vars |
| Project local | .claude/settings.local.json |
You, in this project only | Personal overrides, trying rules before sharing |
| Managed | managed-settings.json and other managed sources |
Every machine your organization deploys to | Security policy and compliance |
Managed file paths per Anthropic's docs: /Library/Application Support/ClaudeCode/managed-settings.json on macOS, /etc/claude-code/managed-settings.json on Linux and WSL, and C:\Program Files\ClaudeCode\managed-settings.json on Windows. A managed-settings.d/ folder of drop-in files can sit next to it.
On Windows, ~/.claude means %USERPROFILE%\.claude. There is also ~/.claude.json, which holds your account, MCP configuration and trust decisions. Claude Code maintains it, so you rarely edit it.
A small detail: when you choose "Yes, and don't ask again" on a permission prompt, Claude Code writes that allow rule to .claude/settings.local.json. The first time it writes the file it adds it to your global git excludes. If you created the file by hand, add it to .gitignore yourself.
Precedence: who wins
Highest first:
- Managed settings. Nothing in user, project or
--settingsoverrides them. - Command line. JSON passed with
claude --settings <file-or-json>, for that session only. - Project local,
.claude/settings.local.json. - Shared project,
.claude/settings.json. - User,
~/.claude/settings.json.
Three rules trip people up:
- Lists merge.
permissions.allowand similar lists combine entries from every level. Each level can add, but none can remove another level's entries. - Deny wins. If user settings allow something and project settings deny it, it's denied. A user-level deny also blocks a project-level allow.
- Environment variables sit outside the stack. An exported
ANTHROPIC_MODELbeats themodelkey in any file, and--modelbeats both.ANTHROPIC_DEFAULT_MODELapplies only when no file setsmodel.
permissions: writing allow, ask and deny
{
"permissions": {
"allow": ["Bash(npm run *)", "Bash(git diff *)"],
"ask": ["Bash(git push *)"],
"deny": ["Read(./.env)", "Read(./.env.*)", "Read(./secrets/**)"]
}
}
- allow runs without asking.
- ask prompts every time.
- deny blocks the call.
Evaluation goes deny → ask → allow, and the first match decides, however specific the rules are. A broad deny like Bash(aws *) therefore blocks a narrower allow like Bash(aws s3 ls). A deny that names only the tool, such as "Bash", removes that tool from Claude's context entirely.
Rule syntax cheat sheet
| Rule | Meaning |
|---|---|
Bash or Bash(*) |
Every shell command |
Bash(npm run build) |
That exact command only |
Bash(npm run *) |
Commands starting with npm run, including bare npm run |
Bash(ls:*) |
Older form equal to Bash(ls *); only valid at the end |
Read(./.env) |
.env in the current directory |
Edit(/src/**/*.ts) |
Path relative to the settings source (the project root in project settings) |
Read(~/.zshrc) |
A file in your home directory |
Read(//etc/hosts) |
An absolute filesystem path (two slashes) |
WebFetch(domain:example.com) |
Fetches to that host; add domain:*.example.com for subdomains |
mcp__github__* |
Every tool from the MCP server named github |
Agent(Explore) |
The Explore subagent |
Three details decide whether a rule really works:
- The space before
*matters.Bash(ls *)doesn't matchlsof;Bash(ls*)does.Bash(git diff*)would also allowgit diff-index. - Put
*after the subcommand.Bash(git *)allows every git subcommand, push included. To allow only log, writeBash(git log *). - Compound commands are split.
Bash(safe-cmd *)doesn't approvesafe-cmd && other-cmd, while deny and ask rules apply if any part matches. Rules match commands as written, soBash(git push *)doesn't catchgit -C . push.
A .claudeignore file has no effect; move its entries into Read deny rules. Also note that Read(./.env) stops the file tools and commands that name the file, but not a grep -r over the whole directory. For stricter isolation, add the sandbox settings.
defaultMode: which mode a session starts in
| Value | Behavior |
|---|---|
default |
Asks on first use of each tool (labeled Manual; manual is accepted as an alias) |
acceptEdits |
Auto-accepts file edits and common file commands like mkdir, touch, mv, cp inside the working directory |
plan |
Read-only exploration, no source edits |
auto |
A background classifier reviews shell commands and network requests, so routine prompts go away |
dontAsk |
Denies everything that would prompt and runs only pre-approved actions; good for locked-down CI |
bypassPermissions |
Skips almost every prompt; only for containers or VMs |
{ "permissions": { "defaultMode": "acceptEdits" } }
auto and bypassPermissions set in .claude/settings.json or .claude/settings.local.json don't take effect. Put them in user or managed settings, or pass --permission-mode at launch. To forbid these modes, set permissions.disableBypassPermissionsMode or permissions.disableAutoMode to "disable". They work from any scope, and in managed settings nobody can override them.
Auto mode is a Claude Code feature: a background classifier (by default claude-sonnet-5) reviews routine shell commands and network requests. If you rely on exact usage accounting, test a small request first; if you want fully predictable usage, use acceptEdits plus an explicit allow list for daily work.
The env block: setting the base URL in settings.json
Claude Code copies the variables under env straight into its process environment, so they apply however you launch it. A user-level example:
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"env": {
"ANTHROPIC_BASE_URL": "https://api.qcode.cc/api",
"ANTHROPIC_AUTH_TOKEN": "cr_your_key"
},
"model": "claude-sonnet-5-5"
}
Things to know:
- Keep the key in
~/.claude/settings.jsonor.claude/settings.local.json, never in the committed.claude/settings.json. The shared file can carryANTHROPIC_BASE_URL; each person's key goes in their own local file. - Drop
ANTHROPIC_API_KEY. With QCode keep onlyANTHROPIC_AUTH_TOKEN, which is sent as anAuthorization: Bearerheader. - Values aren't shell-expanded.
~and$HOMEstay as typed, so write absolute paths. - Conflicts with shell variables. If the same variable is set in both the
envblock and your shell, keep just one place to save yourself debugging time; if you must keep both, check which value Claude Code actually uses before you rely on it. - Alternate endpoints:
https://asia.qcode.cc/apifor Asia andhttps://us.qcode.cc/apifor North America / Europe.
model: default model and alias mapping
The model key sets the model for new sessions. It takes an alias (sonnet, opus, haiku) or a full model ID, and you can still switch mid-session with /model. To pin what each alias resolves to, set these in env:
{
"model": "sonnet",
"env": {
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5-5",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5"
}
}
ANTHROPIC_DEFAULT_HAIKU_MODEL also drives Claude Code's background tasks. Per QCode's /models page (read 2026-11-22; live prices win), official prices per million tokens are Sonnet 5.5 $2 / $10, Opus 5.5 $4 / $20 and Haiku 5.5 $0.10 / $0.50 for prompts up to 100K. To restrict which models a team can pick, use availableModels in managed settings.
A safe team default you can commit
This .claude/settings.json suits most Node.js repositories. Common read-only and test commands run freely, pushes and publishes need confirmation, sensitive files and risky commands are blocked, and bypass mode is off.
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"env": {
"ANTHROPIC_BASE_URL": "https://api.qcode.cc/api"
},
"permissions": {
"defaultMode": "default",
"allow": [
"Bash(npm run lint)",
"Bash(npm run test *)",
"Bash(git status)",
"Bash(git diff *)",
"Bash(git log *)"
],
"ask": [
"Bash(git push *)",
"Bash(npm publish *)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)",
"Bash(curl *)",
"Bash(rm -rf *)"
],
"disableBypassPermissionsMode": "disable"
}
}
Each teammate then puts their key and personal preferences in their own .claude/settings.local.json:
{
"env": { "ANTHROPIC_AUTH_TOKEN": "cr_personal_key" },
"permissions": { "defaultMode": "acceptEdits" }
}
After you commit, tell teammates that project allow rules start working once they open and trust the folder, while deny and ask rules apply immediately. Rules match commands as written: Bash(curl *) won't stop wget or a curl call inside a script, so pair it with the sandbox or hooks for that kind of risk.
In CI with claude -p, project allow rules don't apply and allow rules go on the command line. See Claude Code in GitHub Actions.
How to confirm the configuration loaded
- Run
/status: theSetting sourcesline lists every settings file loaded for this session. - Run
/permissions: it shows every rule and the file it came from, and you can add or remove rules mid-session. - Run
claude doctor: it lists rejected entries and JSON errors. - Settings files are strict JSON. A
//comment or a trailing comma is an error. The$schemaline gives you autocomplete and validation in your editor.
Most edits, including permissions and hooks, apply as soon as you save. A few keys such as model are read only at session start, so use /model or restart.
FAQ
What's the difference between settings.json and settings.local.json?
.claude/settings.json is committed and shared with the team. .claude/settings.local.json applies only to you in that project and stays out of git. When both set the same key, the local file wins.
Why isn't my allow rule working?
There are three usual causes: a deny or ask rule at some level matched first; the pattern doesn't match, often because of a missing space before *; or a project allow rule is waiting for you to trust the folder. Check rule sources with /permissions and errors with claude doctor.
Can I set defaultMode to auto in the project settings.json?
It won't take effect. auto and bypassPermissions only work from user or managed settings, and project or local values are ignored. You can also pass --permission-mode auto at launch.
Should ANTHROPIC_BASE_URL go in my shell or in settings.json?
If you only use Claude Code, the env block in ~/.claude/settings.json is simplest because it doesn't depend on how you launch. If other tools need the same endpoint, a shell export works too, but keep only one of the two so they don't fight.
Can someone else's allow rule override my deny?
No. A deny at any level beats every allow, including --allowedTools on the command line. A managed deny can't be changed even with --settings.
How do I stop Claude from reading .env files?
Add Read(./.env) and Read(./.env.*) to permissions.deny. .claudeignore has no effect. For directory-wide commands such as grep -r, add sandbox settings too.
How can a team share one model setting without exposing anyone's key?
Set model and ANTHROPIC_BASE_URL in the project's .claude/settings.json, and have each person put their own ANTHROPIC_AUTH_TOKEN in their local file. To enforce a model list, use availableModels in managed settings.
Using Claude Code every day?
If you code with Claude Code daily, QCode's Daily 35 plan gives you $35 of usage per day at official prices (×1.0 for Anthropic and OpenAI models), reset every day at 00:00 Beijing time, with one key for both the Anthropic and OpenAI protocols. Drop your key into the env block above and you're set. Personal plans start from $9 for 30 days; see /pricing.
Sources: Anthropic's Claude Code docs (settings, permissions, permission modes, environment variables, example settings and managed settings pages) and QCode's docs on permissions and environment variables, all read 2026-11-25.