ডকুমেন্টেশন

CLI রেফারেন্স

প্রতিটি lean-ctx কমান্ড, ফ্ল্যাগ এবং রিড মোডের সম্পূর্ণ রেফারেন্স।

এটি প্রতিটি 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'

Raw মোড

যখন আপনার সম্পূর্ণ, অপরিবর্তিত আউটপুট প্রয়োজন তখন কম্প্রেশন সম্পূর্ণ বাদ দিন। তিনটি সক্রিয় করার উপায়:

# 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 token খরচ হয় (cache থেকে)।0% (প্রথম পড়া), ~99% (cache থেকে)
mapডিপেন্ডেন্সি গ্রাফ + এক্সপোর্ট + প্রধান সিগনেচারশুধু কনটেক্সটের ফাইল - সব না পড়ে স্ট্রাকচার বুঝুন।90–98%
signaturestree-sitter AST এক্সট্রাকশন (18টি ভাষা)শুধু API সারফেস - ফাংশন/মেথড/ক্লাস সিগনেচার।92–99%
aggressiveসিনট্যাক্স বাদে বিষয়বস্তুলজিক সংরক্ষণ করে সর্বোচ্চ কম্প্রেশন।85–95%
entropyShannon entropy + Jaccard ফিল্টারিংশুধু তথ্য-ঘন লাইন রাখুন।70–90%
diffশুধু পরিবর্তিত লাইন (শেষ পড়ার তুলনায়)সম্পাদনার পর - শুধু কী পরিবর্তন হয়েছে দেখুন।90–99%
taskটাস্ক-ফিল্টারড কনটেন্টবর্তমান intent অনুযায়ী IB-স্কোরড এক্সট্রাকশন - শুধু অ্যাক্টিভ টাস্কের জন্য প্রাসঙ্গিক কোড70–90%
referenceক্রস-রেফারেন্স কনটেক্সটটার্গেট সিম্বল/ফাংশনের সম্পর্কিত টাইপ, কলার ও ডিপেন্ডেন্সি60–85%
lines:N-Mনির্দিষ্ট লাইন রেঞ্জশুধু আপনার প্রয়োজনীয় অংশ পড়ুন। একাধিক রেঞ্জ সমর্থন করে: lines:10-50,80-100varies

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

এটি অভ্যন্তরীণভাবে তিনটি ধাপ চালায়:

  1. শেল অ্যালায়াস ইনস্টল করে (init --global)
  2. প্রতিটি শনাক্ত AI টুলের জন্য MCP কনফিগার করে
  3. সবকিছু কাজ করছে কিনা যাচাই করে (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 কনফিগার করুন।

AgentNotes
cursorCursor IDE (default MCP setup)
claudeClaude Code / Claude Desktop
codexOpenAI Codex CLI
geminiGoogle Gemini CLI
antigravityAlias for gemini
windsurfWindsurf IDE
copilotGitHub Copilot
clineCline (VS Code extension)
rooRoo Code
aiderAider CLI
continueContinue.dev
zedZed Editor
voidVoid Editor
ampAmp (Sourcegraph)
traeTrae IDE
kiloKilo Code
opencodeOpenCode CLI
piInstalls pi-lean-ctx npm package
customGeneric 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

KeyTypeDefaultDescription
ultra_compactboolfalseEnable ultra-compact output mode for maximum token savings
tee_modestring"off"Tee logging mode: off, on_error, always
checkpoint_intervalint15Number of MCP calls between automatic checkpoints
themestring"default"Dashboard and TUI theme (default, dark, light, neon)
slow_command_threshold_msint5000Threshold in milliseconds for slow-log entries
passthrough_urlsstring[][]URL patterns that bypass compression (comma-separated)
rules_scopestring"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 কনফিগ
  • স্ট্যাটস ফাইল স্থায়িত্ব
  • cache ডিরেক্টরি
  • সমর্থিত শেল শনাক্ত হয়েছে
  • 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]

লাইফটাইম token সাশ্রয় দেখানো ভিজ্যুয়াল টার্মিনাল ড্যাশবোর্ড।

GainEngine দ্বারা চালিত - একটি ইউনিফাইড অবজার্ভেবিলিটি API যা কমপ্রেশন মেট্রিকস, কস্ট ট্র্যাকিং ও সেশন অ্যানালিটিক্সকে এক GainScore (0–100) এ একত্র করে। এতে এমবেডেড ModelPricing (নেটওয়ার্ক লাগে না) এবং 13 ক্যাটাগরির TaskClassifier আছে।

ফ্ল্যাগআউটপুট
(none)সম্পূর্ণ ড্যাশবোর্ড: মোট সাশ্রয়, রেট, USD, শীর্ষ কমান্ড, স্পার্কলাইন
--scoreGainScore (0–100): কমপ্রেশন রেশিও, কস্ট এফিসিয়েন্সি, কোয়ালিটি ও কনসিস্টেন্সি মিলিয়ে
--costএমবেডেড প্রাইসিংসহ মডেল অনুযায়ী কস্ট ব্রেকডাউন ( --model=<name> ফিল্টার সাপোর্ট )
--tasks13 ক্যাটাগরিতে টাস্ক ক্লাসিফিকেশন ব্রেকডাউন (file-ops, search, shell, memory, ইত্যাদি)
--agentsমাল্টি-এজেন্ট সেশনে প্রতি-এজেন্ট স্ট্যাটস (calls, tokens, cost attribution)
--heatmapফাইল অ্যাক্সেস হিটম্যাপ - AI সবচেয়ে বেশি কোন ফাইল পড়ে
--wrappedSpotify Wrapped-স্টাইল সেশন সারাংশ ( --period=week|month|all সাপোর্ট )
--deepকম্বাইন্ড ডিপ-ডাইভ: report + tasks + cost + agents + heatmap এক আউটপুটে
--liveস্বয়ং-রিফ্রেশিং মোড (প্রতি 2 সেকেন্ডে আপডেট)। বন্ধ করতে q চাপুন।
--graphদৈনিক বারসহ 30-দিনের সাশ্রয় চার্ট
--dailytoken সংখ্যা ও USD-সহ দিন-ভিত্তিক টেবিল
--pipelinePipeline-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) প্রভাব রিপোর্ট - স্কোর ট্রেন্ড, cache হিট রেট এবং মোড বিতরণ দেখায়।

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.

FlagDescription
(none)Pretty-print CEP score with breakdown
--jsonMachine-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-এ ইন্টারেক্টিভ ওয়েব ড্যাশবোর্ড খুলুন। ইন্টারেক্টিভ চার্ট, সেশন হিস্ট্রি, সক্রিয় এজেন্ট এবং প্রজেক্ট নলেজ প্যানেল রয়েছে।

FlagDescription
--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]

আপনার token সাশ্রয়ের একটি শেয়ারযোগ্য "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 "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) ব্যবহার করে আপনার প্রজেক্ট ফাইলে প্রকৃত token বেঞ্চমার্ক চালান। প্রতিটি ফাইল জুড়ে প্রতিটি রিড মোডের সঠিক সাশ্রয় পরিমাপ করে।

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

আপনার শেল হিস্ট্রি স্ক্যান করে এমন কমান্ড খোঁজে যা কম্প্রেশন থেকে উপকৃত হতে পারে কিন্তু ইন্টারসেপ্ট হচ্ছে না। প্রতি-কমান্ড token অনুমান এবং 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
স্তরকমান্ডআচরণ
VERBATIMdf, git status, git stash, ls, find, wc, envশূন্য কম্প্রেশন। আউটপুট সম্পূর্ণ অপরিবর্তিত অবস্থায় পাস করে।
MINIMALgit diff, git log, docker ps, grep, ruff, npm audit, pytest, pip, curlশুধুমাত্র হালকা ফর্ম্যাটিং। সমস্ত নিরাপত্তা-সমালোচনামূলক ডেটা (কোড diff, ত্রুটি বিবরণ, CVE ID, স্বাস্থ্য স্থিতি) সম্পূর্ণরূপে সংরক্ষিত।
STANDARDcargo build, npm install, eslint, tsc, go build, maven, gradle, dotnetকাঠামোবদ্ধ কম্প্রেশন। ত্রুটি, সতর্কতা এবং কার্যকরযোগ্য আইটেম সর্বদা সংরক্ষিত।
AGGRESSIVEkubectl 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.

FlagDefaultDescription
--port=<N>9119Port to listen on
--host=<addr>127.0.0.1Bind address (0.0.0.0 for all interfaces)
--statelessoffDisable session persistence - each request is independent
--rate-limit=<N>100Max requests per minute per client
--timeout=<ms>30000Request timeout in milliseconds
--corsoffEnable 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.

FlagDescription
--filter=<pattern>Only show events matching the pattern (e.g. ctx_read, error)
--no-tuiHeadless 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.

SubcommandDescription
startStart the proxy daemon
stopStop the running proxy
statusShow 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.

ModeDescription
offTerse Agent disabled - standard MCP output
liteLight compression: removes boilerplate, keeps structure
fullFull terse mode: abbreviated keys, minimal whitespace, Fn refs
ultraMaximum 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).

FlagDescription
(none)Summary report for the current session
--project=<path>Report for a specific project directory
--period=<p>Time period: today, week, month, all
--by-toolBreak down usage by MCP tool
--by-modeBreak down usage by read mode
--jsonMachine-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]

SubcommandDescription
statusShow cache size, hit rate, and entry count
clearClear 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]

SubcommandDescription
listShow all tracked gotchas for the current project
add "<description>"Add a new gotcha entry
remove <id>Remove a gotcha by its ID
clearRemove 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>]

SubcommandDescription
statusShow buddy status and current name
onEnable the buddy
offDisable 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

Context Packages

বহনযোগ্য কনটেক্সট প্যাকেজ তৈরি, পরিচালনা এবং শেয়ার করুন যা জ্ঞান, গ্রাফ ডেটা, সেশন আবিষ্কার এবং সমস্যাসমূহকে ভার্সনড আর্কাইভে বান্ডেল করে।

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

FlagDescription
(none)Print current MCP instructions to stdout
--rawOutput raw instruction text without formatting
--jsonOutput as JSON object with metadata
--injectInject 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.