Headless
Headless (non-interactive) mode means running Claude Code without the chat window, using the -p (or --print) flag. You give it a single request on the command line, Claude carries it out, prints the result and exits. This mode lets you use Claude Code in scripts, in automated checks (CI) and in chains of commands, with nobody sitting next to it.
Running Claude without the chat window: you give it the task in a single command (“claude -p”), it does it, gives you the result and stops. Good for automation.
How it shows up in Claude Code
The basic command is claude -p "your request". The documentation calls this using the Agent SDK from the command line. A few flags often go together with -p:
--allowedToolssays which tools Claude may use without asking, for example"Read,Edit,Bash";--output-formatpicks the shape of the answer:text(the default),jsonorstream-json;--continueor--resumepicks up an earlier conversation;--barestarts faster by skipping hooks, skills, MCP servers and CLAUDE.md, so you get the same result on every machine.
Headless mode also reads its input, so you can send text into it with a pipe (|). When it's done, it exits with code 0 on success and a non-zero code on failure, so a script can decide what to do next.
Example
You have a file with a build error and want an explanation written to another file:
cat build-error.txt | claude -p "briefly explain the cause of this error" > explanation.txt
Or you want the result as JSON, so another program can read it:
claude -p "Summarize this project" --output-format json
Common mistakes
- Waiting for permission questions. In
-pmode nobody is there to answer, so the tools it needs must be allowed in advance. - Running
-pin someone else's folder without--bare. The documentation warns that it then runs hooks from the project's settings and connects the servers in.mcp.json, with no trust prompt. - Giving wide permissions to a bot that reads text from strangers.
Related terms and where you learn it
Headless mode is the basis for CI and GitHub Actions, takes data through a pipe and can answer in JSON. Without well-set permissions, it stops at the first tool it isn't allowed to use.
In the course: the lesson “What is headless mode?” in module 10, Claude on autopilot.
Source: Claude Code documentation: Run Claude Code programmatically
How it appears in the course
“Headless” means Claude works without a chat window. You give it a single command, it does it and stops.
Introduction · Module 10, Claude on autopilot
→ So what does headless mean?
What is headless mode? · Module 10, Claude on autopilot
In headless mode there’s nobody there to answer. So you tell it beforehand what it’s allowed to do.
What settings can you give the command? · Module 10, Claude on autopilot
Learn Claude Code from zero, in plain English
12 modules with 1–2 minute lessons, which you can also do on your phone. The first two modules are free.