Claude Code Configuration: Where Every Setting Lives
Claude Code configuration explained: which file, flag or env var holds each setting, which wins in a conflict, and what to set globally vs per project.

On this page
Claude Code configuration lives in five places: CLAUDE.md files, ~/.claude/commands, MCP scopes, environment variables in your shell profile, and CLI flags. The rule that decides conflicts: for thinking tokens, the MAX_THINKING_TOKENS environment variable has the highest priority and overrides everything else (zitao.dev). Put workflow rules in the global file, project context in the project root, and anything risky in a flag you type deliberately.
| Setting type | Where it lives | What decides it |
|---|---|---|
| Global CLAUDE.md | ~/.claude/CLAUDE.md | System-wide, workflow-oriented instructions (seanpedersen.github.io) |
| Project CLAUDE.md | Project root or subdirectories | Project-specific context (seanpedersen.github.io) |
| Custom commands | ~/.claude/commands/*.md | File name becomes the slash name (seanpedersen.github.io) |
| MCP servers | local (default), user, or project (.mcp.json) | The --scope option (zitao.dev) |
| Thinking tokens | MAX_THINKING_TOKENS env var | Highest priority; default is 0, no thinking (zitao.dev) |
| Verdict | Global for habits, project for context | Choose the narrowest scope that fits |
Where does each Claude Code setting live?
The table above is the map. Details worth knowing:
- Instructions:
~/.claude/CLAUDE.mdholds system-wide instructions, and CLAUDE.md files in a project root or subdirectories add more precise context (seanpedersen.github.io). - Commands: creating
~/.claude/commandsand a file likefollow-up.mdlets you call/follow-up(seanpedersen.github.io). - MCP: scopes map to local (project
.claude/), user (~/.claude/), and project (.mcp.json) (zitao.dev). - Environment variables: on macOS zsh edit
~/.zshrc; on Linux bash edit~/.bashrc, then open a new terminal. Keep files containing keys out of Git (monkeytheme.com).
For a starter file without hand-writing it, use the Claude MD Generator.
How do you set up CLAUDE.md globally and per project?
- Create
~/.claude/CLAUDE.mdand keep it general and workflow oriented (seanpedersen.github.io). - Add a
CLAUDE.mdat each project root with that project's context (seanpedersen.github.io). - Add a safety rule globally: never run destructive commands like rm, DB or ufw changes without asking the user for confirmation first (seanpedersen.github.io).
- Phrase rules positively. Negative rules such as "do not use random data to test the environment" are hard for current AI systems to follow (seanpedersen.github.io). Write "use fixtures from
tests/fixtures" instead.
If a rule applies to every repo you touch, it goes global. If it names a framework, folder, or command, it goes in the project file.
Which MCP scope should a server use?
The claude mcp add default scope is local; you can set -s, --scope to user or project (zitao.dev). Our recommendation:
- local: experiments and servers with personal tokens.
- user: servers you want in every project, such as a docs lookup.
- project: servers the whole team needs, since
.mcp.jsonsits in the repo (zitao.dev).
Servers cost context. Disable MCP servers by default and load them only when needed (seanpedersen.github.io). To lock a session down, pass --strict-mcp-config: only servers from --mcp-config are used and all other MCP configurations are ignored (zitao.dev). Supported transports are stdio, sse, and http. The MCP Config Generator produces the config file for common servers.
How do you configure thinking tokens, and which method wins?
The default is 0, meaning no thinking, and the maximum is 31,999 (zitao.dev).
| Method | How | Scope |
|---|---|---|
| Env var (wins) | export MAX_THINKING_TOKENS=31999 in ~/.bashrc or ~/.zshrc | Every session (zitao.dev) |
| Keyword | Type ultrathink in a message | That turn gets 31,999 thinking tokens (zitao.dev) |
| Flag | claude -p --max-thinking-tokens 31999 "your prompt" | Print mode only (zitao.dev) |
The env var overrides everything (zitao.dev). Pick it if you want thinking always on. Pick the keyword if you want it only for hard problems and a lean default. Use the flag for scripted one-shot calls.
One pitfall: the settings-file route once displayed in the UI but did not sync to the runtime calculation layer (zitao.dev). That is why the env var is the dependable choice.
Which CLI flags belong in a config and which are dangerous?
-p, --print: prints the response and exits, useful for pipes. It skips the workspace trust dialog, so use it only in trusted directories (zitao.dev).--allowedTools/--disallowedTools: comma or space-separated tool names, for example"Bash(git:*) Edit"(zitao.dev). Safe to put in aliases. For a persistent allow and deny list, build one with the Permissions Generator.--fallback-model <model>: automatic fallback when the default model is overloaded; works with print mode (zitao.dev). Good for unattended scripts.--fork-session: with--resumeor--continue, creates a new session ID instead of reusing the original (zitao.dev). Session IDs must be valid UUIDs.--dangerously-skip-permissions: bypasses all permission checks and is recommended only for sandboxes with no internet access (zitao.dev). Never alias it, never put it in a shell profile.
How do you point Claude Code at a custom endpoint and model?
This applies if you use a third-party gateway. The monkeytheme.com guide sets four variables (monkeytheme.com):
- Set
ANTHROPIC_BASE_URLto the root domain. Do not append/v1/messages(monkeytheme.com). - Set
ANTHROPIC_AUTH_TOKENto your key. - Set
ANTHROPIC_MODEL; the guide usesclaude-opus-4-8, and other groups need their IDs checked separately (monkeytheme.com). - Set
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICto1. It does not disable all networking (monkeytheme.com).
On macOS and Linux use export; in Windows PowerShell use $env: (monkeytheme.com). When changing groups, recheck the model, restart Claude Code, and remove conflicting authentication variables from earlier providers. An unexpected official login flow may mean an older authentication setting is overriding yours. Launching proves installation only, and a test request may cost money. Do not share keys or complete session logs.
When is this configuration the wrong choice, and how do you keep it lean?
Everything always loaded costs context. Claude Code suffers from context rot: the longer and noisier the context, the worse the performance and the more tokens used (seanpedersen.github.io). Use /clear or /compact when a task finishes or Claude gets stuck.
Keep global files short and move specifics into project files. Prefer skills for rarely used knowledge: only a name and description load upfront, and the full SKILL.md is read when a task triggers it (seanpedersen.github.io). Global thinking tokens are the wrong choice if most of your work is small edits; use ultrathink per turn instead.
Configuration also does not replace design. Plan the architecture yourself, then have Claude implement small features that are easy to validate (seanpedersen.github.io).
Next action: write a five-line ~/.claude/CLAUDE.md with the confirm-before-destructive rule, then set your MCP servers to user or project scope only where they earn their context. The Claude Code Cheat Sheet lists the commands for checking the rest.
ClockedCode: Upgrade your Claude Code setup in one paste A curated Claude Code setup: vetted tools, subagents, and a tuned CLAUDE.md, compiled into one master prompt you paste once.