A model-driven harness that gives AI coding agents a model-first workflow: model the business, evaluate and repair it, generate a typed application, and verify the result.
yvgude/lean-ctx
Open-source Rust engine that filters and compresses the context AI coding tools read, with MCP server, shell hooks and local audit records.
- Stars
- 3,897
- Forks
- 356
- Open issues
- 10
- Last commit
- 13 hours ago
What is it?
LeanCTX is a context gateway for AI tools. It sits between an AI coding agent and the files, shell output and tool results the agent reads, selecting task-relevant content and reducing repeated or noisy input so less of the context window is spent on it.
The open-source Engine runs locally through a CLI, an MCP server, shell hooks and an optional request proxy. Supported read modes include full, map, signatures, diff and line-range views, and shell output from tools such as git, npm, cargo, docker and kubectl is compressed. Tree-sitter parsing covers 27 languages, and configured path permissions, content filters and context budgets apply on supported paths.
The project also keeps local session memory, a code property graph for impact analysis, and records of context operations that can be inspected with `lean-ctx inspect` or a browser dashboard. Setup is handled by `lean-ctx wrap` for supported agents such as Cursor, Claude Code and Codex.
Key features
- 01Multiple file read modes, including structural maps, signatures and line ranges, with cached re-reads returning compact references.
- 02Shell output compression for common tools such as git, npm, cargo, docker and kubectl.
- 03Tree-sitter structural parsing for 27 languages.
- 04Local session memory and a code property graph for impact analysis.
- 05Configured path permissions, content filters and context budgets on supported paths.
- 06Local CLI, MCP server and browser dashboard for inspecting context activity.
Use cases
- Reducing token use for an AI coding agent working in a large repository.
- Keeping shell-heavy agent sessions from filling the context window with build and test logs.
- Resuming long projects across chat sessions with retained task and decision records.
- Restricting an AI tool's filesystem access to a configured project scope.
Quick start
- 1
Install LeanCTX from a package manager listed in the README (npm, crates.io or AUR)
- 2
Configure a supported AI tool integration
lean-ctx setup - 3
Check local token savings after using it for a while
lean-ctx savings
Things to know
- The README states a mixed license, and the metadata lists Apache-2.0, so check LICENSE.md before commercial use.
- Several features such as multi-agent handoff, context packages, snapshots and addons are marked experimental Research.
- Shadow Mode savings are simulated estimates rather than measured results, and do not prove answer quality.
In collections
Topics
FAQ
- What is lean-ctx?
- Open-source Rust engine that filters and compresses the context AI coding tools read, with MCP server, shell hooks and local audit records. LeanCTX is a context gateway for AI tools. It sits between an AI coding agent and the files, shell output and tool results the agent reads, selecting task-relevant content and reducing repeated or noisy input so less of the context window is spent on it.
- Is lean-ctx free to use? What license does it have?
- lean-ctx is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is lean-ctx still maintained?
- Actively maintained. The last commit to lean-ctx was on Oct 24, 2026.
- What can I use lean-ctx for?
- Reducing token use for an AI coding agent working in a large repository. Keeping shell-heavy agent sessions from filling the context window with build and test logs. Resuming long projects across chat sessions with retained task and decision records. Restricting an AI tool's filesystem access to a configured project scope.
- How do I install lean-ctx?
- Install LeanCTX from a package manager listed in the README (npm, crates.io or AUR) Configure a supported AI tool integration: lean-ctx setup Check local token savings after using it for a while: lean-ctx savings
- Where can I get lean-ctx?
- The source code and installation instructions are on GitHub: https://github.com/yvgude/lean-ctx
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A coding agent built on pi that routes routine decisions, like permission checks and context pruning, to a small judge model so the main model can focus on code.
Open source AI coding agent that runs in VS Code, JetBrains IDEs, or the terminal, with access to 500+ models.
A local-first, evidence-first AI coding terminal that connects LLMs to real project files, tools, permissions, verification and context.
A Claude Code plugin with self-correcting memory, persistent FTS5 research wikis, and workflow skills, commands and hooks for AI coding agents.
A CLI that scans your codebase and generates compact AI context files (CLAUDE.md, .cursorrules, AGENTS.md) so coding assistants spend fewer tokens exploring the project.