Files
wehub-resource-sync 26382a7ac6
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
JetBrains Plugin / Actionlint (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
CodeQL / Analyze (rust) (push) Waiting to run
JetBrains Plugin / Validation (push) Waiting to run
JetBrains Plugin / Build (push) Waiting to run
JetBrains Plugin / Test (push) Blocked by required conditions
Security Check / Security Scan (push) Waiting to run
CI / Clippy (push) Failing after 15m13s
CI / Test (ubuntu-latest) (push) Failing after 16m1s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Build (no embeddings / no ORT) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Cookbook (Node) (push) Has been cancelled
CI / Pi Extension (Node) (push) Has been cancelled
CI / Rust SDK (lean-ctx-client) (push) Has been cancelled
CI / Embed SDK (lean-ctx-sdk) (push) Has been cancelled
CI / Python SDK (leanctx) (push) Has been cancelled
CI / Hermes Plugin (Python) (push) Has been cancelled
CI / SDK Conformance Matrix (push) Has been cancelled
CI / Coverage (push) Has been cancelled
CI / cargo-deny (push) Has been cancelled
CI / Adversarial Safety (push) Has been cancelled
CI / Benchmarks (push) Has been cancelled
CI / Output-Quality Gate (eval A/B) (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CI / CI Green (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:35:30 +08:00

5.3 KiB

lean-ctx Integration Guides

Step-by-step guides for setting up lean-ctx with your AI coding agent.

Quick Start

All agents follow the same pattern:

# 1. Install lean-ctx
curl -fsSL https://leanctx.com/install.sh | sh

# 2. Connect your AI tools (auto-detects everything installed)
lean-ctx onboard

# 3. Verify
lean-ctx doctor

lean-ctx onboard detects and configures every AI tool on your machine with sensible defaults. Prefer step-by-step control, or only want one specific agent? Use the guided wizard or the per-agent command instead:

lean-ctx setup                  # guided wizard, full control
lean-ctx init --agent cursor    # configure a single agent

Agent Comparison

Agent Integration Shell Hook Rules File Config Format Setup Command
Claude Code Hybrid ~/.claude/CLAUDE.md block + skill ~/.claude.json lean-ctx init --agent claude
Cursor Hybrid ~/.cursor/rules/lean-ctx.mdc Cursor Settings UI lean-ctx init --agent cursor
Aider MCP-only Dedicated .md .aider.conf.yml lean-ctx init --agent aider
Windsurf Hybrid ~/.codeium/windsurf/rules/lean-ctx.md MCP JSON lean-ctx init --agent windsurf
Gemini CLI Hybrid ~/.gemini/GEMINI.md (shared) ~/.gemini/settings.json lean-ctx init --agent gemini
OpenCode Hybrid ~/.config/opencode/AGENTS.md (shared) opencode.json lean-ctx init --agent opencode
Codex CLI Hybrid ~/.codex/instructions.md (shared) ~/.codex/config.toml lean-ctx init --agent codex
Pi Coding Agent Hybrid AGENTS.md Pi Package lean-ctx init --agent pi

Integration Modes

Available for agents with shell access. Combines:

  • MCP tools for file reads and search (cached, compressed)
  • Shell hooks for command output compression (git, npm, cargo, docker, etc.)

MCP-Only Mode

For agents without direct shell access. All 80 tools available via MCP protocol.

What lean-ctx Sets Up

Running lean-ctx init --agent <name> or lean-ctx setup configures:

  1. MCP server registration — adds lean-ctx to the agent's MCP config
  2. Agent rules — injects lean-ctx usage instructions into the agent's rules file
  3. Shell hooks — installs command compression (hybrid mode agents only)
  4. SKILL.md — installs the lean-ctx skill file (supported agents only)

Common Tools Reference

Every agent gets access to the same 81 MCP tools. The most important ones:

Tool Purpose When to Use
ctx_read(path, mode) Read files with 10 compression modes Always — replaces native file reads
ctx_search(pattern, path) Token-efficient code search Finding code patterns
ctx_shell(command) Compressed shell output Running commands via MCP
ctx_overview(task) Fast project orientation Session start
ctx_semantic_search(query) Meaning-based code search Understanding code by concept
ctx_knowledge(action, ...) Persistent knowledge graph Remembering decisions/findings
ctx_session(action, ...) Session state management Task tracking across chats
ctx_compress Memory checkpoint When context grows large
ctx_graph(action) Code relationship graph Impact analysis
ctx_refactor(action, ...) LSP-powered refactoring Rename, references, go-to-definition

Read Modes

All agents use the same mode selection strategy:

Mode Use When Token Savings
full You will edit the file Baseline (cached)
map Context only — deps + exports + key signatures 60-80%
signatures API surface only 70-90%
diff Re-reading after edits 80-95%
aggressive Large files, context only 80-95%
entropy Shannon + Jaccard filtering 70-90%
task Task-relevant filtering 60-80%
lines:N-M Specific line range Varies
reference Quote-friendly excerpts 70-85%
auto Unsure — system selects optimal Varies

Troubleshooting

See the troubleshooting section in each individual guide. Common issues:

# Verify installation
lean-ctx doctor

# Check MCP server status
lean-ctx status

# See real-time token savings
lean-ctx gain --live

# Disable temporarily
lean-ctx-off

# Re-run setup
lean-ctx setup

More Resources