context-inspector
Reviewed
at commit d15db0e
Context waste analyzer for Claude Code: what fills the window, re-reads, near-duplicate outputs, what compaction kept, advice
0 upvotes
Log in to upvote or save- Made by
- YeonwooSung
- Pinned commit
-
d15db0ef3aa8e47051a516849cf487777bdaa1b4 - What we checked
-
Watches what enters the context window (tool output, file reads, prompts, compactions) and reports what fills it, files read twice, near-duplicate output and what compaction dropped, with advice, in /context-inspect, a pane and the status line. It measures sizes and hashes in memory only, changes nothing, makes no network calls, and /context-export writes metadata (paths, redacted commands) to ~/.claude/context-inspector.
Review details
Static review of the source at the pinned commit; not run. Registers session.start (resets its in-memory ledger, registers the commands context-inspect, context-pane and context-export through $.command.register), session.end (reset after clear or resume), session.append (records each row's length, a content hash and a SimHash, plus the target of tool results), tool.call (records tool name and target such as file path, Bash command, Grep pattern, URL or agent name before the call and whether it failed or was a whole-file Read after it; always passes the call and answer through unchanged), turn.step (pass-through of the stream, reads token usage from stop chunks), session.compact (observes the result after next() to see which items and entities survived; does not alter it), turn.complete (repaints) and ui.render for its pane. Runtime calls: $.session.messages (one read-back after a reload or /clear), $.session.usage (context percent and, for /context-inspect, the MCP tool and memory file breakdown), $.session.id, $.clock.after, $.ui.status, $.ui.toast (at most one per session for high-severity advice, can be turned off with toastAdvice), $.ui.open, $.ui.invalidate, $.env.get('HOME') and $.fs.write. The only file write is /context-export, run by the user: JSONL chunks under 3.5 MiB to outputDir/<session id>/ (default ~/.claude/context-inspector), holding file paths, item sizes, hashes, turn numbers and summary figures; command lines, patterns, URLs and agent names are passed through a best-effort secret redactor and cut to 200 characters, compaction errors and typed identifiers are stored as hashes only, and no file or output content is written. The report and pane also pass text through the redactor. All bookkeeping is wrapped in try/catch so it never breaks the session. Everything else is pure analysis code (re-read classification, SimHash clustering, compaction retention, token calibration, rule-based advice). No network calls, no processes, no $.model calls, no npm dependencies.
- What it uses
-
- Reads your prompts: yes
- Sees tool calls: yes
- Blocks or changes tool calls: no
- Reads or writes files: yes
- Runs programs on your machine: no
- Calls the model (uses tokens): no
- Sends data over the network: no
- Stores data: no
- Shows something on screen: yes
Made this mod? Add a badge to your README
Paste this into your README. The badge says reviewed once the current version has been reviewed, and links readers to this page.
[](https://modsforclaude.com/mods/context-inspector/)