Skip to content

[research] lean-ctx — 88% token reduction via shell hook + MCP server, RTK successor #71

@jpleva91

Description

@jpleva91

What It Does

lean-ctx is a single Rust binary that reduces LLM token consumption by 88-99% through three complementary strategies: a transparent shell hook that compresses CLI output before it reaches the model (90+ patterns: git, cargo, npm, docker, grep), a 21-tool MCP server with cached file reads and cross-session memory (CCP), and AI Tool Hooks for one-command integration with Claude Code, Codex, Copilot, and Cursor. It also ships a Token Dense Dialect (TDD) mode that uses mathematical symbols and short identifiers to shrink LLM communication further.

Why It Matters for ShellForge

ShellForge already bundles RTK for token compression, but lean-ctx is its direct successor and explicit RTK replacement (the repo has a vs RTK comparison section). The MCP server with cross-session memory (CCP) directly solves cold-start token overhead in ShellForge's 24/7 swarm mode — typical savings are -99.2% on re-reads. The shell hook integrates at the shellforge run subprocess boundary (same layer as RTK today), and lean-ctx init --agent crush would wire it into the Crush agent loop automatically. Zero dependencies, homebrew install, npm + crates.io.

Integration point: Replace/extend RTK in the Optimize layer. Add lean-ctx to the stack table in README and wire lean-ctx setup into shellforge setup.

Links

Integration Effort

Drop-inlean-ctx setup auto-configures shell hooks. MCP server integration is moderate (extend AgentGuard to proxy MCP tool calls through lean-ctx).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low priority / nice to haveenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions