--print (or -p) and Claude outputs its response to stdout then exits — no UI, no prompts, no spinner.
Basic usage
The workspace trust dialog is skipped when using
-p. Only run Claude Code with --print in directories you trust.Output formats
Control how Claude’s response is serialised with--output-format. This flag only takes effect when --print is also set.
JSON output structure
With--output-format json, Claude Code writes a single JSON object to stdout after the run completes:
subtype is one of error_during_execution, error_max_turns, or error_max_budget_usd, and an errors array is included.
stream-json event stream
With--output-format stream-json, Claude Code emits newline-delimited JSON events as they happen:
--include-partial-messages to also receive partial assistant message chunks as they stream in.
Tool control
--allowedTools
Restrict which tools Claude can use. Accepts a space- or comma-separated list. Supports permission rule syntax.
--disallowedTools
Block specific tools entirely.
--tools
Specify the complete set of built-in tools available. Use "" to disable all tools, "default" to restore the full set.
Model and limits
MCP servers
Load MCP server configuration for a headless run with--mcp-config. Accepts one or more JSON file paths or inline JSON strings.