Expand description
Claude Code -p --output-format stream-json transcript parsing.
Parses the newline-delimited JSON event stream that claude -p --output-format stream-json --verbose writes (captured per task as
outputs/claude-events.jsonl). The assistant/user events wrap a full
Anthropic Messages object under message, so tool-call extraction is shared
with the in-session claude_code_transcript
parser. The differences are all in the envelope: there are no per-line
timestamps, and a terminal result event carries the authoritative final
text, wall-clock duration, and token usage. system, rate_limit_event, and
any other non-message events are ignored (they don’t deserialize into an
assistant/user record, so the shared extractor skips them).
Functions§
- parse_
claude_ stream_ json - Parse the event stream into ordered tool invocations. Reuses the in-session extractor: non-message events deserialize into records the extractor skips.
- parse_
claude_ stream_ json_ full - Parse the event stream into a full
TranscriptSummary. Final text, duration, and token totals come from the terminalresultevent; on a missing or erroredresultthe final text falls back to the last assistant message’s text, and duration/tokens fall back toNone.