How to Configure Claude Code: Settings, Permissions, and Environment Variables
Claude Code's configuration system uses five scopes that merge together to control permissions, model selection, hooks, and runtime behavior. Understanding how precedence works, where settings files live, and how teams share configuration in Claude Cowork workflows prevents the silent overrides and permission loops that trip up most developers.
How the Configuration Hierarchy Works
73% of engineering teams now use AI coding tools daily, a 32-point jump from 41% a year earlier, according to the Pragmatic Engineer Survey of 15,000 developers in February 2026. But adoption speed has outpaced configuration literacy. Claude Code ships with over 125 settings spread across five distinct scopes, and most teams never move past the defaults. The gap between "it works" and "it works well" is almost always a configuration problem.
The scope system determines where a setting is defined, who it affects, and whether it travels with the project. Here is how the five scopes rank, from highest precedence to lowest:
A managed policy set by your IT team cannot be overridden by any lower scope. A local setting overrides the project and user scopes. CLI flags override everything except managed policies.
The merge behavior is the critical detail most developers miss. For scalar settings like model or effortLevel, the highest-precedence scope wins outright. For array settings like permissions.allow and permissions.deny, values concatenate and deduplicate across all scopes. This means a deny rule in your project settings works alongside an allow rule in your user settings. They don't replace each other.
Most settings hot-reload when you save the file. Permissions, hooks, API key helpers, and credential configuration all take effect immediately without restarting. Model changes are the exception: switch models mid-session with the /model command, or restart Claude Code entirely.
In practice, most developers start with user-scope settings for their personal model preference and effort level. When joining a team project, the project-scope settings layer on shared permission rules and hooks. The local scope handles anything personal that should vary per project, like API keys for a staging environment or a different default model for a cost-sensitive prototype.
Where to Find Each Settings File
Each scope maps to a specific file path. Knowing which file to edit is half the configuration battle, because editing the wrong file means your change either gets overridden silently or doesn't apply where you expect.
User scope:
~/.claude/settings.json Personal defaults for all projects
~/.claude/CLAUDE.md Personal memory and instructions
~/.claude/agents/ Custom subagent definitions
Project scope (committed to git):
.claude/settings.json Team-shared settings
.claude/CLAUDE.md Project memory and instructions
.claude/agents/ Project subagent definitions
.mcp.json MCP server configuration
Local scope (gitignored):
.claude/settings.local.json Personal project-specific overrides
Managed scope (system-level):
macOS: /Library/Application Support/ClaudeCode/
Linux: /etc/claude-code/
Windows: C:\Program Files\ClaudeCode\
A basic settings.json looks like this:
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"model": "claude-sonnet-4-6",
"effortLevel": "high",
"permissions": {
"allow": [
"Bash(npm run lint)",
"Bash(npm run test *)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)"
]
},
"env": {
"BASH_DEFAULT_TIMEOUT_MS": "300000"
}
}
The $schema field enables autocomplete in VS Code, Cursor, and other JSON-aware editors. It validates your configuration against the official schema, catching typos before they silently break your setup.
The CLAUDE.md files at each scope provide natural language instructions that Claude Code reads at session start. User-scope CLAUDE.md contains personal preferences and global guidelines. Project-scope CLAUDE.md holds project-specific context like directory structure, coding conventions, and team processes. These files complement settings.json by giving Claude Code context rather than structured configuration rules.
Enterprise administrators get a drop-in directory at managed-settings.d/. Any .json file placed there merges into managed settings alphabetically: 10-telemetry.json loads before 20-security.json. Scalar values from later files override earlier ones. Arrays concatenate and deduplicate. This lets IT teams compose policies from independent modules without maintaining one monolithic file.
On Windows, user-scope paths map to %USERPROFILE%\.claude\. The managed scope uses C:\Program Files\ClaudeCode\ on v2.1.75 and later. Legacy installs on Windows used C:\ProgramData\ClaudeCode\, which is no longer the default path.
How to Set Up Permission Rules and Security Boundaries
The permission system controls which tools Claude Code can run without asking. Three arrays define the rules: allow for automatic execution, deny for blocked operations, and ask for actions that require your confirmation each time.
{
"permissions": {
"allow": [
"Bash(npm run lint)",
"Bash(npm run test *)",
"Bash(git status)",
"Bash(git diff *)",
"Read(~/.zshrc)"
],
"deny": [
"Bash(curl *)",
"Bash(rm -rf *)",
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)"
]
}
}
Each rule follows the pattern ToolName(argument_pattern). The * wildcard matches any string, and ** matches across directory boundaries. Bash(npm run test *) allows any npm test command. Read(./secrets/**) matches files at any depth inside the secrets directory.
The ask array is useful for operations you want Claude Code to attempt but with your explicit confirmation each time. This works well for commands like database migrations, deployment scripts, or force-pushes where you want visibility into every execution without a hard block.
When rules conflict across scopes, deny wins. If your user settings allow Bash(curl *) but your project settings deny it, the deny takes effect. This design is intentional: project maintainers can enforce security boundaries that individual developers cannot bypass from their personal settings.
A practical team pattern puts common build and test commands in the project's .claude/settings.json:
{
"permissions": {
"allow": [
"Bash(npm run *)",
"Bash(npx jest *)",
"Bash(git log *)",
"Bash(git status)",
"Bash(git diff *)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Bash(git push *)",
"Bash(git reset --hard *)"
]
}
}
This lets Claude Code run builds, tests, and read-only git commands without interrupting you for approval. It blocks access to environment secrets and prevents destructive git operations. Individual developers can then layer personal rules on top through .claude/settings.local.json without changing the team baseline.
Enterprise teams with stricter requirements can set allowManagedPermissionRulesOnly: true in managed settings. This ignores all user and project permission rules entirely, locking configuration to IT-deployed policies. Combined with allowManagedHooksOnly, this gives administrators complete control over what Claude Code can execute across the organization.
Give your Claude Code agents persistent file storage
Fast.io's MCP endpoint lets agents read, write, and share files across sessions, with auto-indexing for semantic search and RAG. Starts with a 14-day free trial.
Environment Variables That Control Behavior
Environment variables offer another configuration layer, especially useful for authentication, model routing, and feature toggles. You can set them in your shell before launching claude, or persist them in the env field of any settings.json file.
{
"env": {
"API_TIMEOUT_MS": "1200000",
"BASH_DEFAULT_TIMEOUT_MS": "300000",
"CLAUDE_CODE_DEBUG_LOG_LEVEL": "verbose"
}
}
Shell-set variables take precedence over values from the env field. This makes shell variables useful for quick session-level overrides, while the env field handles persistent defaults you don't want to set every time you open a terminal.
A common pattern for build-heavy projects: set BASH_DEFAULT_TIMEOUT_MS to 600000 in your project's .claude/settings.json so that long Webpack or Gradle builds don't get killed at the default 2-minute mark. Keep the value in the project scope rather than your user settings, because timeout requirements vary by repo. A React monorepo with a 4-minute production build needs a different timeout than a small CLI tool that compiles in seconds.
Authentication and API Routing
The most common authentication variable is ANTHROPIC_API_KEY, which sends your key as the X-Api-Key header. For AWS Bedrock, use AWS_BEARER_TOKEN_BEDROCK. For Vertex AI, set ANTHROPIC_VERTEX_PROJECT_ID alongside your GCP credentials. If your organization routes requests through a proxy or API gateway, ANTHROPIC_BASE_URL overrides the default endpoint.
For corporate environments with TLS inspection, three variables handle mutual TLS: CLAUDE_CODE_CLIENT_CERT for the certificate file path, CLAUDE_CODE_CLIENT_KEY for the private key, and CLAUDE_CODE_CLIENT_KEY_PASSPHRASE for encrypted keys. CLAUDE_CODE_CERT_STORE controls which CA certificate sources Claude Code trusts, accepting bundled, system, or both comma-separated.
Model Selection and Feature Toggles
ANTHROPIC_MODEL overrides the configured model for the current session without changing your settings files. The ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL, and ANTHROPIC_DEFAULT_FABLE_MODEL variables remap built-in model tiers to custom identifiers. This is useful when routing through AWS Bedrock ARNs or Vertex AI model paths that differ from Anthropic's standard model names. You can also add a custom model to the /model picker with ANTHROPIC_CUSTOM_MODEL_OPTION.
Feature toggles follow a CLAUDE_CODE_DISABLE_* naming convention. CLAUDE_CODE_DISABLE_AUTO_MEMORY turns off automatic memory extraction. CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING stops file snapshots before edits, disabling the /rewind command. CLAUDE_CODE_DISABLE_1M_CONTEXT reverts to standard context windows. About two dozen disable flags exist, each controlling a specific capability you can turn off independently.
The default bash command timeout is 120 seconds (BASH_DEFAULT_TIMEOUT_MS), which is often too short for builds and deployments. Set it to 300000 (5 minutes) or higher for projects with slow compilation. BASH_MAX_TIMEOUT_MS caps the maximum at 600000 (10 minutes) by default.
One detection variable worth knowing: CLAUDECODE is automatically set to 1 in any subprocess that Claude Code spawns. Your build scripts, linters, and CI tools can check this flag to adjust their behavior when running inside a Claude Code session versus a standard terminal.
How to Share Configuration Across Claude Cowork Teams
Sharing configuration across a development team is where Claude Code's scope system pays off. The project scope (.claude/settings.json) travels with your repository, so every collaborator gets the same permission rules, model defaults, and hooks as soon as they clone. Personal preferences stay in .claude/settings.local.json, which is gitignored by default. This split means teams agree on security boundaries while each developer keeps their own model and effort preferences.
A practical pattern for onboarding: add a SessionStart hook to .claude/settings.json that prints a checklist of required environment variables. New developers cloning the repo get immediate feedback about missing API keys instead of hitting cryptic errors mid-session. Combined with deny rules that block .env reads, this keeps secrets out of Claude Code's context while making sure the developer has them configured in their shell.
For Claude Cowork setups where agents produce artifacts that humans review, keeping shared configuration in the project scope means every team member and every agent session starts with identical permission boundaries. The local scope then handles per-developer preferences like model selection or custom hooks for personal linting tools. This layered approach scales from a two-person team to an enterprise deployment without requiring everyone to maintain identical dotfiles.
Hooks for Lifecycle Automation
Hooks run custom commands at specific points in Claude Code's lifecycle. The supported events are PreToolUse, PostToolUse, SessionStart, Stop, CwdChanged, and Notification. A team might configure a PostToolUse hook that runs a linter after every file write, or a SessionStart hook that verifies required API keys are present before work begins.
Hook configuration lives in settings.json alongside permissions and other settings. Hooks hot-reload when the file changes, so you can iterate on them without restarting your session. For enterprise environments, administrators can restrict hooks to managed scope only with allowManagedHooksOnly, preventing user-defined or project-defined hooks from executing in the organization.
MCP Server Configuration
The .mcp.json file at the project root defines which Model Context Protocol servers Claude Code connects to. MCP servers make external tools and data sources available during conversations. Teams share MCP configurations through git by committing .mcp.json to the repository.
Individual developers can override which servers load using enabledMcpjsonServers and disabledMcpjsonServers in their local settings. For enterprise environments, allowedMcpServers and deniedMcpServers in managed settings control which servers are permitted organization-wide. Setting allowManagedMcpServersOnly restricts connections to administrator-approved servers only.
Model overrides let teams standardize which models are available. The availableModels setting restricts the model picker to a specific list, preventing accidental use of higher-cost models in CI/CD pipelines or cost-sensitive environments:
{
"availableModels": ["sonnet", "haiku"],
"model": "claude-sonnet-4-6"
}
Persistent Storage for Agent Workflows
When Claude Code agents need file storage that persists between sessions and is accessible to other team members, the options include local directories (simple but not portable), cloud storage like S3 or Google Drive (requires custom integration scripts), and workspace platforms built for agent collaboration.
Fast.io provides an MCP-native workspace where agents read, write, and share files through a single endpoint at mcp.fast.io. Intelligence Mode auto-indexes uploaded files for semantic search, so agents can query workspace contents without building a separate retrieval pipeline. Fast.io plans include workspace storage and monthly AI credits, and every org starts with a 14-day free trial.
For Claude Cowork patterns where agents produce outputs that humans need to review, Fast.io supports ownership transfer. An agent creates a workspace, populates it with files, and transfers ownership to a human who reviews the output through the web interface. The agent retains admin access for future updates. This bridges agent-generated work and human approval without manual file shuffling between systems. See the MCP documentation for setup details.
Frequently Asked Questions
Where is Claude Code's settings.json file?
User settings live at ~/.claude/settings.json and apply to all projects. Project settings go in .claude/settings.json at your repository root and are shared with collaborators via git. Personal project overrides use .claude/settings.local.json, which is gitignored by default. On Windows, the user path maps to %USERPROFILE%\.claude\settings.json.
What are Claude Code's configuration scopes?
Claude Code has five scopes listed from highest to lowest precedence: Managed (IT-deployed policies), CLI (command-line flags), Local (.claude/settings.local.json), Project (.claude/settings.json), and User (~/.claude/settings.json). Scalar settings follow this precedence directly. Array settings like permission rules merge across all scopes instead of being replaced.
How do I configure Claude Code permissions?
Add allow, deny, and ask arrays to the permissions object in any settings.json file. Each rule follows the ToolName(pattern) format. For example, Bash(npm run *) allows any npm script, and Read(./.env) blocks reading the .env file. Deny rules always take precedence when they conflict with allow rules, even across different scopes.
What environment variables does Claude Code support?
Claude Code supports over 60 environment variables across categories including authentication (ANTHROPIC_API_KEY), model selection (ANTHROPIC_MODEL), endpoint routing (ANTHROPIC_BASE_URL), feature toggles (CLAUDE_CODE_DISABLE_* flags), bash timeouts (BASH_DEFAULT_TIMEOUT_MS), and debugging (CLAUDE_CODE_DEBUG_LOG_LEVEL). Set them in your shell or persist them in the env field of settings.json.
How do I share Claude Code settings with my team?
Commit .claude/settings.json to your repository. This file travels with the codebase and gives every collaborator the same permission rules, hooks, and model defaults. Personal preferences go in .claude/settings.local.json, which is gitignored automatically. MCP server configurations use .mcp.json at the project root.
What is the precedence order for Claude Code settings?
From highest to lowest: Managed (enterprise policies), CLI flags, Local (settings.local.json), Project (.claude/settings.json), and User (~/.claude/settings.json). Managed settings cannot be overridden by any lower scope. Permission rules are the exception, since they merge across all scopes instead of replacing each other.
How do I configure MCP servers in Claude Code?
Create a .mcp.json file at your project root with server definitions. Project-level MCP configurations are shared through git. Control which servers load using enabledMcpjsonServers and disabledMcpjsonServers in your settings.json. Enterprise administrators can restrict servers organization-wide with allowedMcpServers and deniedMcpServers in managed settings.
Can I use Claude Code with a proxy or custom API endpoint?
Yes. Set the ANTHROPIC_BASE_URL environment variable to route API requests through your proxy or gateway. For corporate environments with TLS inspection, configure CLAUDE_CODE_CLIENT_CERT and CLAUDE_CODE_CLIENT_KEY for mutual TLS authentication. The CLAUDE_CODE_CERT_STORE variable controls which CA certificate sources Claude Code trusts, accepting bundled, system, or both.
Related Resources
Give your Claude Code agents persistent file storage
Fast.io's MCP endpoint lets agents read, write, and share files across sessions, with auto-indexing for semantic search and RAG. Starts with a 14-day free trial.