yvgude/lean-ctx
LeanCTX — Context Intelligence for AI systems.
What it solves
LeanCTX is an AI Value Gate and context engineering layer designed to reduce token waste and API costs for AI coding agents. It prevents the common issue of agents repeatedly sending unchanged file content or noisy shell output to the model, which consumes the context window and increases expenses.
How it works
LeanCTX operates on two planes to optimize the flow of information:
- Read Path: It acts as an MCP server and shell hook, providing specialized read modes (such as AST signatures or entropy-filtered views) and compressing common CLI output (e.g., git, npm, docker) before the agent sees it.
- Wire Path: An optional local proxy sits between the agent and the model provider, compressing every request—including system prompts and history—while remaining prompt-cache-safe.
It uses a Tree-sitter AST for structural understanding of 27 languages and a property graph for code analysis. All compression is reversible; pruned content is stored in a content-addressed store that the model can retrieve on demand.
Who it’s for
Developers using AI coding agents like Cursor, Claude Code, Copilot, Windsurf, and Gemini who want to lower their API bills, extend their useful coding session lengths, and maintain local ownership of their project's context and memory.
Highlights
- Context Compression: Offers 10 read modes and 95+ shell-output patterns to reduce token usage without losing data.
- Session Memory: Persists facts and decisions across different chat sessions to avoid "cold starts."
- AI Value Gate: Provides a real-time dashboard to track token usage, USD savings, and the "Cost per Accepted Outcome" (CPAO) metric.
- Model-Agnostic: Works across different LLM providers (OpenAI, Anthropic, Gemini) without locking context into a vendor's black box.
- Portable Context: Allows exporting knowledge and session data as
.ctxpkgfiles. - CPAO Tracking: Uses "Shadow Mode" to compare LeanCTX's optimized context against a baseline to prove actual savings.
Related
- Project
- Project
- Project
- Project
- Project