Run Claude Code programmatically changedheadless
Nearest release: v2.1.334, published 5 hours before upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 2 Dec 2026 00:40 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 2 Dec 2026 01:07 UTC.
Upstream edited
Recorded here
Lines+1added
Lines−1removed
From line
206
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits61to this page, all time
The whole hunk
from line 206, old and new numbered
/
from line 206
206206
207207Find each [`result` message](https://code.claude.com/docs/en/agent-sdk/typescript#sdkresultmessage) by `type`, because a message such as a task notification can follow a result and start another turn. A successful `result` message holds any final response text, the running cost total, and session metadata.
208208
209If your consumer reads the stream slowly, Claude Code waits for the queued output to drain before exiting, scaling the wait with how much is still queued, capped at 30 seconds.
209If your program reads the stream slowly, Claude Code waits up to 30 seconds for queued output to drain before exiting.
210210
211211The following example uses [jq](https://jqlang.org/) to filter for text deltas and display only the streaming text. The `-r` flag outputs raw strings (no quotes) and `-j` joins without newlines so tokens stream continuously:
212212
No line in this hunk matches that.