diffctx is a Git diff context tool for LLMs and AI agents. Its goal is not just to show the changes themselves, but to answer "what exactly does a Git change touch, and what code is needed to understand it."
Purpose diffctx is used to provide agents or code reviewers with context beyond the change diff, including: the callers of that change, the tests that can reach those callers, and the interface contracts it crosses. On this basis, the tool selects the minimum code snippets necessary to understand the change within a given token budget.
Main capabilities
- Diff as seed: the input is a code change, and the output is what it touches and the code needed to explain those things.
- Budgeted snippet selection: selects code snippets under a token budget constraint.
- Deterministic: the output is deterministic and easy to reproduce.
- Runs locally, requires no index, and makes no model calls.
- Caller resolution is static and language-specific; when it cannot resolve, it says so explicitly instead of outputting a zero value.
- Built-in MCP server.
- Provides a Python API.
How to use
- Installation: supports pipx, pip, cargo, npm, Docker, Scoop, etc., and can be integrated with other MCP clients and the Python API.
- --diff argument: accepts a Git range, the staging area (staged), or a time window up to the present (for example, 24h, 90min, 2w).
- Command-line reference: fully documents every argument, default value, and exit code.
- Provides a GitHub Action that can run diff context as a CI step.
- Token counting: supports token budgets for non-GPT models via --budget.
Comparison with the previous two types of tools Whole-repository packaging tools export everything; code graph servers answer queries against a maintained index. diffctx is "diff as seed": the input is a change, and the output is what it touches and its explanation. Relevant measurement results and applicable scenario descriptions can be found in COMPARISON.md.
Compatibility and renaming The tool was previously released under the name treemapper; after the rename, every command, argument, and API call remains unchanged.
Applicable scenarios Suitable for development workflows that need to automatically supplement change context for AI agents or code reviewers and control prompt token size, and also suitable for integration as a CI step.
Limitationsand information not yet provided
- Caller resolution is static and language-specific; languages or situations that cannot be resolved will clearly indicate that they cannot be resolved, rather than giving a result.
- Pricing, charging model, the list of specific supported programming languages, the specific commands for each installation method, detailed usage of the Python API, MCP client configuration steps, performance benchmark data, etc. are not yet provided in the supplied materials.