yvgude/lean-ctx

Control what your AI can see. LeanCTX (Lean Context) is the context intelligence layer for AI agents — one local Rust binary that decides what they read,...

View on GitHub ↗Jump to charts ↓Open shareable report

Summary Information

Updated 6 minutes ago
Added to GitGenius on August 2nd, 2026
Created on March 23rd, 2026
Open Issues & Pull Requests: 20 (+0)
GitHub issues: Enabled
Number of forks: 323
Total Stargazers: 3,543 (+1)
Total Subscribers: 22 (+0)

Issue Activity (beta)

Open issues: 20
New in 7 days: 33
Closed in 7 days: 18
Avg open age: 4 days
Stale 30+ days: 0
Stale 90+ days: 0

Recent activity

Opened in 7 days: 27
Closed in 7 days: 17
Comments in 7 days: 19
Events in 7 days: 114

Top labels

  • bug (482)
  • status: integrated (462)
  • enhancement (256)
  • priority: medium (221)
  • priority: high (190)
  • mcp (139)
  • cli (122)
  • proxy (98)

Repository Insights (GitGenius)

Median issue/PR response: 0.0 hours
Mean response time: 2.6 hours
90th percentile: 6.8 hours
Tracked items: 903

Most active contributors

Detailed Description

LeanCTX is a context intelligence layer for AI coding agents, implemented as a single local Rust binary that optimizes how AI models interact with codebases. The project addresses a fundamental problem in agentic coding: AI agents waste significant token budgets on redundant file reads, uncompressed command output, and context that resets between chat sessions. By running locally alongside coding agents like Cursor, Claude Code, Copilot, and 30+ other platforms, LeanCTX reduces token consumption by 60–90% while maintaining full context fidelity.

The core functionality spans four dimensions of context management. First, compression handles input efficiency through ten distinct read modes including full content, map-based structural views, AST signatures, diff views, line ranges, and density-based filtering that keeps only high-entropy content. File reads that would normally cost 2000 tokens drop to approximately 13 tokens on cached re-reads. Shell output compression handles 95+ patterns specific to tools like git, npm, cargo, docker, kubectl, and terraform, reducing raw git status output from 800 tokens to 120 tokens. The compression is reversible by design—pruned content moves to a content-addressed store, allowing models to request original bytes back through multiple recovery paths including in-band markers and API endpoints.

Second, routing ensures appropriate fidelity per file read. An adaptive mode predictor learns optimal read modes per file type from past sessions, while an intent engine classifies query complexity to keep simple lookups cheap. Third, memory persistence solves the problem of context resetting between chats. Session memory survives across conversations, structured recovery queries persist through compaction, and a knowledge graph tracks temporal facts with validity windows. A property graph maintains multi-edge code relationships including imports, calls, exports, and type references to power impact analysis and search ranking. Critically, all memory stays local and portable—users can export sessions as .ctxpkg packages and move them across machines or models without vendor lock-in.

Fourth, the system provides proof and visibility through a signed, verifiable savings ledger and real-time dashboard showing token and USD savings. Users gain full visibility into context window budget allocation and can set budget controls. The project is distributed across multiple package managers: crates.io for Rust, npm for Node.js, AUR for Arch Linux, and Pi.dev. It includes 76 MCP tools and integrates with 30+ agents without requiring configuration changes. The README emphasizes that LeanCTX operates on a local-first, model-agnostic principle—users can swap between OpenAI, Anthropic, and Gemini without losing context or cache, keeping the context moat portable rather than locked into a vendor's billing model. The project's philosophy centers on owning context as a managed resource rather than renting it back from the model provider, with telemetry opt-in only and security as an explicit design concern.

lean-ctx
by
yvgudeyvgude/lean-ctx

Repository Details

Fetching additional details & charts...