Home / Servers

diffctx

by nikolay-e

diffctx — smart diff context for LLM code review

CI PyPI crates.io npm License

diffctx selects the minimum code an LLM needs to review a git diff. Instead of pasting whole files, it walks the dependency graph outward from the changed lines and stops once more context stops paying for itself.

Formerly published as treemapper — every command, flag, and API call works unchanged.

How it compares

Whole-repo packers (repomix and friends) seed on the repository and export everything; persistent code-graph servers answer structural queries against a maintained index. diffctx is diff-seeded: the input is a change, the output is the fragments needed to understand it, packed under a hard token budget — local, deterministic, no index, no model calls. Measured results and when the other two families fit better: COMPARISON.md.

Install

uvx diffctx . --diff HEAD~1             # zero-install, run once via uv
pipx install diffctx                    # recommended: isolated CLI, no venv needed
pip install diffctx                     # or: into an active environment
pipx install 'diffctx[mcp]'             # + MCP server for AI assistants

Without Python:

cargo install diffctx                   # native CLI from crates.io
npx diffctx . --diff HEAD~1             # npm wrapper over the native binary
docker run --rm -v "$PWD:/repo" ghcr.io/nikolay-e/diffctx . --diff HEAD~1

On Windows, via Scoop (this repository is the bucket):

scoop bucket add diffctx https://github.com/nikolay-e/diffctx
scoop install diffctx/diffctx

Prebuilt binaries for linux (x86_64/aarch64), macOS (arm64) and Windows (x64) are attached to every release. The native binary and Docker image cover diff mode with YAML/JSON output and write to stdout (redirect to capture); tree mode, Markdown output, the graph subcommand and the MCP server live in the Python package.

Quick start

diffctx . --diff HEAD~1       # smart context for last commit → paste into Claude/ChatGPT
diffctx . -f md -c            # full codebase export → clipboard in Markdown

diffctx demo

diffctx . --diff HEAD~1 selects only the fragments an LLM needs to review the last commit, instead of dumping every changed file in full.

Diff context mode

Finds the minimal set of fragments needed to understand a change — imports, callers, type definitions, config dependencies — across 50+ file types. It builds a code graph (imports, co-changes, type refs), propagates relevance outward from the changed lines, and stops when relevance drops below --tau or the --budget token cap is hit.

FlagDefaultDescription
--scoringegoego = bounded expansion around changed nodes (fast, predictable radius); ppr = Personalized PageRank (global, smoother decay, slower); bm25 = lexical retrieval against the diff hunks (baseline for sparse graphs); rrf = reciprocal-rank fusion of ego and bm25 (widest recall, no scale calibration between the two signals)
--budgetautoHard cap in o200k_base tokens (see Token counting): N enforces a fixed cap, -1 disables it, 0 is a strict-zero floor (empty select

Related servers

n8n

by n8n-io

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

NOASSERTION198,904

@modelcontextprotocol/server-everything

Official

by modelcontextprotocol

MCP server that exercises all the features of the MCP protocol

89,105

@modelcontextprotocol/server-filesystem

Official

by modelcontextprotocol

MCP server for filesystem access

SEE LICENSE IN LICENSE89,105

mcp-server-fetch

Official

by modelcontextprotocol

A Model Context Protocol server providing tools to fetch and convert web content for usage by LLMs

89,105