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.
# Add to your Claude Code skills
git clone https://github.com/aovestdipaperino/tokensaveWhen 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.
┌──────────────────────────────────────────────────────────────┐
│ 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 │ │
│ └───────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
No comments yet. Be the first to share your thoughts!
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.
| | | |
|---|---|---|
| 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. |
Incremental syncs could accumulate duplicate edges over time, causing the database to grow far beyond the size of the source code. v3.1.0 adds a unique index on edges and deduplicates existing databases automatically on upgrade. If your .tokensave/tokensave.db had grown unexpectedly large, it will shrink to normal size on first run.
The CLI and background daemon can no longer run sync at the same time. A PID-based lockfile prevents conflicts, with stale lock detection for crashed processes.
tokensave doctor now reports database size and runs VACUUM to reclaim disk space — especially useful after upgrading from versions with duplicate edges.
New docs/INDEX-DESIGN.md documents the full schema, extraction pipeline, reference resolution, incremental sync algorithm, and how diff_context queries work.
All 31 language grammars now ship as a single bundled dependency (tokensave-large-treesitters), eliminating 20+ individual tree-sitter-* crate dependencies. This means faster builds, simpler dependency management, and guaranteed grammar version consistency across all languages. The vendored C grammars (Protobuf, COBOL) have also moved into the bundle, removing cc from build dependencies.
tokensave install now offers to set up the background daemon as an autostart service after configuring your agent. The daemon watches all tracked projects for file changes and runs incremental syncs automatically, so your code intelligence is always fresh without manual tokensave sync calls.
The status table now shows when your index was last updated:
│ Last sync 2m ago Full sync 3d ago │
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.
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.
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 the pname field, and tokensave_search("buildInputs") shows what each derivation depends on.
Import path resolution — import ./path.nix now creates a file-level dependency edge. tokensave_callers and tokensave_impact can trace which Nix files depend on which, enabling cross-file change impact analysis.
Flake output schema awareness — In flake.nix files, 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 its buildInputs as child Field nodes.
Protobuf files are now first-class citizens with dedicated node kinds:
message definitions become ProtoMessage nodes with their fields as childrenservice definitions become ProtoService nodesrpc methods become ProtoRpc nodesoneof fields, and import statements are all trackedThis enables queries like "what services depend on this message type?" via tokensave_callers.
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).
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.db directly via SQL (tables: nodes, edges, files). This handles edge cases and complex structural queries that go beyond the built-in tools.
Improvement feedback — when the agent discovers a gap where an extractor, schema, or tool could be improved, it proposes to the user to open an issue at github.com/aovestdipaperino/tokensave, reminding them to strip sensitive data from the description.
cargo install tokensave # or brew upgrade tokensave
tokensave install # re-run for updated prompt rules + daemon