Skip to content

Token-Efficient Workflows

Input tokens are 85-95% of AI coding bills. NestWeaver’s graph-based retrieval is designed to minimize token spend — but how you query matters. This guide covers the strategies that make the biggest difference.

NestWeaver gives your agent precomputed answers instead of raw files. But even within NestWeaver, there’s a spectrum from “broad and expensive” to “narrow and cheap.”

Rule of thumb: Filter early, use concise format for scanning, and switch to detailed only for the results you need to read deeply.

NestWeaver offers two query interfaces. They return the same data, but their token costs differ significantly.

InterfaceWhen to useToken overhead
MCP toolsMain conversation loop, interactive work~18K tokens for tool schemas (loaded once per session)
CLI via BashSubagents, batch scripts, hooksZero schema overhead — precomputed answers only

Use CLI in subagents for ~40-60% fewer tokens per query. The CLI returns the same data without loading tool schemas into context. Always pass --json for machine-readable output.

Terminal window
# In a subagent or script — CLI is cheaper
nestweaver context "UserService" --token-budget 2000 --json
# In the main conversation loop — MCP is natural
# (tool schemas are already loaded)

Every context query accepts filters that narrow results before ranking. Unfiltered queries return broader but less focused results — more tokens for less signal.

FilterEffectExample
reposLimit to specific repositoriesrepos: ["my-backend"]
tagsFilter by tagtags: ["project/auth"]
path_prefixLimit to a directorypath_prefix: "src/services/"
kindsSymbol, Note, or Section onlykinds: ["Symbol"]
exclude_tagsRemove unwanted categoriesexclude_tags: ["archived"]

Every context and search tool supports response_format:

  • "concise" — Titles, kinds, and UIDs only. Use for scanning many results. ~60% fewer tokens than detailed.
  • "detailed" — Adds text excerpts, scores, and full metadata. Use when you need to read the content.

Pattern: Query with concise first to find the right nodes, then use read_symbols or note_get on the specific items you need.

The token_budget parameter (default: 3000) controls how much context NestWeaver returns. The graph fills the budget with the highest-ranked symbols — Personalized PageRank ensures the most structurally relevant results come first.

Terminal window
# Tight — just the entry points
nestweaver context "payment processing" --token-budget 1000
# Standard — good for most tasks
nestweaver context "payment processing" --token-budget 3000
# Generous — deep architectural understanding
nestweaver context "payment processing" --token-budget 8000
NeedToolWhy
Structural context around a topicbrain_contextPPR-ranked, token-budget-aware
Keyword searchbrain_searchBM25, fast lookup
Read a specific symbol’s sourceread_symbolsCheapest — returns only the span you need
Project-wide overviewproject_contextPre-scoped to a project’s subgraph
Check before changing codeblast_radiusShows downstream dependents
  1. Use CLI in subagents — 40-60% fewer tokens vs MCP
  2. Filter with repos/tags/path_prefix — narrow before ranking
  3. Use concise format for scanning — switch to detailed only when needed
  4. Set explicit token budgets — don’t accept the default if you need less
  5. Use read_symbols for specific lookups — cheapest way to read source