npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

claude_stream_viewer

v1.0.18

Published

Claude Stream Viewer - Pretty-prints Claude API stream-json events from stdin with colorized output.

Downloads

410

Readme

claude_stream_viewer

Pretty-prints Claude Code stream-json events from stdin with colorized output. Drop it at the end of a claude --output-format stream-json pipe to read the stream as a human instead of as raw JSON.

claude_stream_viewer demo

Requirements

Install

npm install -g claude_stream_viewer
# or run on demand without installing
npx -y claude_stream_viewer@latest

Usage

Pipe any source of stream-json events into the viewer:

claude --output-format stream-json --verbose \
       --permission-mode auto -p "explain quantum computing like I'm 5" \
  | npx -y claude_stream_viewer@latest

The viewer reads one JSON event per line from stdin and writes a colorized, human-readable rendering to stdout. It exits when stdin closes, printing [stream ended].

What it renders

The viewer consumes Claude Code's consolidated event layer (system, assistant, user, rate_limit_event, result). The fine-grained stream_event SSE envelopes are ignored — the consolidated events already carry fully assembled content blocks.

| Event | Output | |--------------------|-------------------------------------------------------------------------------------| | system (init) | === SESSION === header with model, cwd, tool count, session id, claude-code version | | assistant | One block per content type: --- thinking ---, plain assistant text, or → <tool> with a per-tool compact body (Bash → $ <command>, Read/Write/Edit → file path, Grep/Glob → pattern, TodoWrite → checkbox list, etc.). Unknown tools fall back to a JSON dump. | | user | ← <tool> result (or ← <tool> ERROR) followed by the tool output, truncated past 40 lines | | rate_limit_event | One-line [rate_limit] <status> notice | | result | === RESULT === summary with terminal_reason, stop_reason, turns, duration, cost (full token/latency/tool stats via --stats) | | stream_event | Silently skipped | | Anything else | === <type> === header followed by the raw JSON |

Tool calls and their results are paired by tool_use_id, so each ← <tool> result is labeled with the matching call's tool name.

Malformed lines are reported on stderr (Invalid JSON: …) without aborting the stream.

Stats summary

Pass --stats (-s) to suppress the streamed log and print only an end-of-stream summary, computed from the result event:

cat session.jsonl | npx -y claude_stream_viewer@latest --stats

It reports:

  • RESULT — terminal_reason, stop_reason, turns, duration, cost, and health signals (is_error, permission_denials)
  • LATENCY — wall vs API vs local (tools + overhead) split, plus output throughput
  • TOKENS — input / output / cache read / cache create / total, cache-hit %, and a per-model breakdown with per-model cost
  • CONTEXT — peak prompt size and % of the context window used at peak
  • TOOLS — call count per tool and tool-result error rate

Choose the output format with --json or --markdown (both imply --stats):

cat session.jsonl | npx -y claude_stream_viewer@latest --json | jq .tokens
cat session.jsonl | npx -y claude_stream_viewer@latest --markdown

Truncated streams (no result event) still print CONTEXT and TOOLS from what was observed, with a "stream truncated" note.

Options

| Flag | Description | Default | |---------------|---------------------------------------------------------|---------| | -s, --stats | Print only the summary stats; suppress the streamed log | off | | --json | Output stats as JSON (implies --stats) | — | | --markdown | Output stats as Markdown (implies --stats) | — | | --no-color | Disable colored output | colored | | --version | Print the package version | — | | --help | Print usage help | — |

Development

cd packages/claude_stream_viewer
npm install
npm run dev        # tsx ./src/cli.ts
npm run build      # compile TypeScript → dist/
npm run typecheck  # type-check without emitting

Output

  • Rendered events are written to stdout.
  • Parse errors and processing errors are written to stderr; the process keeps reading.