lean-ctx 3.6.1

Context Runtime for AI Agents with CCP. 51 MCP tools, 10 read modes, 60+ compression patterns, cross-session memory (CCP), persistent AI knowledge with temporal facts + contradiction detection, multi-agent context sharing, LITM-aware positioning, AAAK compact format, adaptive compression with Thompson Sampling bandits. Supports 24+ AI tools. Reduces LLM token consumption by up to 99%.
Documentation
---
description: "lean-ctx hybrid: MUST use ctx_read/ctx_search (MCP) + lean-ctx -c (CLI). NEVER use native Read/Grep/Shell."
alwaysApply: true
---

# lean-ctx — Context Engineering Layer
<!-- lean-ctx-rules-hybrid-v2 -->

## Mode: Hybrid (MCP reads + CLI shell)

CRITICAL: ALWAYS use lean-ctx tools. This is NOT optional.

Use MCP tools for file reads and search (cached, token-efficient):

| MUST USE (MCP) | NEVER USE | Why |
|----------------|-----------|-----|
| `ctx_read(path, mode)` | `Read` / `cat` / `head` / `tail` | Session cache, 10 modes, re-reads ~13 tok |
| `ctx_search(pattern, path)` | `Grep` / `rg` | Compact, token-efficient results |

Use lean-ctx CLI for shell commands (no MCP schema overhead):

| MUST USE (via Shell) | NEVER USE |
|----------------------|-----------|
| `lean-ctx -c "<cmd>"` | `ctx_shell` / raw `Shell` |
| `lean-ctx ls [path]` | `ctx_tree` / `ls` / `find` |

File editing: use native Edit/StrReplace. Write/Delete/Glob → use normally.
REMINDER: You MUST use lean-ctx tools. NEVER use native Read, Grep, or Shell directly.