Claude Code Field Guide
30 / 35

Headless / Non-Interactive Mode

Run Claude Code with no back-and-forth and no approval prompts, using the -p flag — turning it into a scriptable, pipeable tool.

Updated since the video
Currency check: The -p flag and its behavior are accurately described. The official terminology has settled differently than the video predicted.

Normal Claude Code is interactive: you type, it responds, you approve actions, back and forth. Add the -p flag and it runs the entire task in one shot with no conversation and no approval prompts — it processes the request and outputs the result, full stop. This is what makes Claude Code composable with the rest of your toolchain: pipe a log file into it, run it inside a CI job, chain it with other commands.

Terminology update: the video says this used to be called “headless mode” and is “now officially CLI mode.” In current documentation it's simply referred to as non-interactive mode (the -p / --print flag), and it's positioned as one entry point into the broader Agent SDK — the same underlying engine, available as a CLI for scripts and CI, or as Python/TypeScript packages for full programmatic control (see the Agent SDK topic). A newer --bare flag is worth knowing: it skips loading hooks, skills, plugins and CLAUDE.md for faster, more predictable, script-safe runs.

A Slack alert from a log tail

tail -200 app.log | claude -p "Slack me if you see any anomalies" turns Claude Code into an unattended log-monitoring step, with no one needing to babysit a conversation.

Automated PR review in CI

A CI pipeline runs claude -p against the diff of every pull request with a fixed set of allowed tools, posting a structured review as a comment — consistent, automatic review on every PR without a human needing to trigger it.