Stream JSON Messages
With --output-format stream-json, Claude Code writes one JSON object per line to stdout.
With --input-format stream-json, you send JSON lines on stdin, and the same channel carries control requests.
For example, claude -p "Explain this repo" --output-format stream-json --verbose --include-partial-messages prints a system / init line, then stream_event lines while the answer grows, then a final result line.
Flags add more lines: --include-partial-messages, --include-hook-events, --forward-subagent-text, and --replay-user-messages. Turn the format on with --output-format stream-json and --input-format stream-json.
Message Types
The tables list the message types that the bundled schema of 2.1.304 defines.
Each row has a short form of the schema description. A row without a description says so.
A type is marked Documented when a docs page other than the changelog and the Agent SDK pages names it.
Source: Run Claude Code Programmatically, CLI Reference, and the program (the message schema).
A type written as system / init means type is system and subtype is init.
Documented Types
type / subtype | Status | What It Does |
|---|---|---|
user | Documented | A user message, such as a message of a subagent when -- is on. |
result | Documented | The final result of the run. |
system / init | Documented | Session data at the start of each turn: session ID, model, working folder, tools, MCP servers, slash commands, and plugins. |
stream_ | Documented | A step of the answer as it grows, only with --. |
system / compact_ | Documented | The conversation was compacted here. |
system / api_ | Documented | An API request failed with an error that can be retried, and Claude Code will try again after a wait. |
system / hook_ | Documented | A hook started to run. |
system / hook_ | Documented | A hook reported progress. |
system / hook_ | Documented | A hook finished with a response. |
system / plugin_ | Documented | Progress of a plugin install in print mode, when CLAUDE_ is set. |
system / permission_ | Documented | A tool call was denied, and the final result lists the denials in permission_. |
prompt_ | Documented | The predicted next prompt, sent after each turn when prompt suggestions are on. |
Undocumented Types
Only the program shows these. They can change without notice.
type / subtype | Status | What It Does |
|---|---|---|
rate_ | Undocumented | Rate limit information changed. |
system / status | Undocumented | No description in the program schema. |
system / post_ | Undocumented | A summary made in the background after each assistant turn. |
system / task_ | Undocumented | A progress line in the middle of a turn. |
system / session_ | Undocumented | A patch of session data for a local host, such as the list of published artifacts. |
system / informational | Undocumented | A text banner: a status line, hook feedback, or the output of a slash command. |
system / permission_ | Undocumented | Tools run again after a change of permission mode allowed commands that were denied before. |
system / stop_ | Undocumented | Which Stop and Subagent hooks ran at the end of a turn, their output, and whether one stopped the continuation. |
system / memory_ | Undocumented | The memory system wrote to the listed paths. |
system / agents_ | Undocumented | Background agents were stopped, for example on an interrupt. |
system / instruction_ | Undocumented | The instruction files of the session are larger than the advised limit. |
system / away_ | Undocumented | A summary of what happened while you were away. |
system / thinking | Undocumented | The thinking text itself. |
transcript_ | Undocumented | Sent after each successful write of the local transcript. |
system / mirror_ | Undocumented | A batch of the transcript mirror failed after 3 tries. |
system / control_ | Undocumented | Progress of a long control request, matched by request_. |
system / model_ | Undocumented | No description in the program schema. |
system / model_ | Undocumented | No description in the program schema. |
system / model_ | Undocumented | No description in the program schema. |
system / model_ | Undocumented | A check before the request moved the session off the model that was asked for. |
system / file_ | Undocumented | A snapshot of the plan and todo files, made for rewind. |
system / scheduled_ | Undocumented | A scheduled task (cron) started. |
system / peer_ | Undocumented | A message from another session was held and not queued, and how the hold ended. |
system / turn_ | Undocumented | The wall-clock time of a turn, with the budget and the number of background jobs. |
system / api_ | Undocumented | An API error that can be retried, with the error data and the retry counts. |
system / local_ | Undocumented | The output of a local slash command, such as /. |
tool_ | Undocumented | No description in the program schema. |
auth_ | Undocumented | No description in the program schema. |
system / files_ | Undocumented | No description in the program schema. |
system / task_ | Undocumented | No description in the program schema. |
system / task_ | Undocumented | No description in the program schema. |
system / task_ | Undocumented | No description in the program schema. |
system / background_ | Undocumented | No description in the program schema. |
system / feedback_ | Undocumented | The Send tool wrote a draft to ~/.. |
system / session_ | Undocumented | The state of the session changed. |
system / session_ | Undocumented | No description in the program schema. |
system / worker_ | Undocumented | No description in the program schema. |
system / turn_ | Undocumented | No description in the program schema. |
system / ui_ | Undocumented | No description in the program schema. |
system / ui_ | Undocumented | A plugin called $., and the screen adds a dim notice under the name of the plugin. |
system / ui_ | Undocumented | A plugin called $., and the screen shows a short note under the prompt. |
system / ui_ | Undocumented | A plugin called $., and the screen pins a line under the prompt. |
system / ui_ | Undocumented | A plugin scrolled a site that a remote screen draws. |
system / ui_ | Undocumented | A plugin moved the focus ring of a site that a remote screen draws. |
system / commands_ | Undocumented | The full list of slash commands, sent after a change in the middle of a session. |
system / notification | Undocumented | A text notification from the loop. |
system / task_ | Undocumented | No description in the program schema. |
system / thinking_ | Undocumented | A live estimate of the thinking tokens while the thinking text is hidden. |
tool_ | Undocumented | No description in the program schema. |
system / memory_ | Undocumented | No description in the program schema. |
system / elicitation_ | Undocumented | An MCP server confirmed that a URL-mode elicitation is complete. |
system / permission_ | Undocumented | No description in the program schema. |
system / code_ | Undocumented | No description in the program schema. |
system / vcs_ | Undocumented | No description in the program schema. |
system / dev_ | Undocumented | No description in the program schema. |
system / turn_ | Undocumented | No description in the program schema. |
system / per_ | Undocumented | The conversation stopped sending the effort with each turn, because the server refused it. |
system / file_ | Undocumented | No description in the program schema. |
system / cloud_ | Undocumented | No description in the program schema. |
control_ | Undocumented | A request of the control protocol, which either side can send on the same stream. |
control_ | Undocumented | The single reply to a control_. |
control_ | Undocumented | The sender no longer needs the answer to one of its own control requests. |
keep_ | Undocumented | A heartbeat with no payload. |
update_ | Undocumented | Updates env vars while the process runs. |
Example
{"type":"system","subtype":"init","session_id":"...","model":"...","tools":["Read","Bash"]}
{"type":"stream_event","event":{"type":"content_block_delta"}}
{"type":"result","subtype":"success","is_error":false,"result":"..."}
claude -p "Say hi" --output-format stream-json --verbose | jq -c 'select(.type=="result")'
How It Works
The control_request, control_response, control_cancel_request, keep_alive, and update_environment_variables lines share the stream with the messages above.
Mirror lines (transcript_mirror) follow each local transcript write. For the file format, see Transcript Format.