yvgude/lean-ctx
Control what your AI can see. LeanCTX (Lean Context) is the context intelligence layer for AI agents — one local Rust binary that decides what they read, remembers what they learn, guards what they touch, and proves what they save. 60–90% fewer tokens as the receipt. 76 MCP tools, 30+ agents, local-first.
What it solves
AI agents often suffer from context bloat, where repeated file reads, verbose shell outputs, and long chat histories consume massive amounts of tokens, increasing costs and reducing reasoning space. LeanCTX addresses this by managing the information passed to the model, reducing token usage by 60–90%.
How it works
LeanCTX acts as a local binary layer between the AI agent and its environment (code, shell, and data). It operates on two planes:
- Read Path: It uses various modes (like AST signatures or entropy-filtered views) to decide exactly what information to extract from files and shell commands.
- Wire Path: It acts as a local proxy that compresses system prompts, history, and tool results in a way that remains compatible with model provider prompt caching.
- Memory & Graph: It uses a property graph and session memory to persist knowledge across different chat sessions locally.
Who it’s for
Developers using AI coding agents (such as Cursor, Claude Code, Copilot, or Windsurf) who want to reduce API costs, extend useful coding sessions by saving context space, and maintain local, portable ownership of their agent's memory.
Highlights
- Token Reduction: Achieves 60–90% savings on reads and shell outputs.
- Local-First Memory: Persists task facts and decisions across chats via a local knowledge graph.
- Reversible Compression: Uses content-addressed storage so pruned data can be retrieved on demand.
- Model-Agnostic: Works with OpenAI, Anthropic, and Gemini without locking context to a specific vendor.
- Observability: Includes a dashboard for real-time token tracking and budget control.