lean-ctx
Context Intelligence Engine with CEP + CCP — 25 MCP tools, 90+ shell patterns, tree-sitter AST for 18 languages, Cognitive Efficiency Protocol (CEP), cross-session memory (CCP), LITM-aware positioning. Compresses LLM context by up to 99%.
Best use case
lean-ctx is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Context Intelligence Engine with CEP + CCP — 25 MCP tools, 90+ shell patterns, tree-sitter AST for 18 languages, Cognitive Efficiency Protocol (CEP), cross-session memory (CCP), LITM-aware positioning. Compresses LLM context by up to 99%.
Teams using lean-ctx should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/lean-ctx/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How lean-ctx Compares
| Feature / Agent | lean-ctx | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Context Intelligence Engine with CEP + CCP — 25 MCP tools, 90+ shell patterns, tree-sitter AST for 18 languages, Cognitive Efficiency Protocol (CEP), cross-session memory (CCP), LITM-aware positioning. Compresses LLM context by up to 99%.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# LeanCTX v2.9.0 — The Intelligence Layer for AI Coding + CEP + CCP + Persistent Project Graph LeanCTX is a Rust binary that optimizes LLM context through 25 MCP tools, 90+ shell compression patterns, and tree-sitter AST parsing for 18 languages (TS/JS, Rust, Python, Go, Java, C, C++, Ruby, C#, Kotlin, Swift, PHP, Bash, Dart, Scala, Elixir, Zig). It provides adaptive file reading with per-language entropy thresholds, incremental deltas, intent detection, cross-file deduplication with TF-IDF cosine similarity, task-conditioned relevance scoring, a heuristic attention prediction model, a project intelligence graph, the **Cognitive Efficiency Protocol (CEP)** with output token budgets, the **Context Continuity Protocol (CCP)** for cross-session memory with LITM-aware positioning, and a feedback loop for learning optimal compression parameters. ## When to use lean-ctx Always prefer `lean-ctx -c <command>` over running commands directly when: - The command produces verbose output (build logs, git diffs, dependency trees, test results) - You are reading files and only need the structure or API surface - You want to check token savings for the current session ## Shell commands (use instead of raw exec) ```bash lean-ctx -c git status # Compressed git output lean-ctx -c git diff # Only meaningful diff lines lean-ctx -c git log --oneline -10 lean-ctx -c npm install # Strips progress bars, noise lean-ctx -c cargo build lean-ctx -c cargo test lean-ctx -c docker ps lean-ctx -c kubectl get pods lean-ctx -c aws ec2 describe-instances lean-ctx -c helm list lean-ctx -c prisma migrate dev lean-ctx -c curl -s <url> # JSON schema extraction lean-ctx -c ls -la <dir> # Grouped directory listing ``` Supported: git, npm, pnpm, yarn, bun, deno, cargo, docker, kubectl, helm, gh, pip, ruff, go, eslint, prettier, tsc, aws, psql, mysql, prisma, swift, zig, cmake, ansible, composer, mix, bazel, systemd, terraform, make, maven, dotnet, flutter, poetry, rubocop, playwright, curl, wget, and more. ## File reading (compressed modes) ```bash lean-ctx read <file> # Full content with structured header lean-ctx read <file> -m map # Dependency graph + exports + API (~5-15% tokens) lean-ctx read <file> -m signatures # Function/class signatures only (~10-20% tokens) lean-ctx read <file> -m aggressive # Syntax-stripped (~30-50% tokens) lean-ctx read <file> -m entropy # Shannon entropy filtered (~20-40% tokens) lean-ctx read <file> -m diff # Only changed lines since last read ``` Use `map` mode when you need to understand what a file does without reading every line. Use `signatures` mode when you need the API surface of a module (tree-sitter for 18 languages). Use `full` mode only when you will edit the file. ## AI Tool Integration ```bash lean-ctx init --global # Install shell aliases lean-ctx init --agent claude # Claude Code PreToolUse hook lean-ctx init --agent cursor # Cursor hooks.json lean-ctx init --agent gemini # Gemini CLI BeforeTool hook lean-ctx init --agent codex # Codex AGENTS.md lean-ctx init --agent windsurf # .windsurfrules lean-ctx init --agent cline # .clinerules lean-ctx init --agent copilot # VS Code / Copilot .vscode/mcp.json ``` ## New in v2.7.0 — Persistent AI Memory + Multi-Agent MCP tools: - `ctx_knowledge(action="remember", category, key, value)` — persistent cross-session project knowledge store - `ctx_knowledge(action="recall", query)` — search stored facts by text or category - `ctx_knowledge(action="consolidate")` — extract session findings into permanent knowledge - `ctx_agent(action="register", agent_type, role)` — multi-agent context sharing with scratchpad messaging - `ctx_agent(action="post", message, tags)` — share findings/warnings between concurrent agents - `ctx_agent(action="read")` — read messages from other agents - Antigravity editor support in setup + doctor - Dashboard: agents panel, knowledge panel, improved CEP score calculation ## Session Continuity (CCP) ```bash lean-ctx sessions list # List all CCP sessions lean-ctx sessions show # Show latest session state lean-ctx wrapped # Weekly savings report card lean-ctx wrapped --month # Monthly savings report card lean-ctx benchmark run # Real project benchmark (terminal output) lean-ctx benchmark run --json # Machine-readable JSON output lean-ctx benchmark report # Shareable Markdown report ``` MCP tools for CCP: - `ctx_session status` — show current session state (~400 tokens) - `ctx_session load` — restore previous session (cross-chat memory) - `ctx_session task "description"` — set current task - `ctx_session finding "file:line — summary"` — record key finding - `ctx_session decision "summary"` — record architectural decision - `ctx_session save` — force persist session to disk - `ctx_wrapped` — generate savings report card in chat ## Analytics ```bash lean-ctx gain # Visual token savings dashboard lean-ctx dashboard # Web dashboard at localhost:3333 lean-ctx session # Adoption statistics lean-ctx discover # Find uncompressed commands in shell history ``` ## Tips - The output suffix `[lean-ctx: 5029→197 tok, -96%]` shows original vs compressed token count - For large outputs, lean-ctx automatically truncates while preserving relevant context - JSON responses from curl/wget are reduced to schema outlines - Build errors are grouped by type with counts - Test results show only failures with summary counts - Cached re-reads cost only ~13 tokens
Related Skills
android-clean-architecture
适用于Android和Kotlin多平台项目的Clean Architecture模式——模块结构、依赖规则、用例、仓库以及数据层模式。
codebase-cleanup-tech-debt
You are a technical debt expert specializing in identifying, quantifying, and prioritizing technical debt in software projects. Analyze the codebase to uncover debt, assess its impact, and create acti
codebase-cleanup-refactor-clean
You are a code refactoring expert specializing in clean code principles, SOLID design patterns, and modern software engineering best practices. Analyze and refactor the provided code to improve its quality, maintainability, and performance.
codebase-cleanup-deps-audit
You are a dependency security expert specializing in vulnerability scanning, license compliance, and supply chain security. Analyze project dependencies for known vulnerabilities, licensing issues, outdated packages, and provide actionable remediation strategies.
code-refactoring-refactor-clean
You are a code refactoring expert specializing in clean code principles, SOLID design patterns, and modern software engineering best practices. Analyze and refactor the provided code to improve its quality, maintainability, and performance.
clean-code
This skill embodies the principles of "Clean Code" by Robert C. Martin (Uncle Bob). Use it to transform "code that works" into "code that is clean."
Cleaning Business Operations
Commercial and residential cleaning business operations agent. Covers pricing, bidding, staffing, supply costs, insurance, OSHA compliance, quality control, and growth from solo operator to multi-crew company.
doc-cleaner
Convert PDF, DOCX, XLSX, and text files to clean, structured Markdown. CJK-friendly, table-friendly, privacy-first.
aws-cost-cleanup
Automated cleanup of unused AWS resources to reduce costs
clean-code
Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments
ai-slop-cleaner
Clean AI-generated code slop with a regression-safe, deletion-first workflow and optional reviewer-only mode
ai-slop-cleaner
Run an anti-slop cleanup/refactor/deslop workflow