# Non-Interactive Mode

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

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** Headless mode, claude -p, Print mode

## Think of it like

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

## 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

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

## Example code

```bash
claude -p "list the TODOs in src/"
```

Ask once, print the answer, and exit.

## Why it matters

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

## 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.

## Three principles

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

## Related terms

- [Claude Code](https://learn.benibix.com/term/ai/claude-code)
- [Bare Mode](https://learn.benibix.com/term/ai/bare-mode)
- [Continuous Integration (CI)](https://learn.benibix.com/term/development/continuous-integration)
- [Permission Mode](https://learn.benibix.com/term/ai/permission-mode)
- [Claude Code GitHub Actions](https://learn.benibix.com/term/ai/claude-code-github-actions)

## Taught in

- [Claude Code Run Modes](https://learn.benibix.com/learn/ai-claude-code/claude-code-run-modes): Claude Code, 16/16

![One prompt goes in, one answer comes out, and the program ends. No back and forth.](https://learn.benibix.com/diagrams/cc-non-interactive-mode.svg)

---

Source: https://learn.benibix.com/term/ai/non-interactive-mode
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
