LeanCTX Context Intelligence
A local context layer that controls, compresses, remembers, and measures what coding agents send to models.
- Source repo
- yvgude/lean-ctx
- Stars
- ★ 4k
- Last updated
- 1d ago v3.12.11
- FARS reviewed
- Nov 07, 2026 +9 new
- License
- Apache-2.0
- Primary language
- Rust
- FA score
- 69/100 · Some gaps
At a glance
- How it runs
- Works with
- Universal · cross-platformCodex · Claude Code · OpenAI API · Claude API
- Cost
- Free software; you pay for model usage
- Setup effort
- Low · running in minutes
- You'll need
- Typical use
- Developers who use Cursor, Claude Code, or Codex every day and frequently run git, test, and build commands can use hybrid mode to reduce repeated reads and noisy terminal output.
- Not a fit if
- Users in tiny repos who rarely call the shell from their AI tool
- Workflows that always need raw, unfiltered logs; --raw lowers the payoff
- Teams unwilling to change local agent config and install shell, MCP, hook, and daemon components
- Website
- leanctx.com ↗ set on GitHub
- Maintenance
- Commits in the last 30 dayslast commit 2026-12-02latest release v3.12.11 (2026-12-02)+1.0 ★/day over 7 days
- Source review
- 69/100 · Some gaps
What does this agent do, and when should you use it?
LeanCTX is a local-first context engineering layer for AI coding agents, delivered as a single Rust binary with an MCP server, shell hooks, an optional request proxy, session memory, a code graph, and a browser dashboard. It compresses repository reads, common development-command output, and—when the proxy is enabled—the requests sent to model providers, while retaining pruned material in content-addressed storage for recovery. Ten read modes and Tree-sitter support for 27 languages provide structural views, while a multi-edge property graph supports search, impact analysis, and related-file discovery. The product also records tokens, cost, accepted outcomes, and CPAO through Shadow Mode, an auditable savings ledger, context proofs, and reporting commands. It supports more than 30 coding agents and exposes Python, TypeScript/Node, and Rust SDK or client options; code, memory, and telemetry remain local by default unless the user enables an external capability.
On the read path, a coding agent reaches LeanCTX through ctx_* MCP tools or shell commands. lean-ctx read can return full, map, signatures, diff, lines:N-M, density:X, and other views, while shell hooks condense output from git, npm, cargo, docker, kubectl, terraform, and other recognized commands. Tree-sitter analysis, ModePredictor, and IntentEngine extract structure, select read depth, and classify task complexity; omitted bytes are stored under deterministic handles and can be recovered with ctx_expand, ctx_retrieve, or /v1/references/{id}. Session memory, a temporal knowledge graph, and a multi-edge property graph retain tasks, facts, decisions, and code relationships for cross-chat recall, hybrid search, and lean-ctx graph impact. On the optional wire path, lean-ctx proxy enable places a local proxy between the agent and OpenAI, Anthropic, or Gemini and compresses system prompts, history, and tool results. lean-ctx gain, savings, value-report, shadow, and the Context Manager dashboard produce token, dollar-cost, CPAO, quality, and baseline-comparison reports; ctx_proof and ctx_verify add four-layer verification and CI drift gates. Multi-agent work is supported through ctx_agent, ctx_handoff, shared state, portable .ctxpkg bundles, signed snapshots, and an addon gateway for upstream MCP servers.
- Developers who use Cursor, Claude Code, or Codex every day and frequently run git, test, and build commands can use hybrid mode to reduce repeated reads and noisy terminal output.
- Teams maintaining medium-to-large repositories or monorepos can use AST signatures, hybrid search, the property graph, and
graph impactto inspect APIs and estimate change blast radius. - Engineers carrying a refactor or investigation across multiple chats can persist tasks, facts, and decisions in local session memory and the knowledge graph.
- Organizations switching among OpenAI, Anthropic, and Gemini can retain a portable local cache and memory layer while enabling the request proxy only where appropriate.
- Engineering leads who need evidence of AI return on cost can inspect CPAO, the verified savings ledger, Shadow Mode comparisons, benchmarks, and live dashboards.
- Teams coordinating planner, developer, and reviewer agents can use
ctx_agent,ctx_handoff, diaries, shared state, and context-transfer bundles for deterministic handoffs.
Key setup facts
Pulled from the install and usage notes below. The project README has the current values.
- Install / run
curl -fsSL https://leanctx.com/install.sh | shnpm install -g lean-ctx-bincargo install lean-ctx
- Config files
~/.config/lean-ctx/config.toml- Install notes cover
- Windows · macOS
How do you install or deploy this agent?
Choose one documented installation route:
curl -fsSL https://leanctx.com/install.sh | sh
brew tap yvgude/lean-ctx && brew install lean-ctx
npm install -g lean-ctx-bin
cargo install lean-ctx
pi install npm:pi-lean-ctxThen configure a supported agent with one command, for example:
lean-ctx wrap cursor
lean-ctx wrap claude
lean-ctx wrap codex
lean-ctx wrap vscodewrap installs shell hooks, registers the MCP server, configures agent hooks, starts the daemon, and verifies the connection. lean-ctx onboard can connect all detected tools without prompts, while lean-ctx setup provides an interactive wizard. For a Windows source build, clone the repository and run ./install.ps1 in PowerShell; add -BuildOnly to avoid installation. No credential is documented for the basic local layer. Enabling model proxying, cloud sync, public-web ingestion, or external providers requires access to the corresponding network service.
How do you use this agent?
After wrapping the agent, run lean-ctx doctor to verify the integration. Initial working commands include:
lean-ctx read src/server.rs -m map
lean-ctx -c "git status"
lean-ctx overview
lean-ctx graph impact src/auth.rs
lean-ctx gain --live
lean-ctx dashboardRun lean-ctx proxy enable if every request sent to the model should pass through the local compression proxy. For baseline savings analysis, add [shadow] and enabled = true to ~/.config/lean-ctx/config.toml, use LeanCTX for a while, then run lean-ctx savings and lean-ctx shadow --latest. Application integrations can start lean-ctx serve and call /v1/tools/call or use lean-ctx-client. For message-array compression only, install lean-ctx-sdk and call Python's compress(messages, model="claude-sonnet-4") or TypeScript's compress(messages, { model: "gpt-4o" }).
Safety boundaries, hardening & integrations
Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.
Declared capability surface (blast radius)
Can run terminal commands; pair with approval gates or container/OS sandboxing.
Modifies local files; work on a clean Git branch or dedicated worktree.
Makes outbound requests; verify telemetry settings and model data routing on private repos.
Inherits capabilities of connected MCP servers; audit third-party servers before enabling.
FARS trust-control audit
- data-flow disclosure
What are this agent's strengths and limitations?
- One local Rust binary combines MCP reads, shell-output compression, an optional request proxy, memory, graph intelligence, and cost observability instead of requiring a separate product for each layer.
- Compression has explicit recovery paths: pruned content is moved into content-addressed storage and can be retrieved through tools, in-band handles, or an HTTP reference endpoint.
- More than 30 coding agents are documented, alongside standard MCP, an HTTP
/v1API, Python and TypeScript compression SDKs, and Python, TypeScript, and Rust clients. - Cost and quality measurement is unusually concrete: real-time token and dollar reporting, CPAO, Shadow Mode, an auditable event ledger, reproducible benchmark commands, and CI quality gates are all described.
- Telemetry is off by default, memory and caches are local and portable, and
.ctxpkgpackages plus signed snapshots reduce dependence on one model provider.
- The payoff depends on how much of the context window LeanCTX can reach, whether sessions are long-lived, and how the provider prices prompt caching; the documented matrix says unfavorable combinations may only break even.
- Users of tiny repositories, workflows with little shell activity, or processes that always require raw logs are explicitly described as poor fits;
--rawexists but reduces the benefit. - Full integration changes local agent configuration and installs shell, MCP, hook, and daemon components, which teams must assess against their existing development environment.
- Request proxying, cloud sync, public-web reads, addon installation, and model calls introduce network or third-party boundaries beyond the otherwise local-first workflow.
- Several team-scale capabilities remain roadmap items, including hosted
ctxpkg.comhistory, the broader unified context graph, and fuller OpenTelemetry or Prometheus export.
How does this agent compare with similar options?
The project positions LeanCTX as a layer spanning both the agent read path and the model request path, and names RTK, Context+, and MemGPT in its comparison documentation. It can also host tools such as Headroom, Sophon, Repomix, Serena, Mem0, Cognee, Letta, and Sequential Thinking as addons, then compress, archive, index, and mark their output as untrusted. Those products may therefore overlap with individual LeanCTX capabilities or operate behind its gateway; the supplied material does not provide enough comparative evidence to claim item-by-item superiority.
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| LeanCTX Context Intelligence This agent | 69 · Some gaps | CLIFree + model costs | ★ 4k | 1d ago | Rust | Codex · Claude Code · OpenAI API · Claude API |
| EGC — One Brain for Every AI Coding Agent | 76 · Good | CLIFree | ★ 71 | 4d ago | JavaScript | Codex · Claude Code |
| LLMSlim Context and Memory | 70 · Some gaps | MCP serverFree + model costs | ★ 27 | 1d ago | Python | Codex · Claude Code |
| Entroly | 75 · Good | CLIFree + model costs | ★ 491 | 1d ago | Python | Codex · Claude Code · OpenAI API · Claude API |
How does FollowAgents rate this agent?
Why each dimension lost points
The docs describe PathJail, shell allowlisting, role policies, and workspace trust gates, while noting that controls depend on integration and configuration and are not an OS sandbox (2). High-impact configuration changes are explicit, and runtime installation requires consent (2). Data paths among the proxy, host, and model, plus observability limits, are clearly described (3). Secret detection has stated coverage limits, and sampled code includes reads for sensitive file extensions, so handling is only partly supported (2). The sample contains no dependency inventory or vulnerability remediation evidence (1). Installation, updates, proxying, and addons can have external effects; several consequences and opt-in paths are described, but there is no complete effects inventory (2). Unwrap, uninstall, configuration recovery, and reversible security switches are documented, but rollback coverage for persistent memory, snapshots, and other writes is unclear (2). The repository and product are identifiable, but publisher identity is unverified and maintenance ownership is unclear (1).
The README, install guide, security docs, and integration matrix are broadly consistent on core boundaries, though the many capabilities and compatibility paths add complexity (2). The install guide states platform prerequisites, download and offline constraints; optional model and external service availability are partly documented (2). doctor, status, install checks, and several failure states are described, but coverage is not exhaustive (2).
Concrete scenarios cover coding, cross-session knowledge, code understanding, and integrations with entry points for each (3). The docs distinguish OSS, SDK, Enterprise, experimental features, host-owned model calls, and supported boundaries (3). Trigger descriptions point to MCP tools and integrations, though the skill also applies broadly to tasks needing a focused view (2). macOS, Linux, Windows, multiple editors, and MCP-only paths are covered; platform differences still require checking the installed host (2).
The README, references, integration matrix, install guides, and skills provide strong navigation (3). Installation, removal, diagnosis, platform requirements, and offline use are described concretely (3). LeanCTX, lean-ctx, SDK, and OSS are distinguished, though the interface and feature names are numerous (2). Scenario examples, commands, troubleshooting, and configuration guidance are substantial (3). The materials state limits around sandboxing, detection coverage, simulated baselines, experimental features, and provider observations (3). The supplied license metadata says Apache-2.0 and LICENSE shows Apache 2.0, but the README says Mixed and the sample refers to LICENSE.md and a license matrix; scope is only partly clear (1). The README links a changelog and the sample includes version-specific notes, but changelog contents are not supplied to assess maintenance cadence (2). The sample does not establish maintenance responsibility, and publisher identity is unknown (1).
The product offers inspectable context operations, policy records, and structured output, but its own docs limit proof to observed context operations rather than later host model calls (2). Selection, compression, controls, and local continuity have clear claimed value for coding workflows, but the sample lacks independent outcome evidence (2). Setup and maintenance involve several paths, configurations, and optional components; shadow cost reporting is simulated, so cost-benefit support is thin (1).
Many claims point to specific docs, commands, and source files, but the cited implementation files are not in this sample and cannot be checked here (2). The README, integration matrix, security guide, and install guide corroborate key boundaries, while some details appear in only one source (2). The materials clearly separate observed operations, estimates, experimental capabilities, and limitations—for example, simulated shadow baselines and the inability to observe later host model calls (3).
- This assessment uses only the supplied static sample; code was not executed and implementation was not independently verified. Recorded context evidence does not prove answer quality or subsequent model calls.
- Before installation, check the actual integration, configuration, and workspace trust settings. Secret detection does not cover every secret, and relaxing PathJail or shell restrictions widens access.
- The materials include both Apache-2.0 and Mixed license descriptions; verify the license scope of each component before use or redistribution.
Recent releases
Latest entries from the project's GitHub Releases. Notes are quoted from upstream as written, not rewritten or tested by FollowAgents.
-
Release notes excerpt
Upgrade notes - **The lean-ctx line in an existing CLAUDE.md or agent rules file changes on the next lean-ctx init or setup refresh (#2284).** Installs set up earlier keep the previous wording, which still calls shell output lossless, until then. Fixed - **Reading the full copy that a shortened shell output points to returns it whole (#2284).** A [lean-ctx: full original at …] marker said to cat the copy, yet the proxy shortened that cat again, so the full output could not be recovered without MCP. A plain cat, type or Get-Content of files in …View on GitHub ↗ -
Release notes excerpt
Upgrade notes - **lean-ctx config validate exits with 1 when the loader cannot read the config (gh-2283).** A known key with a value the loader rejects made lean-ctx run on defaults while validate reported success; it now names the value and fails, so scripts that ran validate on such a config see exit code 1. - Vault links now belong to the Cloud and account they were made on. After connecting to another Cloud, or to another account on the same Cloud, this computer no longer shows, syncs, uploads or reports …View on GitHub ↗ -
Release notes excerpt
Upgrade notes - Library crates for the new cloud status member. lean-ctx-protocol 0.10.0 adds user to CloudCliStatusV1 (a new public field, so code that builds the struct itself adds user: None). lean-ctx-ocla 10.0.0, lean-ctx-workgraph 0.6.0 and lean-ctx-tasks 0.5.0 follow because they depend on it. Added - cloud status --json names the linked account (rc3-9). A new user: {email} member carries the sign-in address the Cloud's instance card names, so LeanCTX Code shows "Signed in as …" without asking the Cloud again. It is read from the account …View on GitHub ↗
FAQ
Does local use cost money or send telemetry by default?
Can compression permanently hide code or logs?
ctx_expand, ctx_retrieve, in-band markers, and the HTTP reference endpoint. Teams should still validate that compressed views meet their diagnostic and audit requirements.Is it tied to one model provider or editor?
How can I bypass compression during a failure investigation?
lean-ctx -c --raw "git status" for one uncompressed command, lean-ctx-off to disable it in the current shell, and lean-ctx doctor --json to produce shareable diagnostics.Can it be removed cleanly?
lean-ctx uninstall --dry-run to preview changes, then lean-ctx uninstall to remove processes, hooks, editor configuration, rules, autostart entries, data, and the binary. Package-manager installations also require the matching brew, cargo, npm, or Pi uninstall command.Thanks — we use this to improve the page.
Subscribe to the FollowAgents RSS feed, or save this agent to your browser shortlist to compare on your next visit.