यह हर lean-ctx कमांड के लिए संपूर्ण संदर्भ है। त्वरित चीट शीट के लिए, त्वरित संदर्भ देखें। एनालिटिक्स और डैशबोर्ड विवरण के लिए, एनालिटिक्स गाइड देखें।
शेल कम्प्रेशन
ये कमांड शेल कमांड को lean-ctx के 95+ कम्प्रेशन पैटर्न के माध्यम से चलाते हैं। आउटपुट LLM तक पहुँचने से पहले स्वचालित रूप से शोर, बॉयलरप्लेट और अनावश्यकता से साफ़ किया जाता है।
lean-ctx -c "<command>"
कोई भी शेल कमांड चलाएँ और उसके आउटपुट को कम्प्रेस करें। एलियास: lean-ctx exec।
lean-ctx -c "git status"
lean-ctx -c "kubectl get pods -A"
lean-ctx -c "cargo build 2>&1"
lean-ctx exec "docker ps" शेल हुक (lean-ctx init के माध्यम से इंस्टॉल) सामान्य कमांड के लिए यह स्वचालित बनाता है - आपको उन्हें -c से प्रीफ़िक्स करने की आवश्यकता नहीं। शेल हुक द्वारा कवर नहीं किए गए कमांड के लिए स्पष्ट रूप से -c का उपयोग करें।
lean-ctx shell
एक इंटरैक्टिव शेल सत्र शुरू करें जहाँ सभी कमांड आउटपुट कम्प्रेस किए जाते हैं। आपके डिफ़ॉल्ट शेल (zsh, bash या fish) को रैप करता है।
lean-ctx shell
# Now every command output is compressed automatically
git log --oneline -20
docker compose logs
# Exit with Ctrl+D or 'exit' रॉ मोड
जब आपको पूर्ण, अपरिवर्तित आउटपुट चाहिए तो कम्प्रेशन को पूरी तरह छोड़ दें। सक्रिय करने के तीन तरीके:
# CLI flag
lean-ctx -c --raw git log --stat
# Shell function (after lean-ctx init --global)
lean-ctx-raw kubectl get pods -o yaml
# MCP parameter
ctx_shell(command="cat package.json", raw=true)
# Environment variable
LEAN_CTX_RAW=1 lean-ctx -c npm list
# Bypass command - guaranteed zero compression
lean-ctx bypass "git diff HEAD~1"
# Kill-switch: disable ALL compression
LEAN_CTX_DISABLED=1 lean-ctx -c git status lean-ctx bypass "<command>"
गारंटीकृत शून्य संपीड़न के साथ कोई भी कमांड चलाएँ। आंतरिक रूप से कमांड निष्पादित करने से पहले LEAN_CTX_RAW=1 सेट करता है। जब आपको पूर्ण निश्चितता चाहिए कि आउटपुट अपरिवर्तित है, तब इसका उपयोग करें।
lean-ctx bypass "git diff HEAD~1" # guaranteed unmodified output
lean-ctx bypass "docker logs myapp" # no compression, no truncation
lean-ctx bypass "npm audit" # raw vulnerability report सुझाव: bypass LEAN_CTX_RAW=1 lean-ctx -c "command" के समतुल्य है लेकिन अधिक सुविधाजनक है। कमांड स्ट्रिंग सीधे शेल को पास की जाती है।
फ़ाइल ऑपरेशन
lean-ctx की फ़ाइल रीडिंग, खोज और नेविगेशन टूल्स तक सीधी CLI पहुँच। ये वही ऑपरेशन हैं जो MCP सर्वर AI टूल्स को प्रदान करता है।
lean-ctx read <file> [-m <mode>]
वैकल्पिक कम्प्रेशन मोड के साथ फ़ाइल पढ़ें। डिफ़ॉल्ट मोड full है।
lean-ctx read src/main.rs # auto-selects best mode
lean-ctx read src/main.rs -m full # full content (cached)
lean-ctx read src/main.rs -m map # dependency graph + exports
lean-ctx read src/main.rs -m signatures # tree-sitter AST extraction
lean-ctx read src/main.rs -m aggressive # syntax-stripped
lean-ctx read src/main.rs -m entropy # Shannon entropy filtered
lean-ctx read src/main.rs -m diff # changed lines only
lean-ctx read src/main.rs -m task # IB-filtered for current task
lean-ctx read src/main.rs -m reference # cross-reference context
lean-ctx read src/main.rs -m lines:10-50 # specific line range
lean-ctx read src/main.rs -m lines:10-50,80 # multiple ranges lean-ctx diff <file1> <file2>
संरचित परिवर्तन सारांश के साथ दो फ़ाइलों के बीच संपीड़ित diff।
lean-ctx diff old.rs new.rs lean-ctx grep <pattern> [path]
संपीड़ित, समूहीकृत परिणामों के साथ फ़ाइल सामग्री खोजें। आंतरिक रूप से ripgrep का उपयोग करता है।
lean-ctx grep "pub fn" src/
lean-ctx grep "TODO" .
lean-ctx grep "async fn.*Result" rust/src/ lean-ctx find <pattern> [path]
नाम पैटर्न से फ़ाइलें खोजें। .gitignore का सम्मान करता है और एक संक्षिप्त फ़ाइल ट्री आउटपुट करता है।
lean-ctx find "*.rs" src/
lean-ctx find "test_*" . lean-ctx ls [path]
फ़ाइल गणना के साथ ट्री मैप के रूप में संक्षिप्त डायरेक्टरी लिस्टिंग।
lean-ctx ls
lean-ctx ls src/components/ lean-ctx deps [path]
प्रोजेक्ट डिपेंडेंसी ग्राफ़ दिखाएँ। पैकेज मैनेजर पहचानता है और डिपेंडेंसी निकालता है।
lean-ctx deps .
lean-ctx deps frontend/ रीड मोड
रीड मोड नियंत्रित करते हैं कि lean-ctx read और MCP टूल ctx_read फ़ाइल सामग्री को कैसे कम्प्रेस करते हैं। अपने उपयोग के लिए सही मोड चुनें:
| मोड | आउटपुट | उपयोग का मामला | Savings |
|---|---|---|---|
auto | कॉन्टेक्स्ट के लिए सबसे अच्छा मोड | कोई मोड न देने पर डिफ़ॉल्ट - lean-ctx सर्वोत्तम स्ट्रेटेजी चुनता है | 60–95% |
full | पूर्ण फ़ाइल सामग्री | जिन फ़ाइलों को आप संपादित करेंगे। पुनः पढ़ने की लागत ~13 टोकन (कैश्ड)। | 0% (पहली बार पढ़ना), ~99% (कैश्ड) |
map | डिपेंडेंसी ग्राफ़ + एक्सपोर्ट + मुख्य सिग्नेचर | केवल-संदर्भ फ़ाइलें - सब कुछ पढ़े बिना संरचना समझें। | 90–98% |
signatures | tree-sitter AST एक्सट्रैक्शन (18 भाषाएँ) | केवल API सतह - फ़ंक्शन/मेथड/क्लास सिग्नेचर। | 92–99% |
aggressive | सिंटैक्स-हटाई गई सामग्री | तर्क संरक्षित करते हुए अधिकतम कम्प्रेशन। | 85–95% |
entropy | Shannon एन्ट्रॉपी + Jaccard फ़िल्टरिंग | केवल सूचना-सघन पंक्तियाँ रखें। | 70–90% |
diff | केवल बदली हुई पंक्तियाँ (अंतिम पढ़ने की तुलना में) | संपादन के बाद - केवल देखें कि क्या बदला। | 90–99% |
task | टास्क-फ़िल्टर्ड कंटेंट | वर्तमान इरादे के आधार पर IB-स्कोरड एक्सट्रैक्शन - सिर्फ सक्रिय टास्क से संबंधित कोड | 70–90% |
reference | क्रॉस-रेफरेंस कॉन्टेक्स्ट | टार्गेट सिंबल/फ़ंक्शन के लिए संबंधित टाइप्स, कॉलर्स और डिपेंडेंसीज़ | 60–85% |
lines:N-M | विशिष्ट पंक्ति श्रेणियाँ | केवल वह अनुभाग पढ़ें जो आपको चाहिए। एकाधिक श्रेणियों का समर्थन करता है: lines:10-50,80-100 | varies |
signatures मोड के लिए समर्थित भाषाएँ: TypeScript, JavaScript, Rust, Python, Go, Java, C, C++, Ruby, C#, Kotlin, Swift, PHP (tree-sitter के माध्यम से कुल 14)।
सेटअप और कॉन्फ़िगरेशन
lean-ctx setup
एक-कमांड सेटअप। आपका शेल (zsh/bash/fish/PowerShell) स्वचालित रूप से पहचानता है, इंस्टॉल किए गए AI टूल्स खोजता है, और MCP सर्वर + शेल हुक कॉन्फ़िगर करता है। lean-ctx इंस्टॉल करने के बाद एक बार चलाएँ।
lean-ctx setup यह आंतरिक रूप से तीन चरण चलाता है:
- शेल एलियास इंस्टॉल करता है (
init --global) - प्रत्येक पहचाने गए AI टूल के लिए MCP कॉन्फ़िगर करता है
- सब कुछ काम करता है इसकी पुष्टि करता है (
doctor)
Since v3.3.3, the setup wizard includes a Premium Features step where you can configure Terse Agent Mode, Tool Result Archive, and Output Density interactively.
lean-ctx init [--global | <shell>]
अपने शेल प्रोफ़ाइल में शेल कम्प्रेशन एलियास इंस्टॉल करें।
# File-based: writes aliases directly into your shell profile
lean-ctx init # install for current shell
lean-ctx init --global # same, explicit flag
# Eval-based: prints hook code to stdout (like starship, zoxide, atuin)
eval "$(lean-ctx init bash)" # bash: add to ~/.bashrc
eval "$(lean-ctx init zsh)" # zsh: add to ~/.zshrc
lean-ctx init fish | source # fish: add to config.fish
lean-ctx init powershell | Invoke-Expression # PowerShell: add to $PROFILE यह ~/.zshrc, ~/.bashrc, ~/.config/fish/config.fish, या आपके PowerShell प्रोफ़ाइल में एक ब्लॉक लिखता है। ब्लॉक में git, docker, npm, cargo और 95+ अन्य कमांड के लिए एलियास शामिल हैं।
eval पैटर्न: eval मेथड hook कोड को stdout पर प्रिंट करता है, यह सुनिश्चित करते हुए कि यह हमेशा इंस्टॉल किए गए बाइनरी संस्करण से मेल खाता है। यह starship, zoxide और atuin द्वारा उपयोग किया जाने वाला वही पैटर्न है। अपग्रेड के बाद hook कभी पुराने नहीं होते।
lean-ctx init --agent <name>
पूर्ण सेटअप चलाए बिना किसी विशिष्ट AI टूल के लिए MCP कॉन्फ़िगर करें।
| Agent | Notes |
|---|---|
cursor | Cursor IDE (default MCP setup) |
claude | Claude Code / Claude Desktop |
codex | OpenAI Codex CLI |
gemini | Google Gemini CLI |
antigravity | Alias for gemini |
windsurf | Windsurf IDE |
copilot | GitHub Copilot |
cline | Cline (VS Code extension) |
roo | Roo Code |
aider | Aider CLI |
continue | Continue.dev |
zed | Zed Editor |
void | Void Editor |
amp | Amp (Sourcegraph) |
trae | Trae IDE |
kilo | Kilo Code |
opencode | OpenCode CLI |
pi | Installs pi-lean-ctx npm package |
custom | Generic MCP config - prompts for path |
lean-ctx init --agent cursor
lean-ctx init --agent claude
lean-ctx init --agent codex
lean-ctx init --agent gemini
lean-ctx init --agent antigravity # alias for gemini
lean-ctx init --agent windsurf
lean-ctx init --agent copilot
lean-ctx init --agent cline
lean-ctx init --agent roo
lean-ctx init --agent aider
lean-ctx init --agent continue
lean-ctx init --agent zed
lean-ctx init --agent void
lean-ctx init --agent amp
lean-ctx init --agent trae
lean-ctx init --agent kilo
lean-ctx init --agent opencode
lean-ctx init --agent pi # installs pi-lean-ctx npm package
lean-ctx init --agent custom # generic MCP config lean-ctx config [set <key> <value>]
~/.lean-ctx/config.toml पर संग्रहीत कॉन्फ़िगरेशन दिखाएँ या संपादित करें।
lean-ctx config # show current config
lean-ctx config set ultra_compact true # enable ultra-compact mode
lean-ctx config set tee_on_error true # log errors to ~/.lean-ctx/tee/
lean-ctx config set checkpoint_interval 20 Settable Configuration Keys
| Key | Type | Default | Description |
|---|---|---|---|
ultra_compact | bool | false | Enable ultra-compact output mode for maximum token savings |
tee_mode | string | "off" | Tee logging mode: off, on_error, always |
checkpoint_interval | int | 15 | Number of MCP calls between automatic checkpoints |
theme | string | "default" | Dashboard and TUI theme (default, dark, light, neon) |
slow_command_threshold_ms | int | 5000 | Threshold in milliseconds for slow-log entries |
passthrough_urls | string[] | [] | URL patterns that bypass compression (comma-separated) |
rules_scope | string | "project" | Scope for rules loading: project, global, or both |
lean-ctx config set theme neon
lean-ctx config set slow_command_threshold_ms 3000
lean-ctx config set passthrough_urls "localhost:3000,api.example.com"
lean-ctx config set rules_scope both lean-ctx doctor
8 इंस्टॉलेशन और पर्यावरण डायग्नोस्टिक्स चलाएँ:
- बाइनरी इंस्टॉल और PATH में है
- शेल हुक सक्रिय
- पहचाने गए संपादकों के लिए MCP कॉन्फ़िग
- स्टैट्स फ़ाइल स्थायित्व
- कैश डायरेक्टरी
- समर्थित शेल पहचाना गया
- AI टूल डिटेक्शन
- वर्शन जाँच
- Rules injection status
- Claude Code instructions (rules + skill installed)
- Build integrity verification
lean-ctx doctor lean-ctx update [--check]
GitHub Releases से lean-ctx बाइनरी को सेल्फ-अपडेट करें।
lean-ctx update # download and install latest version
lean-ctx update --check # check if a newer version is available (no install) lean-ctx login <email> [--password <pw>] v3.3.3
Authenticate with LeanCTX Cloud. Only attempts login - does not create a new account. If password is omitted, prompts interactively.
lean-ctx login user@example.com
lean-ctx login user@example.com --password mypassword
On success, saves the API key to ~/.lean-ctx/cloud/credentials.json and syncs
your data. If your email is not yet verified, you'll receive a reminder to check your inbox.
lean-ctx register <email> [--password <pw>] v3.3.3
Create a new LeanCTX Cloud account. Separate from login - no auto-fallback.
A verification email is sent after registration.
lean-ctx register user@example.com
lean-ctx register user@example.com --password mypassword lean-ctx forgot-password <email>
Request a password reset email for an existing LeanCTX Cloud account.
lean-ctx forgot-password user@example.com lean-ctx uninstall
सभी lean-ctx कॉन्फ़िगरेशन हटाएँ: शेल हुक, सभी संपादकों से MCP कॉन्फ़िग, और ~/.lean-ctx/ डेटा डायरेक्टरी। बाइनरी हटाने के निर्देश प्रिंट करता है।
lean-ctx uninstall एनालिटिक्स और डैशबोर्ड
स्क्रीनशॉट और व्याख्याओं के साथ विस्तृत गाइड के लिए, एनालिटिक्स गाइड देखें।
lean-ctx gain [flags]
आजीवन टोकन बचत दिखाने वाला विज़ुअल टर्मिनल डैशबोर्ड।
GainEngine द्वारा संचालित - एक यूनिफ़ाइड ऑब्ज़र्वेबिलिटी API जो कम्प्रेशन मेट्रिक्स, कॉस्ट ट्रैकिंग और सेशन एनालिटिक्स को एक GainScore (0–100) में समेटता है। इसमें एम्बेडेड ModelPricing (नेटवर्क नहीं चाहिए) और 13 कैटेगरी वाला TaskClassifier है।
| फ़्लैग | आउटपुट |
|---|---|
(none) | पूर्ण डैशबोर्ड: कुल बचत, दर, USD, शीर्ष कमांड, स्पार्कलाइन |
--score | GainScore (0–100): कम्प्रेशन रेशियो, कॉस्ट एफिशिएंसी, क्वालिटी और कंसिस्टेंसी का संयुक्त स्कोर |
--cost | एम्बेडेड प्राइसिंग के साथ मॉडल-वार कॉस्ट ब्रेकडाउन ( --model=<name> फ़िल्टर सपोर्ट ) |
--tasks | 13 कैटेगरी में टास्क क्लासिफ़िकेशन ब्रेकडाउन (file-ops, search, shell, memory, आदि) |
--agents | मल्टी-एजेंट सेशन्स में प्रति-एजेंट आँकड़े (calls, tokens, cost attribution) |
--heatmap | फ़ाइल एक्सेस हीटमैप - AI सबसे ज़्यादा कौन-सी फाइलें पढ़ता है |
--wrapped | Spotify Wrapped-स्टाइल सेशन समरी ( --period=week|month|all सपोर्ट ) |
--deep | कंबाइंड डीप-डाइव: report + tasks + cost + agents + heatmap एक ही आउटपुट में |
--live | ऑटो-रिफ़्रेशिंग मोड (हर 2s में अपडेट)। छोड़ने के लिए q दबाएँ। |
--graph | दैनिक बार के साथ 30-दिन बचत चार्ट |
--daily | टोकन गणना और USD के साथ दिन-दर-दिन तालिका |
--pipeline | Pipeline-view: shows compression stages and per-stage token savings |
--json | सभी आँकड़ों का कच्चा JSON एक्सपोर्ट (स्क्रिप्टिंग/ऑटोमेशन के लिए) |
मॉडिफ़ायर्स
| फ़्लैग | आउटपुट |
|---|---|
--model=<name> | किसी खास मॉडल पर फ़िल्टर करें (जैसे --model=claude-4-sonnet) |
--period=<p> | टाइम विंडो: today, week, month, all (डिफ़ॉल्ट: all) |
--limit=<n> | रैंक्ड टेबल्स में अधिकतम रोज़ (डिफ़ॉल्ट: 10) |
--reset | सभी स्टैट्स साफ़ करें और नई शुरुआत करें |
lean-ctx gain # overview with GainScore
lean-ctx gain --score # GainScore breakdown
lean-ctx gain --cost --model=claude-4-sonnet # cost for specific model
lean-ctx gain --tasks # task classification heatmap
lean-ctx gain --agents # multi-agent cost attribution
lean-ctx gain --deep # full deep-dive report
lean-ctx gain --wrapped --period=week # weekly summary
lean-ctx gain --live # real-time monitoring
lean-ctx gain --graph # ASCII savings graph
lean-ctx gain --daily # daily breakdown
lean-ctx gain --pipeline # per-stage compression breakdown
lean-ctx gain --json > stats.json # machine-readable export ctx_gain MCP टूल वही एनालिटिक्स प्रोग्रामेटिकली देता है - एजेंट सेशन के दौरान token savings, cost breakdowns और GainScore क्वेरी कर सकते हैं। देखें MCP Tools Reference।
lean-ctx cep [--json]
CEP (Cognitive Efficiency Protocol) प्रभाव रिपोर्ट जो स्कोर ट्रेंड, कैश हिट दर और मोड वितरण दिखाती है।
Internally uses ctx_gain --score to compute the Context Efficiency Protocol score.
The CEP score ranges from 0–100 and measures how efficiently context is being utilized across
read modes, shell compression, and deduplication.
| Flag | Description |
|---|---|
(none) | Pretty-print CEP score with breakdown |
--json | Machine-readable JSON output |
lean-ctx cep # show CEP score with breakdown
lean-ctx cep --json # JSON output for CI/CD integration lean-ctx dashboard [--port=N] [--project=<path>]
http://localhost:3333 पर इंटरैक्टिव वेब डैशबोर्ड खोलें। इंटरैक्टिव चार्ट, सत्र इतिहास, सक्रिय एजेंट और प्रोजेक्ट ज्ञान पैनल शामिल हैं।
| Flag | Description |
|---|---|
--port=<N> | Custom port (default: 3333) |
--project=<path> | Scope dashboard to a specific project directory instead of the global view |
lean-ctx dashboard # opens at localhost:3333
lean-ctx dashboard --port=8080 # custom port
lean-ctx dashboard --project=~/my-app # scoped to a single project lean-ctx wrapped [--week|--month|--all]
अपनी टोकन बचत का साझा करने योग्य "Wrapped" रिपोर्ट कार्ड जनरेट करें।
| फ़्लैग | अवधि |
|---|---|
(none) | वर्तमान सप्ताह |
--week | वर्तमान सप्ताह (स्पष्ट) |
--month | वर्तमान माह |
--all | आजीवन आँकड़े |
lean-ctx wrapped
lean-ctx wrapped --month
lean-ctx wrapped --all सत्र प्रबंधन
lean-ctx sessions [list|show|cleanup]
~/.lean-ctx/sessions/ पर संग्रहीत CCP (Context Continuity Protocol) सत्र प्रबंधित करें।
| सबकमांड | क्रिया |
|---|---|
list | सभी सहेजे गए सत्रों की सूची |
show | नवीनतम सत्र स्थिति दिखाएँ |
cleanup | पुराने/बासी सत्र हटाएँ |
lean-ctx sessions list
lean-ctx sessions show
lean-ctx sessions cleanup lean-ctx session
अपनाने के आँकड़े दिखाएँ - आपके वर्कफ़्लो का कितना हिस्सा lean-ctx कम्प्रेशन का उपयोग करता है।
lean-ctx session ज्ञान प्रबंधन
स्थायी प्रोजेक्ट ज्ञान भंडार तक पूर्ण CLI पहुँच। तथ्य, पैटर्न और परंपराएँ सत्रों के बीच बनी रहती हैं और संचयी प्रोजेक्ट समझ को सक्षम करती हैं।
lean-ctx knowledge remember <value> --category <c> --key <k>
वैकल्पिक विश्वास स्कोर के साथ प्रोजेक्ट ज्ञान आधार में तथ्य संग्रहीत करें।
lean-ctx knowledge remember "Uses JWT for auth" --category auth --key token-type
lean-ctx knowledge remember "PostgreSQL 16" --category arch --key database --confidence 0.95 lean-ctx knowledge recall [query] [--category <c>] [--mode auto|semantic|hybrid]
क्वेरी टेक्स्ट या श्रेणी के आधार पर तथ्य पुनर्प्राप्त करें। एम्बेडिंग सक्षम होने पर सिमेंटिक रिकॉल का समर्थन करता है।
lean-ctx knowledge recall "authentication"
lean-ctx knowledge recall --category security
lean-ctx knowledge recall "auth" --mode semantic lean-ctx knowledge search <query>
सभी प्रोजेक्ट और सत्रों में मिलान करने वाले तथ्यों की खोज करें।
lean-ctx knowledge search "database migration" lean-ctx knowledge export [--format json|jsonl|simple] [--output <path>]
प्रोजेक्ट ज्ञान आधार निर्यात करें। डिफ़ॉल्ट रूप से stdout पर आउटपुट (पाइप-अनुकूल)। तीन फ़ॉर्मैट: json (पूर्ण नेटिव, डिफ़ॉल्ट), jsonl (प्रति पंक्ति एक तथ्य), simple (अन्य टूल से माइग्रेशन के लिए समुदाय-संगत ऐरे)।
lean-ctx knowledge export # full JSON to stdout
lean-ctx knowledge export --format jsonl --output backup.jsonl # JSONL to file
lean-ctx knowledge export --format simple | jq '.[].key' # pipe-friendly lean-ctx knowledge import <path> [--merge replace|append|skip-existing] [--dry-run]
JSON, JSONL, या नेटिव एक्सपोर्ट फ़ाइल से तथ्य आयात करें। इनपुट फ़ॉर्मैट स्वतः पहचानता है। डिफ़ॉल्ट मर्ज रणनीति skip-existing है (सुरक्षित — कभी ओवरराइट नहीं करता)।
lean-ctx knowledge import backup.json --dry-run # preview changes
lean-ctx knowledge import facts.jsonl --merge replace # overwrite existing
lean-ctx knowledge import migration.json --merge skip-existing lean-ctx knowledge remove --category <c> --key <k>
ज्ञान आधार से एक विशिष्ट तथ्य हटाएँ।
lean-ctx knowledge remove --category auth --key token-type lean-ctx knowledge status
ज्ञान आधार का सारांश दिखाएँ — तथ्य संख्या, श्रेणियाँ, और अंतिम अपडेट समय।
lean-ctx knowledge status lean-ctx knowledge health
गुणवत्ता मेट्रिक्स, पुराने तथ्यों की पहचान, और रूम बैलेंस के साथ स्वास्थ्य रिपोर्ट।
lean-ctx knowledge health बेंचमार्किंग
lean-ctx benchmark run [path] [--json]
tiktoken (o200k_base) का उपयोग करके अपनी प्रोजेक्ट फ़ाइलों पर वास्तविक टोकन बेंचमार्क चलाएँ। हर फ़ाइल में प्रत्येक रीड मोड के लिए सटीक बचत मापता है।
lean-ctx benchmark run # benchmark current directory
lean-ctx benchmark run src/ # benchmark specific path
lean-ctx benchmark run . --json # output as JSON lean-ctx benchmark report [path]
बेंचमार्क परिणामों से साझा करने योग्य Markdown रिपोर्ट जनरेट करें।
lean-ctx benchmark report # generate report for current directory
lean-ctx benchmark report src/ > BENCHMARK.md Tee और फ़िल्टर
lean-ctx tee [list|clear|show <file>|last]
~/.lean-ctx/tee/ पर सहेजी गई पूर्ण आउटपुट tee फ़ाइलें प्रबंधित करें। सबसे हाल का सहेजा गया आउटपुट देखने के लिए lean-ctx tee last का उपयोग करें। tee_mode के माध्यम से कॉन्फ़िगर करें: always, failures, या never।
lean-ctx filter [list|validate|init]
~/.lean-ctx/filters/*.toml में कस्टम कम्प्रेशन फ़िल्टर प्रबंधित करें।
# Create example filter
lean-ctx filter init
# List loaded filters
lean-ctx filter list
# Validate filter syntax
lean-ctx filter validate यूटिलिटी
lean-ctx discover
उन कमांड्स के लिए अपना शेल इतिहास स्कैन करें जो कम्प्रेशन से लाभान्वित हो सकते हैं लेकिन इंटरसेप्ट नहीं किए जा रहे। प्रति-कमांड टोकन अनुमान और USD बचत प्रक्षेपण दिखाता है।
lean-ctx discover lean-ctx ghost [--json]
Reveals hidden token waste in your workflow - shows unoptimized shell commands, redundant reads,
and oversized contexts with a monthly USD savings estimate. Use --json for CI integration.
lean-ctx ghost
lean-ctx ghost --json lean-ctx cheatsheet
अपने टर्मिनल में सीधे सभी कमांड और वर्कफ़्लो की एक संक्षिप्त चीट शीट प्रिंट करें।
lean-ctx cheatsheet lean-ctx tee [list|clear|show <file>]
~/.lean-ctx/tee/ पर संग्रहीत एरर लॉग फ़ाइलें प्रबंधित करें। जब कॉन्फ़िग में tee_on_error सक्षम हो, विफल कमांड अपना पूर्ण आउटपुट यहाँ लॉग करते हैं।
| सबकमांड | क्रिया |
|---|---|
list | सभी एरर लॉग फ़ाइलों की सूची |
clear | सभी एरर लॉग हटाएँ |
show <file> | एक विशिष्ट एरर लॉग प्रदर्शित करें |
lean-ctx tee list
lean-ctx tee show 2026-03-29_10-30.log
lean-ctx tee clear lean-ctx slow-log [list|clear]
~/.lean-ctx/slow-commands.log पर धीमी कमांड लॉग दिखाएँ या साफ़ करें। अपेक्षा से अधिक समय लेने वाले कमांड डिबगिंग के लिए यहाँ लॉग किए जाते हैं।
lean-ctx slow-log list
lean-ctx slow-log clear प्रोजेक्ट Graph
प्रोजेक्ट का dependency graph बनाएं या जांचें। Graph फ़ाइल संबंधों (imports, exports, सिंबल) को इंडेक्स करता है और heat-ranking, इंटेंट विश्लेषण और स्मार्ट प्रीलोडिंग के लिए उपयोग किया जाता है।
lean-ctx graph build
प्रोजेक्ट डायरेक्टरी को स्कैन करें और dependency graph इंडेक्स बनाएं। MCP टूल्स का उपयोग करते समय graph स्वचालित रूप से भी बनाया जाता है।
lean-ctx graph build कॉन्टेक्स्ट Heat Map
फ़ाइल token घनत्व और dependency graph कनेक्टिविटी को रंग-कोडित heat map के रूप में विज़ुअलाइज़ करें। उच्च token गणना और अधिक कनेक्शन वाली फ़ाइलें अधिक गर्म दिखाई देती हैं।
lean-ctx heatmap
वर्तमान प्रोजेक्ट की सभी फ़ाइलों का टर्मिनल heat map प्रदर्शित करें, हीट स्कोर (token गणना और graph कनेक्टिविटी का संयोजन) के अनुसार क्रमबद्ध।
lean-ctx heatmap सुरक्षा स्तर
LeanCTX प्रत्येक समर्थित कमांड को एक सुरक्षा स्तर में वर्गीकृत करता है जो निर्धारित करता है कि आउटपुट कितनी आक्रामक रूप से संपीड़ित होता है। उच्च स्तर कभी भी सुरक्षा-महत्वपूर्ण जानकारी (त्रुटियाँ, CVE, स्वास्थ्य स्थिति) को नहीं हटाते।
lean-ctx safety-levels
एक विस्तृत तालिका प्रदर्शित करता है जो दिखाती है कि प्रत्येक कमांड प्रकार कैसे संपीड़ित होता है, कौन सा डेटा संरक्षित रहता है और कौन सी वैश्विक सुरक्षा सुविधाएँ सक्रिय हैं।
lean-ctx safety-levels | स्तर | कमांड | व्यवहार |
|---|---|---|
VERBATIM | df, git status, git stash, ls, find, wc, env | शून्य संपीड़न। आउटपुट पूरी तरह से अपरिवर्तित गुजरता है। |
MINIMAL | git diff, git log, docker ps, grep, ruff, npm audit, pytest, pip, curl | केवल हल्की फ़ॉर्मेटिंग। सभी सुरक्षा-महत्वपूर्ण डेटा (कोड diff, त्रुटि विवरण, CVE ID, स्वास्थ्य स्थिति) पूरी तरह से संरक्षित रहता है। |
STANDARD | cargo build, npm install, eslint, tsc, go build, maven, gradle, dotnet | संरचित संपीड़न। त्रुटियाँ, चेतावनियाँ और कार्रवाई योग्य आइटम हमेशा संरक्षित रहते हैं। |
AGGRESSIVE | kubectl describe, aws, terraform, docker images | विस्तृत आउटपुट के लिए भारी संपीड़न। फिर भी त्रुटि संदेश और सुरक्षा-महत्वपूर्ण कीवर्ड संरक्षित रहते हैं। |
वैश्विक सुरक्षा सुविधाएँ सभी स्तरों पर लागू होती हैं: सेफ्टी-नीडल स्कैन (CRITICAL, FATAL, panic, CVE-*, OOMKilled आदि को संरक्षित करता है), सुरक्षा अनुपात (>95% संपीड़न को रोकता है), प्रमाणीकरण पहचान (टोकन/पासवर्ड को मास्क करता है) और न्यूनतम टोकन सीमा (50 टोकन से कम पर कोई संपीड़न नहीं)।
शेल एलियास
lean-ctx init --global चलाने के बाद, ये एलियास आपके शेल में उपलब्ध हैं। ये आपको पुनरारंभ किए बिना कम्प्रेशन चालू और बंद करने देते हैं:
| एलियास | क्रिया |
|---|---|
lean-ctx-on | सभी कम्प्रेशन एलियास सक्षम करें |
lean-ctx-off | कम्प्रेशन अक्षम करें (मानव-पठनीय आउटपुट) |
lean-ctx-status | दिखाएँ कि कम्प्रेशन वर्तमान में सक्रिय है या नहीं |
lean-ctx-raw <cmd> | कम्प्रेशन के बिना एक कमांड चलाएँ |
lean-ctx-status # check current state
lean-ctx-off # temporarily disable for human reading
git log # now shows full, uncompressed output
lean-ctx-on # re-enable for AI sessions कब अक्षम करें: जब आप कमांड आउटपुट स्वयं पढ़ना चाहते हैं (डिबगिंग, लॉग समीक्षा) तब कम्प्रेशन बंद करें। AI कोडिंग सत्र शुरू करने से पहले इसे वापस चालू करें।
Server & Services
lean-ctx can run as a long-lived HTTP server, a TUI watcher, or a network proxy. These modes are useful for CI/CD pipelines, multi-agent orchestration, and headless environments.
lean-ctx serve [flags] feature: http-server
Start an HTTP/REST server that exposes all MCP tools as REST endpoints.
Requires the http-server feature gate.
Supports both stateful (session-persisted) and stateless modes.
| Flag | Default | Description |
|---|---|---|
--port=<N> | 9119 | Port to listen on |
--host=<addr> | 127.0.0.1 | Bind address (0.0.0.0 for all interfaces) |
--stateless | off | Disable session persistence - each request is independent |
--rate-limit=<N> | 100 | Max requests per minute per client |
--timeout=<ms> | 30000 | Request timeout in milliseconds |
--cors | off | Enable CORS headers for browser access |
# Start server with defaults
lean-ctx serve
# Public-facing with rate limits
lean-ctx serve --host=0.0.0.0 --port=8080 --rate-limit=50
# Stateless mode for CI/CD
lean-ctx serve --stateless --timeout=60000
# With CORS for web dashboard
lean-ctx serve --cors --port=9119
Once running, all MCP tools are available at POST /v1/tools/<tool_name>.
A health endpoint is at GET /health.
lean-ctx watch
Start lean-ctx in TUI (Terminal UI) mode with a live event bus.
Monitors all MCP activity in real time and writes events to
~/.lean-ctx/events.jsonl for post-hoc analysis.
| Flag | Description |
|---|---|
--filter=<pattern> | Only show events matching the pattern (e.g. ctx_read, error) |
--no-tui | Headless mode - stream events to stdout as JSONL |
lean-ctx watch # full TUI with live event stream
lean-ctx watch --filter=ctx_shell # only shell events
lean-ctx watch --no-tui # headless JSONL to stdout lean-ctx proxy <start|stop|status> feature-gated
Manage the lean-ctx network proxy. When active, the proxy intercepts MCP traffic
and applies compression transparently. Requires the proxy feature gate.
| Subcommand | Description |
|---|---|
start | Start the proxy daemon |
stop | Stop the running proxy |
status | Show proxy status (running/stopped, port, uptime) |
lean-ctx proxy start # start proxy daemon
lean-ctx proxy status # check if proxy is running
lean-ctx proxy stop # stop the proxy Terse Agent
The Terse Agent controls output density for AI agent communication. It persists across sessions and can be toggled at any time. See also the Configuration guide.
lean-ctx terse [lite|full|ultra|off]
Query or set the Terse Agent mode. Without arguments, shows the current mode. With an argument, sets the mode persistently.
| Mode | Description |
|---|---|
off | Terse Agent disabled - standard MCP output |
lite | Light compression: removes boilerplate, keeps structure |
full | Full terse mode: abbreviated keys, minimal whitespace, Fn refs |
ultra | Maximum density: single-line responses, aggressive abbreviation, diff-only |
lean-ctx terse # show current terse mode
lean-ctx terse lite # set to lite mode
lean-ctx terse full # set to full mode
lean-ctx terse ultra # maximum compression
lean-ctx terse off # disable terse agent Token Reports
Generate detailed token usage reports for analysis and cost tracking.
lean-ctx token-report [flags]
Display a comprehensive token usage report for the current or specified project.
Also available as lean-ctx report-tokens (alias).
| Flag | Description |
|---|---|
(none) | Summary report for the current session |
--project=<path> | Report for a specific project directory |
--period=<p> | Time period: today, week, month, all |
--by-tool | Break down usage by MCP tool |
--by-mode | Break down usage by read mode |
--json | Machine-readable JSON output |
lean-ctx token-report # current session summary
lean-ctx token-report --period=week # weekly report
lean-ctx token-report --by-tool --period=month # monthly per-tool breakdown
lean-ctx report-tokens --json > report.json # alias, JSON export Cache Management
Manage the lean-ctx content cache that accelerates repeated reads and avoids redundant compression.
lean-ctx cache <subcommand> [flags]
| Subcommand | Description |
|---|---|
status | Show cache size, hit rate, and entry count |
clear | Clear all cached entries |
invalidate <pattern> | Invalidate cache entries matching a glob pattern |
reset --project=<path> | Reset cache for a specific project only |
lean-ctx cache status # cache stats
lean-ctx cache clear # purge entire cache
lean-ctx cache invalidate "src/**/*.rs" # invalidate Rust files
lean-ctx cache reset --project=~/my-app # reset for one project Gotchas
Manage known gotchas - common pitfalls, edge cases, and warnings that lean-ctx
tracks across your projects. Also available as lean-ctx bugs (alias).
lean-ctx gotchas [list|add|remove|clear]
| Subcommand | Description |
|---|---|
list | Show all tracked gotchas for the current project |
add "<description>" | Add a new gotcha entry |
remove <id> | Remove a gotcha by its ID |
clear | Remove all gotchas for the current project |
lean-ctx gotchas list
lean-ctx gotchas add "ctx_shell timeout on M1 with Docker Rosetta"
lean-ctx gotchas remove 3
lean-ctx bugs list # alias for gotchas list
lean-ctx bugs clear Buddy
The Buddy (also called Pet) is an interactive companion feature that provides contextual tips, encouragement, and session insights. Purely cosmetic and opt-in.
lean-ctx buddy [status|on|off|name <name>]
| Subcommand | Description |
|---|---|
status | Show buddy status and current name |
on | Enable the buddy |
off | Disable the buddy |
name <name> | Give your buddy a custom name |
lean-ctx buddy status # check buddy state
lean-ctx buddy on # enable buddy
lean-ctx buddy name Ferris # name your buddy
lean-ctx pet off # alias - disable buddy कॉन्टेक्स्ट पैकेज
पोर्टेबल कॉन्टेक्स्ट पैकेज बनाएं, प्रबंधित करें, और शेयर करें जो ज्ञान, ग्राफ डेटा, सत्र निष्कर्ष, और गॉचा को वर्शन्ड आर्काइव में बंडल करते हैं।
lean-ctx pack create --name <name> [--layers <layers>]
Create a context package from the current project. Layers default to all available
(knowledge,graph,session,patterns,gotchas).
lean-ctx pack create --name my-pkg
lean-ctx pack create --name api-knowledge --layers knowledge,gotchas
lean-ctx pack create --name full-snapshot --version 2.0.0 lean-ctx pack list
List all installed packages with version and auto-load status.
lean-ctx pack list lean-ctx pack info <name>
Show detailed metadata, layers, stats, and integrity hash for a package.
lean-ctx pack info my-pkg lean-ctx pack export <name> [-o <file>]
Export a package to a portable .lctxpkg file. Default output is <name>.lctxpkg.
lean-ctx pack export my-pkg
lean-ctx pack export my-pkg -o shared/my-pkg.lctxpkg lean-ctx pack import <file>
Import a package from a .lctxpkg file. Verifies SHA-256 integrity before installing.
lean-ctx pack import my-pkg.lctxpkg lean-ctx pack install <name>
Merge a package's context into the current project — knowledge facts, graph nodes, and gotchas.
lean-ctx pack install my-pkg lean-ctx pack remove <name>
Remove a package from the local registry.
lean-ctx pack remove my-pkg lean-ctx pack auto-load <name> <on|off>
Enable or disable auto-loading. When enabled, the package is merged into the project
context automatically when ctx_overview runs at session start.
lean-ctx pack auto-load my-pkg on
lean-ctx pack auto-load my-pkg off Instructions
Manually retrieve MCP server instructions. Useful in headless or non-interactive environments where the MCP handshake does not automatically deliver instructions.
lean-ctx instructions [flags] v3.3.x
| Flag | Description |
|---|---|
(none) | Print current MCP instructions to stdout |
--raw | Output raw instruction text without formatting |
--json | Output as JSON object with metadata |
--inject | Inject instructions into the active agent session |
lean-ctx instructions # print formatted instructions
lean-ctx instructions --raw # raw text for piping
lean-ctx instructions --json # JSON with metadata
lean-ctx instructions --inject # inject into running session This is particularly useful when integrating lean-ctx into CI/CD pipelines or custom agent frameworks that don't support the MCP instructions handshake natively.