A community-driven registry for Claude, Cursor, Windsurf, Cline & more. Not affiliated with Anthropic.
Are you the author? Sign in to claim
Control what your AI can see. LeanCTX (Lean Context) is the context intelligence layer for AI agents — one local Rust bi
██╗ ███████╗ █████╗ ███╗ ██╗ ██████╗████████╗██╗ ██╗ ██║ ██╔════╝██╔══██╗████╗ ██║ ██╔════╝╚══██╔══╝╚██╗██╔╝ ██║ █████╗ ███████║██╔██╗ ██║ ██║ ██║ ╚███╔╝ ██║ ██╔══╝ ██╔══██║██║╚██╗██║ ██║ ██║ ██╔██╗ ███████╗███████╗██║ ██║██║ ╚████║ ╚██████╗ ██║ ██╔╝ ██╗ ╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
LeanCTX — Lean Context Intelligence for AI agents
LeanCTX — short for Lean Context — is the context intelligence layer for AI agents. It runs as a single local binary between your agents and your code, shell and data: it decides what they read, remembers what they learn, guards what they touch — and proves what they save with a signed, verifiable savings ledger. The result: 60–90% fewer tokens — and that's the receipt, not the product. Zero config required. Local-first.
| Problem | With LeanCTX |
|---|---|
| Repeated file reads: ~2000 tokens each | Cached re-reads: ~13 tokens |
Raw git status: ~800 tokens | Compressed: ~120 tokens |
| Context resets every chat | Session memory persists across chats |
| No visibility into context usage | Real-time dashboard + budget control |
Website · Docs · Install · Scenarios · Demo · Benchmarks · Cookbook · Security · Changelog
Control what your AI can see. LeanCTX — short for Lean Context — is the context intelligence layer for AI agents: one local Rust binary that decides what your agents read, remembers what they learn, guards what they touch — and proves what they save.
Token savings are the receipt. Intelligence is the product. Works with Cursor, Claude Code, Copilot, Windsurf, Codex, Gemini and 30+ other agents — no config needed.
See it in action:
Read + Shell Map-mode reads + compressed CLI output |
Gain (live) Tokens + USD savings in real time |
Benchmark proof Measure compression by language + mode |
All GIFs are generated from reproducible VHS tapes in demo/.
lean-ctx setup command, no config changes neededSaves you tokens? Give it a star — it helps others discover LeanCTX.
LeanCTX treats context as a managed resource, not an afterthought. One binary covers the four dimensions that decide how well an AI agent actually performs:
Your AI agent reads files and runs commands. LeanCTX compresses both automatically.
full, map, signatures, diff, lines:N-M, density:X, …) — cached re-reads cost ~13 tokensdensity:0.4): SDE-style budget compression — keeps the highest-entropy lines until ~40% of the original tokens remain, deterministicsignatures carries line spans and points at lines:N-M for targeted expansion — outline first, bodies on demandNot every file needs the same depth. LeanCTX sends the signal, not the noise.
ModePredictor: learns the optimal read mode per file type from past sessionsIntentEngine: classifies query complexity so simple lookups stay cheapContext doesn't disappear between chats anymore.
Performance is accuracy, not just speed. You stay in control of the window.
ctx_proof, ctx_verify): 4-layer verification engine with CI drift gatesctx_url_read): pull a public web page, PDF, or YouTube transcript into context as compressed, citation-backed text — facts/quotes return claims with a confidence score + source URL, relevance-ranked research-compression distils to a token budget, SSRF-guarded (http/https only)ctx_refactor): language-server-powered rename, references, go-to-definition via rust-analyzer, typescript-language-server, pylsp, goplsctx_agent, ctx_handoff): agent handoff with context transfer bundles, diary system, synchronized shared statectx_expand search_all): FTS5-powered cross-archive search over all previously archived tool outputslean-ctx pack --pr builds a PR-ready context pack (changed files, related tests, impact, artifacts)lean-ctx pack create bundles Knowledge + Graph + Session into portable .ctxpkg files with SHA-256 integritylean-ctx gain --live for real-time savings, lean-ctx wrapped for weekly/monthly summaries (gain --svg/--share for a shareable card or self-hostable page), lean-ctx watch for TUI monitoringlean-ctx savings is an auditable, per-event ledger (tokenizer transparency, bounce-netting, tamper-evident SHA-256 chain) — local-only, on by defaultlean-ctx serve for Streamable HTTP MCP + /v1/tools/call (used by the Cookbook + SDK)LeanCTX is growing from a single context layer into a full cognitive context layer for whole teams: version-controlled context strategy, one unified graph, and a governance layer across many agents.
The full roadmap lives in VISION.md.
AI tool → (MCP tools + shell commands) → lean-ctx → your repo + CLI
ctx_* tools (read modes, caching, deltas, search, memory, multi-agent)# 1) Install (pick one)
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
cargo install lean-ctx # Rust
pi install npm:pi-lean-ctx # Pi Coding Agent
# 2) Connect your AI tools (zero prompts, sensible defaults)
lean-ctx onboard # or: lean-ctx setup (guided, full control)
# 3) Verify
lean-ctx doctor
# 4) Restart your shell + AI tool, use it normally, then see the payoff
lean-ctx gain # savings appear after your AI's first lean-ctx call
After onboarding, restart your shell and your editor/AI tool once so the MCP + hooks are active. lean-ctx gain is empty until your AI tool makes its first lean-ctx call — that's expected, not a misconfiguration.
lean-ctx-offlean-ctx -c --raw "git status"shell_activation = "agents-only" in ~/.config/lean-ctx/config.toml.lean-ctx.toml in your project root (auto-merged with global config)/workspace: create .lean-ctx-id with a unique name to prevent context collisionslean-ctx updatelean-ctx doctor --jsonLeanCTX grows with you. Below are the journeys most people actually take — each links to a complete, function-by-function walkthrough in the Reference (every CLI command and all 76 MCP tools are documented there).
🟢 Your first 60 seconds"I just installed it — now what?" hljs language-bash One command auto-detects Cursor/Claude/Codex/… and configures MCP + hooks. → Journey 1 — Setup & Onboarding |
📖 Coding every day"Stop re-reading the same files." hljs language-bash Your agent reads less and searches smarter — automatically. → Journey 2 — Daily Use |
🧠 Resume where you left off"My new chat forgot everything." hljs language-bash Session memory + a project knowledge graph persist across chats. → Journey 3 — Memory & Knowledge |
🗺️ Understand a new codebase"Where does this function ripple to?" hljs language-bash A multi-edge property graph powers impact analysis + ranked search. → Journey 4 — Code Intelligence |
🔌 Wire in proxy, providers, plugins"Pull in GitHub issues and our Postgres schema." hljs language-bash External data flows through the same consolidation pipeline. → Journey 5 — Advanced & Integrations |
🛠️ Keep it healthy"Update, fix, or cleanly remove." hljs language-bash Self-healing diagnostics; surgical uninstall that only removes its own blocks. → Journey 6 — Lifecycle & Troubleshooting |
🎛️ Take control of the window"Budget my context like a pro." hljs language-bash Phi-scored planning + knapsack compilation + a context ledger. → Journey 7 — Context Engineering |
🤝 Run a team of agents"Planner + coder + reviewer on one repo." hljs language-text Shared message bus, diaries, knowledge, and deterministic handoffs. → Journey 8 — Multi-Agent Collaboration |
🏢 Share across a team / CI"One shared index, headless in pipelines." hljs language-bash Scoped tokens, optional cloud sync, verifiable context gates. → Journey 9 — Team, Cloud & CI |
🎚️ Tune & govern"Make it behave exactly how we want." hljs language-bash Compression levels, tool profiles, themes, and rules governance. → Journey 10 — Customization & Governance |
📊 Prove the payoff"Show me the numbers." hljs language-bash All analytics live in the CLI/dashboard — never burning agent tokens. → Journey 11 — Analytics & Insights |
📚 The full reference"I want to read everything." Every command and all 76 MCP tools, organized as user journeys, plus appendices for the CLI map, MCP tools, and paths & config. → Reference index |
LeanCTX is a standard MCP server, so it works with any MCP-compatible client. Two integration modes are auto-selected per agent:
| Mode | How it works | Best for |
|---|---|---|
| Hybrid | MCP for cached reads (~13 tokens) + shell hooks for command compression | Agents with shell access (Cursor, Claude Code, Codex, ...) |
| MCP | All 76 tools via MCP protocol, no shell hooks | Protocol-only agents (JetBrains, VS Code, Zed, ...) |
| Agent | Hybrid | MCP | Setup |
|---|---|---|---|
| Cursor | ● | lean-ctx init --agent cursor | |
| Claude Code | ● | lean-ctx init --agent claude | |
| CodeBuddy | ● | lean-ctx init --agent codebuddy | |
| Augment CLI / VS Code | ● | lean-ctx init --agent augment | |
| Codex CLI | ● | lean-ctx init --agent codex | |
| Gemini CLI | ● | lean-ctx init --agent gemini | |
| Windsurf | ● | lean-ctx init --agent windsurf | |
| GitHub Copilot | ● | lean-ctx init --agent copilot | |
| CRUSH | ● | lean-ctx init --agent crush | |
| Hermes | ● | lean-ctx init --agent hermes | |
| OpenCode | ● | lean-ctx init --agent opencode | |
| Pi | ● | lean-ctx init --agent pi | |
| Qoder | ● | lean-ctx init --agent qoder | |
| Amp | ● | lean-ctx init --agent amp | |
| Cline | ● | lean-ctx init --agent cline | |
| Roo Code | ● | lean-ctx init --agent roo | |
| Kiro | ● | lean-ctx init --agent kiro | |
| Antigravity | ● | lean-ctx init --agent antigravity | |
| Amazon Q | ● | lean-ctx init --agent amazonq | |
| Qwen | ● | lean-ctx init --agent qwen | |
| Trae | ● | lean-ctx init --agent trae | |
| Verdent | ● | lean-ctx init --agent verdent | |
| Aider | ● | lean-ctx init --agent aider | |
| Continue | ● | lean-ctx init --agent continue | |
| JetBrains IDEs | ● | lean-ctx init --agent jetbrains | |
| QoderWork | ● | lean-ctx init --agent qoderwork | |
| VS Code | ● | lean-ctx init --agent vscode | |
| Zed | ● | lean-ctx init --agent zed | |
| Neovim | ● | lean-ctx init --agent neovim | |
| Emacs | ● | lean-ctx init --agent emacs | |
| Sublime Text | ● | lean-ctx init --agent sublime |
Any MCP-compatible client works out of the box — the table above shows agents with first-class auto-setup.
Great fit if you...
Skip it if you...
--raw, but ROI is lower)Try these in any repo:
lean-ctx read rust/src/server/mod.rs -m map
lean-ctx -c "git log -n 5 --oneline"
lean-ctx gain --live
lean-ctx dashboard # Context Manager (browser)
lean-ctx watch # TUI monitor
lean-ctx benchmark report .
demo/vhs demo/leanctx.tape
vhs demo/gain.tape
vhs demo/benchmark.tape
lean-ctx benchmark report .
update_check_disabled = true or LEAN_CTX_NO_UPDATE_CHECK=1)See SECURITY.md.
One command removes everything — it stops all processes, then deletes hooks, editor configs, rules, autostart (LaunchAgent/systemd), the data dir, and the binary itself:
lean-ctx uninstall # full clean removal
lean-ctx uninstall --dry-run # preview every change, write nothing
lean-ctx uninstall --keep-config # keep MCP configs + rules (for reinstall)
lean-ctx-off # or just disable for the current shell session
No binary on PATH (or you used the curl installer)? Run the same removal from the installer:
curl -fsSL https://leanctx.com/install.sh | sh -s -- --uninstall
If you installed via a package manager, uninstall removes everything it wrote and
tells you the one command to finish removing the binary:
brew uninstall lean-ctx # Homebrew
cargo uninstall lean-ctx # cargo install
npm uninstall -g lean-ctx-bin # npm
pi uninstall npm:pi-lean-ctx # Pi Coding Agent
Start with CONTRIBUTING.md. Easy first PR: propose a new CLI compression pattern via the issue template.
Apache License 2.0 — see LICENSE.
A Jetbrains IDE IntelliJ plugin aimed to provide coding agents the ability to leverage intelliJ's indexing of the codeba
Run Claude Code as an MCP server so any agent can delegate coding tasks to it
mcp-language-server gives MCP enabled clients access semantic tools like get definition, references, rename, and diagnos