/ 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

Pick your client

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "lean-ctx-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/yvgude/lean-ctx"
      ],
      "_inferred": true
    }
  }
}

Open Claude Desktop → Settings → Developer → Edit Config. Restart after saving.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "lean-ctx-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/yvgude/lean-ctx"
      ],
      "_inferred": true
    }
  }
}

Cursor uses the same mcpServers schema as Claude Desktop. Project config wins over global.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "lean-ctx-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/yvgude/lean-ctx"
      ],
      "_inferred": true
    }
  }
}

Click the MCP Servers icon in the Cline sidebar, then "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "lean-ctx-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/yvgude/lean-ctx"
      ],
      "_inferred": true
    }
  }
}

Same shape as Claude Desktop. Restart Windsurf to pick up changes.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "lean-ctx-skill",
      "command": "git",
      "args": [
        "clone",
        "https://github.com/yvgude/lean-ctx"
      ]
    }
  ]
}

Continue uses an array of server objects rather than a map.

~/.config/zed/settings.json
{
  "context_servers": {
    "lean-ctx-skill": {
      "command": {
        "path": "git",
        "args": [
          "clone",
          "https://github.com/yvgude/lean-ctx"
        ]
      }
    }
  }
}

Add to context_servers. Zed hot-reloads on save.

claude mcp add lean-ctx-skill -- git clone https://github.com/yvgude/lean-ctx

One-liner. Verify with claude mcp list. Remove with claude mcp remove.

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