0Pricing
Claude Architect · Lesson

Non-Interactive Mode

The -p / --print flag for headless CI execution.

Why Headless Mode Exists

Claude Code defaults to an interactive terminal session: it prompts you, waits for input, and streams a conversation. That model is perfect at your desk and useless inside a pipeline.

A CI/CD runner has no human to confirm a plan, approve an edit, or answer a follow-up question. It needs a single command that runs, produces output, and exits with a status code.

That is exactly what -p / --print delivers: non-interactive (headless) execution. It is the foundational flag for running Claude Code in CI.

The --print Flag

You invoke headless mode by passing your prompt to -p (the short form of --print). Claude runs the agentic loop to completion and prints the final result to stdout, then the process exits.

There is no REPL, no waiting on input, no confirmation prompts. One command in, one result out — the contract a pipeline step needs.

# Interactive (default) — opens a session, waits for you
claude

# Non-interactive (headless) — runs and exits, prints to stdout
claude -p "Review the staged diff and list any blocking issues"

All lessons in this course

  1. Non-Interactive Mode
  2. Structured Output
  3. Session Isolation for Reviews
  4. Test Generation & Standards
← Back to Claude Architect