Back to all articles
TutorialNovember 30, 2026·11 min read

Claude Code settings.json Examples - Permissions, Hooks, and Which File Wins (2026)

You've used Claude Code for a few weeks with the defaults. Now you'd like it to stop asking before every test run, never read your .env file, and start on the model you prefer. Your team also wants a shared file in the repository so everyone gets the same rules. You open the docs, find four different settings files, and aren't sure which one to edit or what happens when two of them disagree.

Claude Code reads settings from JSON files at a few levels. Anthropic's settings documentation says: "Claude Code reads settings from four files, and an organization can also deliver managed settings from the claude.ai console." Each file has a scope, from just you to everyone in your organization, and when the same key appears in more than one place, the higher level wins, with a few exceptions such as permission lists, which merge.

This guide gives five example setups you can adapt: a personal file, a file that keeps secrets out of reach, a team's shared file with a hook, a local override for one project, and a one-session test. It then explains which file wins, how permission rules combine, when edits take effect, and what belongs in settings versus CLAUDE.md.

The four settings files

Anthropic's documentation lists the files and who each one affects:

  • User: ~/.claude/settings.json. You, in every project on this machine. Use it for personal preferences such as theme, editor mode, default model, and your own permission rules.
  • Shared project: .claude/settings.json. Everyone working in the project folder. In a git repository, commit it so teammates get it.
  • Project local: .claude/settings.local.json. You, in this one project only.
  • Managed: managed-settings.json and other managed sources. Everyone your organization deploys it to.

Installing Claude Code doesn't create any of these. The documentation explains that Claude Code writes ~/.claude/settings.json when you save a user setting such as the theme, and writes .claude/settings.local.json when you give a standing approval on a permission prompt.

One rule for all of them: they're strict JSON. The documentation says: "Settings files are strict JSON: a // comment or a trailing comma is a syntax error". Keep comments out of the file itself.

Example 1: A personal settings file

This is the kind of file Anthropic shows for one developer's ~/.claude/settings.json. It sets preferences and pre-approves a couple of safe actions:

  • model set to claude-sonnet-5, so every session starts on that model
  • modelSettings with an effortLevel for that model, to run it at a higher effort than its default
  • editorMode set to vim, for Vim keybindings in the prompt
  • theme set to light-daltonized
  • spinnerTipsEnabled set to false, to hide the rotating tips
  • permissions.allow with Bash(git diff *) and Read(~/.zshrc), so Claude Code runs git diff and reads that file without asking
  • autoUpdatesChannel set to stable
  • cleanupPeriodDays set to 20, which deletes session transcripts and other local session data older than that many days

What to change: your model, your editor mode, and the commands you're comfortable approving everywhere. Keep the allow list short and specific.

Worth knowing: cleanupPeriodDays controls how long local session transcripts stay on your machine. If you rely on resuming old sessions, set it with that in mind.

Example 2: Keep secrets out of reach

Anthropic's documentation uses this as its first editing example: let Claude Code run lint and tests without asking, and stop it reading environment files. In ~/.claude/settings.json:

  • permissions.allow with Bash(npm run lint) and Bash(npm run test *)
  • permissions.deny with Read(./.env) and Read(./.env.*)

The documentation also recommends a schema line, $schema pointing to the published Claude Code settings schema, which gives you autocomplete and inline validation in editors that support it.

What deny does. Anthropic's permissions documentation describes how a deny rule interacts with an allow rule: "A broad deny rule like Bash(aws *) blocks every matching call, including calls that also match a narrower allow rule like Bash(aws s3 ls). An allow rule can't carve an exception out of a deny rule."

What it doesn't cover. The team example notes that rules match the command and path as written, so a rule for Bash(git push *) doesn't match the same command written another way. Keep that in mind before you rely on a single rule for something sensitive.

Example 3: A team's shared settings with a hook

This is the shape of Anthropic's team example, saved at .claude/settings.json at the top of the repository and committed:

  • permissions.allow with Bash(npm run *), to run npm scripts without asking
  • permissions.ask with Bash(git push *), to confirm before every push
  • permissions.deny with Read(./.env), Read(./.env.*), and Read(./secrets/**)
  • hooks.PreToolUse with a matcher of Bash and a command hook that runs a script in the repository, ${CLAUDE_PROJECT_DIR}/.claude/hooks/block-rm.sh, before every Bash call
  • extraKnownMarketplaces registering the team's plugin marketplace, and enabledPlugins turning on one plugin from it
  • sandbox enabled, with a writable build folder and a short list of allowed network domains
  • plansDirectory set to ./plans, to keep plan files inside the repository

Why the hook lives in the repo. The documentation says: "The hook is a script in the repo." That way every teammate runs the same check. We covered what hooks can do and when they run in our guide to Claude Code hooks.

What waits for trust. Some keys in a shared file don't apply until each person trusts the folder. The settings documentation says that permissions.allow rules, permissions.additionalDirectories, extraKnownMarketplaces, and most env values apply only after each teammate trusts the folder.

What never applies from a shared file. Some keys are ignored in a repository file. For example, the documentation says the permissions.defaultMode values auto and bypassPermissions don't take effect from project or local settings.

Example 4: A personal override for one project

Your team's file sets a model, and you want a different one in this project only. The documentation's example is exactly that: when the committed file sets model to claude-sonnet-5 and you want Opus, you set model to claude-opus-5-5 in your local file, and only your sessions change.

So in .claude/settings.local.json:

  • model set to the model you want in this project

The same file collects your standing approvals. The documentation explains that when you choose Yes, and don't ask again on a Bash permission prompt, Claude Code saves that approval as an allow rule in .claude/settings.local.json.

Keep it out of commits. Claude Code adds the local file to your global git excludes the first time it writes it. If you create the file by hand, add it to .gitignore yourself.

Example 5: Test a value for one session

To try a setting without saving it, pass it when you start Claude Code. The documentation's example starts one session on Opus without changing your default, using --settings with a JSON object that sets model to claude-opus-5-5.

The documentation lists three ways to change a value for one session: --settings with inline JSON or a file path, a flag for that key such as --model, or an environment variable such as ANTHROPIC_MODEL.

Command-line settings last one session. The documentation's precedence example says: "--settings lasts one session and doesn't write to any file."

Which file wins

Anthropic's documentation gives the order, highest first: "managed settings, command line, project local, shared project, user. A key set at a higher level overrides the same key set lower down."

In practice:

  • Your team's file beats your user file in that project.
  • Your local file beats your team's file for you in that project.
  • --settings beats every file except managed for one session.
  • Managed beats everything. The documentation says: "Nothing in your own settings files or --settings overrides a managed key".

Environment variables are separate. The documentation says they aren't a level in this stack, and which one applies is decided per pair of variable and key.

Permission lists merge

Lists are the main exception to the highest-level-wins rule. The documentation says: "When you set the same list key, such as permissions.allow, in more than one file, Claude Code combines the lists instead of picking one, so each file can add entries without removing another file's."

Once the lists are combined, the rule type decides the outcome. The permissions documentation says: "Rules are evaluated in order: deny, then ask, then allow."

That explains a common surprise. If your team's file has an ask rule for a command and you choose Yes, and don't ask again, the documentation says your saved allow rule doesn't outrank the ask rule from a project or managed file, so you'll still be prompted.

When edits take effect

Most edits apply without a restart. The documentation says Claude Code "watches your settings files and reloads them when they change, so it applies most edits to the running session without a restart, including edits to permissions, hooks, and credential helpers such as apiKeyHelper."

A few keys are read only at session start, including model and effortLevel. Use /model and /effort to change those mid-session.

Confirm what loaded. Run /status inside Claude Code. The Status tab includes a Setting sources line listing each settings file Claude Code loaded. The documentation notes it shows which files were read, not which file supplied each key.

If a file is broken. Claude Code shows a Settings Error for invalid JSON or a rejected value, with options to fix the file, exit, or continue without it. A Settings Warning means only individual entries failed, and the rest of the file stays in effect.

Settings aren't instructions

Settings change how Claude Code behaves: permissions, hooks, model, sandbox. They don't tell Claude how to work on your project. The documentation says: "Claude Code's system prompt isn't published. To give Claude standing instructions, use CLAUDE.md files or the --append-system-prompt flag."

So a good split is: rules about what Claude Code may do go in settings, and context about your project, such as conventions, decisions, and how to run things, goes in CLAUDE.md.

What people try first

Adding comments to settings.json. Strict JSON rejects them.

Allowing a command the team file asks about. The ask rule still prompts.

Carving an exception out of a deny rule. An allow rule can't do that.

Committing permissions.defaultMode set to bypassPermissions. It doesn't take effect from project files.

Restarting after every edit. Most edits apply to the running session.

Putting project conventions in settings. Use CLAUDE.md for instructions.

The Fix: Set up settings that stay predictable

Step 1: Pick the right file

Personal preferences in ~/.claude/settings.json, team rules in .claude/settings.json, personal project overrides in .claude/settings.local.json.

Step 2: Start with deny rules for secrets

Deny reads of .env files and secret folders before you add allow rules.

Step 3: Confirm with /status

Check the Setting sources line after each change.

Step 4: Write down your project's context

Note conventions, decisions, and why your rules exist, in your own words, separate from the settings themselves.

Setting this up in MemoryLake

Settings files tell Claude Code what it may do. The reasons behind them, and the context of the project they protect, live somewhere else: in your head, in CLAUDE.md, or in a chat from last month. That context is useful in every assistant you work with, not just one.

MemoryLake is a memory layer for that kind of context, kept in one place you maintain and available to the assistants you connect, such as ChatGPT, Claude Code, and Codex.

You write the entries yourself, in your own words. Nothing is read out of, written to, or deleted from your settings files, your CLAUDE.md files, your Claude Code sessions, your permission rules, or any vendor's store. Claude Code settings work the way Anthropic describes them.

Step 1: Create an API key

Sign in and generate a key from the dashboard. Keep it somewhere private.

The MemoryLake console showing the API keys screen, where a new key is created and copied for use in an agent
The MemoryLake console showing the API keys screen, where a new key is created and copied for use in an agent

Step 2: Upload your first memories

Start with what you wrote in Step 4 of the fix: conventions, decisions, and the reasons behind your rules. One topic per entry.

The MemoryLake workspace with the first documents uploaded, listing each file as it becomes searchable memory
The MemoryLake workspace with the first documents uploaded, listing each file as it becomes searchable memory

Step 3: Connect your AI & agents

Connect ChatGPT, Claude Code, Codex, and the other assistants you use, so the same context is there in each.

The MemoryLake integrations screen listing the AI clients and agent frameworks that can be connected to the memory layer
The MemoryLake integrations screen listing the AI clients and agent frameworks that can be connected to the memory layer

What this changes in practice

The first difference is clarity. Settings hold rules, and your notes hold the reasons.

The second is portability. The context works in other assistants, where Claude Code settings don't apply.

The third is onboarding. A teammate can read why the rules exist, not just what they are.

Best practices for Claude Code settings

Keep personal and team settings apart. Use the local file for personal overrides.

Prefer specific allow rules. Broad rules approve more than you expect.

Use deny for anything sensitive. Deny is checked first.

Add the schema line. It catches mistakes in your editor.

Check /status after changes. It shows which files loaded.

Keep instructions in CLAUDE.md. Settings control behavior, not guidance.

Conclusion

Claude Code reads four settings files: user, shared project, project local, and managed. When the same key is set in more than one place, the order is managed, command line, project local, shared project, then user. Permission lists merge across files, and once combined they're checked deny first, then ask, then allow, so an allow rule can't override a deny or an ask from another file.

The five examples here cover the common setups: personal preferences, keeping secrets out of reach, a team file with a hook, a local override, and a one-session test with --settings. Most edits apply without a restart, /status confirms which files loaded, and settings files must be strict JSON. Keep instructions and project context in CLAUDE.md and in your own notes, where the reasons behind your rules are easy to find.

Frequently asked questions

Where is Claude Code's settings.json?

Your personal file is ~/.claude/settings.json. A project's shared file is .claude/settings.json, and your personal project file is .claude/settings.local.json.

Which settings file takes precedence?

Managed, then command line, then project local, then shared project, then user.

Do permission rules from different files combine?

Yes. List keys such as permissions.allow merge across files.

Can an allow rule override a deny rule?

No. Rules are checked deny, then ask, then allow.

Can I add comments to settings.json?

No. Settings files are strict JSON, and a comment is a syntax error.

Do I need to restart Claude Code after editing settings?

Usually not. Most edits apply to the running session, though keys such as model are read at start.

How do I check which settings loaded?

Run /status and look at the Setting sources line.