Skip to Content

Repository-aware Context Compiler for LLM Coding Agents

Parse once. Retrieve precisely. Fit any context window.
Find the code that matters for a change, and fit it into an LLM's context window — automatically.

701
Real commits benchmarked
286
Automated tests
Python
Production ready
MCP
Claude Code / Cursor
git change
changed functions
hybrid retrieval
graph ∪ BM25 ∪ file
token budget
top-k + tokens
LLM-ready context
  • Zero runtime dependencies, Python 3.9+, pip install diffcontext
  • MCP server for Claude Code / Cursor / Windsurf: pip install "diffcontext[mcp]"
  • Output is honest by construction: a meta header discloses exactly which symbols were dropped, so the model knows what it cannot see.

Why

Ask an AI assistant to change one function in a 50,000-line project and you have three bad options:

  • Paste the whole repo — doesn’t fit, and models get worse in huge contexts
  • Paste just the function — the model breaks three callers it never saw
  • Grep for the name — grep can’t find the subclass that overrides it or the handler that receives it through functools.partial — grep’s recall plateaus no matter the budget

DiffContext is option 4: understand the repository’s structure once, then, for any change, select the few functions that actually matter and compile them into the smallest useful package for the model.

Measured limits

Claims on this site are measured against real commit history, and the measured limits are published alongside the wins. Four that a summary should not omit:

  • Recall is the strength (hybrid ~0.70 mean vs 0.56 call-graph-only); precision is under 0.1 at the default top-k, so retrieved context is a wide net of supporting code, not a curated shortlist. --cutoff gap trades recall for precision, and the size of that trade depends on the benchmark: roughly 4× precision for ~30% relative recall on the co-change benchmark, 2.2× for ~14% on ContextBench. evidence →
  • The verify sufficiency score is a structural proxy, not a probability, and it has zero discriminating power on TypeScript today. evidence →
  • Calibration is a ranking signal (r≈0.29 measured), not a confidence guarantee. evidence →
  • Context roughly quadruples pass@1 (5.5% → 25.8%, McNemar p < 0.0001) — but seeds are oracle (extracted from the gold patch, so this measures context quality given correct localization, not end-to-end issue solving), 121/128 effective tasks are django, and the three context variants are statistically indistinguishable (p = 0.36–0.81) at n=128. evidence →

Who is this for?

Built for:

  • AI coding agents
  • IDE assistants
  • Code review bots
  • Automated refactoring tools
  • Repository-scale code generation

Use as a Library

from diffcontext.pipeline import index_repository, analyze_impact, compile idx = index_repository("/path/to/repo") impact = analyze_impact(idx, ["./src/auth.py:validate_jwt"]) # hybrid by default ctx = compile(idx, impact, max_tokens=8000, top_k=20) print(ctx.text) # paste-ready context with meta-header

Example API Output

The output provides an exact breakdown of what was included and what had to be dropped to respect the token budget:

=== DIFFCONTEXT CONTEXT COMPILATION === Budget limit: 8000 tokens Included top-level files/symbols: 42 --- The following relevant symbols were excluded due to budget limits: - ./src/utils.py:format_date - ./src/db/models.py:User (partial representation) ======================================== # File: src/auth.py def validate_jwt(token: str) -> dict: ...

Explore the Docs

Last updated on