snoop-cli 0.0.0-stage → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +355 -2
  3. package/bin/snoop.js +32 -0
  4. package/package.json +18 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joshua Alexander Zillwood
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,356 @@
1
- # Temporary Holding Version
1
+ <h1>
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jzills/snoop/main/site/static/mark-dark.svg">
4
+ <img src="https://raw.githubusercontent.com/jzills/snoop/main/site/static/mark-light.svg" alt="" height="28">
5
+ </picture>
6
+ snoop
7
+ </h1>
2
8
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
9
+ This is a fast terminal viewer for Claude Code session transcripts
10
+ (`~/.claude/projects/**/*.jsonl`). You can keep it open in a second terminal
11
+ next to `claude` to watch a session live, or browse past sessions to see what
12
+ each prompt cost, how full the context is, which files changed, what the
13
+ subagents did and where the time went. The documentation is at
14
+ https://jzills.github.io/snoop/.
15
+
16
+ ![snoop: the summary across sessions, a session's timeline with a turn's
17
+ waterfall, an expanded subagent, the Files tab and Stats](https://raw.githubusercontent.com/jzills/snoop/main/demo/demo.gif)
18
+
19
+ ## Install
20
+
21
+ ```
22
+ brew install jzills/tap/snoop # macOS and Linux
23
+ curl -fsSL https://jzills.github.io/snoop/install.sh | sh
24
+ npm install -g snoop-cli # or: pipx install snoop-cli
25
+ go install github.com/jzills/snoop/cmd/snoop@latest
26
+ ```
27
+
28
+ On Windows, use npm, PyPI or the PowerShell script:
29
+
30
+ ```
31
+ irm https://jzills.github.io/snoop/install.ps1 | iex
32
+ ```
33
+
34
+ Every method installs the same `snoop` command. On npm and PyPI the package
35
+ is named `snoop-cli`, since `snoop` was taken, and it carries the binary for
36
+ your platform, so nothing is downloaded or built when it installs. With
37
+ `uv`, run `uv tool install snoop-cli`.
38
+
39
+ The install script picks the build for your machine, checks it against the
40
+ release's `SHA256SUMS`, and installs it to `~/.local/bin` without sudo. To
41
+ install somewhere else, set `SNOOP_INSTALL_DIR`, and to install a given
42
+ release instead of the newest, set `SNOOP_VERSION`, such as `v0.1.0`. The
43
+ PowerShell script does the same on Windows, installing to
44
+ `%LOCALAPPDATA%\Programs\snoop` and adding it to your `PATH`.
45
+
46
+ You can also download a binary for Linux, macOS or Windows from the
47
+ [latest release](https://github.com/jzills/snoop/releases/latest). Each
48
+ archive holds the `snoop` executable, the license and this README.
49
+
50
+ Testing covers Claude Code 2.1.280 through 2.1.310. The transcript format is
51
+ undocumented and changes between versions. Records that snoop doesn't
52
+ recognize are ignored, so a new version may show less rather than break.
53
+ Please open an issue if something goes missing.
54
+
55
+ ## Use
56
+
57
+ ```
58
+ snoop # pick a session (all projects)
59
+ snoop --follow # follow the newest session for this directory, live;
60
+ # switches automatically when a new session starts
61
+ snoop --live # every session at work right now, across projects
62
+ snoop 64f3ec44 # open by session id prefix (or a .jsonl path)
63
+ snoop --project DIR # treat DIR as the current project
64
+ snoop hooks install # let the Diff tab send comments to the agent
65
+ snoop --version
66
+ ```
67
+
68
+ ## What you see
69
+
70
+ **Timeline:** The timeline shows every prompt, reply, thinking block and tool
71
+ call, one per line, with a blank line before each prompt so every turn
72
+ stands apart. A row in the same minute as the one above shows only its
73
+ seconds (`:42`). Tool rows show their duration and status (`✓` done, `✗`
74
+ error, `◌` running). Built-in tools (`▸`), skills (`✦`), MCP calls (`⇄`,
75
+ shown as `server·tool`) and subagents (`⤷`) each have their own color. The
76
+ right pane shows the selected item in full: Bash commands, Edit diffs, Write
77
+ content, agent prompts and results.
78
+
79
+ Each prompt row shows that turn's tokens, estimated cost (`≈`) and duration,
80
+ and compactions appear as `⟳ compacted (auto) 253k → 68k`. The header shows
81
+ how full the context window is (`ctx 142k/200k ▰▰▰▰▰▰▰▱▱▱ 71%`), turning to
82
+ the accent color at 70% and red at 90%. Selecting a prompt shows where its
83
+ turn's time went: totals, the five slowest tool calls, and a waterfall that
84
+ places each call by its start and end, so parallel calls overlap.
85
+
86
+ Pressing `x` on an Agent call expands its subagent inline, indented under a
87
+ `│` rule and kept live while it runs. Pressing `X` expands every subagent,
88
+ nested ones too. Search and filters reach into subagents, and a collapsed call
89
+ whose subagent has matches is kept and marked `●`.
90
+
91
+ **Tools:** The Tools tab groups every tool call by kind (built-in, skills,
92
+ MCP, subagents), then by name (tool, skill, MCP `server·tool`, subagent type),
93
+ then lists the individual calls, with counts, errors and average latency.
94
+ Selecting a group summarizes it in the right pane, and pressing `enter` on a
95
+ call jumps to it in the timeline.
96
+
97
+ **Files:** The Files tab lists every file the session and its subagents read,
98
+ edited or wrote, with read, edit and write counts and the lines added and
99
+ removed. Changed files come first, then files only read, each most recent
100
+ first. The right pane shows a file's history with every change as a diff,
101
+ which `n` and `N` step through, and pressing `enter` shows the latest change
102
+ in the timeline. Pressing `T` switches to a tree of folders, each with the
103
+ totals of its files. Changes made through Bash aren't tracked.
104
+
105
+ **Stats:** The Stats tab opens with the session's cost, duration, tokens (and
106
+ how many came from cache) and context. Below them, Turns lists each prompt's
107
+ time, tokens, cost and context, with a bar for its share of the cost and the
108
+ costliest prompt highlighted. Tools lists the tools used most, with errors
109
+ and average time, beside where the tokens went. Models lists each model with
110
+ its requests and cost.
111
+
112
+ Claude Code records a session's cost only when the session ends, so while it
113
+ runs, snoop estimates the cost from each request's tokens at the model's API
114
+ prices, and marks it `≈` and "estimated". Once the cost is recorded, snoop
115
+ splits each model's total across the prompts by token use, weighted by each
116
+ kind of token's price, so the prompt costs add up to the recorded total. The
117
+ estimate leaves out subagents' requests, and models without a known price
118
+ show tokens only.
119
+
120
+ ## Many sessions at once
121
+
122
+ **Live board:** The live board, opened with `snoop --live` or by pressing `w`
123
+ in the picker, lists every session written in the last 30 minutes, across
124
+ projects, most urgent first.
125
+
126
+ | State | Meaning |
127
+ | --- | --- |
128
+ | `? asking` | the session asks for permission to use a tool, which you can answer here |
129
+ | `◌ waiting` | a tool call has had no result for `--stall` (30s), usually a permission prompt |
130
+ | `✓ your turn` | the turn ended, or you interrupted it |
131
+ | `● working` | replying, or running a tool or subagent (shown underneath) |
132
+ | `· idle` | no prompts yet, or nothing written for 10 minutes |
133
+
134
+ The board's header counts the sessions waiting on you (`1 waiting on you`).
135
+ Each row shows the project, the session, how full its context is, its cost
136
+ and when it last wrote. Press `enter` to open a session and `esc` to come
137
+ back, or `o` and `O` to sort by another column. Only sessions on the board are read, and after the first read, only
138
+ what they add.
139
+
140
+ **Answer permission prompts:** With snoop's hooks installed (see
141
+ [Review and comment](#review-and-comment)), a session that asks for
142
+ permission shows as `? asking` on the board, with the request in full under
143
+ the list: the command, the edit's diff, or the tool's input. Press `A` to
144
+ allow it once, or `D` to deny it, optionally with a reason that Claude sees.
145
+ The same keys work in the session's own view, where its footer shows the
146
+ request. Claude Code's own prompt still appears in the session's terminal,
147
+ and whichever answer comes first wins.
148
+
149
+ The hook waits for an answer only while a live board or session view is
150
+ open, for at most 5 minutes (set with `snoop hooks install --ask-wait 10m`),
151
+ and answering in the terminal ends the wait at once. There is no "always
152
+ allow" here, so rules stay in Claude Code's own prompt.
153
+
154
+ **Find:** Pressing `f` in the picker finds sessions by a file they read or
155
+ changed, a command they ran, or a prompt, subagents included. Every word must
156
+ match the same file, command or prompt. Each result shows what matched, and
157
+ opening it searches its timeline for the same words. Sessions are indexed by
158
+ the same background scan as the summary and cached with it.
159
+
160
+ ## Review and comment
161
+
162
+ The Diff tab (`5`) shows the session's changes in one of two scopes, and `b`
163
+ switches between them. **Uncommitted** is `git diff HEAD`, with untracked
164
+ files shown as added. **Branch** is everything the branch changed since it
165
+ left its base, committed or not, which is what a pull request would show plus
166
+ the work in progress, so you can review an agent's whole branch without
167
+ opening a PR. Files with changes since the last commit are tagged
168
+ `uncommitted`. The tab opens in Branch when the branch has commits of its own.
169
+
170
+ Unless you choose one, snoop compares with the closest of `develop`, `main`,
171
+ `master` and `trunk`, preferring `origin/` copies, since a local one may be
172
+ out of date. The line at the top of the tab names the base. Press `B` to pick
173
+ another base, which is saved for the branch in its git config
174
+ (`branch.<name>.snoopBase`), or set `git config snoop.base` for a whole
175
+ repository.
176
+
177
+ Files the session changed come first, and files changed by you or another
178
+ agent are dimmed. The tab refreshes as the session edits files or runs a
179
+ command, and `r` reads the diff again.
180
+
181
+ Press `tab` to move into a file's lines, then `c` to comment on a line. Press
182
+ `v` and move to select a range first, or press `C` to comment on the whole
183
+ file. Press `e` or `x` to edit or delete the comment under the cursor.
184
+ Comments wait until you press `S`, which sends them all at once. Each comment
185
+ names the file and lines and quotes the code, so the agent doesn't have to
186
+ reread the file.
187
+
188
+ Sending needs Claude Code hooks, which you add once:
189
+
190
+ ```
191
+ snoop hooks install # in ~/.claude/settings.json
192
+ snoop hooks install --project # in ./.claude/settings.json instead
193
+ snoop hooks status # or uninstall
194
+ ```
195
+
196
+ The hooks run `snoop hook` after each tool call, when the agent tries to
197
+ finish, and when you submit a prompt. The agent sees your comments at the
198
+ first of these, so a working agent gets them mid-turn and an agent that has
199
+ finished keeps going. The footer shows when they are delivered. Without the
200
+ hooks, `S` copies the comments to the clipboard instead. A fourth hook runs
201
+ when a session asks for permission, so the live board can
202
+ [answer it](#many-sessions-at-once). If you installed the hooks before that
203
+ hook existed, `snoop hooks status` says so, and running `snoop hooks install`
204
+ again adds it.
205
+
206
+ The hooks are the only change snoop makes to Claude Code's settings, and
207
+ `snoop hooks uninstall` removes exactly those entries. Sent comments wait in a
208
+ `snoop/inbox` folder in your state directory (`~/.local/state` on Linux) until
209
+ a hook delivers them. Permission requests wait in `snoop/asks` beside it, and
210
+ open snoops refresh a small `snoop/listening` file every 2 seconds, which is
211
+ how the hook knows to wait. A session that was already running may need a restart
212
+ before it uses the hooks.
213
+
214
+ ## Summary across sessions
215
+
216
+ Pressing `s` in the session picker switches to a summary of the sessions
217
+ listed, so it follows `c` and the search. It shows sessions, prompts, tool
218
+ calls and the error rate, cost and tokens, a daily cost chart for the last 30
219
+ days, and the top tools, skills, MCP servers, subagent types and models with
220
+ their error rates. Every transcript is parsed in the background
221
+ (`scanning 12/48` in the header), and the results are cached in
222
+ `~/.cache/snoop/summaries.json` (the user cache directory), so later opens are
223
+ instant. Unreadable transcripts are counted and skipped.
224
+
225
+ ## Copy and export
226
+
227
+ Pressing `y` copies the selection to the clipboard over OSC 52, which works
228
+ over SSH, and in tmux with `set-clipboard on`. It copies the command for
229
+ Bash, the diff for edits, the content for Write, the full text of messages,
230
+ and the result for other tools. In the Files tab, it copies all of the file's
231
+ changes.
232
+
233
+ Pressing `e` exports the timeline as shown (search, filter, thinking and
234
+ expanded subagents included) to `./<session-id-8>-<YYYYMMDD-HHMM>.md`.
235
+ Prompts become headings, tool calls become collapsible `<details>` blocks,
236
+ and subagent events are quoted under their call. You can also export from the
237
+ shell:
238
+
239
+ ```
240
+ snoop export 64f3ec44 # whole session to stdout, without thinking
241
+ snoop export 64f3ec44 -o notes.md
242
+ ```
243
+
244
+ ## Alerts
245
+
246
+ While a session is receiving new lines, the header flags what needs your
247
+ attention:
248
+
249
+ | Alert | Raised when |
250
+ | --- | --- |
251
+ | `✗ error` | a tool call fails; the header counts unseen errors |
252
+ | `◌ waiting 30s on Bash` | a tool call has no result after `--stall` (default 30s), which may be a permission prompt, since those aren't recorded until answered |
253
+ | `✓ your turn` | Claude finishes |
254
+ | `⟳ compacted` | the context is compacted |
255
+ | `ctx 90%` | the context window passes 90% |
256
+ | `? Bash: npm test` | the session asks for permission (needs the hooks) |
257
+
258
+ Any key hides the alert, and pressing `!` jumps to it. Lines already in the
259
+ transcript when it opens never raise alerts.
260
+
261
+ ```
262
+ snoop --follow --bell # ring the bell on errors, turn ends and permission requests
263
+ snoop --live --notify # a desktop notification when any session needs you
264
+ snoop --follow --bell --alerts error,stall,turn,compact,ctx,ask
265
+ snoop --stall 2m # 0 disables the waiting alert
266
+ ```
267
+
268
+ The live board raises the same alerts for every session on it, prefixed with
269
+ the project (`api: ✓ your turn`).
270
+
271
+ With `--notify`, snoop sends a desktop notification naming the session and
272
+ what happened (`api · Fix the flaky test` / `Your turn · finished after
273
+ 2m10s`), so you can work elsewhere and come back when a session needs you. It
274
+ picks one way to deliver them:
275
+
276
+ | Where snoop runs | Notification |
277
+ | --- | --- |
278
+ | iTerm2, WezTerm, Ghostty, kitty | the terminal's own (clicking it focuses the tab) |
279
+ | over SSH | the terminal's own, so it shows on your machine, not the server |
280
+ | WSL | a Windows toast, through `powershell.exe` |
281
+ | macOS, other terminals | `osascript` |
282
+ | Linux desktop | `notify-send` |
283
+ | anywhere else | the terminal's own escape sequence (OSC 777) |
284
+
285
+ To override the choice, use `--notify=terminal` or `--notify=system`. In
286
+ tmux, let the terminal's own notifications through with
287
+ `set -g allow-passthrough on`.
288
+
289
+ Nothing is sent while snoop's window has focus (in terminals that report
290
+ focus). At most one notification goes out per session and alert a minute, and
291
+ several snoops watching the same session send one between them.
292
+
293
+ ## Keys
294
+
295
+ Press `?` anywhere for the keys of the current screen. The full list follows.
296
+
297
+ | Key | Action |
298
+ | --- | --- |
299
+ | `↑↓` / `j k`, wheel | move (the wheel over the right pane scrolls it) |
300
+ | `enter` / `tab` | focus the detail pane (zoom it on narrow terminals) |
301
+ | `J K` / `ctrl+d ctrl+u` | scroll the detail pane |
302
+ | `/` | search text, commands, paths and results (all words must match) |
303
+ | `f` / `F` | cycle the filter: all, chat, tools, skills, mcp, agents, errors |
304
+ | `t` | show thinking blocks |
305
+ | `n` / `N` | next / previous prompt |
306
+ | `x` / `X` | expand a subagent inline / expand or collapse all |
307
+ | `a` | open the subagent transcript for an Agent call (`esc` returns) |
308
+ | `g G` | top / bottom (bottom re-enables following) |
309
+ | `1 2 3 4 5`, `[ ]` | switch tabs |
310
+ | `esc` | clear the search or filter, then go back |
311
+ | `!` | jump to the latest alert |
312
+ | `A` / `D` | allow once / deny the session's permission request |
313
+ | `y` / `e` | copy the selection / export the view to Markdown |
314
+ | `?` | every key for the current screen |
315
+ | `q` | quit |
316
+
317
+ In the Tools tab, `space` expands or collapses a group, `enter` on a call
318
+ shows it in the timeline, and `←` and `→` collapse and expand (`←` on a call
319
+ moves to its group). Pressing `E` expands everything (press it again to
320
+ reset), and a `/` search keeps only matching calls with their groups opened.
321
+
322
+ In the Files tab, `T` switches between the list and a tree of folders. In
323
+ the tree, `space` and `enter` open or close a folder, `←` and `→` close and
324
+ open (`←` on a file moves to its folder), and `E` opens every folder (press
325
+ it again to reset).
326
+
327
+ In the Diff tab, `b` switches between the uncommitted changes and the whole
328
+ branch, and `B` picks the branch's base. Press `tab` to move between the
329
+ files and their lines, and `J` and `K` to jump between hunks. The keys `c`,
330
+ `v`, `C`, `e`, `x` and `S` work as described in
331
+ [Review and comment](#review-and-comment).
332
+
333
+ In the picker, `/` starts a fuzzy search and `f` finds across sessions, and
334
+ `esc` clears either. Pressing `c` toggles this project only, `s` switches to
335
+ the summary, and `w` opens the live board. On the picker and the live board,
336
+ `o` sorts by the next column and `O` reverses the order. Search results stay
337
+ best match first until you choose a column.
338
+
339
+ ## Notes
340
+
341
+ - The transcript format is undocumented and changes between Claude Code
342
+ versions. Unknown records are ignored, and bulky internal records
343
+ (`api-request*`, `attachment`, `file-history-*`) are skipped without being
344
+ decoded, so a 75 MB transcript loads in about 150 ms.
345
+ - It respects `CLAUDE_CONFIG_DIR`.
346
+ - Running `go run ./cmd/probe` parses every local transcript and reports
347
+ timings.
348
+ - The demo GIF is rendered from `demo/demo.tape` against fictional sessions
349
+ by `demo/render.sh`, which needs [vhs](https://github.com/charmbracelet/vhs).
350
+
351
+ This independent project isn't affiliated with or endorsed by Anthropic.
352
+ Claude and Claude Code are trademarks of Anthropic.
353
+
354
+ ## License
355
+
356
+ [MIT](https://github.com/jzills/snoop/blob/main/LICENSE)
package/bin/snoop.js ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+ // Runs the snoop binary from the platform package npm installed beside this
3
+ // one (@jzills/snoop-cli-<platform>-<arch>), passing the arguments through.
4
+ "use strict";
5
+
6
+ const { spawnSync } = require("node:child_process");
7
+
8
+ const pkg = `@jzills/snoop-cli-${process.platform}-${process.arch}`;
9
+ const exe = process.platform === "win32" ? "snoop.exe" : "snoop";
10
+
11
+ let bin;
12
+ try {
13
+ bin = require.resolve(`${pkg}/bin/${exe}`);
14
+ } catch {
15
+ console.error(
16
+ `snoop: no build for ${process.platform}/${process.arch} was installed (${pkg}). ` +
17
+ "Builds exist for Linux, macOS and Windows on x64 and arm64; if npm skipped " +
18
+ "optional dependencies, reinstall without --omit=optional, or see " +
19
+ "https://jzills.github.io/snoop/docs/install/",
20
+ );
21
+ process.exit(1);
22
+ }
23
+
24
+ const run = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
25
+ if (run.error) {
26
+ console.error(`snoop: ${run.error.message}`);
27
+ process.exit(1);
28
+ }
29
+ if (run.signal) {
30
+ process.kill(process.pid, run.signal);
31
+ }
32
+ process.exit(run.status ?? 1);
package/package.json CHANGED
@@ -1,6 +1,20 @@
1
1
  {
2
2
  "name": "snoop-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.1",
4
+ "description": "A terminal viewer for Claude Code sessions: follow one live, or see what any past one cost, changed and spent its time on.",
5
+ "license": "MIT",
6
+ "repository": {"type": "git", "url": "git+https://github.com/jzills/snoop.git"},
7
+ "homepage": "https://jzills.github.io/snoop/",
8
+ "keywords": ["claude", "claude-code", "agents", "tui", "terminal"],
9
+ "bin": {"snoop": "bin/snoop.js"},
10
+ "files": ["bin"],
11
+ "engines": {"node": ">=18"},
12
+ "optionalDependencies": {
13
+ "@jzills/snoop-cli-linux-x64": "0.2.1",
14
+ "@jzills/snoop-cli-linux-arm64": "0.2.1",
15
+ "@jzills/snoop-cli-darwin-x64": "0.2.1",
16
+ "@jzills/snoop-cli-darwin-arm64": "0.2.1",
17
+ "@jzills/snoop-cli-win32-x64": "0.2.1",
18
+ "@jzills/snoop-cli-win32-arm64": "0.2.1"
19
+ }
20
+ }