CLAUDE LABJP
WWDC — WWDC 2026 opens Jun 8; the revamped Siri is reported to run on Google Gemini, with Claude among the third-party AI choicesBILLING — From Jun 15, Agent SDK, headless Claude Code, GitHub Actions, and third-party agents move off subscription limits to API-rate monthly credit (1 week left)FALLBACK — Claude Code adds a fallbackModel setting that tries up to three models in order when the primary is overloaded (Jun)DENY-GLOB — Deny rules now support glob patterns in the tool-name position, with stronger cross-session message security (Jun)OPUS4.8 — Claude Opus 4.8 is now the default on Max, Team Premium, Enterprise pay-as-you-go, and the Anthropic API (Jun)MANAGED-AGENTS — Claude Managed Agents can run in a sandbox you control and connect to your private MCP servers (Jun)WWDC — WWDC 2026 opens Jun 8; the revamped Siri is reported to run on Google Gemini, with Claude among the third-party AI choicesBILLING — From Jun 15, Agent SDK, headless Claude Code, GitHub Actions, and third-party agents move off subscription limits to API-rate monthly credit (1 week left)FALLBACK — Claude Code adds a fallbackModel setting that tries up to three models in order when the primary is overloaded (Jun)DENY-GLOB — Deny rules now support glob patterns in the tool-name position, with stronger cross-session message security (Jun)OPUS4.8 — Claude Opus 4.8 is now the default on Max, Team Premium, Enterprise pay-as-you-go, and the Anthropic API (Jun)MANAGED-AGENTS — Claude Managed Agents can run in a sandbox you control and connect to your private MCP servers (Jun)
Articles/Claude Code
Claude Code/2026-04-18Intermediate

Claude Code Environment Variables & Configuration Flags: The Complete Reference

A comprehensive reference for every Claude Code environment variable, CLI flag, and settings.json field. Covers CLAUDE_CODE_USE_POWERSHELL_TOOL, timeout tuning, CI/CD setup, and team configuration patterns.

claude-code174environment-variables2configuration8powershell3settings.json2cli4

There's a specific moment most Claude Code users hit: you want to tweak some behavior — enable PowerShell support, extend a Bash timeout, or run headlessly in CI — and you end up digging through scattered docs trying to find the right knob to turn.

This guide gathers all of those knobs in one place. Claude Code exposes three layers of configuration (settings files, environment variables, and CLI flags), and understanding which layer to reach for makes the difference between a smooth workflow and a frustrating afternoon.

The Three Configuration Layers

Claude Code's settings are organized by scope. Choosing the right layer depends on how broadly you want a change to apply.

1. ~/.claude/settings.json (User-global settings) Applies to every project on your machine. Best for personal defaults: your preferred model, theme, and permission policies that make sense across all your work.

2. .claude/settings.json (Project settings) Applies only to the current project. You can commit this file to your repository so the whole team shares the same configuration. Project settings override user-global settings.

3. Environment variables and CLI flags (Dynamic overrides) Applied at runtime to a single invocation or shell session. Perfect for CI/CD pipelines, temporary experiments, or one-off configuration changes.

The precedence order is: CLI flags > environment variables > project settings.json > global settings.json

What You Can Configure in settings.json

Here's a practical example of a ~/.claude/settings.json setup:

{
  "model": "claude-sonnet-4-6",
  "theme": "dark",
  "autoUpdates": true,
  "permissions": {
    "allow": [
      "Bash(git:*)",
      "Bash(npm:*)",
      "Bash(node:*)",
      "Read(**)",
      "Write(src/**)"
    ],
    "deny": [
      "Bash(rm -rf:*)",
      "Write(.env:*)"
    ]
  },
  "env": {
    "NODE_ENV": "development",
    "BASH_DEFAULT_TIMEOUT_MS": "300000"
  }
}

Key fields:

  • model: Default model for all sessions. claude-sonnet-4-6 for most tasks, claude-haiku-4-5-20251001 for lightweight work where speed matters
  • theme: UI theme — dark, light, or auto
  • autoUpdates: Whether Claude Code updates itself automatically (default: true)
  • permissions.allow: Tool patterns that run without confirmation
  • permissions.deny: Tool patterns that are always blocked — deny takes precedence over allow
  • env: Environment variables injected into every command Claude Code runs

For a deep dive into the permissions system, see Claude Code Permission Modes and Production Security Guide.

Environment Variable Reference

These can be set with export in your shell profile, or persisted via settings.json's env field.

API and Authentication

# Your Anthropic API key (required)
export ANTHROPIC_API_KEY="YOUR_ANTHROPIC_API_KEY"
 
# Use Amazon Bedrock as the backend
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION="us-east-1"
# AWS credentials via ~/.aws/credentials or IAM role
 
# Use Google Vertex AI as the backend
export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION="us-east5"
export ANTHROPIC_VERTEX_PROJECT_ID="your-project-id"

Behavior Control

# Enable the PowerShell tool (Windows / WSL environments)
# Unlocks .ps1 script execution and system management commands
export CLAUDE_CODE_USE_POWERSHELL_TOOL=1
 
# Bash command timeout in milliseconds (default: 120000 = 2 minutes)
# Increase this for slow builds, Docker, or full test suite runs
export BASH_DEFAULT_TIMEOUT_MS=600000  # 10 minutes
 
# Disable update checks at startup (helpful on slow connections)
export CLAUDE_CODE_DISABLE_UPDATE_CHECK=1
 
# Use GitHub Copilot API (for users with an active Copilot subscription)
export CLAUDE_CODE_USE_COPILOT=1

Telemetry and Debugging

# Opt out of usage telemetry
export CLAUDE_TELEMETRY_DISABLED=1
 
# Enable debug logging — invaluable when something behaves unexpectedly
export CLAUDE_CODE_DEBUG=1
 
# Write debug logs to a file instead of stderr
export CLAUDE_CODE_LOG_FILE="/tmp/claude-debug.log"

CI/CD and Automation

# Force non-interactive mode (standard CI convention)
# When set, confirmation prompts are automatically skipped
export CI=1
 
# Skip all permission checks
# ⚠️ Only use this in fully trusted automation environments
# Never set this for local development — unintended file changes are hard to catch
export CLAUDE_CODE_SKIP_PERMISSIONS=1

CLI Flag Reference

Flags apply only to the current command invocation — they're the highest-priority override and require no file editing.

# Interactive session (default)
claude
 
# One-shot execution
claude "Describe what this function does"
 
# Non-interactive / piped input (useful for scripts)
claude -p "Review this diff for issues" < changes.diff
claude --print "Suggest a better variable name for this code"
 
# Model selection
claude --model claude-sonnet-4-6
claude --model claude-haiku-4-5-20251001  # Faster and cheaper for simple tasks
 
# Session continuity
claude --continue                  # Resume the most recent conversation
claude --resume SESSION_ID         # Resume a specific session (see: claude history)
 
# Permission control
claude --dangerously-skip-permissions       # Skip all confirmations
claude --allowedTools "Bash,Read,Write"     # Explicitly whitelist tools
 
# Output formats (for scripting and pipelines)
claude --output-format json                 # Structured JSON response
claude --output-format stream-json          # Streaming JSON for incremental processing
 
# Miscellaneous
claude --no-update-check                    # Skip startup update check

Configuration Recipes for Common Scenarios

Enabling PowerShell on Windows or WSL

If you're working on Windows natively or via WSL and need PowerShell capabilities, add this to your shell profile:

# Add to ~/.bashrc, ~/.zshrc, or ~/.profile
export CLAUDE_CODE_USE_POWERSHELL_TOOL=1

Alternatively, set it permanently in settings.json:

{
  "env": {
    "CLAUDE_CODE_USE_POWERSHELL_TOOL": "1"
  }
}

For a full Windows setup walkthrough, see Claude Code Windows Native + WSL2 Complete Guide.

Fixing Bash Timeout Errors on Long Builds

If you're seeing timeout failures with next build, Docker image builds, or full test runs, the default 2-minute limit is likely the culprit.

# Extend to 10 minutes for the current session
export BASH_DEFAULT_TIMEOUT_MS=600000

To apply this project-wide so teammates don't hit the same issue, add it to .claude/settings.json:

{
  "env": {
    "BASH_DEFAULT_TIMEOUT_MS": "600000"
  }
}

Automated Code Review in GitHub Actions

Setting CI=1 is usually all you need to make Claude Code work non-interactively:

# .github/workflows/ai-review.yml
name: AI Code Review
on:
  pull_request:
    types: [opened, synchronize]
 
jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
 
      - name: Run Claude Code review
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
          CI: "1"
        run: |
          npm install -g @anthropic-ai/claude-code
          git diff origin/main...HEAD > diff.txt
          claude -p "Review this PR diff. Flag any bugs, security issues, or significant code quality problems." \
            < diff.txt

Sharing a Consistent Configuration Across Your Team

Committing .claude/settings.json to your repository ensures everyone works under the same constraints without manual setup.

// .claude/settings.json — commit this to your repo
{
  "permissions": {
    "allow": [
      "Bash(npm:*)",
      "Bash(npx:*)",
      "Bash(git:*)",
      "Bash(node:*)",
      "Read(**)",
      "Write(src/**)",
      "Write(tests/**)",
      "Write(docs/**)"
    ],
    "deny": [
      "Bash(rm -rf:*)",
      "Write(.env:*)",
      "Write(.env.local:*)",
      "Write(*.pem:*)"
    ]
  }
}

The explicit deny on .env files is worth highlighting: it prevents Claude Code from accidentally overwriting API keys or other secrets, even when operating in a permissive allow mode.

Next Step

Start with ~/.claude/settings.json. Add permissions.allow entries for the commands you run most often in your projects. You'll notice fewer interrupting confirmation prompts immediately, and the workflow becomes noticeably smoother.

If you want to go deeper on the full settings.json schema, the Claude Code settings.json Complete Guide covers every available field with detailed examples.

Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

Claude Code2026-04-10
Claude Code --bare Mode Complete Guide — Advanced Configuration, Usage, and Debugging
Take full control of Claude's system prompt with --bare mode. Learn implementation patterns, custom agent design, and production-ready deployment strategies.
Claude Code2026-04-26
Should You Flip CLAUDE_CODE_USE_POWERSHELL_TOOL=1? — A Practical Decision Guide for Windows Developers
When you run Claude Code on Windows, you eventually wonder whether CLAUDE_CODE_USE_POWERSHELL_TOOL=1 is worth flipping on. After running both modes across several projects, here is the decision rubric I now use.
Claude Code2026-04-25
Editing Multiple Repositories at Once With Claude Code --add-dir
How to use Claude Code's --add-dir flag to edit multiple repositories in a single session. Practical patterns for cross-repo API changes, shared utility refactoring, and keeping docs in sync with code.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →