Claude Code Headless Mode with --print Flag

Headless Claude Code Operation
The source reveals that Claude Code, likely referring to Anthropic's Claude coding assistant or a related tool, supports headless execution through the --print flag. This mode bypasses interactive sessions entirely.
How It Works
According to the source, you pipe a prompt into the tool and get the output directly. The specific command structure appears to be: claude code --print with input piped to it. This is a standard Unix-style approach where you might use something like echo "your prompt" | claude code --print.
Practical Applications
The source specifically mentions three use cases:
- CI/CD pipelines
- Git hooks
- Bash scripts
These are common automation scenarios where non-interactive execution is essential. The source notes that many users only employ Claude Code interactively and miss this capability entirely.
Technical Context
Headless operation is a common feature in developer tools that enables automation. The --print flag suggests this outputs results directly to stdout rather than through an interactive interface. This type of functionality is particularly valuable for integrating AI coding assistants into automated workflows where human intervention isn't practical or desired.
For tools like Claude Code, this means you could automate code reviews, generate documentation, create test cases, or perform code transformations as part of your build process. The exact capabilities would depend on Claude Code's specific features, but the headless mode provides the infrastructure to integrate it programmatically.
📖 Read the full source: r/LocalLLaMA
👀 See Also

Running OpenClaw Inside Ollama's Docker Container for Simpler Networking
A Reddit user shows how to install OpenClaw inside the official ollama/ollama Docker container so OpenClaw talks to Ollama via localhost, avoiding host.docker.internal and extra networking setup. Trade-off is higher RAM usage.

OpenClaw v2026.3.13 adds per-agent cacheRetention config for OpenAI token cost savings
OpenClaw v2026.3.13 adds per-agent cacheRetention configuration that enables OpenAI's 24-hour prompt cache retention, potentially cutting input token costs by up to 90% for agents with heartbeat cycles longer than 10 minutes.

Claude Prompt Codes Retested: L99 Sharper, OODA Narrower, ARTIFACTS Faded, and 3 New Codes to Use
A 6-month retest of L99, OODA, and ARTIFACTS prompt codes on Claude shows L99 sharper on Sonnet 4.6/Opus 4.7, OODA failing on strategic prompts, ARTIFACTS unnecessary for code, and three new codes (/skeptic, /blindspots, /decompose) earning daily use. Stack no more than 2 codes.

Claude's Research Output Varies by Language: Same Prompt, Different Sources
A Reddit test shows Claude returning different sources and developments across English, Chinese, Russian, Spanish, and Hindi prompts — same model, same structure, diverging results.