Tune Claude Code Settings and Permissions Safely
- Claude Code reads four kinds of settings: user (
~/.claude/settings.json), shared project (.claude/settings.json), project local (.claude/settings.local.json) and organization-managed. When a key is set in several places, the higher level wins: managed > command line (--settings) > local > shared project > user. List keys such aspermissions.alloware merged, not replaced. - Permission rules have three kinds:
allow,askanddeny. They are checked in the order deny, then ask, then allow, and the first match decides. A deny at any level cannot be undone by an allow at another level. - To keep Claude away from secrets, add
Readdeny rules such asRead(./.env). Rules are enforced by Claude Code itself, not by the model, so they hold even if a prompt or CLAUDE.md says otherwise. - A Bash rule is not a security boundary.
Bash(rm *)does not stop/bin/rmorbash -c '...'. For hard limits, use the OS-level sandbox or a PreToolUse hook. bypassPermissionsskips prompts, even for writes to.gitand.claude. Use it only inside a container or VM.- We checked the official docs on 2026-11-02. We ran only a JSON syntax check and
claude doctor(Claude Code 2.1.316) in a temporary folder. We did not run an interactive session, so prompts and the/permissionsscreen come from the docs.
What you’ll be able to do after this tutorial
Section titled “What you’ll be able to do after this tutorial”- Tell which settings file to edit for “just me”, “my team” and “just this project”.
- Predict which value wins when the same key is set in two places.
- Write allow, ask and deny rules, and keep
.envand secrets out of Claude’s reach. - Choose a permission mode and explain what it does and does not protect.
Concepts to know first
Section titled “Concepts to know first”C14 introduced permission modes in one table, and Coding 10 showed how a hook can block an action. This tutorial covers the settings those features live in. The key idea: CLAUDE.md is a request, settings rules are enforcement. The official permissions page says rules are enforced by Claude Code, not by the model.
Where settings live (official docs, 2026-11-02)
Section titled “Where settings live (official docs, 2026-11-02)”| Scope | File | Who it affects |
|---|---|---|
| User | ~/.claude/settings.json |
You, in every project on this machine |
| Shared project | .claude/settings.json |
Everyone who works in that folder. Commit it to git |
| Project local | .claude/settings.local.json |
You, in this one project only |
| Managed | managed-settings.json, MDM or server-managed settings |
Everyone your organization deploys it to |
Installing Claude Code does not create any of these files. Claude Code creates ~/.claude/settings.json the first time you change a /config option stored there, and .claude/settings.local.json the first time you pick “Yes, and don’t ask again” on a permission prompt. On Windows, ~/.claude means %USERPROFILE%\.claude.
Which value wins
Section titled “Which value wins”From highest to lowest: managed settings, then the command line (--settings), then project local, then shared project, then user. Two details matter in practice:
- Lists merge. If user settings and project settings both have
permissions.allow, Claude Code combines them. - Environment variables are not a level. Whether a variable or a settings key wins is decided key by key; check the key’s entry in the settings reference.
Permission modes in short
Section titled “Permission modes in short”| Mode | What runs without asking |
|---|---|
default (shown as Manual) |
Reads only |
acceptEdits |
Reads, file edits and common file commands such as mkdir, mv, cp |
plan |
Reads; Claude proposes a plan and does not edit your source files |
auto |
Most actions, with a background classifier checking them |
dontAsk |
Only pre-approved tools; anything that would prompt is denied (for CI) |
bypassPermissions |
Everything, except a short list that no mode auto-approves |
Switch with Shift+Tab or start with claude --permission-mode <mode>. Deny rules block in every mode, including bypassPermissions.
Step-by-step guide
Section titled “Step-by-step guide”-
Open or create the right file
For this practice, create the shared project file in your practice folder. Everything below is also fine in
.claude/settings.local.jsonif you do not want teammates to get it.Terminal window mkdir -p .claudeSettings files are strict JSON: a
//comment or a trailing comma is an error, and Claude Code reports it as a Settings Error at the next start. If you create.claude/settings.local.jsonby hand, add it to.gitignoreyourself. Claude Code only does that automatically when it creates the file. -
Write allow, ask and deny rules
Save this as
.claude/settings.json. It follows the pattern in the official docs. The first two rules let Claude run your lint and test commands without asking, and the deny rules stop it reading.envfiles.{"$schema": "https://json.schemastore.org/claude-code-settings.json","permissions": {"allow": ["Bash(npm run lint)","Bash(npm run test *)"],"ask": ["Bash(git push *)"],"deny": ["Read(./.env)","Read(./.env.*)","Read(./secrets/**)"]}}Rule format is
ToolorTool(specifier). In a Bash rule,*matches any text, so put it after the subcommand:Bash(git log *)allows onlygit log, whileBash(git *)allows every git command. The space before a trailing*matters:Bash(ls *)does not matchlsof, butBash(ls*)does.Claude Code watches settings files and applies most edits, including
permissions, to the running session without a restart. -
Confirm what loaded
/statusThe Status tab has a
Setting sourcesline that lists each settings file Claude Code loaded, such asUser settingsorProject local settings. It shows which files were read, not which file supplied each key. To see rules and where each came from, type/permissions. To list entries Claude Code rejected, runclaude doctorin the terminal. -
Protect sensitive files
Ask Claude to read a file you protected. Create a dummy
.envfirst. Never test with a real key.Terminal window echo "EXAMPLE_KEY=not-a-real-secret" > .envCopy and paste this promptRead the .env file in this folder and tell me what is in it.
With
Read(./.env)indeny, Claude Code should refuse. Per the docs, aReaddeny rule also blocks the Edit and Write tools on the same path. It applies to@filementions on a best-effort basis.Know the limits. The docs warn that Read and Edit deny rules cover Claude’s built-in file tools and the file commands Claude Code recognizes in Bash (
cat,head,tail,sed,tee) plus redirections. They do not cover a command that reads files without naming them, such asgrep -r pattern ., or a Python or Node script that opens files itself. For OS-level blocking of all processes, enable the sandbox. -
Set the starting permission mode
To make every terminal session on your machine start in Manual mode, put this in
~/.claude/settings.json(an example from the permission-modes page):{"permissions": {"defaultMode": "default"}}The next session shows
manual mode onin the status bar, according to the docs. With Claude Code v2.1.283 or later, a terminal or VS Code session with no mode set starts in auto mode, so choose deliberately if you prefer to approve things yourself. To remove auto or bypass mode entirely, setpermissions.disableAutoModeorpermissions.disableBypassPermissionsModeto"disable". They work in any settings file but are most useful in managed settings. -
Try a one-session override
To test a setting without saving it, pass it on the command line. It sits above your files (except managed) and lasts one session.
Terminal window claude --settings '{"permissions": {"defaultMode": "plan"}}'We did not run this command. If you set
autoorbypassPermissionsfor one session, use--permission-modeinstead.When a setting does not seem to apply - Claude Code promptType /status→ Check that the file appears in the Setting sources line
- TerminalRun claude doctor→ See entries Claude Code rejected, such as bad JSON or a malformed rule
- Your settings filesLook for the same key at a higher level→ Managed, --settings and local files outrank shared project and user files
- Settings referenceLook up the key and its Scope column→ Some keys never apply from a repository file
This is a simplified flow. See the official help page for the actual screens.
Quick reference
Section titled “Quick reference”Rule examples
Section titled “Rule examples”| Rule | Effect |
|---|---|
Bash(npm run build) |
Exactly npm run build |
Bash(npm run *) |
Any npm run ... command |
Read(./.env) |
The .env file in the current directory |
Read(**/.env) or Read(.env) |
Any .env at or under the current directory |
Read(//Users/alice/secrets/**) |
An absolute path (note the double slash) |
Read(~/Documents/*.pdf) |
A path under your home directory |
WebFetch(domain:example.com) |
Fetches to that domain |
Edit(/src/**) |
Edits under src/ in the primary working directory (project settings) |
A single leading slash is not the filesystem root. It anchors at the settings source. Use // for absolute paths. In user settings, Read(/secrets/**) blocks ~/.claude/secrets/**, not a folder in your project.
Rule order
Section titled “Rule order”- A matching deny rule blocks the call.
- Otherwise a matching ask rule prompts.
- Otherwise a matching allow rule lets it run.
Specificity does not change the order, so Bash(aws *) in deny also blocks aws s3 ls even when an allow rule names it. An allow rule cannot carve an exception out of a deny.
Things Claude Code does not auto-approve
Section titled “Things Claude Code does not auto-approve”Writes to protected paths are never auto-approved except in bypassPermissions. The docs list directories such as .git, .vscode, .idea, .husky and .claude, and files such as .gitconfig, .bashrc, .zshrc, .npmrc, .mcp.json and .claude.json. An allow rule such as Edit(.claude/**) does not pre-approve them. See the permission-modes page for the full list and per-mode behavior.
Common sticking points
Section titled “Common sticking points”My allow rule does nothing
Section titled “My allow rule does nothing”- Cause: The folder is not trusted yet, the file is not valid JSON, or a deny or ask rule matches first.
- Fix: Accept the trust dialog interactively, run
/statusandclaude doctor, and open/permissionsto see every rule and its file.
I wrote Write(docs/**) and edits still prompt
Section titled “I wrote Write(docs/**) and edits still prompt”- Cause: File permissions are checked against
Edit(path)andRead(path)rules only. Claude Code acceptsWrite(path),NotebookEdit(path)andGlob(path)rules but never matches them. - Fix: Use
Edit(docs/**)andRead(docs/**). Do not rely on a.claudeignorefile either; the docs say it has no effect.
I chose “Yes, and don’t ask again” but still get asked
Section titled “I chose “Yes, and don’t ask again” but still get asked”- Cause: That choice saves an allow rule to your local file, and an allow rule does not outrank an ask rule from another file.
- Fix: Look in
/permissionsfor the matching ask rule.
My defaultMode: "auto" in the project file is ignored
Section titled “My defaultMode: "auto" in the project file is ignored”- Cause:
autoandbypassPermissionsdo not take effect from project or local settings. - Fix: Put it in
~/.claude/settings.json, or pass--permission-mode auto.
A teammate does not get my rules
Section titled “A teammate does not get my rules”- Cause: The key is in your local file, or the key never applies from a repository file, or the teammate has not trusted the folder.
- Fix: Put team rules in the committed
.claude/settings.json, and tell teammates to accept the trust dialog.
My organization overrides my setting
Section titled “My organization overrides my setting”- Cause: Managed settings are the top level. Nothing in your files or
--settingschanges them. - Fix: Run
/statusto see the managed source, and ask your administrator.
Practical tips
Section titled “Practical tips”- Start with deny rules for secrets and
askrules for risky commands such asgit push, then addallowrules only for commands you really repeat. - Prefer exact or prefix rules (
Bash(npm run test *)) over broad ones such asBash(npm *). - Keep personal exceptions in
.claude/settings.local.jsonso they never reach your teammates’ sessions. - Add the
$schemaline so your editor can validate the file, but treat a warning on a brand-new key with care: the docs say the schema can lag behind the newest releases. - Use
bypassPermissionsonly in an isolated container or VM, never on your everyday machine. - Before you run
claude -pover a repository you did not write, read its.claude/files. The docs suggest--setting-sources useror--barefor that case. - This tutorial covers the permission keys only. The full key list is in the official settings reference.
Next tutorials
Section titled “Next tutorials”- C14. Claude Code key features — CLAUDE.md, subagents, MCP and permission modes
- 10. Automate checks with hooks — block risky commands with a PreToolUse hook
- 12. Create your own subagents — limit a subagent’s tools
- 1. Getting started with Claude Code
- Dev 7. Headless and GitHub Actions —
-pruns and the trust caution - Developer guide
Sources
Last verified: Nov 16, 2026
- Settings files and precedence code.claude.com
- Configure permissions code.claude.com
- Choose a permission mode code.claude.com
- All settings (permission keys) code.claude.com
Prices, limits, and menu names change often. Before making an important decision, check the official pages above for the latest details.
Finished this tutorial?
Progress is saved only in this browser and never sent anywhere.