Token economy
basemind saves tokens by answering with file paths, line numbers, and signatures — not whole files. A question about your code costs a small fraction of the tokens it takes to read the source.
Why pointers beat file reads
Section titled “Why pointers beat file reads”When you ask “where is the User class defined?”, basemind returns:
src/models/user.ts:42Reading the entire user.ts file would cost 200–2000 tokens, depending on size. The answer costs
just a few tokens.
When you ask “what calls processFile?”, basemind returns 10 call sites with their paths and
line numbers — enough for an agent to decide whether to open each one. Re-reading the whole
calling files would explode your context.
The same discipline applies to every tool: code outline gives you a file’s structure (signatures,
imports) before you open it, so you read only the span you need. code references returns
pointers, not source. git recent shows what happened (commits + file list), not diffs.
See How it works to understand how basemind builds the map that makes this possible.
How savings are estimated
Section titled “How savings are estimated”The saved-token figure in admin telemetry and the statusline is an estimate, not a measurement of
your session. For each call, basemind counts the response tokens and multiplies them by a fixed
per-mode factor modelling what a grep plus file reads would have cost:
| Mode | Factor |
|---|---|
code symbols |
25x |
code outline, code references, code implementations |
1.2x |
memory documents |
2.5x |
web scrape / crawl / map |
3x |
git symbol_history |
4x |
git churn |
3x |
code callers, dependents, find, files, grep, graph modes, other git and admin modes |
1x (no saving claimed) |
The factors are calibrated from medians measured by basemind admin eval (see
Evaluation); a mode where basemind did not beat its baseline claims 1x.
Treat the total as an order of magnitude.
Good habits the plugin sets up
Section titled “Good habits the plugin sets up”The plugin nudges agents toward the cheap path by default:
- Get a file’s outline before opening it — then read only the part you need.
- Search for a definition instead of grepping for it —
code symbolsvsgrep. - Look up who calls a function instead of grepping for call sites —
code referencesvsgrep. - Refresh the index after edits —
admin rescaninstead of restarting the server. - Don’t re-read a file basemind already mapped — use the outline instead.
Optional guardrails
Section titled “Optional guardrails”The plugin ships three hooks that enforce token discipline at the moment a tool is used. The guard is on by default; the other two are opt-in:
Guard: redirect wasteful searches
Section titled “Guard: redirect wasteful searches”BASEMIND_GUARD=nudge # default: allow the call, add a one-time advisoryBASEMIND_GUARD=redirect # deny the call and point at the basemind modeBASEMIND_GUARD=off # disableWhen an agent reaches for a built-in Grep or Glob search, the guard points it at the matching
basemind mode (code grep for patterns, code symbols for names, code references for call
sites). In the default nudge mode the call goes through with an advisory, shown once per session
per tool; redirect denies it. The guard needs jq and quietly does nothing without it.
Output compressor: shrink large results
Section titled “Output compressor: shrink large results”BASEMIND_COMPRESS_OUTPUT=1Off by default; 1, on, true or yes turns it on. When a Bash command returns long output (a
build log, a directory listing), the compressor replaces it with a shorter summary chosen by the
command family. It leaves the output alone when it detects a credential or would save under 10 %.
The backend is the basemind compress-output command, which reads stdin.
Re-read shortcut: show only what changed
Section titled “Re-read shortcut: show only what changed”BASEMIND_DELTA_READS=1Off by default; 1, on, true or yes turns it on. When an agent re-reads a file it already
read earlier in the session, the hook shows just the changed lines (basemind delta) instead of
resending the whole file, and only when the diff is meaningfully smaller.
Compression that understands code
Section titled “Compression that understands code”basemind shrinks code by keeping the shape and dropping the bodies — function signatures and imports stay, implementations go — because a signature is useless without its shape:
// Original (2,400 tokens)pub fn process_file(path: &str) -> Result<Vec<Symbol>> { let file = std::fs::read_to_string(path)?; let mut tokens = vec![]; let mut depth = 0; // 100 lines of parsing logic... Ok(tokens)}
// Compressed (240 tokens)pub fn process_file(path: &str) -> Result<Vec<Symbol>>;For prose, compression does a light cleanup: extra whitespace, filler paragraphs, repeated content. It reports honest before/after token counts, and the code version is exact — nothing is lost, just set aside.
code expand brings any one symbol’s full body back when an agent actually needs it: compress to
an outline, then expand only what you read.