lean-ctx 3.6.7

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: context compression layer. Tools replace native Read/Grep/Shell — see tool descriptions."
globs: **/*
alwaysApply: true
---

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

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

MCP tools for reads/search (cached, token-efficient):
- `ctx_read(path, mode)` instead of `Read`
- `ctx_search(pattern, path)` instead of `Grep`

CLI for shell (no MCP schema overhead):
- `lean-ctx -c "<cmd>"` instead of raw Shell
- `lean-ctx ls [path]` instead of `ls`/`find`

## Mode Selection
- Editing → `full` then `diff` for re-reads
- Context only → `map` or `signatures`
- Large file → `aggressive` or `entropy`
- Specific lines → `lines:N-M`
- Unsure → `auto`

## File Editing
Use native Edit/StrReplace. Write/Delete/Glob → use normally.
If Edit fails, use `ctx_edit(path, old_string, new_string)` immediately.
<!-- /lean-ctx -->