Environment Variables
Configure the Claude Code Templates CLI and Claude Code using environment variables for authentication, API keys, and runtime settings.Authentication Variables
ANTHROPIC_API_KEY
string
required
Anthropic API key for Claude Code authentication
- Authenticate Claude Code CLI
- Enable API-based authentication
- Alternative to OAuth authentication
- Visit https://console.anthropic.com/
- Navigate to API Keys section
- Create new API key
- Copy and set as environment variable
~/.claude.json API key.
Security:
- Never commit to git
- Use
.envfiles with.gitignore - Rotate keys regularly
- Use different keys for dev/prod
.env file:
ANTHROPIC_AUTH_TOKEN
string
Alternative authentication token (if using OAuth)
Sandbox Variables
E2B_API_KEY
string
E2B API key for sandbox execution
- Enable E2B sandbox execution
- Required for
--sandbox e2bflag
- Visit https://e2b.dev/
- Sign up for account
- Create API key
- Set as environment variable
--e2b-api-key flag:
CLOUDFLARE_TUNNEL_TOKEN
string
Cloudflare Tunnel token for remote access (optional)
- Use custom Cloudflare Tunnel
- Persistent tunnel URLs
- Team access to dashboards
- Create Cloudflare account
- Install
cloudflared - Create tunnel:
cloudflared tunnel create my-tunnel - Get token from tunnel config
Runtime Configuration
PORT
number
Port for analytics dashboard and web interfaces
3333
Purpose:
- Change default port if 3333 is in use
- Run multiple dashboards simultaneously
NODE_ENV
string
Node.js environment (development, production, test)
development- Development mode (verbose logging)production- Production mode (minimal logging)test- Testing mode
- Control logging verbosity
- Enable debug features
- Configure behavior
DEBUG
string
Enable debug logging for specific modules
- Detailed debugging output
- Module-specific logs
- Troubleshooting
CCT_DEBUG
string
Enable Claude Code Templates debug logging
- Show tracking debug messages
- Display non-critical errors
- Troubleshoot analytics issues
CCT_NO_TRACKING
string
Disable usage tracking and analytics
- Opt out of anonymous usage analytics
- Disable component download tracking
- Privacy-focused installations
CCT_NO_ANALYTICS
string
Alias for CCT_NO_TRACKING (disables analytics)
- Same as CCT_NO_TRACKING
- Alternative environment variable name
- Disables all telemetry
CCT_NO_TRACKING or CCT_NO_ANALYTICS to true will disable tracking.
Shell Configuration
PATH
string
System PATH for global agent executables
- Make global agents accessible
- Enable command-line execution
- Required for user-directory installations
~/.bashrc or ~/.bash_profile):
~/.zshrc):
~/.config/fish/config.fish):
SHELL
string
Current shell (automatically set by system)
/bin/bash/bin/zsh/usr/bin/fish
- Detect shell for PATH configuration
- Shell-specific features
- Autocompletion setup
CI
string
Continuous Integration environment indicator
true- Running in CI environment- Unset - Local development
- Automatically disables tracking in CI/CD
- Prevents analytics in automated environments
- Skips interactive prompts
Project-Specific Variables
These can be set in.claude/settings.json under the env field:
${VAR_NAME} to reference system environment variables.
Environment Variable Precedence
When multiple sources define the same variable:- Command-line flags (highest priority)
- Environment variables
- Local settings (
.claude/settings.local.json) - Project settings (
.claude/settings.json) - User settings (
~/.claude/settings.json) (lowest priority)
.env Files
Project .env
Store environment variables in.env file:
.env.example
Create template for team:Gitignore
Always exclude.env from git:
CI/CD Configuration
GitHub Actions
Set secrets in repository settings:- Go to repository Settings > Secrets and variables > Actions
- Add
ANTHROPIC_API_KEYsecret - Reference with
${{ secrets.ANTHROPIC_API_KEY }}
GitLab CI
- Go to Settings > CI/CD > Variables
- Add
ANTHROPIC_API_KEY(protected, masked)
Docker Configuration
Dockerfile
docker-compose.yml
Security Best Practices
1. Never Commit Secrets
2. Use Separate Keys
- Development: Personal API key
- Staging: Team staging key
- Production: Production key (rotate regularly)
3. Restrict Permissions
4. Rotate Keys Regularly
5. Use Key Management Systems
AWS Secrets Manager:Troubleshooting
Variables Not Loading
Check if variable is set:Authentication Fails
Test API key:- Should start with
sk-ant- - No whitespace or special characters
- Not expired
PATH Not Working
Verify PATH includes bin directory:Permission Denied
Fix file permissions:Next Steps
- CLI Flags Reference - All CLI flags
- Configuration Guide - Settings files
- Health Check - Verify configuration
- CLI Overview - Complete CLI documentation