Claude Code Environment Variables: The Complete Configuration Guide for 2026
Master every Claude Code environment variable, from CLAUDE_CODE_NO_FLICKER to model selection, proxy settings, and the full settings.json hierarchy. The definitive reference for frontend developers.
You open Claude Code vs Antigravity: The Ultimate AI Coding Tool Comparison in 2025">Claude Code Source Leak: Fake Tools, Undercover Mode, and the Secrets Anthropic Didn't Mean to Share">Claude Code, start a long coding session, and the terminal starts flickering like a strobe light. You've seen people mention CLAUDE_CODE_NO_FLICKER on Reddit, but what does it actually do? And what other hidden settings are you missing?
After months of using Claude Code daily for frontend development — and digging through the official docs, the leaked source map, and community discussions — I've compiled the definitive guide to every environment variable and configuration option that matters in 2026.
Whether you're running Claude Code with a direct API key, through Amazon Bedrock, or on a Max subscription, this guide covers the settings that will make your experience dramatically better.
The Flickering Problem: CLAUDE_CODE_NO_FLICKER
Let's start with the most searched-for setting. If you've used Claude Code in VS Code's integrated terminal, tmux, or iTerm2, you've probably noticed annoying screen flickering during long outputs. The terminal struggles to keep up with Claude's rendering throughput.
The fix is simple:
# Add to your .bashrc or .zshrc
export CLAUDE_CODE_NO_FLICKER=1
# Or run it inline
CLAUDE_CODE_NO_FLICKER=1 claudeThis enables fullscreen rendering mode, introduced in Claude Code v2.1.89. Instead of streaming partial updates that cause visual tearing, it buffers the output and renders complete frames. The result: stable visuals and consistent memory usage during extended sessions.
When to use it:
- VS Code integrated terminal (biggest improvement)
- tmux or screen sessions
- iTerm2 with split panes
- Any terminal where you notice rendering artifacts
When you might skip it: Native macOS Terminal.app and modern GPU-accelerated terminals like Kitty or Alacritty rarely have this issue. But honestly, there's no downside to enabling it globally.
Authentication and API Configuration
The most critical environment variables control how Claude Code authenticates and which models it uses.
API Key Authentication
# Direct Anthropic API (pay-as-you-go)
export ANTHROPIC_API_KEY="sk-ant-api03-..."
# Custom API endpoint (for proxies or gateways)
export ANTHROPIC_BASE_URL="https://your-proxy.example.com/v1"Important: If you have both a Claude.ai Max subscription and ANTHROPIC_API_KEY set, the environment variable wins. This means you'll be billed per-token through the API instead of using your subscription. Claude Code will warn you about this conflict — pay attention to it.
You can verify your active auth method anytime with the /status command inside Claude Code.
Cloud Platform Integration
# Amazon Bedrock
export CLAUDE_CODE_USE_BEDROCK=1
export ANTHROPIC_BEDROCK_BASE_URL="https://bedrock-runtime.us-east-1.amazonaws.com"
export AWS_REGION="us-east-1"
# Google Vertex AI
export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION="us-central1"
export ANTHROPIC_VERTEX_PROJECT_ID="your-project-id"If you're on a team that routes AI through a cloud provider for compliance, these variables are essential. One common gotcha: when using Bedrock, you may encounter errors related to anthropic-beta headers. The fix:
# Disable experimental beta features that conflict with Bedrock
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1Model Selection Variables
As of early 2026, Claude Code defaults to Opus 4.6, but you can override which models map to each alias:
# Override the default model for each tier
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4-6-20260301"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4-6-20260301"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-3-5-20241022"
# Add a custom model to the /model picker
export ANTHROPIC_CUSTOM_MODEL_OPTION="my-fine-tuned-model-id"
# Set processing effort level
export CLAUDE_CODE_EFFORT_LEVEL="high" # low | medium | highThe effort level is particularly useful. Setting it to high tells Claude to think more deeply, which is great for complex refactoring or architectural decisions. For quick edits and simple questions, low saves tokens and responds faster.
You can also change the model mid-session with the /model command and effort with /effort — no restart needed.
Network and Proxy Configuration
If you're behind a corporate firewall or VPN, these settings keep Claude Code connected:
# HTTPS proxy (standard format)
export HTTPS_PROXY="http://proxy.corporate.com:8080"
# With authentication
export HTTPS_PROXY="http://user:password@proxy.corporate.com:8080"
# No-proxy exceptions
export NO_PROXY="localhost,127.0.0.1,.internal.company.com"Claude Code respects standard proxy environment variables, so if you've already configured them for npm or git, they'll work here too.
The Settings.json Hierarchy
While not environment variables per se, Claude Code also supports a powerful file-based configuration hierarchy. Understanding the precedence order is crucial:
Priority (highest to lowest):
1. Managed settings (Anthropic admin console / MDM policies)
2. Command-line flags (--effort, --betas, etc.)
3. Environment variables
4. Local directory settings (.claude/settings.local.json)
5. Project settings (.claude/settings.json)
6. User settings (~/.claude/settings.json)User-Level Settings
// ~/.claude/settings.json
{
"permissions": {
"allow": [
"Read(*)",
"Edit(*)",
"Bash(npm run *)",
"Bash(git *)"
],
"deny": [
"Bash(rm -rf /)"
]
},
"env": {
"CLAUDE_CODE_NO_FLICKER": "1",
"CLAUDE_CODE_EFFORT_LEVEL": "medium"
}
}The env key is powerful — it lets you set environment variables persistently without touching your shell profile. This is especially useful on shared machines or when you want project-specific env vars.
Project-Level Settings
// .claude/settings.json (commit this to git)
{
"permissions": {
"allow": [
"Bash(npm run build)",
"Bash(npm run test)",
"Bash(npx prisma *)"
]
}
}
// .claude/settings.local.json (add to .gitignore)
{
"env": {
"ANTHROPIC_API_KEY": "sk-ant-api03-your-personal-key"
}
}The split between settings.json (shared) and settings.local.json (personal) follows the same pattern as .env and .env.local in Next.js projects. Commit the shared one, gitignore the local one.
Essential Command-Line Flags
Beyond environment variables, Claude Code accepts flags that modify behavior for a single session:
# Set effort level for this session only
claude --effort high
# Enable Anthropic API betas (requires API key auth)
claude --betas
# Resume a previous session
claude --resume
# Run in non-interactive mode (CI/CD)
claude -p "Generate unit tests for src/utils.ts"
# Print output as JSON (for scripting)
claude -p "List all TODO comments" --output-format jsonThe non-interactive mode (-p) is incredibly useful for CI/CD pipelines. I use it in pre-commit hooks to auto-generate test descriptions and in GitHub Actions to review PRs. If you're building AI-assisted workflows, check out our guide on Claude Code Hooks for frontend workflows.
The Three Essential Files: CLAUDE.md, .claudeignore, and Skills
While not environment variables per se, these configuration files are just as important for how Claude Code behaves in your project:
CLAUDE.md — Your Project's AI Context
# CLAUDE.md
## Project Overview
This is a Next.js 16 e-commerce app using App Router, Prisma, and Tailwind CSS.
## Architecture
- /app — Next.js App Router pages and layouts
- /lib — Shared utilities, API clients, database queries
- /components — React components (server and client)
## Coding Standards
- Use TypeScript strict mode
- Prefer Server Components by default
- Use 'use client' only when needed (interactivity, hooks)
- Write tests with Vitest + Testing Library
## Commands
- npm run dev — Start dev server
- npm run build — Build for production
- npm run test — Run testsThis file is the single most impactful configuration you can create. It gives Claude Code persistent context about your project without wasting tokens on rediscovery each session. For a deep dive into using Claude Code with Next.js projects, see our comprehensive Claude Code + Next.js tutorial.
.claudeignore — Token Budget Management
# .claudeignore
node_modules/
.next/
dist/
coverage/
*.min.js
*.map
public/assets/videos/
**/*.generated.tsEvery file Claude Code reads costs tokens. A .claudeignore file prevents it from wasting your context window on build artifacts, vendored dependencies, and generated files. Think of it as .gitignore for your AI budget.
Performance and Debugging Variables
A few more environment variables that are useful for specific situations:
# Disable telemetry (if you prefer)
export CLAUDE_CODE_DISABLE_TELEMETRY=1
# Increase timeout for slow connections
export ANTHROPIC_TIMEOUT=120000 # milliseconds
# Enable verbose logging for debugging
export CLAUDE_CODE_DEBUG=1
# Force a specific terminal width (useful in CI)
export COLUMNS=120My Recommended Setup for Frontend Development
After extensive experimentation, here's the configuration I use daily for Next.js and React development:
# ~/.zshrc (or ~/.bashrc)
# Core Claude Code settings
export CLAUDE_CODE_NO_FLICKER=1
export CLAUDE_CODE_EFFORT_LEVEL="medium"
# Aliases for quick access
alias cc="claude"
alias ccr="claude --resume"
alias cch="claude --effort high"
alias ccl="claude --effort low"// ~/.claude/settings.json
{
"permissions": {
"allow": [
"Read(*)",
"Edit(*)",
"Bash(npm run *)",
"Bash(npx *)",
"Bash(git *)",
"Bash(pnpm *)",
"Bash(bunx *)"
],
"deny": [
"Bash(rm -rf *)",
"Bash(sudo *)"
]
},
"env": {
"CLAUDE_CODE_NO_FLICKER": "1"
}
}And in each project:
// .claude/settings.json
{
"permissions": {
"allow": [
"Bash(npm run dev)",
"Bash(npm run build)",
"Bash(npm run test *)",
"Bash(npx prisma *)",
"Bash(docker compose *)"
]
}
}Troubleshooting Common Issues
Here are the most frequent configuration problems and their fixes:
Problem: "anthropic-beta header not supported" on Bedrock
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1Problem: Claude Code ignoring your subscription and charging API
Check for a stale ANTHROPIC_API_KEY in your shell profile or settings.json. Remove it or run unset ANTHROPIC_API_KEY.
Problem: Context window filling up too fast
Add a .claudeignore file and exclude heavy directories. Claude Code's context compaction kicks in automatically in long sessions, but prevention is better than compression.
Problem: Slow responses behind corporate proxy
Ensure HTTPS_PROXY is set correctly and that your proxy allows WebSocket connections, which Claude Code uses for streaming.
What's Coming Next
Based on the leaked source map and recent changelog patterns, we can expect Claude Code to add more granular configuration options in upcoming releases. The Adapter API in Next.js 16.2 and the growing ecosystem of MCP servers suggest that Claude Code's configuration surface will expand significantly in 2026.
For now, mastering the variables and settings in this guide will put you ahead of most developers who are still running Claude Code with zero configuration. The difference between a default setup and a well-configured one is like the difference between a stock IDE and one with your preferred keybindings, theme, and extensions — technically optional, practically essential.
Bookmark this page — I'll update it as new variables and settings are released throughout 2026.
Admin
Dub.co
Short links & analytics for developers — track clicks, create branded links, manage affiliate URLs with ease.
Ranked.ai
AI-powered SEO & PPC service — fully managed, white hat, and built for modern search engines. Starting at $99/month.
Bài viết liên quan
How to Deploy a Node.js App on DigitalOcean: Droplet + Nginx + PM2 + SSL in 2026
A practical step-by-step guide to deploying a production Node.js application on a DigitalOcean Droplet with Nginx as a reverse proxy, PM2 for process management, and a free Let's Encrypt SSL certificate.
Comments (0)
Sign in to comment
No comments yet. Be the first to comment!