🔥 Launch tonight — Claude Code Power Prompts PDF 50p (just 50p tonight)30 battle-tested prompts · 8-page PDF · paste into CLAUDE.md · flat 50p tonight

Claude Code Settings & Configuration

Updated May 2026 · Complete configuration reference

Claude Code has three layers of configuration that stack on top of each other: environment variables (highest priority), settings.json files (project and global), and CLAUDE.md files (instruction context). This page covers all of them.

Configuration Priority Order

LayerFile / mechanismScopePriority
CLI flags--model, --print, etc.Single runHighest
Environment variablesANTHROPIC_MODEL, ANTHROPIC_API_KEY, etc.Shell session2nd
Project local settings.claude/settings.local.jsonOne developer in one project3rd
Project settings.claude/settings.jsonAll team members in one project4th
Global settings~/.claude/settings.jsonAll projects on this machineLowest

settings.json Full Reference

// .claude/settings.json — annotated example
{
  // Model to use (overridable per-session with --model)
  "model": "claude-sonnet-4-6",

  // Pre-approve specific tools to reduce confirmation prompts
  "permissions": {
    "allow": [
      "Read",          // Read files
      "Bash(git *)",   // Any git command
      "Bash(npm *)",   // Any npm command
      "Bash(python *)" // Any python command
    ],
    "deny": [
      "Bash(rm -rf *)" // Never allow recursive delete
    ]
  },

  // Environment variables injected into every Bash command
  "env": {
    "NODE_ENV": "development",
    "LOG_LEVEL": "debug"
  },

  // Hooks — shell commands that fire at lifecycle events
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [{"type": "command", "command": "echo 'Running: $CLAUDE_TOOL_INPUT'"}]
      }
    ],
    "Stop": [
      {
        "hooks": [{"type": "command", "command": "notify-send 'Claude Code done'"}]
      }
    ]
  },

  // Disable specific features
  "theme": "dark",
  "autoUpdates": false,
  "verbose": false
}

File Locations

# Global settings — applies to all projects
~/.claude/settings.json

# Project settings — committed to git (team-shared)
.claude/settings.json

# Project local settings — NOT committed (add to .gitignore)
.claude/settings.local.json

# CLAUDE.md — instructions for Claude (not config)
CLAUDE.md              # project root (loaded always)
src/CLAUDE.md          # subdirectory (loaded when working in src/)
~/.claude/CLAUDE.md    # global (loaded in every project)
Add .claude/settings.local.json to your .gitignore. This file is for personal overrides (your preferred model, local API keys) that shouldn't be shared with the team.

Model Configuration

# In settings.json
{"model": "claude-opus-4-7"}

# Via environment variable
export ANTHROPIC_MODEL=claude-haiku-4-5-20251001

# Per-session override
claude --model claude-sonnet-4-6
Model IDBest forRelative cost
claude-haiku-4-5-20251001Bulk tasks, fast summaries, formatting
claude-sonnet-4-6Most tasks — best value/quality balance~5×
claude-opus-4-7Complex reasoning, large refactors, architecture~15×

Permissions Configuration

Reduce confirmation prompts by pre-approving tools in settings.json. Use specific patterns to grant narrow permissions rather than broad ones:

{
  "permissions": {
    "allow": [
      "Read",              // allow all file reads
      "Write",             // allow all file writes
      "Edit",              // allow all edits
      "Bash(git *)",       // allow any git command
      "Bash(npm test)",    // allow only 'npm test'
      "Bash(npm run *)"    // allow any 'npm run ...' command
    ],
    "deny": [
      "Bash(rm -rf *)",    // never allow recursive delete
      "Bash(git push *)"   // require manual push confirmation
    ]
  }
}

Environment Variables Reference

VariablePurposeExample value
ANTHROPIC_API_KEYRequired. Your Anthropic API key.sk-ant-...
ANTHROPIC_MODELDefault model for all sessionsclaude-sonnet-4-6
ANTHROPIC_BASE_URLCustom API endpoint (proxy, AWS Bedrock)https://...
CLAUDE_AUTO_ACCEPT_EDITSSkip edit confirmation (automation)1
NO_COLORDisable ANSI color in output1
CLAUDE_CODE_MAX_OUTPUT_TOKENSOverride max output tokens4096

Hooks Configuration

Hooks run shell commands at lifecycle events. The available events are:

EventWhen it fires
PreToolUseBefore Claude calls any tool (Bash, Read, Write, etc.)
PostToolUseAfter a tool completes
PreCompactBefore context compaction runs
PostCompactAfter context compaction
StopWhen Claude finishes responding
SubagentStopWhen a spawned subagent completes
{
  "hooks": {
    // Log every bash command to a file
    "PreToolUse": [{
      "matcher": "Bash",
      "hooks": [{
        "type": "command",
        "command": "echo \"$(date -u) $CLAUDE_TOOL_INPUT\" >> ~/.claude-audit.log"
      }]
    }],
    // Desktop notification when Claude stops
    "Stop": [{
      "hooks": [{
        "type": "command",
        "command": "osascript -e 'display notification \"Done\" with title \"Claude Code\"' 2>/dev/null || true"
      }]
    }]
  }
}

CLAUDE.md vs settings.json

Use CLAUDE.md for…

Instructions to Claude: "always use TypeScript strict mode", "this repo uses Tailwind, not Bootstrap", "never modify the src/vendor/ directory", "the test command is 'pnpm test:unit'". CLAUDE.md shapes Claude's behavior within your project.

Use settings.json for…

Runtime configuration: which model to use, which tools are pre-approved, environment variables to inject, hooks to run. settings.json shapes how Claude Code operates (the process) rather than what Claude does (the behavior).

Frequently Asked Questions

Where is Claude Code's settings.json?

Global: ~/.claude/settings.json. Project-shared: .claude/settings.json in your project root. Personal overrides: .claude/settings.local.json (gitignored).

How do I change the model in Claude Code?

Three ways: set "model": "claude-haiku-4-5-20251001" in settings.json; export ANTHROPIC_MODEL=claude-haiku-4-5-20251001; or use claude --model claude-haiku-4-5-20251001 for one session.

How do I stop permission prompts?

Add tools to permissions.allow in settings.json. Use specific patterns like "Bash(git *)" for narrow grants or "Bash" for all bash commands. Keep denies explicit for destructive operations.

What's the difference between CLAUDE.md and settings.json?

CLAUDE.md = instructions for Claude (what to do, how to behave). settings.json = configuration for the Claude Code process (model, allowed tools, env vars, hooks). They serve different purposes and both matter.

How do I add environment variables?

In settings.json under "env": {"VAR": "value"}. These are injected into every Bash command. For secrets, use settings.local.json (gitignored) or system env vars instead of committed settings.json.

How do I configure hooks?

In settings.json under "hooks". Choose an event (PreToolUse, PostToolUse, Stop, etc.), optionally add a matcher for specific tool names, and specify a shell command to run. See our full hooks guide.

→ CLAUDE.md Guide — write effective project instructions

→ Hooks — automate pre/post tool actions

← Back to Home