
The usual token-saving tool takes an existing stream of data and makes it shorter. LeanCTX asks a question one step earlier: does the agent need to read this file in full at all.
The difference is not cosmetic. If the model needs to know which functions a module exports, it can receive a twenty-line list of signatures instead of six hundred lines of source - and then there is nothing left to compress, because the surplus never appeared. Hence the positioning: this is not a compressor but a layer that decides what enters the window.
It is also one of the largest projects in the field, which is exactly what makes it interesting to take apart - it shows plainly what such completeness costs.
Ten ways to read one file
Let me start with the mechanism that makes the project worth a look. The read operation takes a mode parameter, and the README names ten. A caveat straight away: that is the documentation's number, and the code has more - the mode enumeration holds seventeen variants, including service ones such as raw byte reads, reads with per-line anchors, and a compacted full read. What follows covers the ten the project presents as the working set.
| Mode | Returns | Use when |
|---|---|---|
| `auto` | LeanCTX picks for you | the default |
| `full` | the whole file, but cached | you are going to edit it |
| `map` | imports and the API surface | you want the shape of the file |
| `signatures` | function, class and type signatures | you only need the API |
| `aggressive` | a heavily trimmed representation | very large file |
| `entropy` | lines ranked by information density |