winnow
GhalebDweikat · GhalebDweikat/winnow
A Claude Code plugin that hides large tool results the judge model deems irrelevant behind short stubs, restorable on demand, to save context tokens.
A calibrated context sieve for Claude Code: every tool result is judged by a System One model before it enters context.
Preview
What you can do with it
- Cut token use when Claude reads big files or long grep output
- Restore hidden blocks with a key when they turn out to matter
- Keep long coding sessions from filling the context window
Safety check
No risky patterns found in the files we scanned.
Automated scan of the repo files. Always review code you run.
From the README
winnow
A calibrated context sieve for Claude Code.
Every large Read, Bash, or Grep result is judged before it enters Claude's context. Blocks the judge is confident you don't need are replaced with a three-line stub: what was hidden, a one-paragraph summary from a cheap model, and a key that restores the full text on demand. Nothing is lost; it just stops costing tokens until you ask for it.
Terms used below. The judge is the model that answers one yes/no question per block ("is this block needed for the current task?") with a probability. By default that is Jev, TypeSafe AI's System One model: a model that returns calibrated probabilities for typed questions instead of generating text, so a hundred questions come back in one call in a few hundred milliseconds. Jev is in early access. The adapter is TypeSafe's system-one-adapter package, which answers the same questions by prompting Claude Haiku 4.5; it is not calibrated, but it lets the whole pipeline run today.
What it does
Read big.py ──► Claude Code ──► tool.call hook ──► winnow
│
split into ~25-line blocks ◄─────────────────────────┘
one call to the judge: "is block N needed for the current task?" ×N, in parallel
keep confident-yes and uncertain blocks verbatim
hide confident-no blocks: cache full text ─► summarize ─► stub
│
Claude sees ◄── { result } ◄───────────────────────────────┘
A stub looks like this:
[winnow] Lines 41-188 (148 lines) hidden: judged unlikely to matter for the current task (relevance <= 0.22).
[winnow] Summary: Argparse setup for the --export and --format flags, plus the license header.
[winnow] Full text cached as key a1b2c3d4e5f6. Call winnow_recall(key="a1b2c3d4e5f6", start=41, end=188) if you need it.
Without a summarizer the middle line is a deterministic digest instead, so Claude still knows what kind of thing it lost: for a search result, which files the hidden matches came from and how many each; for anything else, the line count, whether it was mostly comments, imports or repetition, and the first line.
Two safety rules are built in. If the judge thinks the output shows an error, nothing is hidden. If a block's probability is merely uncertain (between WINNOW_DROP and WINNOW_KEEP), it is kept. Both thresholds are tunable; the rules themselves are not optional. The default WINNOW_DROP of 0.1 is the bin that came back clean on hand-labeled replay (see Measured); raise it only with your own evidence.
The hook is a function-hook module (see How it hooks in) that talks to a small resident server (winnow serve) on loopback, started at session start, so a judged call costs about 16 ms plus the judge call rather than a Python startup. winnow never judges its own files or its own commands, so recalls and labeling sheets always come back whole.
A second hook runs at prompt time. It ranks the memory files Claude Code keeps for the project (~/.claude/projects//memory/*.md, everything except the MEMORY.md index, which Claude already loads) plus any directories in WINNOW_CONTEXT_DIRS against your prompt, and injects the relevant ones so Claude reads what it needs without a round of Read calls.
What winnow changes is only what Claude sees. Files on disk, the commands that ran, and Claude Code's own transcript are untouched.
Quick start
Requirements: Python 3.10+, uv, Claude Code 2.1.260 or newer with function hooks enabled (early access; one line in settings, below).
First turn on function hooks in ~/.claude/settings.json (winnow does nothing without this, and winnow doctor checks it):
{ "env": { "CLAUDE_CODE_ENABLE_FUNCTION_HOOKS": "1" } }
Then install:
git clone https://github.com/GhalebDweikat/winnow.git
claude plugin marketplace add ./winnow
claude plugin install winnow@winnow
Then add a key (next section), open a new Claude Code session, and read any file longer than about 1,500 characters. If a [winnow] line appears in the result, it's working. If not, see Troubleshooting.
Before you have any key, you can still see what it does:
uv run --project winnow/sidecar winnow demo --fake
That runs a synthetic 130-line file through the real pipeline with a keyword judge and prints what Claude would have seen. Once a key is set, drop --fake and the same command makes the first real judge call.
The repo is its own plugin marketplace, so it also installs straight from GitHub without cloning:
claude plugin marketplace add GhalebDweikat/winnow
claude plugin install winnow@winnow
GitHub shorthand clones over SSH by default; set CLAUDE_CODE_PLUGIN_PREFER_HTTPS=1 if you don't have an SSH key on this machine.
Installing applies everywhere that shares your ~/.claude config: the CLI, the desktop app, and IDE extensions. New sessions pick the plugin up; running sessions don't. The first session after install syncs the sidecar's environment and starts the resident server, which takes a few seconds once; after that, sessions share the running server and start instantly.
Installed plugins are copied to ~/.claude/plugins/cache/, not linked, so after pulling changes run claude plugin update winnow@winnow. For a hot-reload loop while developing, load the checkout for one session instead:
claude --plugin-dir ./winnow
To scope the plugin to one project rather than your whole account, add --scope project to the marketplace add command.
Add your keys
winnow needs one key for the judge and, optionally, one for summaries. Nothing runs until at least the judge key is in place; until then every hook passes results through untouched and, once per session, tells you so.
1. Get a Jev key. Jev is in early access. Join the wait