---
description: "lean-ctx cli-redirect: prefer lean-ctx CLI commands for token savings"
alwaysApply: true
---

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

## Mode: CLI-Redirect (no MCP schema overhead)

Prefer lean-ctx CLI commands over MCP tools:

| USE (via Shell/Bash) | INSTEAD OF (MCP) | Why |
|---------------------|-------------------|-----|
| `lean-ctx read <path> [-m mode]` | `ctx_read` | No MCP schema overhead, same caching |
| `lean-ctx -c "<cmd>"` | `ctx_shell` | Pattern compression (95+ patterns) |
| `lean-ctx grep <pattern> [path]` | `ctx_search` | Compact results via CLI |
| `lean-ctx ls [path]` | `ctx_tree` | Directory maps via CLI |

## Read modes

auto | full | map | signatures | diff | aggressive | entropy | task | reference | lines:N-M

## Mode selection

1. Editing? → `full`, then `diff` for re-reads
2. API surface? → `map` or `signatures`
3. Large context-only? → `entropy` or `aggressive`
4. Unsure? → `auto`

Anti-pattern: never use `full` for files you won't edit.

## File editing

Use native Edit/StrReplace. Write/Delete/Glob → use normally.

