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

Cognithor: A Local-First Agent OS with PGE Trinity Architecture
Cognithor is a fully local, autonomous Agent OS built over a year with 16 development phases. It features the PGE Trinity architecture (Planner → Gatekeeper → Executor), 11,609+ tests with 89% coverage, and supports 16 LLM providers including Ollama and LM Studio.

Agent Smith: One Command To Scaffold MCP Servers, Skills, And A Ticket-To-PR Pipeline For Claude Code
Agent Smith scans your repo, detects exact stack (Go/Echo, React/Zustand, golang-jwt, pgx, etc.), sets up MCP servers, hooks, and skills tailored to your setup, and provides an autonomous ticket-to-PR pipeline.

Stage CLI: Local AI-Generated Changes Reviewed as Logical Chapters
Stage CLI groups your local diff into logical chapters (via any AI agent) and opens a browser UI for step-by-step review. Install with 'npm install -g stagereview' and add the skill via 'npx skills add ReviewStage/stage-cli'.

Transloadit MCP Server Connects AI Agents to Media Processing Pipeline
Transloadit built an MCP server that connects Claude and other AI agents to their media processing pipeline with 86 Robots for video, audio, image, and document processing. Setup in Claude Code requires one line: npx -y @transloadit/mcp-server stdio with TRANSLOADIT_KEY and TRANSLOADIT_SECRET environment variables.