Setting up Claude Code feels a bit like being the first DevOps on Mars. Here’s what I learned automating the configuration for CI/CD pipelines and scripted deployments.
API key without OAuth
Skip the OAuth flow — use an API key helper script:
echo 'echo ${ANTHROPIC_API_KEY}' > ~/.claude/anthropic_key_helper.sh
chmod +x ~/.claude/anthropic_key_helper.sh
claude config set --global apiKeyHelper ~/.claude/anthropic_key_helper.sh
Skip onboarding and trust dialogs
claude config set hasTrustDialogAccepted true
claude config set hasCompletedProjectOnboarding true
The ~/.claude.json skeleton needs hasCompletedOnboarding: true and API key trust uses the last 20 characters of your key.
MCP servers via JSON
Pre-download resources, then add with full control:
docker pull mcp/puppeteer
claude mcp add-json puppeteer '{"command":"docker","args":["run","-i","--rm","--init","-e","DOCKER_CONTAINER=true","mcp/puppeteer"]}'
Permissions without prompts
claude config add allowedTools "Edit,Bash"
claude config add allowedTools "mcp__puppeteer" # note the mcp__ prefix
Useful environment variables
export ANTHROPIC_LOG=debug
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=true # for CI
export BASH_DEFAULT_TIMEOUT_MS=60000
export MCP_TIMEOUT=30000
Parallel tasks
claude config set --global parallelTasksCount 3
Most of this is undocumented. The CLI wasn’t built for headless setup — but it works once you know the levers.