Tokensave
Rust port of CodeGraph — a local-first code intelligence system that builds semantic knowledge graphs from codebases. Ported from the original TypeScript implementation by @colbymchenry.
Install / Use
/learn @aovestdipaperino/TokensaveREADME
Why tokensave?
When Claude Code works on a complex task, it spawns Explore agents that scan your codebase using grep, glob, and file reads. Every tool call consumes tokens.
tokensave gives Claude a pre-indexed semantic knowledge graph. Instead of scanning files, Claude queries the graph instantly — fewer API calls, less token usage, same code understanding.
How It Works
┌──────────────────────────────────────────────────────────────┐
│ Claude Code │
│ │
│ "Implement user authentication" │
│ │ │
│ ▼ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Explore Agent │ ───── │ Explore Agent │ │
│ └────────┬────────┘ └─────────┬───────┘ │
└───────────┼──────────────────────────┼───────────────────────┘
│ │
▼ ▼
┌──────────────────────────────────────────────────────────────┐
│ tokensave MCP Server │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Search │ │ Callers │ │ Context │ │
│ │ "auth" │ │ "login()" │ │ for task │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ └────────────────┼────────────────┘ │
│ ▼ │
│ ┌───────────────────────┐ │
│ │ libSQL Graph DB │ │
│ │ • Instant lookups │ │
│ │ • FTS5 search │ │
│ │ • Vector embeddings │ │
│ └───────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
Without tokensave: Explore agents use grep, glob, and Read to scan files — many API calls, high token usage.
With tokensave: Agents query the graph via MCP tools — instant results, local processing, fewer tokens.
Key Features
| | | |
|---|---|---|
| Smart Context Building | Semantic Search | Impact Analysis |
| One tool call returns everything Claude needs — entry points, related symbols, and code snippets. | Find code by meaning, not just text. Search for "authentication" and find login, validateToken, AuthService. | Know exactly what breaks before you change it. Trace callers, callees, and the full impact radius of any symbol. |
| 31 Languages | 100% Local | Always Fresh |
| Rust, Go, Java, Python, TypeScript, C, C++, Swift, and 22 more — all with the same API. Three tiers (lite/medium/full) let you control binary size. | No data leaves your machine. No API keys. No external services. Everything runs on a local libSQL database. | Git hooks automatically sync the index as you work. Your code intelligence is always up to date. |
What's New in v3.3
sync --doctor
The sync command now accepts a --doctor flag that lists every added, modified, and removed file after an incremental sync. Useful for verifying what changed in the index without digging through logs.
34 MCP Tools
Five new tools round out the analysis suite:
tokensave_commit_context— semantic summary of uncommitted changes for drafting commit messagestokensave_pr_context— semantic diff between git refs for pull request descriptionstokensave_simplify_scan— quality analysis of changed files (duplications, dead code, complexity, coupling)tokensave_test_map— source-to-test mapping at the symbol level, with uncovered symbol detectiontokensave_type_hierarchy— recursive type hierarchy tree for traits, interfaces, and classes
All 34 tools now include MCP annotations (readOnlyHint, title) and the three core tools (tokensave_context, tokensave_search, tokensave_status) are marked anthropic/alwaysLoad so they bypass the client's tool-search round-trip.
Upgrade-Aware Daemon
The background daemon now detects when its binary has been replaced (via brew upgrade, cargo install, scoop update, or any package manager) and automatically restarts with the new version. On Windows, the service is configured with SCM failure recovery actions for automatic restart.
MCP Resources
Three resources are exposed via resources/list and resources/read: tokensave://status, tokensave://files, and tokensave://overview.
v3.2 — 13-26x Faster Indexing
Full index performance improved through rayon parallel extraction, prepared-statement DB writes, suffix-indexed reference resolution, and bulk-load mode. A 1,782-file codebase now indexes in 1.2s (down from 14.8s). A 28K-file monorepo indexes in 22s (down from 565s). New databases get the final schema in one shot instead of running migrations sequentially.
v3.1 — Edge Deduplication
Incremental syncs could accumulate duplicate edges over time. v3.1 adds a unique index on edges and deduplicates existing databases on upgrade. Also adds concurrent sync prevention via PID-based lockfile, and tokensave doctor now runs VACUUM.
v3.0 — Bundled Grammars & Daemon
All 31 language grammars ship as a single bundled dependency. tokensave install offers to set up the background daemon as an autostart service (launchd/systemd/Windows Service).
31 Languages
tokensave supports 31 programming languages with deep extraction: functions, classes, methods, fields, imports, call graphs, inheritance chains, docstrings, complexity metrics, and cross-file dependency tracking.
Feature Flag Tiers
Three compilation tiers control which extractors are compiled:
Full (default) ── 31 languages
Medium ── 20 languages
Lite ── 11 languages
All grammars are always present via the bundled crate; the lang-* feature flags control which extractors are included.
See Supported Languages for the full tier breakdown.
Deep Nix Support
The Nix extractor goes beyond basic function/variable extraction:
-
Derivation field extraction —
mkDerivation,mkShell,buildPythonPackage,buildGoModule, and other builder calls have their attrset arguments extracted as Field nodes.tokensave_search("my-app")finds thepnamefield, andtokensave_search("buildInputs")shows what each derivation depends on. -
Import path resolution —
import ./path.nixnow creates a file-level dependency edge.tokensave_callersandtokensave_impactcan trace which Nix files depend on which, enabling cross-file change impact analysis. -
Flake output schema awareness — In
flake.nixfiles, standard output attributes (packages,devShells,apps,nixosModules,checks,overlays,lib,formatter) are recognized as semantic Module nodes.tokensave_search("devShells")finds your dev shell definition with itsbuildInputsas child Field nodes.
Protobuf Schema Graphs
Protobuf files are now first-class citizens with dedicated node kinds:
messagedefinitions becomeProtoMessagenodes with their fields as childrenservicedefinitions becomeProtoServicenodesrpcmethods becomeProtoRpcnodes- Nested messages, enums,
oneoffields, andimportstatements are all tracked
This enables queries like "what services depend on this message type?" via tokensave_callers.
Porting Assessment Tools
Two new MCP tools help assess and plan cross-language porting:
-
tokensave_port_status— compare symbols between a source and target directory in the same project. Matches by name with cross-language kind compatibility (class↔struct,interface↔trait). Reports coverage percentage, unmatched symbols grouped by file, and target-only symbols. -
tokensave_port_order— topological sort of source symbols for porting. Returns symbols in dependency-leaf-first order: utility functions and constants at level 0, classes that use them at level 1, services that depend on those classes at level 2, etc. Detects and flags dependency cycles that should be ported together.
Both tools assume source and target live in the same indexed project (e.g., src/python/ and src/rust/ side by side).
SQLite Fallback & Feedback Loop
Agent prompt rules now include two new instructions:
- SQLite fallback — when MCP tools can't answer a code analysis question, the agent is instructed to query
.tokensave/tokensave.dbdirectly via SQL (tables:nodes,edges,files). This handles edge cases and complex structural
Related Skills
node-connect
354.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
112.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
354.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
354.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
