Show an AI coding assistant only the code that matters for the change it's making. Measures whether it actually works on your repo.
DiffContext
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
**Show an AI coding assistant only the code that matters for the change it is
making.**
DiffContext is a **context compiler for LLM coding agents**. Give it a Python
repository and a change — a git diff, a branch, or a single function name —
and it returns the small set of functions the model actually needs to make
that change safely: the callers that will break, the subclasses that override
it, the tests that cover it. It fits them to whatever token budget you have,
and it tells the model what it had to leave out.
It is built for people wiring LLMs into real codebases — agent loops, PR
review bots, CI checks — anywhere you have to decide what goes in the prompt
and the repository is far too large to send.
And it grades itself: point it at your repo and it mines your git history,
runs retrieval against real co-change pairs, and prints **NULL RESULT** when
it doesn't fit — finding that out *is* the feature.
The problem
Ask an assistant to change one function in a 50,000-line project and you have
three bad options: paste the whole repository (it does not fit, and models get
worse in very large contexts), paste just that one function (the model breaks
three callers it never saw), or grep for the name (grep cannot find the
subclass that overrides it, or the handler that receives it through
functools.partial — we measured grep's recall *plateauing* no matter how
much budget you give it).
DiffContext is the fourth option. Parse the repository once into a real
dependency graph, then for any change select the few functions that actually
matter and pack them into the smallest useful prompt.
Install
Zero runtime dependencies, Python 3.9+.
For MCP integration (Claude Code / Cursor / Windsurf):
See docs/MCP.md for the server config.
From source for development:
Quick start
More commands: USAGE.md. Production recipes: docs/USE_CASES.md.
Don't trust our benchmarks — run yours (2 minutes)
diffcontext verify --from-history 20 --calibrate mines test cases from
*your* repo's git history and grades retrieval against them — and prints
**NULL RESULT** rather than a decorative number when the tool doesn't fit
your repo. Finding that out *is* the feature.
Does it make the model better?
Yes — measured end to end, not by proxy. On 128 ContextBench Python tasks
judged by each repository's own test suite (no LLM-as-judge), **context
roughly quadruples pass@1: 5.5% → 25.8%**, exact McNemar p < 0.0001.
Two qualifiers, both in benchmarks/contextbench/RESULTS.md
§6: **(a)** the seed functions given to every arm are **oracle** — extracted
from the gold patch — so this measures *"given correct localization, does
context quality matter?"*, not end-to-end issue solving (localization is
handed to every arm for free); **(b)** 121 of the 128 effective tasks are
django, so this is largely a django result.
The honest companion: the three context variants (default / gap / depboost)
are statistically **indistinguishable** from each other, p = 0.36–0.81. The
win is context versus no context — not this selector versus that one. Full
results: benchmarks/contextbench/RESULTS.md.
What this is not
- **Not a code generator.** It selects and packs context; the model writes
the code.
- **Not precision-first.** It casts a wide net — mean precision is under 0.1
at the default top-k. Use --cutoff gap if you pay per token.