CONCEPT The high-value keys in settings.json
Dozens of keys exist, but a handful come up constantly in real config and on the exam. Learn what each does and which type of value it takes:
| Key | Type | What it does |
|---|---|---|
model | string | Default model for the session (e.g. "sonnet", "opus"); switch mid-session with /model |
env | object | Environment variables injected into every session |
permissions | object | Tool allow / deny / ask rules, defaultMode, additionalDirectories |
hooks | object | Shell commands run at lifecycle events (e.g. PreToolUse, PostToolUse) |
apiKeyHelper | string | Custom command that outputs the auth value / API key |
includeCoAuthoredBy | boolean | Add the Co-Authored-By: Claude trailer to git commits (default true) |
cleanupPeriodDays | number | Days to retain session transcripts (default 30) |
statusLine | object | Custom status-line command shown in the footer |
outputStyle | string | Output rendering / response style |
enableAllProjectMcpServers | boolean | Auto-approve every MCP server declared in the project .mcp.json |
forceLoginMethod | string | Restrict auth to "claudeai", "console", or "gateway" |
disableAllHooks | boolean | Turn off all hooks and the custom status line |
model, env, permissions, and hooks are the
four you should be able to write from memory. The rest are recognition-level.CONCEPT permissions — allow, deny, ask
The permissions object is where you shape autonomy. Rules are written as
Tool(pattern), e.g. Bash(npm run test:*) or Read(./.env).
| Sub-key | Effect |
|---|---|
allow | Patterns Claude may run without asking |
deny | Patterns Claude may never run (also blocks reads of secret files) |
ask | Patterns that always prompt for confirmation first |
defaultMode | Starting permission mode for the session |
additionalDirectories | Extra directories outside the repo Claude may access |
deny is the strongest rule: it beats allow. Use it to hard-block
reads of ./.env, ./secrets/**, or dangerous commands like Bash(curl:*).DIAGRAM Where each key takes effect
CODE A realistic project settings.json
Model, injected env, permission rules, and a post-edit hook — the four heavy hitters in one file.
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"model": "sonnet",
"includeCoAuthoredBy": true,
"cleanupPeriodDays": 20,
"env": {
"NODE_ENV": "development",
"MAX_THINKING_TOKENS": "10000"
},
"permissions": {
"allow": ["Bash(npm run test:*)", "Read(~/.zshrc)"],
"deny": ["Read(./.env)", "Read(./secrets/**)", "Bash(curl:*)"],
"ask": ["Bash(git push:*)"],
"defaultMode": "acceptEdits"
},
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write",
"hooks": [{ "type": "command", "command": "npm run lint --silent" }]
}]
}
}
env are strings. A numeric-looking var like
MAX_THINKING_TOKENS must still be quoted as "10000".TRADE-OFFS Broad allow-list vs. tight deny-list
✅ Curated allow + explicit deny
- Fewer confirmation prompts for known-safe commands
denyhard-blocks secrets and dangerous ops- Predictable, reviewable autonomy the team agrees on
⚠️ Wide-open allow (e.g. Bash(*))
- Zero friction — but zero guardrails
- One bad model call can run anything
- Only a
denyrule can claw a pattern back
EXAM TRAPS
allow overrides deny if it's more specific." → No.
deny always wins over allow. It's the safety backstop.ANTHROPIC_MODEL key inside settings.json." → The
settings.json key is model. ANTHROPIC_MODEL is an environment variable, not a
settings key (covered in 2.3).env takes numbers and booleans." → All env values are
strings — quote them.includeCoAuthoredBy: false disables commits." → It only removes the
Co-Authored-By: Claude trailer from commit messages; Claude can still commit.PRACTICE
Q1 · A pattern is in both allow and deny. What happens?
It is denied. deny takes precedence over allow, so the command
is blocked regardless of the allow rule.
Q2 · Which key runs a linter automatically after every file edit?
hooks, using a PostToolUse hook with a matcher like
"Edit|Write" whose command runs the linter. PreToolUse runs before a tool and
can block it; PostToolUse runs after.
Q3 · How do you stop transcripts from piling up for months?
Set cleanupPeriodDays to a smaller number (the default retention is 30 days). Claude
Code deletes session files older than that window.