$git clone https://github.com/yvgude/lean-ctx<pre> ██╗ ███████╗ █████╗ ███╗ ██╗ ██████╗████████╗██╗ ██╗ ██║ ██╔════╝██╔══██╗████╗ ██║ ██╔════╝╚══██╔══╝╚██╗██╔╝ ██║ █████╗ ███████║██╔██╗ ██║ ██║ ██║ ╚███╔╝ ██║ ██╔══╝ ██╔══██║██║╚██╗██║ ██║ ██║ ██╔██╗ ███████╗███████╗██
| 1 | <div align="center"> |
| 2 | |
| 3 | <pre> |
| 4 | ██╗ ███████╗ █████╗ ███╗ ██╗ ██████╗████████╗██╗ ██╗ |
| 5 | ██║ ██╔════╝██╔══██╗████╗ ██║ ██╔════╝╚══██╔══╝╚██╗██╔╝ |
| 6 | ██║ █████╗ ███████║██╔██╗ ██║ ██║ ██║ ╚███╔╝ |
| 7 | ██║ ██╔══╝ ██╔══██║██║╚██╗██║ ██║ ██║ ██╔██╗ |
| 8 | ███████╗███████╗██║ ██║██║ ╚████║ ╚██████╗ ██║ ██╔╝ ██╗ |
| 9 | ╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ |
| 10 | </pre> |
| 11 | |
| 12 | ### **Control what your AI can see.** |
| 13 | |
| 14 | **LeanCTX — Lean Context Engineering for AI agents** |
| 15 | |
| 16 | LeanCTX — short for **Lean Context** — is the context engineering layer for |
| 17 | AI agents. It runs as a single local binary between your agents and everything |
| 18 | they touch — your code, shell, data, and the model itself: it **decides** what |
| 19 | they read, **compresses** what they send (an optional local proxy shrinks every |
| 20 | request — system prompt, history and tool results — prompt-cache-safe), |
| 21 | **remembers** what they learn, **guards** what they touch — and **proves** what |
| 22 | they save with a signed, verifiable savings ledger. The result: 60–90% fewer |
| 23 | tokens. |
| 24 | Zero config required. |
| 25 | Local-first. |
| 26 | |
| 27 | | Problem | With LeanCTX | |
| 28 | |---------|-------------| |
| 29 | | Repeated file reads: ~2000 tokens each | Cached re-reads: **~13 tokens** | |
| 30 | | Raw `git status`: ~800 tokens | Compressed: **~120 tokens** | |
| 31 | | Every turn re-sends the whole history | Proxy compresses each request, **prompt-cache-safe** | |
| 32 | | Context resets every chat | Session memory persists across chats | |
| 33 | | No visibility into context usage | Real-time dashboard + budget control | |
| 34 | |
| 35 | --- |
| 36 | |
| 37 | <p> |
| 38 | <a href="https://github.com/yvgude/lean-ctx/stargazers"><img src="https://img.shields.io/github/stars/yvgude/lean-ctx?style=social" alt="GitHub Stars"></a> |
| 39 | <a href="https://github.com/yvgude/lean-ctx/actions/workflows/ci.yml"><img src="https://github.com/yvgude/lean-ctx/actions/workflows/ci.yml/badge.svg" alt="CI"></a> |
| 40 | <a href="https://github.com/yvgude/lean-ctx/actions/workflows/security-check.yml"><img src="https://github.com/yvgude/lean-ctx/actions/workflows/security-check.yml/badge.svg" alt="Security"></a> |
| 41 | <a href="https://crates.io/crates/lean-ctx"><img src="https://img.shields.io/crates/v/lean-ctx?color=%23e6522c" alt="crates.io"></a> |
| 42 | <a href="https://crates.io/crates/lean-ctx"><img src="https://img.shields.io/crates/d/lean-ctx?color=%23e6522c" alt="Downloads"></a> |
| 43 | <a href="https://www.npmjs.com/package/lean-ctx-bin"><img src="https://img.shields.io/npm/v/lean-ctx-bin?label=npm&color=%23cb3837" alt="npm"></a> |
| 44 | <a href="https://aur.archlinux.org/packages/lean-ctx"><img src="https://img.shields.io/aur/version/lean-ctx?color=%231793d1" alt="AUR"></a> |
| 45 | <a href="https://pi.dev/packages/pi-lean-ctx"><img src="https://img.shields.io/badge/Pi.dev-pi--lean--ctx-6366f1?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJ3aGl0ZSI+PHRleHQgeD0iNCIgeT0iMTgiIGZvbnQtc2l6ZT0iMTYiIGZvbnQtZmFtaWx5PSJzZXJpZiI+z4A8L3RleHQ+PC9zdmc+" alt="Pi.dev"></a> |
| 46 | <a href="LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a> |
| 47 | <a href="https://discord.gg/pTHkG9Hew9"><img src="https://img.shields.io/badge/Discord-Join-5865F2?logo=discord&logoColor=white" alt="Discord"></a> |
| 48 | <a href="https://x.com/leanctx"><img src="https://img.shields.io/badge/𝕏-Follow-000000?logo=x&logoColor=white" alt="X/Twitter"></a> |
| 49 | <img src="https://img.shields.io/badge/Telemetry-Opt--in%20Only-brightgreen?logo=shield&logoColor=white" alt="Opt-in Telemetry"> |
| 50 | </p> |
| 51 | |
| 52 | <p> |
| 53 | <a href="https://leanctx.com">Website</a> · <a href="https://leanctx.com/docs/getting-started">Docs</a> · <a href="#get-started-60-seconds">Install</a> · <a href="#use-it-from-your-own-code-sdks">SDKs</a> · <a href="#real-world-scenarios">Scenarios</a> · <a href="#demo">Demo</a> · <a href="#benchmarks" |