
LeanCTX
Open SourceReduces token costs for Claude, Cursor & Copilot by up to 99%
AI Summary
LeanCTX is an open-source tool that sits between AI coding tools and LLMs and intelligently compresses the sent context. Through AST parsing, shell output optimization, and specialized protocols, 60-99% of tokens are saved without information loss. The tool works transparently in the background and requires no configuration.

✓ Pros
- +Open source and MIT licensed, all data remains local
- +Zero-config installation works with 34+ AI tools out-of-the-box
- +Massive token and cost savings (60-99%) while maintaining code quality
- +Intelligent protocols (CEP, CCP, TDD) additionally optimize AI communication
✗ Cons
- −Requires Rust installation and basic technical understanding for setup
- −Still in active development, beta status for some features like LeanCTL
Use Cases
- →Automatic compression of file reads in Cursor, Claude Code and other AI IDEs
- →Reduction of shell command output for git, npm, docker and kubectl by up to 99%
- →Session caching for repeated file reads with minimal token costs
- →AST-based code analysis to extract only relevant signatures and types
Who is it for?
Developers who regularly use AI coding tools like Cursor, Claude Code or GitHub Copilot and want to drastically reduce their token costs.
Tags
What is LeanCTX?
LeanCTX is an open-source proxy that sits between AI coding tools and the underlying language models. The approach is technically direct: before context is sent to Claude, Cursor, or Copilot, LeanCTX compresses it. Depending on the situation, this reduces token volume by 60 to 99 percent without losing code-relevant information. The tool runs locally, and all data stays on the user's own machine. The license is MIT.
Core features
- AST-based code compression: Instead of complete files, LeanCTX extracts only signatures, types, and relevant structures. This significantly reduces token consumption on file reads.
- Shell output optimization: Output from Git, npm, Docker, and kubectl is filtered and compressed. For verbose commands like
docker buildornpm install, savings of up to 99 percent are possible. - Session caching: After the first pass, repeated reads of the same files cost minimal tokens, because LeanCTX returns cached versions.
- Specialized communication protocols: CEP, CCP, and TDD optimize how context is passed to the model. This goes beyond pure compression.
- Zero-config compatibility: The tool works out of the box with more than 34 AI tools, with no manual configuration required.
Who is LeanCTX for?
Primarily for developers who use AI coding tools daily and whose API costs are climbing noticeably. Anyone working through a large codebase with Claude Code or Cursor and regularly loading many files into context will notice the difference quickly. Some features, including LeanCTL, are still in beta. Anyone who needs stable production conditions should factor that in. Rust is required for setup. Without basic experience with Rust toolchains, installation can be the first stumbling block.
Context & alternatives
LeanCTX occupies a niche that has seen few dedicated tools so far: the transparent proxy layer between IDE and model. Developers looking to reduce token costs typically fall back on manual techniques such as selective file scoping, custom prompt templates, or context-limiting IDE settings. All of that requires active effort from the developer. LeanCTX automates this step. Direct alternatives with a comparable approach are barely documented publicly. Anyone who wants to tackle token efficiency systematically beyond prompt discipline, and has no issue with Rust dependencies, gets a tool that handles exactly this problem in the background.




