✻Founding-member pricing: every lesson for $19/mo. The first 3 lessons are free. Start lesson 1 →
Unit 3 · Configure Claude · Lesson 13 of 40

Settings & Scopes: settings.json Explained

Understand Claude Code's settings files: user, project, local and managed scopes, their precedence, and the most useful keys in settings.json.

ACADEMY10 min+70 XP4-question quiz

🎯 By the end of this lesson you'll be able to

  • Name the settings files and what each is for
  • Explain settings precedence
  • Configure common keys: permissions, env, model, hooks
  • Use /config and /status to inspect settings

One schema, several files

Claude Code behavior (permissions, hooks, default model, environment variables and more) is configured in settings.json files at different scopes:

ScopeFileShared?Use it for
User~/.claude/settings.jsonNoYour personal defaults across all projects
Project.claude/settings.jsonYes, commit itTeam rules: permissions, hooks, shared config
Local.claude/settings.local.jsonNo, gitignoredYour personal tweaks for this one project
ManagedSystem location set by IT/MDM or server-deliveredOrg-widePolicies that can't be overridden

Precedence: who wins?

When the same setting appears in more than one place, the more specific and more authoritative scope wins:

  1. Managed settings (highest, can't be overridden)
  2. Command-line flags for this session
  3. Local project settings
  4. Project settings
  5. User settings (lowest)

Some keys merge instead of replacing. Permission rules from different scopes are combined, and hooks from every scope all run. A deny rule anywhere still denies.

⇅Rank the scopes, highest priority firstdrag or use arrows
  1. ⋮⋮Managed settings
  2. ⋮⋮Command-line flags
  3. ⋮⋮.claude/settings.local.json
  4. ⋮⋮.claude/settings.json
  5. ⋮⋮~/.claude/settings.json

A realistic project settings file

.claude/settings.json
{
  "permissions": {
    "allow": ["Bash(pnpm test *)", "Bash(pnpm lint *)", "Bash(git diff *)"],
    "ask": ["Bash(git push *)"],
    "deny": ["Read(./.env)", "Read(./secrets/**)"]
  },
  "env": {
    "NODE_ENV": "development"
  },
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [{ "type": "command", "command": "npx prettier --write --ignore-unknown \"$(jq -r '.tool_input.file_path')\"" }]
      }
    ]
  }
}

This one file pre-approves safe test and lint commands, makes pushes ask first, blocks reading secrets and auto-formats every edit, for everyone on the team.

Handy keys to know

KeyWhat it controls
permissionsallow / ask / deny rules, defaultMode, extra directories
hooksCommands that run on lifecycle events (Unit 7)
envEnvironment variables for every session
modelDefault model for sessions
statusLineA custom status line command
outputStyleThe default output style

Inspect before you guess

  • /config opens the settings UI.
  • /status shows your current setup: account, model, and which settings sources loaded.
  • /permissions lists every active rule and where it came from.
!
Keep secrets out of shared settings

.claude/settings.json is committed, so never put API keys there. Use .claude/settings.local.json (gitignored), your shell environment, or a secrets manager.

Check your understanding

?Lesson quiz10 XP per correct answer · +25 for a perfect score
QUESTION 1 OF 4

Which settings file should a team commit to share permission rules and hooks?

Why: Project settings in .claude/settings.json are shared through version control.
QUESTION 2 OF 4

Which scope has the highest precedence?

Why: Managed settings come from the organization and can't be overridden.
QUESTION 3 OF 4

If one scope allows Read(./.env) and another denies it, what happens?

Why: Deny rules block regardless of allows elsewhere.
QUESTION 4 OF 4

Where should a personal API key for one project go?

Why: Local settings are gitignored, so secrets don't get committed.
0 / 4 correct
Academy lesson

Unlock lesson 13 and the next 27

You've finished the free lessons. Join the Academy for $19/month to unlock every lesson, quiz, terminal simulation and puzzle, plus the final exam and your certificate of completion.

  • All 40 lessons across 9 units
  • 165+ quiz questions
  • Final exam + certificate
  • New lessons as Claude Code evolves
  • XP, streaks and badges
  • Cancel anytime

Already a member? Log in to continue.

Key takeaways

  • Settings live at user, project, local and managed scopes.
  • Precedence: managed → CLI flags → local → project → user.
  • Permission rules and hooks merge across scopes; deny always wins.
  • Inspect with /config, /status and /permissions; never commit secrets.

Nice work. Lesson 13 done?

Mark it complete to earn +70 XP, keep your streak alive and unlock badges.

Written by Curtis Cornell from Anthropic's public Claude Code documentation. Last reviewed November 14, 2026. Claude Code changes fast; if something here differs from your version, the official docs win.

Start lesson 1 free →