Claude Code environment variables: authentication, routing, and scope

Kenneth Pangan
Written by

Kenneth Pangan

Last edited September 9, 2026

Expert Verified
Illustration of a diner and server beside speech bubbles and an eesel-branded serving cover.

What an environment variable changes

An environment variable is a named value a process receives. It can come from the launching shell, a CI secret store, or an application's configuration. It is not necessarily a system-wide setting, and changing it in one terminal does not update every running app.

Claude Code's environment reference documents supported names and precedence. Do not copy a large list into a shell profile just in case: each entry can change behavior for later sessions and child processes.

VariableDocumented purposeWhat to verify
ANTHROPIC_API_KEYAuthenticate API requestsIntended account and billing route
ANTHROPIC_BASE_URLUse a different API endpointApproved gateway and destination
ANTHROPIC_MODELSelect the model settingAvailability and other overrides
HTTPS_PROXYRoute network traffic through a proxyOrganization policy and credentials
NODE_EXTRA_CA_CERTSAdd trusted CA certificatesApproved certificate file
CLAUDE_CODE_USE_BEDROCKSelect Amazon BedrockProvider credentials and access
CLAUDE_CODE_USE_VERTEXSelect Google's supported cloud provider pathCurrent provider setup requirements
CLAUDE_CODE_USE_FOUNDRYSelect Microsoft FoundryProvider credentials and access
API_TIMEOUT_MSAPI request timeoutMilliseconds, network cause, valid range
BASH_DEFAULT_TIMEOUT_MSDefault Bash command timeoutThe command's behavior and allowed runtime

The two timeouts solve different problems. A longer API timeout does not grant a longer Bash runtime, more model context, or permission to run a command. Increasing either value is not a substitute for investigating why a job stalled.

Choose authentication before setting a key

Claude Code authentication supports subscription accounts, Console access, and cloud providers. API keys are not the only route, and individual developers do not need to share one common key to use the tool as a team.

Be careful with an old ANTHROPIC_API_KEY export. The reference says it can take precedence over a logged-in subscription: interactive use asks you to approve it once, while non-interactive print mode uses it when present. A developer expecting subscription usage can therefore start a differently billed run.

Choose the intended route with the account owner, inspect the active setup, and remove conflicting configuration only after identifying where it comes from. Do not paste a key into a blog example, chat, shell history, or shared project file. Use your approved secret-management mechanism.

Bare programmatic mode is a separate case. The programmatic guide says --bare does not read subscription OAuth or keychain credentials. Supply the supported provider credential or helper explicitly. A successful browser login in yesterday's interactive session does not authenticate that bare job.

Set a harmless value in the right shell

Use a nonsecret setting to understand the mechanics. This Bash or zsh example changes an API timeout for a newly launched Claude Code process:

Bash
export API_TIMEOUT_MS="1200000"
claude

The PowerShell equivalent is:

Powershell
$env:API_TIMEOUT_MS = "1200000"
claude

These are examples of assignment syntax, not a recommendation that every request should wait twenty minutes. The documented default is ten minutes. Use a value that fits an investigated problem and the current reference.

An export lasts in that shell and is inherited by programs it launches. A persistent shell-profile entry affects future shells; a desktop app launched elsewhere may have a different environment. Restart the affected process when you change a shell value, and test the actual terminal, editor, or CI runner that will do the work.

Understand the settings-file env block

Claude Code also accepts variables under env in a settings file. A small nonsecret example is:

JSON
{
  "env": {
    "API_TIMEOUT_MS": "1200000"
  }
}

Merge it into the intended file without deleting existing settings. A shared .claude/settings.json can affect teammates after it is committed; user settings and project-local settings have narrower reach. Do not commit secrets simply because JSON is convenient.

Precedence has two separate questions. First, if the same variable exists in the shell and an env block, the settings value generally replaces the inherited shell value, with documented exceptions. Second, if a feature has both a variable and a dedicated settings key, its own rules decide which wins. For example, ANTHROPIC_MODEL can override the model setting, while --model and /model can override that variable.

Settings-file env changes can update a running session, but startup-only features need a relaunch. Removing an entry from the file does not unset the value in an already running process. Check the current reload rules when a supposedly removed value keeps affecting behavior.

Keep network routing and access control separate

Follow the network guide when using a corporate proxy, custom certificates, or mutual TLS. Proxy URLs can contain passwords, so treat them as sensitive. Resolve certificate problems with approved trust configuration; do not disable certificate verification to make an error disappear.

Cloud-provider selectors are not credentials. Turning on Bedrock still requires the provider's authentication and authorization. Likewise, changing a base URL changes where requests go; it does not establish that the destination is trusted or that every feature works through it.

Tool permissions are another layer. A variable that makes credentials available to a process does not mean every use is approved. Review the coding agent's tool access and the downstream account's role together. A note in CLAUDE.md is not a replacement for either control.

Use eesel CLI after a support-job credential change

Imagine a nightly script checks whether a support teammate's knowledge sources are ready. An owner rotates the script's eesel credential. Before resuming the job, an operations engineer asks Claude Code to help verify access and interpret any errors.

The eesel CLI uses EESEL_API_URL and EESEL_API_TOKEN for an environment-based connection, and EESEL_AGENT_ID selects the teammate. Those connection variables take precedence over stored login. They are separate from ANTHROPIC_API_KEY, which authenticates Claude's API use.

With Node.js 18.17 or newer, inspect only whether the expected values are present in the job's authorized environment:

Bash
node -e 'for (const name of ["EESEL_API_URL", "EESEL_API_TOKEN", "EESEL_AGENT_ID"]) console.log(name + ": " + (process.env[name] ? "set" : "missing"))'

This local check prints no values and makes no network request. It does not prove that a credential is valid. A missing value should stop the proposed job while the owner supplies the intended configuration, rather than silently relying on an unrelated saved login.

Next, in that same approved environment, inspect the actual workspace and selected teammate:

Bash
npx @eesel/cli whoami
npx @eesel/cli agents
npx @eesel/cli status --agent "$EESEL_AGENT_ID"
npx @eesel/cli integrations download list --agent "$EESEL_AGENT_ID"

This block uses Bash syntax. Check the identity and agent against the owner's expected target before continuing past the first two commands. Do not run it with an empty or guessed agent ID. A support lead can review the same teammate in the dashboard while the script or coding agent reads JSON from the CLI.

For the nightly readiness report, distinguish authentication failure, wrong target, and incomplete source download. A successful whoami only establishes identity; a connected source is not necessarily downloaded, and readiness does not prove every answer is correct. Record the observed state and timestamp without copying credentials or unnecessary source content into the report.

Verify recovery with eesel CLI before resuming the job

Define the acceptance checks before calling the credential rotation complete:

  • The approved credential reaches the expected workspace and teammate, and the readiness check returns the expected source state.
  • A deliberately invalid test credential in an isolated test environment produces a handled failure, not a report saying the sources are healthy. Do not revoke or change a production key for this test.
  • A wrong target is rejected by the job's expected-target check before it reads support content or attempts a write. Implement and test that check against the actual JSON structure; do not guess field names from an article.

These are proposed checks, not results we measured. The owner still controls issuing and retiring credentials through the supported account mechanism. The inspection commands do not rotate or revoke a token themselves.

Setup and observation are free in eesel CLI; chat is billed work. This readiness workflow needs no chat, instruction edit, or customer action. If a later fix changes knowledge or configuration, get the exact change approved, inspect the command help, preview supported writes with --dry-run, and verify the updated state. A response or delivery test needs its own authorized target, permissions, and spend.

eesel dashboard showing a Get your teammate ready checklist, helpdesk and chat response channels, and a chat panel.
eesel dashboard showing a Get your teammate ready checklist, helpdesk and chat response channels, and a chat panel.

The dashboard and CLI are two ways to work with the same setup. Try eesel with a defined support job, then let people or coding agents inspect it from the tools they already use.

Frequently Asked Questions

Do I need an API key to start Claude Code?

Not for every setup. Supported Claude subscriptions can use browser login, while API and cloud-provider workflows use their own authentication. Bare programmatic mode needs explicit provider credentials rather than a saved subscription login.

Can ANTHROPIC_API_KEY change which account pays?

Yes. The official reference says the key is used instead of a logged-in subscription when applicable; interactive use asks for approval once, while print mode uses a present key. Confirm the intended authentication and billing route before a run.

Do environment variables always override settings?

No. Precedence depends on the variable and setting. A settings-file env entry generally replaces the inherited shell value, with documented exceptions. Check the exact variable rather than applying one rule to all configuration.

Does changing an export update a running Claude Code session?

No. A process does not inherit later changes made to its parent shell. Relaunch for shell changes. Settings-file env changes have their own reload behavior, and some features read values only at startup.

Should I paste environment output into a support request?

Do not paste a complete environment dump. It may contain API tokens, proxy passwords, and other secrets. Share variable names and redacted diagnostics, and confirm the recipient is authorized.

Does ANTHROPIC_API_KEY authenticate eesel CLI?

No. eesel CLI uses its own login or the documented EESEL_API_URL and EESEL_API_TOKEN variables. Its EESEL_AGENT_ID selects the teammate for that environment; verify the workspace and target separately.

How can eesel CLI help after rotating a script credential?

A human, script, or coding agent can inspect identity and the approved teammate’s source readiness through the same workspace as the dashboard. Confirm access and error handling before resuming the job; a successful identity check alone does not prove an answer or automation works.

Share this article

Kenneth Pangan

Article by

Kenneth Pangan

Writer and marketer for over ten years, Kenneth Pangan splits his time between history, politics, and art with plenty of interruptions from his dogs demanding attention.

Related Posts

All posts →
A complete guide to Salesforce AI bot routing in 2025
Guides

A complete guide to Salesforce AI bot routing in 2025

Looking to master Salesforce AI bot routing? This guide breaks down Einstein Bots, Omni-Channel flows, and key considerations for setup. Discover how to get your automation running smoothly.

Kenneth PanganKenneth PanganOct 20, 2025
Illustration of a presenter pointing to a flip chart
Guides

Amazon Bedrock Claude Code: setup, model access, and limits

How to configure Claude Code through Amazon Bedrock, choose a current inference profile, manage IAM access, and validate the setup.

Kenneth PanganKenneth PanganSep 30, 2025
Split black and colorful geometric artwork for The Way of Code by Rick Rubin with Claude.
Guides

The 5 Claude AI apps you can build without code

See five useful Claude Artifact app types, what sharing, AI, MCP, and storage allow, and the checks to make before publishing.

Katelin TeenKatelin TeenJan 9, 2026
Anthropic example showing a Dispatch mobile conversation beside a browser preview and Claude Code terminal on a computer.
Guides

Claude desktop: Chat, Cowork, Code, local access, and pricing

A current guide to Claude Desktop, Cowork, Claude Code, local files, computer use, plan limits, and a safe review workflow.

Stevia PutriStevia PutriJan 9, 2026
Orange Claude Code lettering beside an illustrated person holding a gear.
Guides

Claude AI coding assistant: a current Claude Code guide

Learn what Claude Code does, where it fits in a development workflow, how permissions and MCP change the risk, and how to release support updates carefully.

Rama Adi NugrahaRama Adi NugrahaJan 9, 2026
Orange Claude Code lettering beside an illustrated person holding a gear.
Guides

Claude AI coding software: a practical Claude Code guide

Learn what Claude Code software does, how its native install, pricing, permissions, and MCP connections work, and how to use it in a controlled bug-triage workflow.

Stevia PutriStevia PutriJan 9, 2026
Claude Code lettering beside an illustrated person holding a gear.
Guides

Claude AI Mac apps: what Claude Desktop and Claude Code can do (2026)

A practical guide to Claude Desktop on Mac, Quick Entry, Cowork, Claude Code permissions, and a safe eesel support handoff.

Stevia PutriStevia PutriJan 9, 2026
Illustration of a person reading a long paper scroll surrounded by orange starbursts.
Guides

Claude analysis: what it can do with files, code, and connected data

Claude can analyze uploaded files, run code, build Artifacts, and use approved connectors. Here is where that helps, where careful review still matters, and how to use it safely with support data.

Kenneth PanganKenneth PanganSep 9, 2025
Illustration of a person holding two gears.
Guides

Claude Code automation: hooks, scripts, and safe controls

A practical guide to Claude Code automation: when to use hooks, scripts, schedules, and GitHub workflows, plus the controls that keep an automated change reviewable.

Kenneth PanganKenneth PanganSep 9, 2025

Ready to hire your AI teammate?

Set up in minutes. No credit card required.

Get started free