Lean Ctx
Lean Ctx is an open-source context runtime for AI coding agents — up to 99% token savings with 63 MCP tools and 10 read modes.
Last verified:
What is Lean Ctx?
Lean Ctx (LeanCTX, lean-ctx) is an open-source context runtime for AI coding agents that sits transparently between your AI coding tool (Cursor, Claude Code, GitHub Copilot, Windsurf, Gemini CLI, and 24+ others) and the large language model. It compresses all context before it reaches the model, reducing token usage by 60-99%, cutting API costs, and making AI responses faster — a single Rust binary with zero config, working locally with no cloud dependencies. Key features include 63 MCP tools for intelligent context delivery, 90+ CLI compression patterns across 34 categories (git, docker, npm, cargo, kubectl, and more), AST-aware compression for 18 languages, 10 read modes (full, map, signatures, diff, aggressive, entropy, task, reference, lines, auto), session caching, a persistent project graph, cross-session memory via the Context Continuity Protocol, multi-agent coordination, and real-time token savings monitoring via a terminal dashboard. MIT + Apache-2.0 dual licensed with zero telemetry.
Lean Ctx pricing
Pricing model: Freemium
Fully free and open source under MIT + Apache-2.0 dual license. No paid plans. Single Rust binary available via npm (npm install -g lean-ctx-bin), cargo (cargo install lean-ctx), Homebrew (brew tap yvgude/lean-ctx && brew install lean-ctx), or direct download (curl -fsSL https://leanctx.com/install.sh | sh). Zero telemetry, everything runs locally with no cloud dependencies or account required. Active developers save $30-100+ per month on AI API costs.
Lean Ctx pros
- Reduces token usage by 60-99%
- Works with 29+ AI coding tools out of the box
- Single Rust binary with zero config required
- Open source under MIT + Apache-2.0 dual license
- Zero telemetry, everything runs locally
- 90+ CLI compression patterns across 34 categories
- 10 read modes for different compression needs
- AST parsing for 18 programming languages
- Cached re-reads cost only ~13 tokens
- Persistent project graph survives across sessions
- Cross-session memory via Context Continuity Protocol
- Real-time token savings dashboard with USD estimates
- Multi-agent context sharing and coordination
- PathJail sandbox for security by default
- Auto-detects and integrates with all major AI tools
- Compression is reversible - full content one call away
- Session cache auto-clears after 5 minutes inactivity
Lean Ctx cons
- Requires restarting shell and AI tool after setup
- Only supports local execution no cloud features in free tier
- Learning curve for all 63 MCP tools
- Some advanced features require manual config
- Binary file detection limits some use cases
- Output size cap may truncate very large results
- Cache may need manual invalidation in subagent workflows
- Limited to 11 languages for code execution
Frequently asked questions about Lean Ctx
What is LeanCTX?
LeanCTX is the Context Layer for AI development. It sits between your AI coding tool and your codebase, compressing file reads by 60-90%, persisting memory across sessions, and verifying all outputs before delivery. It works with 29+ AI tools including Cursor, Claude Code, and GitHub Copilot.
How much does LeanCTX save in token costs?
Active developers save $30-100+ per month on AI API costs. File reads are compressed by 60-90%, shell output by 60-90%, and cached re-reads cost only ~13 tokens. Use lean-ctx gain to measure your personal savings.
Does LeanCTX work with Cursor / Claude Code / Copilot?
Yes. LeanCTX supports 29+ AI coding tools out of the box. Run lean-ctx setup and it auto-detects and configures all installed editors. It supports two integration modes: Hybrid (MCP + shell hooks) and Full MCP.
Is LeanCTX free and open source?
Yes. LeanCTX is fully open source under MIT + Apache-2.0 dual license. Zero telemetry, everything runs locally. The single Rust binary is available via npm, cargo, or direct download.
What is the Context Layer?
The Context Layer is lean-ctx's architecture for managing the full AI context lifecycle. It sits between your code and the AI: deciding what to read, how to compress it, what to remember, and how to verify results.
How do I install LeanCTX?
Install in 60 seconds using one of these methods: curl -fsSL https://leanctx.com/install.sh | sh (universal, no Rust needed), brew tap yvgude/lean-ctx && brew install lean-ctx (macOS/Linux), npm install -g lean-ctx-bin (Node.js), or cargo install lean-ctx (Rust). Then run lean-ctx setup for guided onboarding.
What are the 10 read modes?
The 10 read modes are: full (default, entire file with headers), map (dependency graph + exports + signatures, 85-95% savings), signatures (AST extraction, 83-96% savings), diff (only changed lines, 70-95% savings), aggressive (stripped comments/whitespace, 20-40% savings), entropy (Shannon filtering + dedup, 60-85% savings), task (task-filtered with graph context), reference (ultra-compact pointer), lines:N-M (specific line ranges), and auto (auto-selects best mode).
How does session caching work?
Session caching means files are only transmitted once. On re-read, lean-ctx returns a 13-token cache hit instead of the full file content. The cache auto-clears after 5 minutes of inactivity. Use ctx_cache to manage cache (clear, invalidate, status) or fresh=true to bypass cache for a single read.
What CLI commands are compressed?
LeanCTX compresses 90+ patterns across 34 categories including: git (19 commands, 70-95% savings), docker (10 commands, 70-90%), npm/pnpm/yarn (6 commands, 70-90%), cargo (3 commands, 80%), GitHub CLI (9 commands, 60-80%), kubectl (9 commands, 60-85%), Python/pip/ruff (60-80%), test runners like jest/vitest/pytest (90%), and many more including Terraform, Maven, .NET, Flutter, AWS, and databases.
Is LeanCTX secure?
Yes, security is default. Features include PathJail sandbox (paths must resolve inside project root, blocking ../ traversal and symlink attacks), size caps (5MB max read, 1MB max shell output), TOCTOU mitigation, prompt injection hardening, file-write blocking in shell commands, command size limit (8KB max), and binary file detection for 100+ extensions.