Skip to main content

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 / subtypeStatusWhat It Does
userDocumentedA user message, such as a message of a subagent when --forward-subagent-text is on.
resultDocumentedThe final result of the run.
system / initDocumentedSession data at the start of each turn: session ID, model, working folder, tools, MCP servers, slash commands, and plugins.
stream_eventDocumentedA step of the answer as it grows, only with --include-partial-messages.
system / compact_boundaryDocumentedThe conversation was compacted here.
system / api_retryDocumentedAn API request failed with an error that can be retried, and Claude Code will try again after a wait.
system / hook_startedDocumentedA hook started to run.
system / hook_progressDocumentedA hook reported progress.
system / hook_responseDocumentedA hook finished with a response.
system / plugin_installDocumentedProgress of a plugin install in print mode, when CLAUDE_CODE_SYNC_PLUGIN_INSTALL is set.
system / permission_deniedDocumentedA tool call was denied, and the final result lists the denials in permission_denials.
prompt_suggestionDocumentedThe 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 / subtypeStatusWhat It Does
rate_limit_eventUndocumentedRate limit information changed.
system / statusUndocumentedNo description in the program schema.
system / post_turn_summaryUndocumentedA summary made in the background after each assistant turn.
system / task_summaryUndocumentedA progress line in the middle of a turn.
system / session_metadataUndocumentedA patch of session data for a local host, such as the list of published artifacts.
system / informationalUndocumentedA text banner: a status line, hook feedback, or the output of a slash command.
system / permission_retryUndocumentedTools run again after a change of permission mode allowed commands that were denied before.
system / stop_hook_summaryUndocumentedWhich Stop and SubagentStop hooks ran at the end of a turn, their output, and whether one stopped the continuation.
system / memory_savedUndocumentedThe memory system wrote to the listed paths.
system / agents_killedUndocumentedBackground agents were stopped, for example on an interrupt.
system / instruction_size_warningUndocumentedThe instruction files of the session are larger than the advised limit.
system / away_summaryUndocumentedA summary of what happened while you were away.
system / thinkingUndocumentedThe thinking text itself.
transcript_mirrorUndocumentedSent after each successful write of the local transcript.
system / mirror_errorUndocumentedA batch of the transcript mirror failed after 3 tries.
system / control_request_progressUndocumentedProgress of a long control request, matched by request_id.
system / model_refusal_fallbackUndocumentedNo description in the program schema.
system / model_refusal_no_fallbackUndocumentedNo description in the program schema.
system / model_fallbackUndocumentedNo description in the program schema.
system / model_consent_fallbackUndocumentedA check before the request moved the session off the model that was asked for.
system / file_snapshotUndocumentedA snapshot of the plan and todo files, made for rewind.
system / scheduled_task_fireUndocumentedA scheduled task (cron) started.
system / peer_message_holdUndocumentedA message from another session was held and not queued, and how the hold ended.
system / turn_durationUndocumentedThe wall-clock time of a turn, with the budget and the number of background jobs.
system / api_errorUndocumentedAn API error that can be retried, with the error data and the retry counts.
system / local_command_outputUndocumentedThe output of a local slash command, such as /usage.
tool_progressUndocumentedNo description in the program schema.
auth_statusUndocumentedNo description in the program schema.
system / files_persistedUndocumentedNo description in the program schema.
system / task_notificationUndocumentedNo description in the program schema.
system / task_startedUndocumentedNo description in the program schema.
system / task_updatedUndocumentedNo description in the program schema.
system / background_tasks_changedUndocumentedNo description in the program schema.
system / feedback_draft_queuedUndocumentedThe SendFeedback tool wrote a draft to ~/.claude/feedback/drafts/.
system / session_state_changedUndocumentedThe state of the session changed.
system / session_title_changedUndocumentedNo description in the program schema.
system / worker_shutting_downUndocumentedNo description in the program schema.
system / turn_handoff_availableUndocumentedNo description in the program schema.
system / ui_invalidateUndocumentedNo description in the program schema.
system / ui_logUndocumentedA plugin called $.ui.log(text), and the screen adds a dim notice under the name of the plugin.
system / ui_toastUndocumentedA plugin called $.ui.toast(text), and the screen shows a short note under the prompt.
system / ui_statusUndocumentedA plugin called $.ui.status(text), and the screen pins a line under the prompt.
system / ui_scrollUndocumentedA plugin scrolled a site that a remote screen draws.
system / ui_focusUndocumentedA plugin moved the focus ring of a site that a remote screen draws.
system / commands_changedUndocumentedThe full list of slash commands, sent after a change in the middle of a session.
system / notificationUndocumentedA text notification from the loop.
system / task_progressUndocumentedNo description in the program schema.
system / thinking_tokensUndocumentedA live estimate of the thinking tokens while the thinking text is hidden.
tool_use_summaryUndocumentedNo description in the program schema.
system / memory_recallUndocumentedNo description in the program schema.
system / elicitation_completeUndocumentedAn MCP server confirmed that a URL-mode elicitation is complete.
system / permission_check_statusUndocumentedNo description in the program schema.
system / code_change_publishedUndocumentedNo description in the program schema.
system / vcs_state_changedUndocumentedNo description in the program schema.
system / dev_intentUndocumentedNo description in the program schema.
system / turn_preemptedUndocumentedNo description in the program schema.
system / per_turn_effort_changedUndocumentedThe conversation stopped sending the effort with each turn, because the server refused it.
system / file_attachments_missingUndocumentedNo description in the program schema.
system / cloud_session_deltaUndocumentedNo description in the program schema.
control_requestUndocumentedA request of the control protocol, which either side can send on the same stream.
control_responseUndocumentedThe single reply to a control_request.
control_cancel_requestUndocumentedThe sender no longer needs the answer to one of its own control requests.
keep_aliveUndocumentedA heartbeat with no payload.
update_environment_variablesUndocumentedUpdates env vars while the process runs.

Example​

Lines from a short run (shortened)
{"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":"..."}
Pick out the final 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.