Skip to content
BENIBIX Learn

Non-Interactive Mode

AI⌨️ Claude CodeClaude Code Concepts

Also known as Headless mode, claude -p, Print mode

Running Claude Code on one prompt, with no chat, then exiting.

Think of it like

It is like sending a note, not making a call. One note goes, one reply comes back.

Example

Jack adds one line to his build script. Each night, claude -p reads the test log and writes a short report of what failed.

Why it matters

It lets Claude Code run inside other tools and jobs, not just in front of a person.

Definition

Non-interactive mode runs Claude Code on one prompt and then exits, with no chat. You start it with the -p flag, short for --print. The answer goes to the screen or into another program, so it works in scripts, pipes and CI jobs. The run is still saved as a session you can resume, unless you turn that off. It used to be called headless mode. The Agent SDK offers the same thing from Python and TypeScript.

Example code

bash
claude -p "list the TODOs in src/"
Ask once, print the answer, and exit.
One prompt in, one answer out, then the program ends.

Common mistake

Expecting it to stop and ask for permission. There is no one to ask, so set the allowed tools before you run it.

Key takeaways

  1. 1
    One prompt. Then it exits.
  2. 2
    The -p flag. Short for print.
  3. 3
    For scripts. Pipes and CI.

Learn it properly