Context Diet for Claude Code
Huge tool outputs, trimmed before they fill Claude's context. Nothing is lost: the full text is one Read away.
Context Diet is a Claude Code mod. When a command prints a wall of text (a test run, a build log, a 5,000-row JSON, a git diff with a lockfile), Claude gets a short digest instead: the errors with their context, the summary, the shape of the data, and the path to a file with the full output. When Claude needs more, it reads that file.
Works in the Claude Code terminal and the Claude desktop app (Code tab). Tested on macOS.


Install
In Claude Code:
/plugin marketplace add drkokorev/context-diet
/plugin install context-diet@context-diet
Or from your shell:
claude plugin marketplace add drkokorev/context-diet
claude plugin install context-diet@context-diet
There is nothing to set up. Run /diet demo to see the panel filled in, and /diet reset to clear it.
Why
- Logs eat the context. One test run of 600 suites is 30,000 characters, about 7,600 tokens, almost all of them
PASS lines. A few of those and the context is half full, compaction comes sooner, and Claude forgets what you said at the start.
- The very long ones hide the failure. Past about 30,000 characters, Claude Code saves the output to a file and shows Claude only its first 2 KB. A failure in the middle or at the end isn't in that preview, so Claude has to open the file first. Context Diet replaces the preview with a digest of the whole file, so the failure is right there.
What Claude gets
Every digest starts with a note like this:
[Context Diet: Bash output cut from 30,372 to 1,153 characters. Kept: every failure with
its message and code frame, the summary. Full output: /path/to/project/.context-diet/out-007.txt.
Read it before answering about anything not shown here.]
[jest] 611 passing files not listed, 1 failing; 68 console lines of 5 kinds, one of each shown
What it keeps depends on what the output is:
| Output | What stays |
|---|
Test runners and build tools it knows: jest, vitest, node --test, pytest, go test, cargo, tsc, eslint, npm / yarn / pnpm / pip install, docker build | Every failure or error with its message, code frame and stack, the summary; passing tests are counted, not listed; noise (console lines, deprecation warnings, compile steps) shown once per kind with a count |
| Other logs | Every error with two lines before and three after, then each distinct warning once, the first and last lines, the summary. Identical lines and lines that differ only in numbers ("Compiling crate_1 … crate_1500") fold into one with a count |
| Tables, CSV, columns of numbers | The header and the first and last rows, exactly. Rows are never folded or summarized; the note says which lines were left out |
| JSON (Bash or MCP) | The structure: every key, the first items of each array with the count of the rest and their keys, long strings shortened |
| Diffs | Every file with its +/− counts and its hunks; lockfiles and generated files (package-lock.json, yarn.lock, *.min.js, dist/…) reduced to counts |
| grep results | Match counts for every file and the first matches in each, as many as fit |
File lists (find, Glob) | Grouped by directory with counts and the first names, the shared path prefix written once |
Outputs from Bash, Grep, Glob and MCP tools (JSON only) longer than 8,000 characters (≈2k tokens) get a digest; shorter ones pass as they are. The threshold is one command away: /diet 16k.
Failing tests: the part Claude Code hides
When a command fails, Claude Code shortens its output to about 10,000 characters by cutting the middle and the end, and saves nothing. With a verbose test run, that is exactly where the failures and the summary are: Claude sees thousands of PASSED lines and has to run the tests again with tail or grep to find out what broke.
/diet capture on fixes that for test and build commands (pytest, jest, vitest, go test, cargo, tsc, eslint, npm test, make, gradle…). The command runs as written, in the same shell, but its output also goes to .context-diet/run-NN.log; Context Diet then digests the whole log, so Claude gets every failure with its cause and line, and the summary, on the first run: