Lean Cortex

The Cognitive Context Layer for Agentic Systems.

LeanCTX helps AI agents perceive, compress, remember, and route context. Less noise, better signal. One binary, zero config, open source.

- installs
- GitHub stars
61 AI tools supported
[x] [-] [o] lean-ctx session
$ lean-ctx read src/lib/auth.ts -m map
exports: authenticate(), validateToken(), refreshSession()
4,200 → 180 tokens (96% saved)
cached: 13 tokens on re-read
$ lean-ctx grep "authenticate" src/
3 matches in 0.8ms
auth.ts:14, middleware.ts:8, routes.ts:23
$ lean-ctx -c "cargo build --release"
Compiling lean-ctx v3.6.8 in 3.2s
compressed: 847 → 42 tokens
curl -fsSL https://leanctx.com/install.sh | sh
The Problem

You can't optimize what you can't see.

Every file read, every shell command, every search result — your AI sends it all to the model without filtering. You have no visibility into what's eating your context window. The result? Wasted tokens, lost focus, and decisions based on noise.

"Compression saves tokens. But knowing what's in your context — that's what changes the output."

Without lean-ctx
AI reads 800-line file
→ Thousands of tokens sent to LLM
Includes comments, whitespace, imports
→ Slow, expensive, hits context limits
With lean-ctx
AI reads 800-line file
→ lean-ctx compresses via AST parsing
Keeps types, signatures, logic
→ 60–90% fewer tokens, same signal
See It In Action

What it looks like in your terminal.

lean-ctx works silently behind the scenes. When your AI reads a file, the context layer transparently compresses, routes, and optimizes the output. Here's a real ctx_read call and the metrics dashboard.

[x] [-] [o] ctx_read - map
AI calls: ctx_read({ path: "src/lib/mcpManifest.ts", mode: "map" })
schema_version 1
tools.granular 61
tools.unified 5
read_modes 10
modes: auto, full, map, signatures, diff, aggressive
Real-time context visibility — see every file, token count, and rule cost as it happens
60–99% typical token reduction per file read. Real-time visibility into every token. Up to 99% on cached re-reads. See methodology
61 context intelligence tools — compression, visibility, memory, control, and multi-agent support
0 configuration required — install and go. Auto-adapts to your IDE.
Compatibility

Works with every major AI coding tool.

Cursor, Claude Code, GitHub Copilot, Windsurf, Pi, Neovim, Sublime Text, Emacs, Codex — lean-ctx integrates with all of them. Zero vendor lock-in, zero configuration per tool. Install once, benefit everywhere.

AiderAmazon QAmpAntigravityAWS KiroClaude CodeClineContinueCursorEmacsGemini CLIGitHub CopilotJetBrainsNeovimOpenAI CodexOpenCodePiQwen CodeRoo CodeSublime TextTraeVerdentWindsurfZed
FAQ

Frequently Asked Questions

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 up to 99%, 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-99%, 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. Learn more on the Architecture page.

Stop guessing. Start seeing what's in your context.

One Rust binary. No cloud. No account. MIT + Apache-2.0 licensed. Install in 60 seconds — see what's in your context, then optimize it.