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

cowork-session-sync v1.0.0 provides session continuity for Claude Cowork
cowork-session-sync v1.0.0 is a tool that maintains session continuity for Claude Cowork by archiving raw transcripts, distilling them to Markdown, and enabling one-phrase bootstrap with 'catchup-bunny' to restore full context.

Claude Code CLI Toolkit: Four Tools for Code Review, Project Briefs, Auto-Journaling Git Hooks
A developer has released four CLI tools built around Claude Code's print mode that handle code reviews, project brief generation, auto-journaling git hooks, and Claude session status. The tools use existing Claude Code authentication and are available as open source.

GodotIQ MCP Server Gives AI Coding Agents Spatial Understanding of Godot Scenes
GodotIQ is an MCP server that provides coding agents with true understanding of 2D/3D scenes, signals, and code dependencies in Godot. In a test, it autonomously built a twin-stick survivors game in one hour from assets and a prompt.

Octopoda MCP Server Adds Persistent Memory, Loop Detection, and Audit Trails to Claude Code
A developer built Octopoda, an MCP server that integrates with Claude Code to provide persistent memory, loop detection, audit trails, and shared knowledge spaces for AI agents. The system uses PostgreSQL with pgvector for semantic search, FastAPI, and a React dashboard.