Overview
--print flag (short form -p):
Basic Usage
-p:
Output Format
--output-format (short form -o) to specify the output format. The default is text:
| Format | Description | Use Case |
|---|---|---|
text | Plain text result (default) | Direct reading, simple scripts |
json | Single JSON Object containing the result and Metadata | Programmatic parsing of the final result |
stream-json | Line-by-line JSON Message Stream | Real-time consumption of intermediate processes |
--input-format, supporting text and stream-json. When using stream-json input, you can continuously send Structured Messages via standard input.
Common Flags
| 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 for a single query |
--permission-mode <mode> | Set the permission mode |
--allowed-tools <tool> | Allow only specified tools |
--disallowed-tools <tool> | Deny specified tools |
-m, --model <model> | Specify the Model |
--session-id <id> | Use the specified session ID |
-w, --cwd <dir> | Switch the working directory before startup |
Permission Control
- In plain text Headless mode, any operation that "requires confirmation" defaults to deny. If driven by a Host Application via the stream-json protocol (e.g., Agent SDK), confirmation requests are forwarded to the Host Application for decision. See "Consumption methods of
askin different runtime environments" in Permissions. - Use
--permission-mode accept_editsto automatically approve safe file edits within the working directory. - Use
--yolo(equivalent to--permission-mode bypass_permissions) to skip all confirmations. This is only recommended for use in fully trusted environments.
CI/CD Example
json to make it easier for subsequent pipeline steps to parse Qoder's results.