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: Use ctx_read/ctx_search/ctx_shell instead of native Read/Grep/Shell."
globs: **/*
alwaysApply: true
---

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

CRITICAL: ALWAYS use lean-ctx MCP tools instead of native equivalents:

| MUST USE | INSTEAD OF |
|----------|------------|
| `ctx_read(path, mode)` | `Read` / `cat` / `head` / `tail` |
| `ctx_search(pattern, path)` | `Grep` / `rg` |
| `lean-ctx -c "<cmd>"` (via Shell) | raw `Shell` |
| `lean-ctx ls [path]` (via Shell) | `ls` / `find` |

ctx_read modes: full|map|signatures|diff|aggressive|entropy|task|reference|lines:N-M.
Re-reads cost ~13 tokens. fresh=true bypasses cache.

File editing: use native Edit/StrReplace. Write/Delete/Glob → use normally.
If Edit fails, use `ctx_edit(path, old_string, new_string)` immediately.

REMINDER: You MUST use lean-ctx tools. NEVER use native Read, Grep, or Shell directly.
<!-- /lean-ctx -->