Files
wehub-resource-sync 26382a7ac6
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
JetBrains Plugin / Actionlint (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (rust) (push) Has been cancelled
JetBrains Plugin / Validation (push) Has been cancelled
JetBrains Plugin / Build (push) Has been cancelled
JetBrains Plugin / Test (push) Has been cancelled
Security Check / Security Scan (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:35:30 +08:00

6.6 KiB

lean-ctx vs Repomix

Last updated: May 2026 | Both tools help AI agents understand codebases — but they take fundamentally different approaches.

Overview

lean-ctx Repomix
Approach Live context layer with session memory Snapshot-based codebase packer
GitHub Stars 2,600+ 25,000+
Language Rust (single binary) TypeScript (Node.js)
License Apache 2.0 MIT
MCP Tools 68+ 8
Compression Up to 99% (10 modes, context-aware) ~70% (tree-sitter --compress)

The Core Difference

Repomix packs your entire codebase into a single file (XML, Markdown, or JSON) so you can paste it into an LLM prompt. It's a one-shot snapshot — great for quick questions about a repo you just cloned.

lean-ctx is a persistent context layer that sits between your AI agent and your codebase. It caches reads, compresses shell output in real-time, tracks session state, and builds a knowledge graph across conversations. It doesn't just pack — it understands and remembers.

Feature Comparison

Feature lean-ctx Repomix
File read compression 10 modes (map, signatures, diff, entropy, ...) Tree-sitter extract (--compress)
Token reduction Up to 99% ~70%
Cached re-reads ~13 tokens N/A (re-packs every time)
Shell output compression 95+ patterns (git, npm, cargo, docker, ...) No
Session memory Knowledge graph + temporal facts No
Multi-agent support ctx_agent, ctx_handoff, diary, sync No
Semantic search Hybrid BM25 + dense vector No
Call graph analysis Multi-hop BFS + risk classification No
Blast radius / impact ctx_impact (6 actions) No
Repo-map (PageRank) ctx_repomap (session-aware) No
Repo packing ctx_pack (PR packs, .ctxpkg bundles) Core feature (XML/MD/JSON/Plain)
Remote repo support Via ctx_pack Native (GitHub URLs)
Security scanning PathJail, shell allowlist Secretlint
Observability dashboard Real-time token tracking, budgets No
VS Code extension Planned No
Tree-sitter languages 26 30+
Agent support 28 agents auto-configured Works with any MCP client
Privacy 100% local, no telemetry by default 100% local
Installation Single binary, lean-ctx setup npx repomix or npm install

When to Use Which

Choose Repomix if you...

  • Need to quickly pack a repo and paste it into ChatGPT, Claude, or another web UI
  • Want one-shot codebase context without installing anything (npx repomix)
  • Work primarily with remote GitHub repos you don't have locally
  • Prefer a simple tool that does one thing well

Choose lean-ctx if you...

  • Use AI coding agents daily (Cursor, Claude Code, Codex, Windsurf, ...)
  • Want context to persist across chat sessions
  • Work on medium/large codebases where re-reading files wastes tokens
  • Need shell output compression (git, test runners, build tools)
  • Want semantic search, call graphs, and impact analysis alongside context packing
  • Care about real-time observability of context window usage

Compression: 99% vs 70%

Repomix's --compress flag uses tree-sitter to extract key code elements, achieving approximately 70% token reduction. This is a static, one-pass operation.

lean-ctx offers 10 context-aware read modes that adapt to what the agent actually needs:

# Map mode: dependency graph + exports + key signatures
lean-ctx read src/server/mod.rs -m map        # ~95% reduction

# Signatures: API surface only
lean-ctx read src/server/mod.rs -m signatures # ~98% reduction

# Diff mode: only changed lines (after edits)
lean-ctx read src/server/mod.rs -m diff       # ~99% reduction

# Cached re-read: file hasn't changed
lean-ctx read src/server/mod.rs               # ~13 tokens

The key difference: lean-ctx compression is context-aware. It knows what you've already read, what changed, and what the current task requires. Repomix treats every pack as a fresh snapshot.

Session Memory vs Snapshots

With Repomix, every interaction starts from zero. Pack the repo, feed it to the LLM, get an answer, repeat.

With lean-ctx, the agent builds cumulative knowledge:

# Session 1: Agent discovers architecture
# lean-ctx remembers: "Auth is in src/auth/, uses JWT, depends on user service"

# Session 2: Agent picks up where it left off
# lean-ctx recalls previous findings, decisions, and file context
# No need to re-read and re-analyze the entire codebase

This is especially valuable for multi-day refactoring, debugging sessions, or feature development across multiple chat conversations.

Shell Compression

Repomix focuses exclusively on file content. lean-ctx also compresses shell output — which often dominates context window usage in real coding sessions:

# Raw git status: ~800 tokens
# lean-ctx compressed: ~120 tokens

# Raw npm install output: ~3000 tokens
# lean-ctx compressed: ~200 tokens

# Raw cargo test output: ~2000 tokens
# lean-ctx compressed: ~150 tokens

95+ pattern modules cover git, npm, cargo, docker, kubectl, terraform, and more.

Migration from Repomix

If you're currently using Repomix and want to try lean-ctx:

1. Install lean-ctx

curl -fsSL https://leanctx.com/install.sh | sh
lean-ctx setup

2. Replace repo packing with live context

Instead of:

npx repomix --compress -o context.xml
# Then paste context.xml into your LLM

Use lean-ctx's MCP tools directly from your AI agent:

# Your agent can now call ctx_read, ctx_search, ctx_repomap
# No manual packing needed — context is served on demand

3. For one-shot packing, use ctx_pack

# Pack entire repo (like Repomix, but with lean-ctx compression)
lean-ctx pack create ./my-project -o context.ctxpkg

# Build a PR-focused context pack
lean-ctx pack --pr

4. Keep both

lean-ctx and Repomix don't conflict. You can use Repomix for quick one-off packing and lean-ctx as your daily context layer. They solve different problems at different scales.

Summary

Repomix is an excellent tool for what it does: pack a codebase into an LLM-friendly format. With 25k+ stars, it's proven and well-maintained.

lean-ctx goes further by providing a complete context engineering layer — compression is just one of 72+ tools. If you use AI coding agents daily and want persistent memory, shell compression, semantic search, and real-time observability, lean-ctx is built for that workflow.


Both projects are open source. We encourage you to try both and choose what fits your workflow.

Get started with lean-ctx | Repomix on GitHub