Claude Code settings.json: file locations, precedence, keys
Where Claude Code's settings.json files live (user, project, local, managed), which wins, permission rule syntax, common keys, and checking what loaded.
Claude Code reads four settings files. ~/.claude/settings.json is yours, for every project. .claude/settings.json in a project is shared with whoever clones it. .claude/settings.local.json is yours for one project and stays out of git. A managed-settings.json from your organization sits in a system folder (/etc/claude-code/ on Linux). Highest wins: managed, then --settings on the command line, then local, then the shared project file, then your user file. Lists such as permissions.allow are combined across files rather than replaced, and a deny rule anywhere beats an allow anywhere. Run /status to see which files loaded. MCP servers and your account live in a different file, ~/.claude.json. As of November 2026 (Claude Code 2.1.331).
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"model": "claude-sonnet-5-5",
"permissions": {
"allow": ["Bash(npm run *)", "Bash(git diff *)"],
"ask": ["Bash(git push *)"],
"deny": ["Read(./.env)", "Read(./.env.*)", "Read(./secrets/**)"]
}
}CopiedThe four files and who they affect
| Scope | File | Applies to |
|---|---|---|
User | ~/.claude/settings.json | You, in every project on this machine |
Shared project | .claude/settings.json | Everyone working in that folder; commit it so teammates get it |
Project local | .claude/settings.local.json | You, in this one project |
Managed (Linux, WSL) | /etc/claude-code/managed-settings.json | Everyone the organization deploys it to |
Managed (macOS) | /Library/Application Support/ClaudeCode/managed-settings.json | The same |
Managed (Windows) | C:\Program Files\ClaudeCode\managed-settings.json | The same |
Installing Claude Code creates none of them. Claude Code writes your user file the first time you save a preference such as the theme, and writes the local file the first time you answer a permission prompt with “Yes, and don’t ask again”. When it creates the local file in a git repository, it adds **/.claude/settings.local.json to your global git excludes, so it stays out of every repository’s commits; if you create the file by hand, add it to .gitignore yourself. On Windows ~/.claude means %USERPROFILE%\.claude, and setting CLAUDE_CONFIG_DIR moves the home-directory files elsewhere. Managed settings can also arrive through MDM or from the claude.ai admin console instead of a file. Everything here is from Anthropic’s settings page and managed settings page.
Two location details catch people out. The shared .claude/settings.json is read from the folder you start Claude Code in, with no search of parent folders, so a file committed at the repository root applies only when you start there. The local file is the opposite: since v2.1.211 Claude Code reads and writes it at the git repository root even when you start in a subfolder, and in a worktree at the main checkout’s root. It stays beside the shared file outside a git repository, on Windows, when the repository root is your home folder, or when the root or its .git or .claude is not owned by your user.
Which value wins
Highest precedence first:
1. Managed settings (file, MDM or the claude.ai console)
2. --settings <file-or-json> on the command line, this session only
3. .claude/settings.local.json
4. .claude/settings.json
5. ~/.claude/settings.jsonCopiedNothing you set overrides a managed key. A key you set with --settings lasts one session and writes no file:
claude --settings '{"model": "claude-opus-5-5"}'CopiedEnvironment variables are not a level in this stack; each pair is decided on its own. For the model, ANTHROPIC_MODEL exported in your shell beats the model key in any file, and --model beats both.
List settings are combined, not replaced. If your user file allows Bash(npm run *) and the project allows Bash(make *), both apply. Hooks merge across files the same way. A few keys that hold model lists, such as fallbackModel, take the whole value from the highest file instead.
Permissions: allow, ask, deny
A rule is a tool name, or a tool name with a specifier in brackets. The permissions page is explicit about the order: “Rules are evaluated in order: deny, then ask, then allow. The first match in that order determines the outcome, and rule specificity doesn’t change the order.” So a narrow allow cannot carve an exception out of a broad deny, and a deny in your user file blocks an allow in a project file.
| Rule | Matches |
|---|---|
Bash or Bash(*) | Every shell command |
Bash(npm run build) | That exact command only, not npm run build --watch |
Bash(npm run *) | npm run build, npm run test --watch and bare npm run |
Bash(ls *) | ls, ls -la; not lsof (the space counts) |
Bash(ls:*) | The same as Bash(ls *); the :* form works only at the end |
Read(./.env) | Reading .env in the current folder |
Edit(/src/**/*.ts) | TypeScript under the project’s src (in a project file) |
Read(~/.zshrc) | Your home folder’s .zshrc |
Edit(//tmp/scratch.txt) | The absolute path /tmp/scratch.txt |
WebFetch(domain:example.com) | example.com only; domain:*.example.com covers subdomains |
mcp__github__* | Every tool from the MCP server named github |
Path rules use gitignore syntax with four anchors, and the single slash is the trap. Two slashes (//path) is the filesystem root, ~/ is your home folder, and a bare or ./ path is the current folder. A single leading slash is relative to the settings file’s source: the project folder in a project file, but ~/.claude/ in your user file. A Read(/secrets/**) deny in ~/.claude/settings.json protects ~/.claude/secrets, not the project’s secrets folder.
Three limits of Bash and Read rules are worth knowing before you rely on them. Claude Code splits compound commands on &&, ||, ;, | and newlines (among others), and every part must be allowed, so Bash(safe-cmd *) does not approve safe-cmd && other-cmd. A rule matches the command as written: Bash(git push *) does not match git -C . push. And a Read deny covers Claude’s file tools and commands that name the file, such as cat .env, but not grep -r pattern . run over the folder, or a script that opens the file itself. The sandbox, with its unsandboxed retry turned off, closes that gap at the operating-system level; see the Claude Code sandbox.
/permissions opens a dialog that “lists all permission rules and the settings.json file each rule comes from”, and lets you add or remove them. Answering a prompt with “Yes, and don’t ask again” in the terminal saves an allow rule to the local file. That rule does not outrank an ask rule in the project or managed file, which is why some commands keep prompting after you approve them.
The other permission keys people set are defaultMode (one of default, acceptEdits, plan, auto, dontAsk, bypassPermissions) and additionalDirectories, which gives Claude file access outside the folder it started in. A defaultMode of auto or bypassPermissions is ignored in project and local files (since v2.1.257 for bypass) and belongs in your user file; deny rules still block in every mode, bypass included. Choosing between those modes on a server is covered in running Claude Code without permission prompts.
A shared file waits for trust
In a project’s .claude/settings.json, permissions.allow rules, additionalDirectories, extraKnownMarketplaces and most env values take effect only after you accept the workspace trust dialog for that folder; deny and ask rules apply at once, because they only restrict. Trusting a parent folder does not count. A claude -p run never shows the dialog, so it skips an untrusted project’s allow rules and prints a this workspace has not been trusted warning to stderr. Hooks, the env block and helper commands such as apiKeyHelper from the project, though, do run in that case, and the servers in its .mcp.json connect without asking. Anthropic’s permissions page marks the project’s hooks, env block and apiKeyHelper as used when only a parent folder is trusted, too, where its settings page says most env values wait for the folder’s own trust; until the two agree, read a project’s settings file before working under any folder you have trusted. Before running claude -p in a repository you did not write, --setting-sources user makes Claude Code read neither the project’s settings files nor its .mcp.json.
The other keys people set most
model. A model alias or full id, such as"claude-sonnet-5-5". It is read at session start, so mid-session use/model, which also saves your choice to the user file. Ids and aliases are in Claude Code models.env. An object of string values set for every session and the commands it starts, such as"DISABLE_AUTO_COMPACT": "1"or anANTHROPIC_BASE_URL. Project and local files cannot set some variables (the telemetry exporters among them). Keep keys out of a committed file; a value that is a secret belongs in your user file or a helper.hooks. Commands that run at points such as before a tool call; events, matchers and a tested guard script are in Claude Code hooks.statusLine.{"type": "command", "command": "..."}with optionalpaddingandrefreshIntervalin seconds; the JSON your script receives is in the statusline guide.apiKeyHelper. A shell command whose output Claude Code sends “as both theX-Api-KeyandAuthorization: Bearerheaders”, for a key fetched from a vault rather than stored in a file:"apiKeyHelper": "/bin/generate_temp_api_key.sh". Its output is cached and the command re-run after five minutes by default (CLAUDE_CODE_API_KEY_HELPER_TTL_MSchanges that), or when a request fails with 401 or 403.sandbox."enabled": trueturns on Bash sandboxing on macOS, Linux and WSL2, withfilesystem.allowWriteandnetwork.allowedDomainsto widen it.- Smaller ones.
cleanupPeriodDays(how long transcripts are kept),autoUpdatesChannel("stable"instead of latest),outputStyle,theme,editorMode("vim"),spinnerTipsEnabledandattribution, which replaces the deprecatedincludeCoAuthoredByfor the commit and pull request credit line.
The $schema line, /config and editing by hand
Settings files are strict JSON: a // comment or a trailing comma is a syntax error, reported as a Settings Error at the next start, with a choice to fix the file, exit or continue without it. A single bad entry, such as a malformed permission rule, is a Settings Warning instead: that entry is skipped and the rest of the file applies. Adding "$schema": "https://json.schemastore.org/claude-code-settings.json" at the top gives autocomplete and validation in VS Code, Cursor and other editors that read JSON schemas. Anthropic notes the schema “can lag behind the newest CLI releases”, so a warning on a newly documented key does not mean the file is wrong.
/config opens a short list of personal options, not every key. Most of what it saves goes to ~/.claude/settings.json, the output style goes to the project’s settings.local.json, and a handful of options go to ~/.claude.json. One option can be set directly, as in /config verbose=true. Claude Code watches the files and applies most edits, including permissions and hooks, without a restart. If a choice you save does not survive to the next session, check that the user file is writable by you; a file generated or linked read-only by another tool keeps the change for that session only. Claude Code 2.1.330 also fixed user settings being lost when several Claude Code processes saved them at once.
Checking what loaded
/status has a Setting sources line listing each file loaded for the session, such as User settings or Project local settings, and names a managed source if one applies (a managed file shows as Enterprise managed settings (file)). It tells you which files were read, not which file supplied a key. For that:
/permissionsshows each rule with the file it came from.claude doctor, run in your terminal, lists entries Claude Code rejected, including those a-prun silently skipped.- For the model, the startup header names the file when a project or managed file set it.
When a value seems ignored, the usual causes are a higher file setting the same key, an environment variable or flag that outranks it, a key the file cannot set (auto mode from a project file), a project that is not trusted yet, or a project file in a folder other than the one you started in.
What is not in settings.json
~/.claude.json, in your home folder beside the .claude folder rather than inside it, is a file Claude Code writes for itself. It holds your account details, your MCP server configurations, per-project state such as trust decisions, and a set of global options (the reference lists keys such as autoConnectIde and diffTool) that Claude Code “ignores … anywhere else”. A project’s shared MCP servers live in .mcp.json at its root; adding servers is covered in Claude Code MCP servers. Standing instructions for Claude go in CLAUDE.md, not settings; see where Claude Code reads CLAUDE.md from. Because ~/.claude.json carries your sign-in and trust state, running Claude Code once as root can leave it owned by root and send the next normal start back to first-run; that fix is here. Codex keeps the equivalent settings in TOML, described in Codex config.toml.