Control what
your AI can see.
One 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 signs the proof.
60–90% fewer tokens. And that's just the receipt.
Open source · Local-first · Zero telemetry · One Rust binary · 30+ AI tools
A 2,000-token file. Re-read for 13.
curl -fsSL https://leanctx.com/install.sh | sh Reads less. Remembers more. Proves it.
Four things change the moment LeanCTX sits between your agents and your code, shell and data.
Compression makes context smaller. Intelligence makes it right. Five subsystems do the work; compression is one of them.
The agentic era has a context problem.
Every developer runs coding agents. Token spend is a top-3 engineering cost.
Fleets: 5–10 agents per developer (background, CI, review) talking to each other.
Agents in every department. Regulated, audited, budgeted.
More context makes models worse.
Context-rot research shows accuracy falling from 98% to 64% as noise fills the window. Trim the noise and accuracy climbs back. Cheaper is the side effect.
Every provider earns per token.
The layer that minimizes tokens can't come from the people who sell them. It has to sit on your side. This one does.
Stop feeding your agents noise.
Code, shell output, search results, web pages, documents: whatever your agents take in, LeanCTX turns into compact, model-ready context. Each kind gets its own strategy.
Never a dead end. Every original stays locally retrievable, one
ctx_retrieve away. LeanCTX tells your AI exactly when to ask for it.
Watch it decide.
The same file. Three intents. Three different views: exploring gets a map, API work gets signatures, editing gets full code. You don't pick the mode. The intelligence does.
import { verify, sign } from 'jsonwebtoken';
import { Redis } from 'ioredis';
const redis = new Redis(process.env.REDIS_URL);
const JWT_SECRET = process.env.JWT_SECRET!;
export async function authenticate(token: string) {
const payload = verify(token, JWT_SECRET);
const session = await redis.get(`session:${payload.sub}`);
if (!session) throw new Error('Session expired');
return JSON.parse(session);
}
export function refreshSession(userId: string) {
return sign({ sub: userId }, JWT_SECRET, { expiresIn: '1h' });
} exports: authenticate(token), refreshSession(userId)
deps: jsonwebtoken, ioredis
types: string → Promise<object>, string → string
lines: 17 size: 4,200 → 180 tokens
cached: 13 tokens on re-read Same model. Fraction of the tokens.
Measured on real repo operations, reproducible end to end. Don't trust our numbers: run lean-ctx benchmark report . on your own repo.
Compression modes: tokens vs. information
Where the savings come from
Provable savings.
Every saving lands in an Ed25519-signed, hash-chained ledger on your machine. Export it for your CFO, or verify it against us.
How the ledger worksBuilt for every agent. Including yours.
30+ AI tools
Cursor, Claude Code, Codex, Copilot, Windsurf, Cline and more. Auto-detected, zero config per tool.
Any language
Embed it in your own agent via lean-ctx serve: a versioned /v1 API with Python, TypeScript and Rust SDKs.
Any domain
Context personas reshape the layer for coding, research, support or data analysis. Or define your own.
Any data
Universal intake: code, HTML, PDF, CSV, email, RSS, even YouTube transcripts, compressed into facts and quotes.
IDE & Editor
CLI Agent
Platform
Local by default. Provable by design.
Everything runs on your machine. PathJail confines file access, the shell allowlist blocks dangerous commands, secrets are redacted before they reach the model. The audit trail records it all.
What are you building?
Six ways teams put context intelligence to work. Pick yours.
Questions, answered.
What is LeanCTX?
LeanCTX (short for Lean Context) is the open-source context intelligence layer for AI agents. One local Rust binary decides what your agents read, remembers what they learn, guards what they touch, and proves what they save in a signed ledger. It works with 30+ AI coding tools (Cursor, Claude Code, OpenAI Codex, GitHub Copilot and any MCP-capable client) and embeds in any agent via a versioned /v1 API.
Does compressing context hurt answer quality?
No. It usually improves it. Context-rot research shows model accuracy falling from 98% to 64% as windows fill with noise. LeanCTX removes redundancy while preserving meaning: AST-aware maps keep signatures and structure, shell patterns keep errors and results. Nothing is lost, either. Every original stays locally retrievable via ctx_retrieve.
How do I install it?
One command, then one setup. Install via the script, Homebrew, npm, or cargo and run `lean-ctx setup`. LeanCTX auto-detects your editors and wires up the right hooks and MCP server for each. Upgrades are a single `lean-ctx update`.
Is any of my code or data sent to a server?
No. Compression, caching, the savings ledger, and project memory all run locally on your machine; nothing is uploaded. The only network features (the Wrapped share card and the public leaderboard) are strictly opt-in and publish just an anonymous, whitelisted aggregate: a token count and a display name you choose.
Which AI tools does it work with?
30+ and growing: Cursor, Claude Code, OpenAI Codex, GitHub Copilot, Zed, Windsurf, Cline, Roo Code, Gemini CLI, OpenCode, JetBrains IDEs, and any MCP-capable client. Run lean-ctx setup once and every installed tool is auto-detected and configured.
What does LeanCTX stand for?
Lean Context. The name describes the job: lean, precise context for AI agents instead of raw, noisy input. LeanCTX is the brand and project name; lean-ctx is the binary, the package and the CLI command. (Not "Lean Cortex", a misspelling that appeared in early coverage.)
How is LeanCTX different from compression tools like Headroom?
Compression tools shrink what your agent has already read. LeanCTX works one layer deeper, at the source: it decides what gets read in the first place (10 read modes, ~13-token cached re-reads), remembers knowledge across sessions, guards file and shell access, and signs every saving in a verifiable ledger. Compression is one of its five subsystems. And it's fully reversible: every original stays one ctx_retrieve away.
LeanCTX (short for Lean Context) is the open-source context intelligence layer for AI agents. One local Rust binary decides what agents read (10 read modes, 60–90% fewer tokens, ~13-token cached re-reads), remembers what they learn (persistent sessions, knowledge graph), guards what they touch (PathJail, secret redaction, budgets, injection detection) and proves what they save (Ed25519-signed ledger, reproducible benchmark). Compression is one of five subsystems, and every original stays locally retrievable. Works with 30+ AI coding tools via MCP and shell hooks; embeds in any agent via a versioned /v1 API with Python, TypeScript and Rust SDKs. Local use is free forever, enforced by CI.
Read the full storyTake back control of your context.
Start by saving tokens. Stay because everything your agents learn, touch and save is finally under your control. Free for local use, forever. A CI gate makes sure it stays that way.