Claude Code
How do you run Claude Code in headless/CI mode?
QUICK ANSWER
Run Claude Code in headless/CI pipelines by passing the prompt argument directly using: 'claude "<your prompt>" --non-interactive'. Export the token key as an environment variable.
CI/CD Pipeline Integration
export CLAUDE_API_KEY="your-anthropic-api-key"
claude "Run audit on src/utils.ts and list security flaws." --non-interactive
This executes the prompt, prints the final response to standard output, and exits with a status code of 0 (or non-zero if errors are thrown).
Verified against: Claude Code CLI v0.2.5