A developer-focused guide and code samples for extracting and displaying Claude Code CLI thinking blocks as collapsible messages in Telegram using stream-json NDJSON output.
Collecting history — the radar snapshots this repo daily. The trend line appears after 3 days of data (1 so far).
What it is
A step-by-step guide to displaying Claude Code CLI (claude -p) thinking blocks in Telegram as collapsible messages, by parsing NDJSON stream-json events and separating thinking content from final results.
How it works
The README describes running claude with --output-format stream-json --verbose to emit NDJSON where thinking blocks appear as type: thinking dentro assistant.message.content, and final text comes from a type: result event. A minimal TypeScript parser is provided to collect thinking blocks and the final result, then render via Telegram HTML blocks with an expandable section for thinking. It preserves original language for thinking and escapes HTML when rendering. Key data flow: Claude Code CLI → NDJSON parser → { text, thinking? } → Telegram renderer.
Getting started
- Use the command examples:
claude -p "Your prompt" \
--output-format stream-json \
--verbose
claude -p "A farmer has 17 sheep. All but 9 run away. How many remain?" \
--output-format stream-json \
--verbose \
> /tmp/claude-stream.ndjson
- Install and run the provided NDJSON parser in TypeScript, which exposes ParsedClaudeResponse and parseClaudeStreamJson(stdout) to extract text and thinking blocks.
- Render with a Telegram renderer that uses HTML parse_mode and a minimal thinking block renderer shown in code samples.
Recent releases
- Releases section lists "latest 0" with none; no versioned releases are described.
Traction
- Stars: 14
Behind the repo
- No linked startup/company section is provided in the facts.
Caveats
- License is not listed in the repository metadata.
- Created and last_push dates indicate initial activity on 2026-07-14.
- The README emphasizes that thinking content may differ across Claude Code versions and models, and that users should test capabilities.
- The implementation includes TypeScript snippets, NDJSON parsing logic, and Telegram rendering with HTML escaping and expandable blocks.
