/ Directory / Playground / lean-ctx
● Community yvgude ⚡ Instant

lean-ctx

by yvgude · yvgude/lean-ctx

A Rust tool that aggressively prunes context — drops dead imports, trims comments, compresses logs — before sending it to the agent.

lean-ctx is for the cost-conscious: it sits between you and the agent harness, applying token-saving transforms to outgoing context. Works across Claude Code, Codex, Cursor.

Why use it

Key features

Live Demo

What it looks like in practice

ready

Install

Author repository · Claude Skills documentation

Use Cases

Real-world ways to use lean-ctx

Cut session token usage by 40–70%

👤 Claude Code users ⏱ ~15 min intermediate

When to use: Your bills are climbing and you suspect context bloat.

Flow
  1. Install
    Wire lean-ctx into your harness.✓ Copied
    → Prefilter active
  2. Measure
    Compare token counts before/after.✓ Copied
    → Big drop
  3. Tune
    Loosen if accuracy slips.✓ Copied
    → Stable balance

Outcome: Lower bills with same task success.

Combinations

Pair with other MCPs for X10 leverage

lean-ctx-skill + cmux-skill

Watch token graphs while lean-ctx prunes

Combine lean-ctx-skill with cmux-skill: Watch token graphs while lean-ctx prunes✓ Copied

Tools

What this MCP exposes

ToolInputsWhen to callCost
prefilter (see docs) Runs over outgoing context 1 call

Cost & Limits

What this costs to run

API quota
N/A
Tokens per call
Saves tokens
Monetary
Free OSS
Tip
Measure quality regressions; aggressive modes can drop important context

Security

Permissions, secrets, blast radius

Credential storage: None
Data egress: None

Troubleshooting

Common errors and fixes

Agent missing context

Lower aggressiveness; whitelist files that matter

Alternatives

lean-ctx vs others

AlternativeWhen to use it insteadTradeoff
context-modeYou want sandboxed tool outputDifferent layer

More

Resources

📖 Read the official README on GitHub

🐙 Browse open issues

🔍 Browse all 400+ MCP servers and Skills

Continue exploring

Related tools and workflows

Choose another guide for your workflow, or explore a collection.

Browse all topic collections → · See 29 new official additions →