← all repositories
yvgude/lean-ctx

A Rust binary that puts your AI agent on a token diet

LeanCTX sits between your coding agent and your codebase to compress, cache, and govern every token the model sees.

lean-ctx
Velocity · 7d
+32
★ / day
Trend
accelerating
star history

What it does

LeanCTX is a local Rust binary that intercepts the context flowing between AI coding agents and your repository. It compresses file reads and shell output, caches repeated reads, persists session memory across chats, and offers a browser dashboard for token budgeting. The goal is to cut token waste—like shrinking a 2,000-token file read down to roughly 13 on a cache hit—without forcing you to reconfigure your existing tools.

The interesting bit

Instead of treating context as plain text, it builds a property graph of your code and uses Tree-sitter to serve structural summaries rather than raw source. An adaptive ModePredictor learns which fidelity a file needs, while shell output passes through 56 pattern modules that strip noise before the LLM ever sees it. It is essentially an operating system for context: routing, memory, and verification layers wrapped around a single binary.

Key highlights

  • 10 read modes ranging from full content to AST signatures and diff-only views
  • Session memory and a knowledge graph that survive across chat restarts
  • Real-time browser dashboard with token budgets, compression stats, and per-agent throttling
  • 67 MCP tools exposing search, refactoring, multi-agent handoff, and PR context packing
  • Local-first, opt-in telemetry only, with SHA-256 verification chains for savings claims

Verdict

Worth a look if you are burning through API tokens with Cursor, Claude Code, or Copilot and want visibility into where your context window goes. Skip it if you already run a tight, custom context pipeline or prefer your agents to ingest raw shell dumps and full file trees unfiltered.

Frequently asked

What is yvgude/lean-ctx?
LeanCTX sits between your coding agent and your codebase to compress, cache, and govern every token the model sees.
Is lean-ctx open source?
Yes — yvgude/lean-ctx is open source, released under the Apache-2.0 license.
What language is lean-ctx written in?
yvgude/lean-ctx is primarily written in Rust.
How popular is lean-ctx?
yvgude/lean-ctx has 3.4k stars on GitHub and is currently accelerating.
Where can I find lean-ctx?
yvgude/lean-ctx is on GitHub at https://github.com/yvgude/lean-ctx.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.