When to use: Your monthly AI coding bill is growing and you want to reduce it without changing your workflow.
Prerequisites
- lean-ctx installed — brew install lean-ctx or curl -fsSL https://leanctx.com/install.sh | sh
Flow
-
One-command setup
Run: lean-ctx setup✓ Copied
→ Shell hooks installed, all detected editors configured automatically
-
Code normally for a day
Use your AI coding tool as usual — lean-ctx works transparently in the background.✓ Copied
→ No workflow change; compression happens silently
-
Check savings
Run: lean-ctx gain✓ Copied
→ Dashboard showing token savings per category (file reads, git, shell, etc.)
Outcome: Measurable token reduction (typically 60-90%) with zero workflow friction.
Pitfalls
- Compressed output confuses some edge-case prompts — Use
lean-ctx-off to temporarily disable, or use ctx_read with 'full' mode for specific files
When to use: Your AI assistant wastes tokens reading entire files when it only needs the structure or signature.
Flow
-
Use map mode for overview
lean-ctx read src/main.rs -m map✓ Copied
→ File structure at ~10% of full token cost
-
Use signatures mode for API
lean-ctx read src/lib.rs -m signatures✓ Copied
→ Just function/type signatures, no bodies
-
Use diff mode for changes
lean-ctx read src/main.rs -m diff✓ Copied
→ Only lines changed since last read — minimal tokens
Outcome: The AI gets exactly the context it needs at a fraction of the token cost.
Pitfalls
- Aggressive mode strips too much for complex refactoring — Use 'task' mode instead — it preserves context relevant to the current task
When to use: You're using Claude Code for architecture and Cursor for implementation, and they keep re-reading the same files.
Flow
-
Build context in agent A
In Claude Code: analyze the architecture of this project using ctx_overview.✓ Copied
→ Context built and cached by lean-ctx
-
Share to agent B
In Cursor: use ctx_share to pull the architecture context from the last session.✓ Copied
→ Cursor gets the architecture map without re-reading all files
-
Track costs across agents
lean-ctx gain --all-sessions✓ Copied
→ Combined savings across both agents
Outcome: Multiple agents share a cached context layer, avoiding redundant file reads.
Pitfalls
- Stale cache after file changes — lean-ctx tracks file modification times — cache invalidates automatically on change