LeanCTX एक एकल Rust बाइनरी के माध्यम से आपके LLM की टोकन खपत को 99% तक कम करता है जो प्रदान करता है: 95+ CLI कम्प्रेशन पैटर्न के साथ एक शेल हुक, कैश्ड रीड और सत्र बुद्धिमत्ता के लिए 58 टूल्स के साथ एक MCP सर्वर, और संरचनात्मक कोड समझ के लिए एक स्थायी प्रोजेक्ट ग्राफ़। इसे एक बार इंस्टॉल करें, और हर फ़ाइल रीड, शेल कमांड और कोड नेविगेशन अधिक कुशल हो जाता है।
प्रॉम्प्ट जनरेटर
नीचे अपना प्लेटफ़ॉर्म और AI टूल चुनें। जनरेटेड प्रॉम्प्ट किसी भी AI कोडिंग सहायक में पेस्ट किया जा सकता है - यह पूर्ण इंस्टॉलेशन और कॉन्फ़िगरेशन स्वचालित रूप से करेगा।
3 चरणों में शुरू करें
# 1. Install (pick one) curl -fsSL https://leanctx.com/install.sh | sh # universal brew tap yvgude/lean-ctx && brew install lean-ctx # macOS / Linux npm install -g lean-ctx-bin # Node.js cargo install lean-ctx # Rust pi install npm:pi-lean-ctx # Pi Coding Agent # 2. Setup (auto-configures shell + ALL detected editors) lean-ctx setup # 3. Restart your shell source ~/.zshrc # or ~/.bashrc
lean-ctx setup स्वचालित रूप से पहचानता और कॉन्फ़िगर करता है: Cursor, Claude Code, Windsurf, VS Code / Copilot, Codex CLI, Gemini CLI, Zed, Antigravity, OpenCode, Crush, और Pi। सब कुछ काम करता है इसकी पुष्टि के लिए lean-ctx doctor चलाएँ।
प्रति प्लेटफ़ॉर्म विस्तृत इंस्टॉलेशन निर्देश
चरण 1: बाइनरी इंस्टॉल करें
यूनिवर्सल इंस्टॉलर (कोई भी प्लेटफ़ॉर्म)
बिना किसी पूर्वापेक्षा के lean-ctx इंस्टॉल करने का सबसे तेज़ तरीका:
curl -fsSL https://leanctx.com/install.sh | sh The install script detects your OS and architecture, downloads the correct binary, and places it in /usr/local/bin. It works on macOS, Linux, and WSL.
If you prefer to review the script before running it:
curl -fsSL https://leanctx.com/install.sh -o install.sh
chmod +x install.sh
./install.sh --download # pre-built binary (no Rust)
./install.sh # build from source (requires Rust) npm (Node.js)
npm के माध्यम से पूर्व-निर्मित बाइनरी इंस्टॉल करें - कोई Rust टूलचेन आवश्यक नहीं:
npm install -g lean-ctx-bin यह postinstall के दौरान SHA256 सत्यापन के साथ आपके प्लेटफ़ॉर्म के लिए सही बाइनरी डाउनलोड करता है। macOS (Intel + Apple Silicon), Linux (x86_64) और Windows (x86_64) पर काम करता है।
macOS
Option A: Homebrew (recommended)
brew tap yvgude/lean-ctx
brew install lean-ctx Homebrew handles updates and PATH automatically.
Option B: Cargo (build from source)
cargo install lean-ctx If lean-ctx isn't found after install, add Cargo's bin directory to your PATH:
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc Option C: Manual binary download
- Download the binary for your architecture from GitHub Releases:
lean-ctx-aarch64-apple-darwin.tar.gz(Apple Silicon / M1+)lean-ctx-x86_64-apple-darwin.tar.gz(Intel)
- Extract and move to PATH:
tar xzf lean-ctx-aarch64-apple-darwin.tar.gz chmod +x lean-ctx sudo mv lean-ctx /usr/local/bin/
If macOS blocks the binary with a Gatekeeper warning, remove the quarantine attribute:
xattr -d com.apple.quarantine /usr/local/bin/lean-ctx Linux
Option A: Homebrew
brew tap yvgude/lean-ctx && brew install lean-ctx Option B: AUR (Arch Linux)
# Source build from crates.io
yay -S lean-ctx
# Or pre-built binary from GitHub
yay -S lean-ctx-bin Works with any AUR helper: yay, paru, trizen, etc.
Option C: Cargo (build from source)
cargo install lean-ctx Requires Rust toolchain. Install via rustup.rs if needed.
Option D: Manual binary download
- Download
lean-ctx-x86_64-unknown-linux-gnu.tar.gzfrom GitHub Releases - Extract and move to PATH:
tar xzf lean-ctx-x86_64-unknown-linux-gnu.tar.gz chmod +x lean-ctx sudo mv lean-ctx /usr/local/bin/
| Command | Method |
|---|---|
lean-ctx-x86_64-unknown-linux-musl.tar.gz | x86_64 - statically linked (musl) |
lean-ctx-aarch64-unknown-linux-musl.tar.gz | ARM64 / aarch64 (Graviton, Raspberry Pi 4+, etc.) - statically linked |
Windows
Option A: Binary download (recommended)
- Download
lean-ctx-x86_64-pc-windows-msvc.zipfrom GitHub Releases - Extract the
.zipfile - Open the extracted folder - you'll see
lean-ctx.exe - Move
lean-ctx.exeto a folder in your PATH, for example:mkdir %USERPROFILE%\bin move lean-ctx.exe %USERPROFILE%\bin\ - Add the folder to your PATH if it isn't already:
- Open Settings → System → About → Advanced system settings
- Click Environment Variables
- Under User variables, select
Path, click Edit, then New - Add the path to your bin folder (e.g. C:\Users\you\bin)
- Open a new PowerShell or CMD window and verify:
lean-ctx --version
Option B: Cargo (build from source)
- Install Rust if not already installed
- Build and install:
cargo install lean-ctx - The binary is placed in
%USERPROFILE%\.cargo\bin\which is usually already in your PATH.
Option C: Build from source (clone & compile)
git clone https://github.com/yvgude/lean-ctx.git
cd lean-ctx\rust
cargo build --release
copy target\release\lean-ctx.exe %USERPROFILE%\bin\ WSL users: If you're running WSL, follow the Linux instructions instead.
सोर्स से बिल्ड करें (कोई भी प्लेटफ़ॉर्म)
git clone https://github.com/yvgude/lean-ctx.git
cd lean-ctx/rust
cargo build --release बाइनरी target/release/lean-ctx (या Windows पर lean-ctx.exe) पर है। इसे अपने PATH की डायरेक्टरी में कॉपी करें।
चरण 2: सेटअप
बाइनरी इंस्टॉल करने के बाद, सब कुछ स्वचालित रूप से कॉन्फ़िगर करने के लिए lean-ctx setup चलाएँ:
lean-ctx setup यह एकल कमांड:
- 23 शेल एलियास इंस्टॉल करता है (git, npm, cargo, docker, kubectl, curl और अधिक)
- इंस्टॉल किए गए संपादकों को ऑटो-डिटेक्ट करता है (Cursor, Claude Code, Windsurf, VS Code/Copilot, Codex CLI, Gemini CLI, Zed, Antigravity, OpenCode, Crush)
- प्रत्येक पहचाने गए संपादक के लिए MCP कॉन्फ़िग फ़ाइलें बनाता है
- प्रत्येक पहचाने गए टूल के ग्लोबल कॉन्फ़िग में एजेंट नियम इंजेक्ट करता है, AI को नेटिव विकल्पों के बजाय lean-ctx के MCP टूल्स (
ctx_read,ctx_shell,ctx_search,ctx_tree) का उपयोग करने का निर्देश देता है - सब कुछ सत्यापित करने के लिए
lean-ctx doctorचलाता है
महत्वपूर्ण: सेटअप के बाद अपना IDE पुनरारंभ करें!
नए टूल्स और एजेंट नियमों को प्रभावी होने के लिए MCP कनेक्शन को पुनः स्थापित करना होगा। अपने IDE को पूरी तरह बंद करें और पुनः खोलें (Cmd+Q / Ctrl+Q, फिर पुनः खोलें)। पुनरारंभ के बाद, एजेंट नियम हर IDE शुरू होने पर स्वचालित रूप से भी अपडेट होते हैं - भविष्य के अपडेट के बाद lean-ctx setup पुनः चलाने की आवश्यकता नहीं।
सेटअप के बाद, अपना शेल पुनरारंभ करें:
| शेल | पुनरारंभ कमांड |
|---|---|
| Zsh (macOS default) | source ~/.zshrc |
| Bash | source ~/.bashrc |
| Fish | source ~/.config/fish/config.fish |
| PowerShell | Close and reopen PowerShell |
फिर अपने संपादक को पूरी तरह पुनरारंभ करें।
मैनुअल विकल्प
यदि आप संपादक ऑटो-डिटेक्शन के बिना केवल शेल एलियास इंस्टॉल करना पसंद करते हैं:
lean-ctx init --global फिर नीचे चरण 3 के निर्देशों का उपयोग करके अपने संपादक को मैन्युअल रूप से कॉन्फ़िगर करें।
eval-आधारित आरंभीकरण (अनुशंसित)
lean-ctx init --global के विकल्प के रूप में, आप eval पैटर्न का उपयोग कर सकते हैं - यह वही विधि है जो starship, zoxide और atuin द्वारा उपयोग की जाती है। हुक कोड वर्तमान में इंस्टॉल किए गए बाइनरी द्वारा stdout पर प्रिंट किया जाता है, इसलिए अपग्रेड के बाद यह हमेशा अपडेट रहता है:
# bash: add to ~/.bashrc
eval "$(lean-ctx init bash)"
# zsh: add to ~/.zshrc
eval "$(lean-ctx init zsh)"
# fish: add to ~/.config/fish/config.fish
lean-ctx init fish | source
# powershell: add to $PROFILE
lean-ctx init powershell | Invoke-Expression लाभ: eval विधि शेल स्टार्टअप पर इंस्टॉल किए गए बाइनरी से हुक जनरेट करती है, इसलिए lean-ctx update के बाद हुक कभी भी पुराने नहीं होते। अपग्रेड के बाद lean-ctx setup फिर से चलाने की आवश्यकता नहीं है।
Docker इंस्टॉलेशन
Docker कंटेनर के अंदर lean-ctx का उपयोग करने के लिए (जैसे Claude Code, Codex या अन्य AI एजेंट्स के साथ), स्टैटिकली लिंक किए गए musl बाइनरी का उपयोग करें और BASH_ENV सेट करें ताकि शेल हुक नॉन-इंटरैक्टिव शेल में लोड हो।
ARG LEAN_CTX_VERSION=3.5.1
# Download the musl binary (statically linked, no glibc dependency)
RUN curl -fsSL \
"https://github.com/yvgude/lean-ctx/releases/download/v${LEAN_CTX_VERSION}/lean-ctx-x86_64-unknown-linux-musl.tar.gz" \
| tar -xz -C /usr/local/bin lean-ctx && \
chmod +x /usr/local/bin/lean-ctx
# Install shell hook (non-interactive) + configure your AI tool
RUN lean-ctx init --global && \
lean-ctx init --agent claude
# Load shell hook in non-interactive shells
ENV BASH_ENV="/root/.lean-ctx/env.sh"
# Claude Code: sources this file before each command
ENV CLAUDE_ENV_FILE="/root/.lean-ctx/env.sh" For ARM64 hosts (AWS Graviton, Apple Silicon via Docker), use the aarch64 binary instead:
# For ARM64 (Apple Silicon / Graviton), use the aarch64 binary:
RUN curl -fsSL \
"https://github.com/yvgude/lean-ctx/releases/download/v${LEAN_CTX_VERSION}/lean-ctx-aarch64-unknown-linux-musl.tar.gz" \
| tar -xz -C /usr/local/bin lean-ctx यह क्यों काम करता है
| चरण | उद्देश्य |
|---|---|
musl binary | स्टैटिकली लिंक्ड - gcc-libs या glibc इंस्टॉल किए बिना किसी भी Linux डिस्ट्रो पर काम करता है |
lean-ctx init --global | ~/.bashrc में शेल हुक इंस्टॉल करता है (नॉन-इंटरैक्टिव, lean-ctx setup के विपरीत) |
lean-ctx init --agent claude | MCP सर्वर कॉन्फिग को ~/.claude.json में लिखता है। claude को अपने एजेंट से बदलें: cursor, codex, gemini, आदि। |
BASH_ENV | सामान्य नॉन-इंटरैक्टिव शेल (bash -c) इस फ़ाइल को लोड करते हैं। अधिकांश ~/.bashrc नॉन-इंटरैक्टिव मोड में जल्दी बंद हो जाती हैं - env.sh में यह गार्ड नहीं है। |
CLAUDE_ENV_FILE | Claude Code हर कमांड चलाने से पहले इस फ़ाइल को लोड करता है। यह Claude Code के शेल एनवायरनमेंट को कॉन्फ़िगर करने का आधिकारिक रूप से अनुशंसित तरीका है। |
सामान्य समस्याएं
| त्रुटि | कारण | समाधान |
|---|---|---|
command not found: _lc | BASH_ENV सेट नहीं है - शेल हुक लोड नहीं हुआ | ENV BASH_ENV="/root/.lean-ctx/env.sh" जोड़ें (नॉन-रूट यूजर्स के लिए पथ बदलें) |
lean-ctx setup hangs | Docker में stdin के बिना इंटरैक्टिव प्रॉम्प्ट | इसके बजाय lean-ctx init --global का उपयोग करें |
| Binary not found / exec format error | गलत आर्किटेक्चर या glibc के बिना gnu बाइनरी | न्यूनतम कंटेनर्स के लिए musl टारबॉल का उपयोग करें |
चरण 3: सत्यापित करें
- Check the binary is installed:
lean-ctx --version # → lean-ctx 3.5.1 lean-ctx doctor # checks PATH, config, aliases, MCP - Test the shell hook:
git status # output is now compressed lean-ctx gain # shows token savings so far - Open your AI coding tool and start coding - lean-ctx tools should be available automatically.
मैनुअल संपादक कॉन्फ़िगरेशन
केवल अगर lean-ctx setup काम नहीं किया
Connect lean-ctx to your AI coding tool by adding it as an MCP server.
Before you start: Find your lean-ctx binary path. You'll need it for editors that require a full path.
# macOS / Linux:
which lean-ctx
# Example output: /opt/homebrew/bin/lean-ctx or /Users/you/.cargo/bin/lean-ctx
# Windows (PowerShell):
where.exe lean-ctx
# Example output: C:\Users\you\.cargo\bin\lean-ctx.exe Keep this path handy - some editors need the full absolute path instead of just lean-ctx.
Cursor
- Create or edit the MCP config file:
# macOS / Linux: mkdir -p ~/.cursor nano ~/.cursor/mcp.json # Windows (PowerShell): mkdir -Force "$env:USERPROFILE\.cursor" notepad "$env:USERPROFILE\.cursor\mcp.json" - Paste this JSON:
{ "mcpServers": { "lean-ctx": { "command": "lean-ctx" } } } - Restart Cursor completely (Cmd+Q / Alt+F4, then reopen).
- Verify: open the MCP panel in settings - lean-ctx should show as "connected".
Optional: install agent rules to make Cursor prefer lean-ctx tools:
lean-ctx init --agent cursor Claude Code
Claude Code has built-in MCP support. No config file needed:
# Add lean-ctx as MCP server:
claude mcp add lean-ctx lean-ctx
# Install the CLAUDE.md instructions (makes Claude use lean-ctx tools):
lean-ctx init --agent claude The init command creates a CLAUDE.md file that teaches Claude to use lean-ctx tools instead of native file reads and shell commands.
Claude Code: 2048-Character Limit
Claude Code truncates MCP server instructions to 2048 characters. This means lean-ctx's full instruction set (session management, compression protocols, tool preferences) gets cut off.
lean-ctx handles this automatically: lean-ctx init --agent claude installs the full instructions as a Claude Rules file (~/.claude/rules/lean-ctx.md) and an Agent Skill (~/.claude/skills/lean-ctx/). Claude Code loads these without any character cap.
# Automatic (recommended) - run during init:
lean-ctx init --agent claude
# This automatically:
# 1. Registers MCP server in ~/.claude.json
# 2. Installs full instructions to ~/.claude/rules/lean-ctx.md
# 3. Installs Agent Skill to ~/.claude/skills/lean-ctx/ If you installed lean-ctx manually (without init), copy the rules file: lean-ctx init --agent claude to retroactively install rules + skills.
GitHub Copilot (VS Code)
Option A: Copilot CLI (.github/mcp.json)
- Create
.github/mcp.jsonin your project root:{ "mcpServers": { "lean-ctx": { "command": "lean-ctx" } } } - Restart VS Code / Copilot CLI.
Option B: VS Code Copilot (.vscode/mcp.json)
- Create
.vscode/mcp.jsonin your project root:{ "servers": { "lean-ctx": { "type": "stdio", "command": "lean-ctx" } } } - Restart VS Code.
Tip: lean-ctx init --agent copilot creates both files automatically.
Note: GitHub Copilot MCP support requires VS Code 1.99+ and the latest Copilot extension.
Per-project: This config is per-project. Add .github/mcp.json to your .gitignore or commit it to share with your team.
Windsurf
- Open the MCP config file:
# macOS: mkdir -p ~/.codeium/windsurf nano ~/.codeium/windsurf/mcp_config.json # Linux: mkdir -p ~/.codeium/windsurf nano ~/.codeium/windsurf/mcp_config.json # Windows: mkdir -Force "$env:USERPROFILE\.codeium\windsurf" notepad "$env:USERPROFILE\.codeium\windsurf\mcp_config.json" - Paste this JSON:
{ "mcpServers": { "lean-ctx": { "command": "/FULL/PATH/TO/lean-ctx" } } }Important: Windsurf requires the full absolute path to the binary. Example for Homebrew on macOS:
{ "mcpServers": { "lean-ctx": { "command": "/opt/homebrew/bin/lean-ctx" } } } - Restart Windsurf completely.
- Check MCP connection in Windsurf settings.
Zed
- Open Zed settings:
# macOS / Linux: ~/.config/zed/settings.json # Windows: %APPDATA%\Zed\settings.json - Add the lean-ctx context server configuration:
{ "context_servers": { "lean-ctx": { "source": "custom", "command": "lean-ctx", "args": [], "env": {} } } }Note: Zed uses
context_servers(notmcpServers) and requiressource: "custom". - Save and restart Zed.
- Verify: lean-ctx tools should appear in the assistant panel.
Tip: Run lean-ctx init --agent zed to install agent rules that make Zed prefer lean-ctx tools.
OpenAI Codex CLI
- Create or edit the Codex config file:
# macOS / Linux: mkdir -p ~/.codex nano ~/.codex/config.toml # Windows: mkdir -Force "$env:USERPROFILE\.codex" notepad "$env:USERPROFILE\.codex\config.toml" - Add the MCP server entry:
[mcp_servers.lean-ctx] command = "lean-ctx" args = [] - Restart Codex CLI.
Alternative: use the Codex CLI built-in command:
codex mcp add lean-ctx Install agent instructions for Codex:
lean-ctx init --agent codex Gemini CLI
- Create or edit the Gemini MCP config:
# macOS / Linux: mkdir -p ~/.gemini nano ~/.gemini/settings.json # Windows (PowerShell): mkdir -Force "$env:USERPROFILE\.gemini" notepad "$env:USERPROFILE\.gemini\settings.json" - Add the MCP server configuration:
{ "mcpServers": { "lean-ctx": { "command": "lean-ctx" } } }Important: If Gemini can't find the binary, use the full path. Example for Homebrew on macOS:
{ "mcpServers": { "lean-ctx": { "command": "/opt/homebrew/bin/lean-ctx" } } } - Restart Gemini CLI.
- Verify with a prompt that triggers tool use.
Known issue: Gemini CLI may not always invoke MCP tools consistently. If tools aren't triggered, try adding lean-ctx init --agent gemini to install a GEMINI.md with usage instructions.
Antigravity
Antigravity uses the same MCP config format as Gemini CLI but in a separate directory.
- Create the Antigravity MCP config directory and file:
# macOS / Linux: mkdir -p ~/.gemini/antigravity nano ~/.gemini/antigravity/mcp_config.json # Windows (PowerShell): mkdir -Force "$env:USERPROFILE\.gemini\antigravity" notepad "$env:USERPROFILE\.gemini\antigravity\mcp_config.json" - Paste this JSON:
{ "mcpServers": { "lean-ctx": { "command": "lean-ctx" } } }Important: If Antigravity can't find the binary, use the full absolute path to
lean-ctx. - Restart Antigravity.
- Verify with a prompt that triggers tool use.
You can also manage MCP servers via Antigravity's built-in server management UI.
OpenCode
- Create or edit the OpenCode config file:
# macOS / Linux: mkdir -p ~/.config/opencode nano ~/.config/opencode/opencode.json - Add the MCP server configuration:
{ "$schema": "https://opencode.ai/config.json", "mcp": { "lean-ctx": { "type": "local", "command": ["lean-ctx"], "enabled": true } } } - Restart OpenCode.
OpenClaw
OpenClaw supports MCP servers natively. You can add lean-ctx from the settings UI or via CLI.
- Open OpenClaw settings and navigate to the MCP servers section.
- Add a new MCP server with command: lean-ctx
- Restart OpenClaw to activate.
Tip: Run lean-ctx init --agent openclaw to install lean-ctx skills for OpenClaw.
Pi
Pi has a dedicated lean-ctx plugin (pi-lean-ctx) that integrates automatically.
- Make sure lean-ctx is installed:
cargo install lean-ctx - Install the Pi plugin:
pi install npm:pi-lean-ctxOr use lean-ctx's built-in command:
lean-ctx init --agent pi - Restart Pi.
- Verify: lean-ctx tools should appear in Pi's tool list.
Note: Pi's smart reads automatically use lean-ctx when the plugin is installed. No additional configuration needed.
AWS Kiro
AWS Kiro को नेटिव समकक्षों के बजाय lean-ctx टूल्स का उपयोग करने के लिए MCP कॉन्फ़िग और एक स्टीयरिंग फ़ाइल दोनों की आवश्यकता है।
lean-ctx setupचलाएँ - Kiro स्वतः पहचाना जाता है और MCP कॉन्फ़िग व स्टीयरिंग फ़ाइल दोनों बनाई जाती हैं।- या समर्पित कमांड का उपयोग करें (दोनों फ़ाइलें बनाता है):
lean-ctx init --agent kiro - यह दो फ़ाइलें बनाता है:
~/.kiro/settings/mcp.json- MCP सर्वर कनेक्शन.kiro/steering/lean-ctx.md- स्टीयरिंग फ़ाइल जो Kiro कोreadFileके बजायmcp_lean_ctx_ctx_readको प्राथमिकता देने का निर्देश देती है, आदि।
- सक्रिय करने के लिए Kiro पुनरारंभ करें।
महत्वपूर्ण: स्टीयरिंग फ़ाइल (.kiro/steering/lean-ctx.md) प्रति-प्रोजेक्ट होती है। इसके बिना, Kiro डिफ़ॉल्ट रूप से अपने नेटिव टूल्स का उपयोग करेगा और पढ़ने व खोजने के लिए MCP सर्वर को अनदेखा करेगा।
Verdent
Verdent supports MCP servers via configuration or CLI.
- Open Verdent settings or navigate to the MCP section.
- Run the init command:
lean-ctx init --agent verdent - Or manually create the MCP config:
{ "mcpServers": { "lean-ctx": { "command": "lean-ctx" } } } - Restart Verdent to activate.
Note: Verdent's MCP support may require a recent version. Update Verdent if tools don't appear.
Other MCP-compatible tools
Any tool that supports the Model Context Protocol can use lean-ctx. The standard MCP config format is:
{
"mcpServers": {
"lean-ctx": {
"command": "lean-ctx"
}
}
} Key points:
- The
commandmust point to the lean-ctx binary (use full path if not in PATH). - No
argsorenvare required - lean-ctx auto-configures. - The binary communicates via stdio (standard MCP transport).
- After adding the config, restart your tool and verify lean-ctx tools appear.
बचत मॉनिटर करें
# Terminal dashboard (colors, bars, sparklines)
lean-ctx gain
# Web dashboard with charts
lean-ctx dashboard
# Find uncompressed commands in shell history
lean-ctx discover
# Run a real benchmark on your project
lean-ctx benchmark run एजेंट हुक्स और एडिटर इंटीग्रेशन
अपने विशिष्ट AI एजेंट या एडिटर के लिए lean-ctx कॉन्फ़िगर करें। init कमांड MCP कॉन्फ़िगरेशन, शेल हुक्स सेटअप करता है और सत्यापित करता है कि सब कुछ काम कर रहा है। समस्याओं का निदान और स्वतः सुधार के लिए doctor का उपयोग करें।
# Configure a specific AI tool (mode auto-detected; override with --mode)
lean-ctx init --agent cursor
lean-ctx init --agent claude
lean-ctx init --agent codex
lean-ctx init --agent gemini
lean-ctx init --agent hermes
lean-ctx init --agent pi # or: pi install npm:pi-lean-ctx
lean-ctx init --agent qoder
lean-ctx init --agent qoderwork
# Force MCP tools if you prefer ctx_* calls
lean-ctx init --agent cursor --mode mcp
# Run diagnostics and auto-fix issues
lean-ctx doctor --fix
# Check current status (MCP, shell, editors)
lean-ctx status --json अपडेट करना
The fastest way to update lean-ctx:
lean-ctx update This auto-detects your installation method, downloads the latest version, and replaces the binary.
You can also update manually using the original installation method:
| Method | Command |
|---|---|
| Homebrew | brew update && brew upgrade lean-ctx |
| Cargo | cargo install lean-ctx |
| npm | npm update -g lean-ctx-bin |
| AUR | yay -Syu lean-ctx |
| Pi | pi install npm:pi-lean-ctx |
| install.sh | Re-run curl -fsSL https://leanctx.com/install.sh | sh |
| Binary | Download latest from GitHub Releases |
After updating, re-run lean-ctx setup to ensure shell hooks and editor configs are up to date:
lean-ctx setup # re-configures shell + editors
source ~/.zshrc # restart shell अनइंस्टॉल करना
To fully remove lean-ctx from your system:
lean-ctx uninstall This removes:
- Shell hook entries from
~/.zshrc,~/.bashrc,~/.config/fish/config.fish, and PowerShell profiles - Agent rules files (
CLAUDE.md,.cursorrules, etc.) - Cache and config files in
~/.lean-ctx/
Then remove the binary itself:
| Installed via | Remove command |
|---|---|
| Cargo | cargo uninstall lean-ctx |
| Homebrew | brew uninstall lean-ctx |
| AUR | yay -R lean-ctx |
| Pi | pi uninstall npm:pi-lean-ctx |
| Manual binary | rm $(which lean-ctx) |
Restart your terminal and AI coding tool to complete the uninstallation.
एजेंट नियम
Agent rules tell your AI coding tool to prefer lean-ctx MCP tools (ctx_read, ctx_shell, ctx_search, ctx_tree) over native file reads, shell commands, and search. Run lean-ctx init --agent <name> to install them automatically.
यह कैसे काम करता है
lean-ctx init --agent <name>writes a rules/instructions file to the agent's expected location.- The rules file teaches the AI to use
ctx_read,ctx_shell,ctx_search, andctx_treeinstead of native equivalents. - This is optional - lean-ctx works without agent rules, but performance improves when the AI actively uses lean-ctx tools.
- The rules are idempotent - running
initagain updates them without duplicating content.
क्या इंजेक्ट किया जाता है
नियम AI एजेंट को नेटिव विकल्पों के बजाय lean-ctx MCP टूल्स का उपयोग करने का निर्देश देते हैं:
| Instead of | Use | Why |
|---|---|---|
Read / cat | ctx_read | Cached, 10 read modes, re-reads cost ~13 tokens |
Shell / bash | ctx_shell | Pattern compression for git, npm, cargo, docker output |
Grep / search | ctx_search | Compact, token-efficient results |
ls / find | ctx_tree | Compact directory maps with file counts |
Note: Write, StrReplace, Delete, and Glob have no lean-ctx replacement - the rules tell the AI to keep using native tools for those.
Where are rules installed?
| AI Tool | Rules File |
|---|---|
| Claude Code | ~/.claude/CLAUDE.md |
| Codex CLI | ~/.codex/instructions.md |
| Cursor | ~/.cursor/rules/lean-ctx.mdc |
| Windsurf | ~/.codeium/windsurf/rules/lean-ctx.md |
| Gemini CLI | ~/.gemini/GEMINI.md |
| VS Code / Copilot | .github/copilot-instructions.md |
| Zed | ~/.config/zed/rules/lean-ctx.md |
| OpenCode | ~/.config/opencode/rules/lean-ctx.md |
| Pi | pi-lean-ctx package (built-in via pi.dev) |
| Qoder | ~/.qoder/settings.json (PreToolUse hooks) |
Manual rules (fallback)
If your AI tool doesn't support agent rules, you can paste these instructions into the system prompt or a rules file:
# lean-ctx - Context Engineering Layer
Default (CLI-first):
- Use lean-ctx CLI commands for reads/search:
- lean-ctx read <path> [-m mode]
- lean-ctx grep <pattern> <path>
- lean-ctx ls <path>
- Use lean-ctx -c "<cmd>" for compressed shell output
If you're running in MCP/Hybrid mode:
- Prefer ctx_* tools instead of native equivalents:
- ctx_read instead of Read/cat for file reads
- ctx_shell instead of Shell/bash for commands
- ctx_search instead of Grep/search for code search
- ctx_tree instead of ls/find for directory listing
Keep using native tools for: Write, StrReplace, Delete, Glob (no lean-ctx replacement).
Do NOT fall back to native tools for reading/shell/search/tree when a lean-ctx path is available. Cursor users: Save this as .cursor/rules/lean-ctx.mdc in your project root for project-level rules, or ~/.cursor/rules/lean-ctx.mdc for global rules.
समस्या निवारण
lean-ctx: command not found
बाइनरी आपके PATH में नहीं है। जाँचें कि यह कहाँ इंस्टॉल किया गया था:
# Cargo installs here:
ls ~/.cargo/bin/lean-ctx
# Homebrew installs here (macOS):
ls /opt/homebrew/bin/lean-ctx
# Manual installs - wherever you placed it:
ls /usr/local/bin/lean-ctx अपने शेल प्रोफ़ाइल में सही डायरेक्टरी को अपने PATH में जोड़ें।
AI isn't using lean-ctx tools
If the AI keeps using native Read/Shell instead of ctx_read/ctx_shell:
- Run
lean-ctx init --agent <name>to install agent rules - Restart the AI tool completely (not just reload)
- Check that the MCP server is connected (look for lean-ctx in the tool's MCP panel)
- Try prompting explicitly: "use ctx_read to read this file"
No lean-ctx tools appearing
- Verify the binary path is correct in your MCP config
- Run
lean-ctx doctorto check for issues - Check the AI tool's MCP logs for connection errors
- Try using the full absolute path to
lean-ctxin the config
Shell hook causes hangs
If commands hang after installing the shell hook, set the LEAN_CTX_ACTIVE environment variable to bypass compression for specific commands:
LEAN_CTX_ACTIVE=1 cargo test This disables lean-ctx compression for that command. Useful for CI/CD scripts and long-running processes.
macOS Gatekeeper blocks lean-ctx
xattr -d com.apple.quarantine $(which lean-ctx) Windows: PowerShell vs cmd.exe
lean-ctx prioritizes PowerShell on Windows. If you experience issues with cmd.exe, set the LEAN_CTX_SHELL environment variable to force PowerShell: $env:LEAN_CTX_SHELL = "powershell"
अगले कदम
- Project Intelligence Graph - build and query your project's dependency graph
- CEP Protocol - cognitive efficiency scoring for leaner AI responses
- CCP Protocol - cross-session context continuity
- TDD Protocol - token-dense dialect for maximum compression
- All 58 Tools Reference
- CLI Reference