code-graph · context-engineering
What is a context slice?
A context slice is the minimal subgraph of your codebase that answers one question. Here's how GraphSlice extracts one, and why the boundaries matter.
On this page
"Context slice" is the core noun in GraphSlice, so it deserves a precise definition. A context slice is the minimal connected subgraph of your semantic code graph that is sufficient to answer one question.
Anatomy of a context slice
Every context slice has three parts:
The anchor
The symbol the question is about — a method, a type, an interface, a project.
Anchors resolve by real symbol identity, not by name matching. So Process
on OrderService never gets confused with Process on ImagePipeline.
The traversal
From the anchor, GraphSlice walks the edges the question calls for:
| Question | Edges walked |
|---|---|
| "Who calls this?" | incoming CALLS edges |
| "What breaks if I change this?" | implementations, overrides, references |
| "Trace this dependency" | project and package dependencies |
| "Show the flow" | CALLS edges, in execution order |
The traversal is bounded — by depth, by project boundary, or by relevance. A hub symbol with ten thousand references cannot flood the window.
The rendering
The subgraph is rendered in a form the agent consumes efficiently: compact, hierarchical, deduplicated. File-and-line anchors let the agent jump from structure to source when it needs the actual code.
What a context slice deliberately leaves out
The discipline is in the omissions. A context slice does not include:
- Method bodies that are not on the dependency path.
- Symbols that merely share a file with something relevant.
- Anything retrieved because it was textually similar to the question.
Proximity in a file is an accident of formatting. Proximity in the graph is a fact about your software.
Why "minimal" is a feature
It is tempting to pad context "just in case". But every irrelevant symbol in the window can pull the agent toward the wrong thing. Precision in, precision out. Minimal context slices keep token costs flat as the repository grows: the graph gets bigger, but the answers do not.