CLI Reference
CLI Reference
Section titled “CLI Reference”Every tokensave command at a glance.
Use tokensave --debug <command> to emit structured diagnostics on stderr.
Use --log-level off|error|warn|info|debug|trace to select a level or
TOKENSAVE_LOG to pass a level to an agent-launched process. Set log_level
to the same values in .tokensave/config.json for a persistent project default.
CLI flags override the environment, which overrides the project setting. See
Debug diagnostics for capture examples.
tokensave --version --verbose adds the source commit, build profile, target
and compiler. A build from a Git checkout reports the checked-out commit; a
crates.io install (cargo install tokensave) reports the release commit that
Cargo recorded in the published package, with a -dirty suffix if the
package was made from uncommitted changes. When neither is available, as in a
source archive without that record, the commit is unknown.
Use tokensave tool --help or tokensave help tool for the tool subcommand’s
help, and tokensave tool <name> --help for a specific tool’s parameters.
Place global diagnostics flags before the tool name.
tokensave --version # Print the installed versiontokensave --version --verbose # Include build metadatatokensave init [path] # Initialize a new project (full index); without a path, the git root # (a no-op inside an existing project)tokensave init --cpu-usage low # Initialize with a fixed CPU profile (skip the benchmark)tokensave config benchmark # Run or reuse the machine-level hardware benchmarktokensave config benchmark --show # Show the saved benchmark and settings (never measures)tokensave config benchmark --force # Measure this machine againtokensave config benchmark --reset # Delete the saved benchmarktokensave tune [path] [--dry-run] # Re-benchmark, save globally, update a pinned cpu_usagetokensave sync [path] # Incremental sync; without a path, auto_init may initialize a new repotokensave sync --force [path] # Force a full re-indextokensave sync --doctor [path] # Sync and list added/modified/removed filestokensave verify [path] # Read-only index integrity and source-stat checkstokensave verify [path] --deep --json # Full SQLite checks and bounded source hashingtokensave status [path] # Show statistics + cost summarytokensave status [path] --json # Show statistics (JSON output)tokensave status --details # Include node-kind breakdowntokensave cost [range] # Token cost summary (default: 7d)tokensave cost --by-agent # Cost grouped by supported agenttokensave cost --by-model # Cost grouped by modeltokensave cost --by-task # Cost grouped by task categorytokensave cost --export json|csv # Export cost datatokensave gain [--all] [--range R] [--json] # Tokens saved by MCP calls (default: this project, 30d)tokensave gain --history # Tokens saved per daytokensave gain --by-tool # Calls and tokens saved per tooltokensave query <search> [path] # Search symbolstokensave grep [--graph=none] COMMAND... # Run grep, rg or git grep and add index facts to each hittokensave files [--filter dir] [--pattern glob] [--json] # List indexed filestokensave affected <files...> [--stdin] [--depth N] # Find affected test filestokensave install [--agent NAME] # Configure agent integrationtokensave reinstall # Refresh settings for all installed agentstokensave uninstall [--agent NAME] [--local] [--keep-git-hooks] [--dry-run] [--verbose | --quiet]tokensave purge [--dry-run] [--yes] [--local | --project PATH | --all-projects] [--include-history] # Uninstall, then delete tokensave's settings, caches and indexestokensave serve [--idle-timeout-secs N] [--watch] # Start MCP server (N: exit after N idle seconds; --watch: opt-in filesystem watcher)tokensave servers [--json] # List running servers and the index each one holdstokensave monitor # Live TUI showing MCP calls across all projectstokensave memory [--clean] # Per-instance RSS report for all tokensave processestokensave upgrade [--dry-run] [--standalone] # Show installer guidance or verify and upgrade a standalone binarytokensave channel [stable|beta] # Show or switch update channeltokensave doctor [--agent NAME] # Check installation healthtokensave doctor --caveman [--session-id ID] # Also check Caveman compatibility; JSON report on stdouttokensave githooks [on|off] [--local] # Manage git hooks (--local: this repo only, no core.hooksPath)tokensave branch add|list|remove|removeall|gc|set-default # Multi-branch managementtokensave current-counter # Show per-project token countertokensave reset-counter # Reset per-project token countertokensave disable-upload-counter # Opt out of worldwide counter uploadstokensave enable-upload-counter # Re-enable worldwide counter uploads# TOKENSAVE_TELEMETRY=off or DO_NOT_TRACK=1 turns the counter off for one environmenttokensave state list # List relocated project state and the project of eachtokensave state prune [--dry-run] # Delete relocated state whose project directory is gonetokensave okf validate <dir> [--json] [--strict] [--verbose] # Check an OKF bundle (v0.3; earlier versions with fallbacks)tokensave okf export --output <dir> [--project P] # Export the code index as an OKF bundle (no sync)tokensave okf import <dir> [--name N] [--replace] [--strict] [--json] [--project P] # Import a bundle for tokensave_knowledgetokensave okf list [--json] [--project P] # List imported bundlestokensave okf remove <name> [--project P] # Remove an imported bundletokensave scip-compare --index <file.scip> [--rebase-root] [--project P] # Experimental, read-onlyVerbose version output includes the build commit, Cargo build profile, target
triple and Rust compiler version. Values unavailable at build time are shown as
unknown; source archives without Git metadata may not contain a commit. This
command does not open or initialize a project database.
See Open Knowledge Format for the okf commands, their findings, the export layout and imported knowledge.
scip-compare is an experimental, read-only prototype. It appears in CLI help and is disabled by default. Set
"enable_scip": true in the project’s .tokensave/config.json to enable
comparison. A missing setting or false disables it. The command reads a
SCIP index from an external indexer,
such as rust-analyzer scip or scip-typescript, and prints a JSON report that classifies
the graph’s edges as confirmed, contradicted or unverifiable. It also lists
the references the graph lacks, as a dry-run import plan. It never writes the
index. It refuses to run while a sync of the same project is in progress,
and holds the sync lock while it runs. An index whose project_root names
another directory needs --rebase-root. Each document is checked against the
current sources, including a hash comparison when the SCIP index contains
document text. Stale, unindexed or malformed documents are skipped and
counted. See the
SCIP evaluation
for the format mapping, limits, and write-enabled fixture experiment.
Dependency advisory reachability
Section titled “Dependency advisory reachability”Run these commands from an indexed project, or pass its directory as a positional argument..
tokensave vuln-reachability --onlinetokensave vuln-reachabilityThe first command checks OSV and caches the result in the project database for 24 hours. The second uses the current version inventory and matching cached data, if available, and reports its age. Only package ecosystems, names and versions are submitted. OSV receives no project paths or source code.
The report covers declared Cargo, npm, Python and Go dependencies. It uses versions from supported lockfiles where available. Go declarations and manifest-only versions are approximate. npm and Python lockfile matches are also approximate because they are matched by package name across the workspace. Unresolved versions and local or overridden dependencies contribute to the unresolved count.
reachableincludes a direct indexed call from a project symbol to an affected dependency symbol.imported_not_calledmeans the index contains a matching import with no matching call.not_reachablemeans the index contains no matching import for the supplied symbols.unknowncovers missing symbol metadata or insufficient call evidence.
Results describe the local index and the symbol metadata supplied with each
advisory. Dynamic calls and Go receiver methods can require manual review.
Run tokensave sync before checking recently edited code.
Index facts on search output
Section titled “Index facts on search output”tokensave grep COMMAND... runs a grep, rg or git grep command and adds what the index knows to each hit. The search command runs unchanged: the flags, the regular expression dialect, the result set and the exit code are its own. The command reads the index directly and needs no MCP server.
$ tokensave grep git grep -n add_onesrc/lib.rs:4:pub fn add_one(value: i32) -> i32 {<TAB>#ts [defines add_one (function), 4-6]src/lib.rs:14: self.total = add_one(self.total);<TAB>#ts [in Counter::bump, 13-15] [calls add_one, src/lib.rs:4-6]src/lib.rs:19: counter.total = add_one(-1);<TAB>#ts [in reset, 18-20] [calls add_one, src/lib.rs:4]Each path:line: hit keeps its bytes. The facts follow one tab character (<TAB> above) and the marker #ts. Each fact is in square brackets. The facts follow the conventions of the text results of tokensave_search: a line span is a-b, and a kind is in parentheses after the name.
| Fact | Meaning |
|---|---|
[in X, a-b] |
The innermost symbol that contains the line, and its lines. |
[defines X (kind), a-b] |
A symbol starts on the line. The kind is the name that the index uses, for example function or enum_variant. |
[calls X, file:a-b] |
A call on the line, and the definition that the index resolved it to. The first hit on a definition gives its lines. A later hit gives its first line: [calls X, file:a]. |
[ambiguous name, n candidates: A, B, C] |
A call that the index could not resolve to one definition. |
[uses X, file:a-b], [type_of X, file:a-b] and other edge kinds |
A reference that is not a call. The first word is the kind of the edge in the index. The location follows the same rule as for a call. |
[stale] |
The file changed after it was indexed: its modification time is later, or its size is different. A stale file gets no other fact, and a definition in a stale file is named with no location. |
A line with no fact is printed as the search command printed it. This applies to comments outside each symbol and to file types that the index does not parse.
What the command changes, and what it does not:
-nis added when the search command has no line-number flag, because the facts need line numbers.- Output that has no
path:line:hits is not changed:-l,-c,-q,--files,--json,--heading, NUL-separated output, colored output (--color=always) and context lines. --graph=noneruns the search command as written, with no facts and no added-n.- The exit code is the exit code of the search command. A command that is not
grep,rgorgit grepis refused with exit code 2. - The index is opened read-only. The command starts no sync and no migration. When the project has no index, the search command runs as written. When the project has an index that the command cannot read, for example one that needs a migration, the search command also runs as written, and one line on standard error gives the reason:
tokensave grep: no index facts: ....
Limits:
- The search command gives no match positions. A hit gets a
callsfact or a fact of a different edge kind only for a name that the search pattern contains as a whole word, and at most three of them. A search foradd_onereports the call toadd_oneon a hit line and not the other calls on that line. A pattern such asadd_\w+names no symbol, so its hits get onlyinordefines. - A filter after the command sees the facts: in
tokensave grep rg -n Name | grep -v Test, the filter also drops a hit whose facts containTest. - On a branch that has no index of its own, the facts come from the index that the MCP server uses for that branch. Each file is checked against its index entry, so a file that differs is
stale. - A line longer than 1 MiB is copied with no facts.
Run tokensave sync to bring a stale file up to date.
Settings for automatic initialization
Section titled “Settings for automatic initialization”| Setting | Where | Effect |
|---|---|---|
auto_init |
~/.tokensave/config.toml |
true (default): a git repository with no index is initialized by a pathless sync (the post-commit and post-merge hooks) or by serve. false: run tokensave init yourself. |
TOKENSAVE_AUTO_INIT |
environment | Overrides auto_init for one run. 0, false, no, off or empty turn it off; any other value turns it on. |
See Automatic initialization for the guards that apply.
Settings for tool approvals
Section titled “Settings for tool approvals”| Setting | Where | Effect |
|---|---|---|
manage_permissions |
~/.tokensave/config.toml |
true (default) adds read-only approvals where supported. Use --approve-write-tool NAME for exact write-tool grants or --reset-tool-approvals to restore prompts. false preserves user-managed approvals. |
TOKENSAVE_MANAGE_PERMISSIONS |
environment | Overrides manage_permissions for one run. 0, false, no, off or empty turn it off; any other value turns it on. |
See Tool approvals for what each agent gets.
Settings for Caveman cooperation
Section titled “Settings for Caveman cooperation”| Setting | Where | Effect |
|---|---|---|
caveman_compatibility |
~/.tokensave/config.toml |
false (default): the MCP instructions never mention Caveman. true: when a Caveman skill is installed for a supported agent, the MCP initialize instructions ask the agent to keep tokensave results exact. Read when the MCP server starts a session. |
TOKENSAVE_CAVEMAN_COMPATIBILITY |
environment | Overrides caveman_compatibility for one run. 0, false, no, off or empty turn it off; any other value turns it on. |
tokensave init reports an installed Caveman skill and, while the setting is off, how to turn it on; it never changes the setting. See Working alongside Caveman.
Settings for the state location
Section titled “Settings for the state location”| Setting | Where | Effect |
|---|---|---|
state_dir |
~/.tokensave/config.toml |
Unset (default): each project keeps its state in .tokensave/ at its root. An absolute path, or one starting with ~: state lives in <state_dir>/projects/<name>-<hash>/ and nothing is written inside the repository. Read when a tokensave process starts. |
TOKENSAVE_STATE_DIR |
environment | Overrides state_dir. Empty selects the default layout. |
TOKENSAVE_USER_CONFIG_DIR |
environment | Optional absolute directory for machine configuration files and locks. Useful for disposable CLI tests. |
See Keeping state outside the repository for how existing state is kept and how orphans are reported.
Settings for the filesystem watcher
Section titled “Settings for the filesystem watcher”| Setting | Where | Effect |
|---|---|---|
filesystem_watch_enabled |
~/.tokensave/config.toml |
false (default): serve creates no filesystem watcher. true: serve follows file changes through OS notifications and syncs them. |
serve --watch |
command line | Turns the watcher on for one run, whatever filesystem_watch_enabled says. |
watcher_debounce |
~/.tokensave/config.toml |
Quiet period before a burst of changes is applied: "500ms", "2s" (default), "1m". Clamped to 50 ms – 60 s. Read only when the watcher is on. |
See Opt-in filesystem watcher for scope, bounds and platform limits.