Repolode
yvgude

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. 1

    Install LeanCTX from a package manager listed in the README (npm, crates.io or AUR)

  2. 2

    Configure a supported AI tool integration

    lean-ctx setup
  3. 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