Claude Code fails silently when ANTHROPIC_API_KEY is set in cloud environments

Claude Code (CC) has a known issue: if you set the ANTHROPIC_API_KEY environment variable in a cloud environment, Claude Code will fail to execute any commands. The variable overrides CLI billing and routes all calls through the Anthropic API, leading to unexpected charges and a dead tool. This was reported on Hacker News with a reference to the GitHub issue #54497.
Key details from the discussion
- Environment variable triggers failure: Setting
ANTHROPIC_API_KEYin cloud environments (e.g., CI/CD, containers) causes Claude Code to stop working. The tool attempts to use the API key for billing, effectively disabling its free tier or local billing mechanism. - Extra usage charges: One user reported seeing a lot of "Extra usage" in their Anthropic billing — likely because every Claude Code call was being proxied through the API key, incurring per-request costs.
- Misguided documentation: Another commenter noted that Anthropic's own documentation previously (and incorrectly) advised adding
ANTHROPIC_API_KEYfor Claude Code Web usage. This led to accidental charges. Anthropic later updated the docs but refused to refund the incurred costs. - Workaround: Do not set
ANTHROPIC_API_KEYin cloud environments where Claude Code runs. Use alternative authentication methods (e.g., CLI‑based credentials or separate billing tokens) if needed.
Who this affects
Developers using Claude Code in CI/CD pipelines, containerized environments, or any cloud‑based infrastructure where environment variables are injected globally.
📖 Read the full source: HN AI Agents
👀 See Also

Open-source Claude Code reimplementation patched for local model compatibility
A developer patched the open-source Claude Code reimplementation to work with Ollama and local models by removing hardcoded Anthropic client dependencies. The CLI now auto-detects providers from model names and environment variables.

Squeez tool compresses bash output 90%+ to extend Claude Code context window
Squeez is a hook that automatically compresses raw bash output like ps aux, docker logs, and git log before it reaches Claude Code. It reduces token usage by 92.8% on average across 19 common commands, helping sessions last longer.

agent-recall: Local SQLite MCP for Persistent Claude Code Memory
agent-recall is an MCP server that gives Claude Code persistent memory across sessions using a local SQLite file. It provides 9 MCP tools for saving entities, relationships, and observations, with LLM-summarized briefings at session start instead of raw data dumps.

Prism MCP v5.1 adds 10x memory compression and agent learning from corrections
Prism MCP v5.1 introduces 10x memory compression via TurboQuant ported to TypeScript, enabling millions of memories on a laptop without vector databases. The update adds agent learning from user corrections and a visual knowledge graph interface.