Context for an agent on a large codebase
Give an AI agent the context it needs by starting wide and narrowing, so each request stays inside the token budget.
Goal: hand an AI agent the context for a task on a large .NET codebase without spending its window on files the task does not touch.
The principle is to start wide and narrow: a cheap map first, then a scoped drill-in. Each step is one MCP tool call that returns scoped, reduced context. The payoff is measured: in the Layer 4 scenario, one scoped call acquired a task's context in about 40,000 tokens against roughly 512,000 for a generic packer dump at the same single call, while a blind agent must read each needed file at least once (a lower bound of about six round-trips over the 24 pull requests tested). Read that token number with its recall: one scoped query call reaches 51 percent of the changed files, and the change-scoping mode reaches 88 percent when a git base is available.
The sequence
- Survey. Call
fuse_tocfirst. It returns a directory tree with per-file token costs and a symbol outline, a low-token map of the whole codebase that also tells the agent what fetching each file would cost. Usefuse_skeletoninstead when you want signatures rather than an outline. - Drill in. When the agent knows the area by name, call
fuse_focuswith the seed. When it has a topic but not a name, callfuse_searchwith the query. Both expand from the seed through the dependency graph. - Review changes. For a pull request, call
fuse_changeswith the base branch as the git ref, and setreviewto true for diff hunks and direct callers per changed file. - Full control. When you need options the workflow tools do not expose, call
fuse_dotnet.
Example call sequence
fuse_skeleton(path="C:/Projects/MyApp/src", maxTokens=80000)
fuse_focus(path="C:/Projects/MyApp/src", focus="OrderService", depth=1, maxTokens=150000)
fuse_changes(path="C:/Projects/MyApp/src", changedSince="origin/main", maxTokens=100000)The first call orients the agent, the second pulls the order-processing area and its dependencies, and the third scopes a later review to the branch under review.
Budget guidance
| Stage | Tool | Typical tokens |
|---|---|---|
| Survey | fuse_toc | 5,000 to 30,000 |
| Architecture map | fuse_skeleton | 50,000 to 100,000 |
| Focused drill-in | fuse_focus or fuse_search | 100,000 to 200,000 |
| Change review | fuse_changes | 50,000 to 150,000 |
| Full fusion | fuse_dotnet level=aggressive | 200,000 to 800,000 |
Shortcut: ask once
fuse_ask collapses the survey and drill-in: give it a task and a token budget and it
chooses skeleton, focus, or search and packs to budget. See
Ask one question. Across calls in one task, pass a
session id to fuse_focus and fuse_search so files already returned are not sent
again.
When to use it
Use this progressive flow on any codebase too large to hand an agent whole. On a small
project, one fuse_dotnet call is simpler.
Related concept
The tool parameters are in the MCP tools reference, and the modes behind them in Scoping.