Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Explains how to run Claude Code headlessly in containers and CI, covering auth chains, tmux orchestration, root workarounds, and git auth.
9% 45%+36 ptsof test cases passed
Passed 10 of 22 test cases with the skill, and 2 of 22 without it.
3 of 3 safety checks passed
39 agent runs
Running Claude Code outside a desktop terminal — in Docker containers, CI runners, cloud VMs, or orchestrated by another process — is full of undocumented friction. This guide covers everything we've learned getting CC to work reliably in these environments.
CC tries multiple auth strategies in a fixed priority order. Understanding this chain is the key to headless auth.
ANTHROPIC_AUTH_TOKEN — raw bearer token for Anthropic's APIANTHROPIC_API_KEY — direct API key (pay-per-token, no Pro subscription features)apiKeyHelper — executable that prints a token to stdout (set via --settings)CLAUDE_CODE_OAUTH_TOKEN — OAuth token (Pro/Team subscription)/login — interactive browser OAuth dance (unusable in headless)apiKeyHelperThe most flexible headless strategy. Point CC at a script that returns a valid token:
{
"apiKeyHelper": "/path/to/your-auth-script"
}
Pass it via --settings /path/to/settings.json on launch. CC calls this script whenever
it needs a token, so it handles rotation naturally.
Example helper (reads from a credential vault):
#!/bin/bash
# Prints the OAuth token to stdout. CC calls this on demand.
Next to this one in the catalogue, plus more from the same author.