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 slice is the minimal connected subgraph of your semantic code graph that is sufficient to answer one question.
Anatomy of a slice
Every slice has three parts:
The anchor
The symbol the question is about — a method, a type, an interface, a project.
Anchors are resolved 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 that the question type calls for:
| Question | Edges walked |
|---|---|
| "Who calls this?" | incoming call edges |
| "What breaks if I change this?" | implementations, overrides, references |
| "Trace this dependency" | project + package dependency edges |
| "Show the flow" | call edges, direction of execution |
The traversal is bounded — by depth, by project boundary, or by relevance — so a hub symbol with ten thousand references doesn't flood the window.
The rendering
The subgraph is rendered in a form an LLM consumes efficiently: compact, hierarchical, deduplicated, with file-and-line anchors so the assistant can jump from structure to source when it needs the actual code.
What a slice deliberately leaves out
The discipline is in the omissions. A slice does not include:
- Method bodies that aren't on the dependency path.
- Symbols that merely live in the same file as 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's tempting to pad context "just in case" — but every irrelevant symbol in the window is a chance for the model to anchor on the wrong thing. Precision in, precision out. Keeping slices minimal is what keeps token costs flat as the repository grows: the graph gets bigger, but the answers don't.