Overview
Headless (non-interactive) mode lets Qoder CLI CN run without an interactive interface — it takes a prompt, executes the task, writes the result to standard output, and exits. It suits embedding Qoder into shell scripts, automated processes, and CI/CD pipelines.
Enter Headless mode by adding --print (short form -p):
Basic usage
Pass the prompt as an argument along with -p:
Output formats
Specify the output format with --output-format (short form -o); the default is text:
| Format | Description | Best for |
|---|---|---|
text | Plain-text result (default) | Direct reading, simple scripts |
json | A single JSON object with the result and metadata | Programmatic parsing of the final result |
stream-json | A stream of JSON messages emitted one by one | Consuming intermediate progress in real time |
--input-format, supporting text and stream-json. With stream-json input, you can continuously send structured messages via standard input.
Common flags
These flags are commonly used together with Headless mode:
| Flag | Description |
|---|---|
-p, --print | Print the response and exit (non-interactive) |
-o, --output-format <format> | Output format: text / json / stream-json |
--input-format <format> | Input format: text / stream-json |
--max-turns <count> | Limit the maximum conversation turns per query |
--permission-mode <mode> | Set the permission mode |
--allowed-tools <tool> | Allow only the specified tools |
--disallowed-tools <tool> | Disallow the specified tools |
-m, --model <model> | Specify the model |
--session-id <id> | Use a specific session id |
-w, --cwd <dir> | Change the working directory before startup |
Permission control
There is no interactive confirmation in Headless mode, so use permission flags to decide in advance which operations may run automatically:
- In plain-text Headless mode, any operation that "requires confirmation" is denied by default; when driven by a host program via the stream-json protocol (such as the Agent SDK), confirmation requests are handed to the host program to decide — see "How
askis consumed in different runtime environments" in Permissions and Directory Trust. - Use
--permission-mode accept_editsto auto-approve safe file edits within the working directory. - Use
--yolo(equivalent to--permission-mode bypass_permissions) to skip all confirmations — recommended only in fully trusted environments.
CI/CD example
In a pipeline, authenticate via environment variables first, then run in Headless mode:
json makes it easy for later pipeline steps to parse Qoder's result.