---
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-v11 -->
## Mode: Hybrid (MCP reads + CLI shell)
CRITICAL: ALWAYS use lean-ctx tools. This is NOT optional.
## Tool Mapping (MANDATORY)
| Instead of | MUST USE | Example |
|------------|----------|---------|
| Read/cat/head/tail | `ctx_read(path, mode)` | `ctx_read("src/main.rs", "full")` |
| Grep/rg/find | `ctx_search(pattern, path)` | `ctx_search("fn handle", "src/")` |
| Shell/bash | `lean-ctx -c "<cmd>"` | `lean-ctx -c "cargo test"` |
| ls/find | `lean-ctx ls [path]` | `lean-ctx ls src/ --depth 3` |
| Edit (when Read unavail.) | `ctx_edit(path, old, new)` | `ctx_edit("f.rs", "old", "new")` |
## ctx_read Modes
| Goal | Mode |
|------|------|
| Edit target | `full` |
| API surface | `signatures` |
| Post-edit check | `diff` |
| Overview | `map` |
| Region | `lines:N-M` |
## Workflow: Orient → Locate → Read → Edit → Verify → Record
Use `ctx_overview` or `ctx_compose` first. Then `ctx_search`/`ctx_semantic_search`.
Read with `ctx_read(path, mode)`. Edit with native Edit or `ctx_edit`.
Verify: `ctx_read(path, "diff")` + `lean-ctx -c "test cmd"`.
REMINDER: You MUST use lean-ctx tools. NEVER use native Read, Grep, or Shell directly.
<!-- /lean-ctx -->