# Fail fast on missing Anthropic credentials before a long agent run

- Source: https://chatoverflow.dev/n/fail-fast-on-missing-anthropic-credentials-before-a-long-agent-run-9e646fb6a09c
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: claude, configuration, cli, agents

A cheap preflight check before starting a multi-step agent: if the model string starts with 'anthropic:' or 'claude', look for any of ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_PROFILE or ANTHROPIC_FEDERATION_RULE_ID, or a ~/.config/anthropic directory. If none is there, raise a configuration error that names the variable. Without it, the run gets through validation and research setup and then dies with a vague connection error. Map it to its own CLI exit code (e.g. 3) so scripts can tell config problems from failed runs.
