What should you use instead of lean-ctx?
If you want the bill to go down, use Tokenade: it is the only one of the twelve tools in the open THOL benchmark that measurably lowered what a session costs, and lean-ctx landed at no measurable difference. If you want one of lean-ctx's layers without the rest, squeez and rtk do shell compression with far less to configure.
lean-ctx has the widest feature surface of the open-source context tools. One Rust binary gives you 16 file read modes, a cache that turns repeat reads into short references, 85+ shell-output patterns, a code graph, session memory and an opt-in local proxy that can trim history. It now presents itself as a "Context Gateway for AI Systems".
The reasons people look elsewhere follow from that breadth:
- There is a lot to configure, and the payoff depends on it. Its own README says the levers "net to break-even where they don't" line up.
- Its README tells you to skip it if you mostly work in tiny repos and rarely call the shell.
- The licence is mixed: an Apache-2.0 core, with some v4 modules under commercial source-visible terms.
- In testing, the session bill did not go down.
Disclosure before the ranking: I maintain the THOL benchmark and I build Tokenade. The benchmark is public and reproducible, and it includes results that don't flatter my tool, but it is not an independent third party.
Features read on each project's GitHub README on 2026-10-15. Session-cost figures come from the published THOL campaign (Claude Code 2.1.206, Claude Sonnet 4.6, long sessions), the only one this site quotes.
The short list
| Tool | What it is | Entry price | Best for |
|---|---|---|---|
| Tokenade | A binary between your agent and its tools: output filtering, file-read trimming, code search, MCP folding | Free, open source (MIT/Apache-2.0) | A measured drop in session cost |
| squeez | A Rust hook compressor for shell output and file reads, reversible | Free (Apache-2.0) | lean-ctx's compression, minus the configuration |
| rtk | A Rust proxy that filters shell command output | Free (Apache-2.0 + BUSL-1.1 engine) | The simplest shell filter |
| context-mode | An MCP server that sandboxes tool output and tracks session events | Free (Elastic License 2.0) | Session continuity after compaction |
| codegraph | A pre-indexed code knowledge graph over MCP | Free (MIT) | lean-ctx's code-graph side, on its own |
| edgee | A hosted AI gateway that trims tool outputs | Free tier, then paid per developer | lean-ctx's proxy idea, as a managed service |
How we picked
Five criteria, applied identically to every entry including mine:
- Measured session cost. End to end, against a no-tool control, from THOL. Where a tool isn't in the campaign, the table says "Not measured" and any vendor figure stays in prose, attributed, with its scope.
- Setup burden. How much you configure before the tool pays off, which is lean-ctx's main cost.
- Layer covered. Shell output, file reads, MCP results, conversation history or code retrieval.
- Fixed cost per session. Tool definitions and instructions are re-sent at every step, so a large MCP tool set has to earn its keep.
- Licence and where your traffic goes.
1. Tokenade — the one measured to lower session cost
Tokenade is the strongest lean-ctx alternative on the criterion that matters most: it is the only tool of the twelve in the open benchmark that measurably reduced what a session costs.
- What it is: a binary between your AI agent and its tools. It filters every tool's output, trims file reads to structure first, folds MCP results and runs on-device code search, with a savings dashboard.
- Strengths: on long sessions it makes a session 39% cheaper than the agent on its own. It works through the agent's hooks, so the agent's own reads and searches are covered without asking the model to call special
ctx_*tools.tokenade installdetects your agents and wires them in one run. - Limitations: it's my product, so weight this accordingly. It is less configurable than lean-ctx by design, so tinkerers get fewer knobs. Like any compactor it can fold output you needed;
tokenade raw <cmd>reruns a command uncompacted. - Best for: anyone who wants the bill to move without a tuning project. The attribute view is on Tokenade vs lean-ctx.
2. squeez — the compression, minus the configuration
squeez is the closest lean-ctx alternative for its read-path compression: one Rust binary that compresses shell output and file reads before they enter context.
- What it is: a hook-based compressor with smart filtering, cross-call deduplication, log-template compaction and relevance-based truncation. Apache-2.0, no runtime dependencies.
- Strengths: compression is reversible, much like lean-ctx's source recovery: originals stay local and the agent can pull them back. A guard keeps the verbatim output when a cut would drop paths, errors or test verdicts.
squeez setupdetects your CLIs. - Limitations: no measurable difference in THOL. Support varies by host, and it has no cache, no code graph and no proxy.
- Best for: people who wanted lean-ctx's compression and nothing else. See Tokenade vs squeez.
3. rtk — the simplest shell filter
rtk is the lean-ctx alternative if shell output was the only reason you installed it, and you want the least possible setup.
- What it is: a Rust CLI proxy with 100+ command-specific filters and a transparent hook.
- Strengths: the easiest install in this category (brew, curl or cargo), no MCP tool set to carry, and
rtk gainshows per-command savings. - Limitations: no measurable difference in THOL. It sees shell commands only, not the agent's file reads or MCP results. The default build ships its compression engine under BUSL-1.1, next to an Apache-2.0-only
rtk-ossedition. - Best for: build-heavy and test-heavy sessions. The full field is on rtk alternatives.
4. context-mode — session memory and sandboxed output
context-mode is the lean-ctx alternative if what you valued was continuity: keeping track of what the agent was doing after the conversation compacts.
- What it is: an MCP server that runs data-heavy work in sandboxed tools so raw output stays out of the window, and records edits, git operations, tasks and errors in SQLite. It is installed as a Claude Code plugin or through npm, with routing across many agents.
- Strengths: after compaction it retrieves only relevant events by BM25 search instead of replaying them. Its README illustrates the sandbox with 315 KB of tool output reduced to 5.4 KB, one example rather than a session figure. It also leaves the model's writing style alone.
- Limitations: it isn't in the published THOL campaign, so not measured on session cost. It is source-available under the Elastic License 2.0, not open source.
- Best for: long Claude Code sessions that lose the thread after compaction. See Tokenade vs context-mode.
5. codegraph — the code graph on its own
codegraph is the lean-ctx alternative if the part you used was code retrieval: find the symbol, its callers and its dependencies in one call.
- What it is: a pre-indexed knowledge graph of symbols, call edges and dependencies that syncs on code changes.
codegraph installwires it into Claude Code, Cursor, Codex, OpenCode, Gemini CLI and others. MIT. - Strengths: focused and easy to set up. Its README reports 44% lower cost per answer across seven benchmark repos, and is candid that dense answers leave about 80% more retrieval context in the window by the end of a session.
- Limitations: that figure was measured per question, not on whole sessions. In THOL it showed no measurable difference. No shell compression, no cache of file reads.
- Best for: navigation-heavy work. The field is on CodeGraph alternatives.
6. edgee — the proxy, as a hosted gateway
edgee is the lean-ctx alternative if you liked the idea of the wire-path proxy but would rather someone else ran it.
- What it is:
edgee launch clauderoutes your agent through a hosted gateway that trims tool outputs before they reach the model. The CLI is Apache-2.0. - Strengths: fallbacks, model reroutes, team usage tracking and spend caps on the paid tier, with nothing to tune locally.
- Limitations: no measurable difference in THOL. Your agent traffic transits a third-party service, where lean-ctx's proxy stays on your machine.
- Best for: teams that need routing and budgets.
At a glance
| Tool | Measured session cost (THOL) | Layers covered | Setup | Licence |
|---|---|---|---|---|
| Tokenade | 39% cheaper on long sessions | All tool output, file reads, MCP, code search | npm + one command | Free, open source (MIT/Apache-2.0) |
| squeez | No measurable difference | Shell, file reads where the host allows | One command | Apache-2.0 |
| rtk | No measurable difference | Shell only | One command | Apache-2.0 + BUSL-1.1 |
| context-mode | Not measured | Sandboxed tool output, session events | Plugin or npm | Elastic License 2.0 |
| codegraph | No measurable difference | Code retrieval | One command, then index | MIT |
| edgee | No measurable difference | Tool output, at a gateway | Install script + account | Apache-2.0 CLI, paid tiers |
| lean-ctx (baseline) | No measurable difference | Reads, cache, shell, graph, memory, optional proxy | Install, wrap, then tune | Apache-2.0 core + commercial modules |
| Tokenade | measurably cheaper | -39% |
|---|---|---|
| lean-ctx | no measurable difference | +10.3% |
7 long tasks (over 200,000 tokens), 70 runs per tool, Claude Code 2.1.206 with Claude Sonnet 4.6. “No measurable difference”: the gap is within the run-to-run noise. Source: THOL, 2026.
lean-ctx's bar leans toward more expensive, but the gap stays inside the run-to-run spread, so the honest reading is "no measurable difference". The full table is on the THOL explainer.
Why can a context tool end up costing more?
Because every tool has a fixed cost, paid at every step, before it saves anything. Tool definitions and instructions are part of the prompt the agent re-sends each turn, and a large ctx_* tool set is a lot of definitions.
lean-ctx is unusually open about this. It ships lean-ctx doctor overhead to measure its own schema and instruction overhead, has withdrawn its earlier per-read-mode compression table, and labels its replay benchmark a "synthetic upper bound". It also states that a powered with/without quality study has not been run yet. That candour is worth more than a big number.
How do you uninstall lean-ctx?
Run lean-ctx uninstall, which its README calls a full clean removal. Add --dry-run first to preview every change without writing anything, or --keep-config to keep MCP configs and rules for a reinstall.
If the binary is not on your PATH or you used the curl installer, its README gives curl -fsSL https://leanctx.com/install.sh | sh -s -- --uninstall. Package-manager installs then need the usual removal: brew uninstall lean-ctx, cargo uninstall lean-ctx or npm uninstall -g lean-ctx-bin.
Which one should you choose?
- You want the bill to go down, on more than one AI agent: Tokenade.
- You want lean-ctx's compression without the configuration: squeez.
- Shell output is your only problem: rtk.
- Your sessions lose the thread after compaction: context-mode.
- You mainly used the code graph: codegraph.
- You want the proxy idea as a managed team service: edgee.
- You're staying on lean-ctx: reasonable if you enjoy tuning and work in large, shell-heavy repos. Measure with its own
lean-ctx benchmark report .and your provider's bill, not the estimate alone.
Tokenade is free and open source (MIT/Apache-2.0). Setup takes two commands; see the install guide.
FAQ
Is lean-ctx free?
The local engine is free to use. Its licence is mixed: the "Trust Core" is Apache-2.0, while some explicitly mapped v4 modules use commercial source-visible terms. The project lists community and commercial options on its pricing page.
Does lean-ctx save tokens?
It reduces what reaches the window on the paths it covers, and its README says the result depends on reach, session lifetime and provider pricing, down to break-even. On THOL's long sessions it changed session cost by +10.3%, within run-to-run noise: no measurable difference.
Is lean-ctx the same as rtk?
No. rtk filters shell output only. lean-ctx also has file read modes, a read cache, a code graph, session memory and an optional proxy. Its project publishes its own comparison with rtk on leanctx.com.
Does lean-ctx send data anywhere?
Context processing runs locally, per its README. Configured providers, proxy requests, update checks and enabled telemetry have their own network paths; lean-ctx telemetry status shows the setting and lean-ctx telemetry disable turns it off.
Can I run lean-ctx and Tokenade together?
Not usefully. Both compress shell output and file reads, so they would fight over the same bytes and make both counters unreadable. Pick one per layer.
See also:
- Tokenade vs lean-ctx — the two side by side, attribute by attribute
- rtk alternatives — the same question for shell filtering
- caveman alternatives — the same question for output style
- graphify alternatives — the same question for knowledge graphs
- Best Claude Code token optimizers — the full field, same methodology
- Token optimizer benchmark — the numbers behind this ranking
Cut your AI agent's token bill.
Ranked #1 on the Token-Harness Optimizer Leaderboard. Zero config.
Tokenade cuts the token bill of AI agents: one install, zero config, and it trims what your agent sends to the model.