为人类设计的命令。
为 AI 优化的结果。
lean-ctx 在设置后自动运行。但当您需要控制时,这些命令随时待命。
核心 命令
lean-ctx setup 一次性设置。自动检测您的 shell(zsh/bash/fish),查找已安装的 AI 工具,配置 MCP 和 shell 钩子。运行一次,永不再操心。
安装后运行一次lean-ctx init 快速设置特定的 AI 工具。使用 --agent cursor、--agent claude、--agent codex 或 --agent gemini 直接为该工具配置 MCP。
lean-ctx gain 查看您的节省仪表板。终身 token 节省量、压缩率、热门命令和美元成本估算。跨会话持久保存。
随时查看监控与 洞察
lean-ctx gain 终身节省仪表板,包含 token 计数、压缩率、热门命令和美元成本追踪。
$ lean-ctx gain
◆ lean-ctx Token Savings Dashboard
────────────────────────────────
1.7M saved 76.8% rate $4.25 USD
Top Commands
curl 48x ████████████ 728K
git 34x ██████ 375K
lean-ctx gain --live 自动刷新的实时仪表板。每 2 秒更新一次,实时显示 AI 工具的 token 节省量。
$ lean-ctx gain --live
◆ lean-ctx LIVE refreshing every 2s
────────────────────────────────
1.7M saved ▁▃█▇██▁█
Session: 42 cmds | 89.2K saved | 94.1% rate
Press q to quit
lean-ctx gain --graph 30 天节省图表,包含每日柱状图、迷你折线图和趋势可视化。查看您的节省轨迹。
$ lean-ctx gain --graph
Token Savings (30 days)
03-20 │ ██████████████████████ 1.0M
03-21 │ ███████████████ 690K
03-22 │ ████████████████████████ 1.1M
03-23 │ █ 9.4K
03-24 │ ██████████████████████ 1.7M
lean-ctx dashboard 在 localhost:3333 上的 Web 仪表板。在浏览器中查看交互式图表、会话历史和实时监控。
$ lean-ctx dashboard
◆ lean-ctx Dashboard
→ http://localhost:3333
Interactive charts, session history, command breakdown
Press Ctrl+C to stop
lean-ctx wrapped 您 token 节省量的 "Spotify Wrapped"。精美的可分享报告,包含终身统计数据、热门命令和个人压缩成就。
$ lean-ctx wrapped monthly
◆ Your March 2026 Wrapped
────────────────────────────────
4.9M tokens saved
3,241 commands compressed
$12.16 USD saved
Top pattern: curl (97% compression)
You're in the top 5% of lean-ctx users
诊断
lean-ctx doctor 运行 8 项安装检查--二进制文件、shell 钩子、MCP 配置、统计文件、cache 目录、支持的 shell、AI 工具检测和版本检查。
✓ Binary installed
✓ Shell hook active (zsh)
✓ MCP config (Cursor)
✓ Stats persistence
✓ Cache directory
✓ Data directory writable
✓ Project detection
✓ Graph index
✓ Search index
✓ Agent hooks
✓ Version up to date
All 11 checks passed
lean-ctx discover 扫描您的 shell 历史记录,找出可以从压缩中受益但尚未被拦截的命令。
Found 12 uncompressed commands:
kubectl - 34 calls, ~89% savings possible
helm - 12 calls, ~76% savings possible
terraform - 8 calls, ~82% savings possible
Run setup to enable these
lean-ctx benchmark run 使用 tiktoken (o200k_base) 测量您代码库中的真实 token 节省量。精确数据,非估算。
src/auth.ts (123 lines)
full: 3,517 → 3,517 (0%)
map: 3,517 → 412 (88%)
signatures: 3,517 → 252 (93%)
entropy: 3,517 → 312 (91%)
高级用户 命令
| 命令 | 描述 |
|---|---|
lean-ctx init --agent <name> | 为特定 AI 工具快速设置 MCP(cursor、claude、codex、gemini、windsurf、copilot、cline、roo、pi、qwen、trae、amazonq、jetbrains) |
lean-ctx read <file> -m <mode> | 以压缩模式读取任意文件(full、map、signatures、diff、aggressive、entropy)。缓存读取返回约13个token。使用--fresh跳过缓存。 |
lean-ctx diff | 压缩的 git diff--结构化输出,附带变更摘要 |
lean-ctx grep <pattern> | token 高效的模式搜索,提供紧凑的上下文 |
lean-ctx find <pattern> | 按名称查找文件--紧凑的结果,附带文件计数 |
lean-ctx ls | 以紧凑树形图显示目录列表 |
lean-ctx -c "<cmd>" | 通过 lean-ctx 压缩任意 shell 命令输出 |
lean-ctx config set <key> <value> | 配置 lean-ctx 设置--检查点间隔、cache TTL、CRP 模式 |
lean-ctx cache [stats|clear|invalidate] | 管理CLI文件缓存 - 查看统计、清除条目或使特定路径失效 |
lean-ctx setup | 一键配置 - 配置 shell hooks、编辑器 MCP 并验证一切正常工作 |