Tree-sitter and code graphs: navigating code better than grep
Parsing code with tree-sitter into a SQLite symbol graph, cutting the tokens an agent burns versus grep's line-by-line scans.
Single Rust binary, answer in microseconds, 12 languages.
True local semantic search, 100% local. MCP server built in.
* Measured across 13 scenarios. Latency is the outline-query median on the Python fixture; 97% recall requires a matching language server on PATH
Benchmark suite →
cartog init scaffolds .cartog.toml.
cartog index builds the graph.
cartog initDrops a commented .cartog.toml template. Config only — re-runs are a no-op, your toml is never overwritten.
cartog indextree-sitter parses 12 languages into a local SQLite file. Incremental on re-runs; only changed files re-parse. Pair with cartog watch for auto-refresh.
cartog ide (optional)Skip this if you only use the CLI. Need MCP in Claude Code, Cursor, VS Code, Codex CLI, Gemini CLI, OpenCode, Windsurf, Zed, Claude Desktop, Antigravity, Kiro, or Hermes Agent? Run it once per machine.
CLI-only users stop at step 2. The third verb is purely for plugging cartog into MCP-aware editors.
cartog doctor
— health check
Run it after install or when something looks off. Reports git, config, database, and model status.
Single binary, zero config, zero dependencies.
Single binary + SQLite file. No Docker, no language servers required, no graph databases. cargo install and you're done.
cartog watch auto re-indexes on file changes. Debounced, incremental, near-instant. Always query fresh data.
Keyword search (sub-ms, symbol names) + semantic search (natural language). CPU-only local embeddings by default (ONNX via fastembed); optional Ollama or any OpenAI-compatible /v1 endpoint for hosted or GPU-backed embedding.
cartog impact --depth 3 traces callers-of-callers instantly. Know the blast radius before you change anything.
Auto-detects language servers on PATH. Boosts edge resolution from ~25% to ~44–81%. Works without them, better with them.
tree-sitter parsing, SQLite storage, local embeddings. No API keys, no telemetry. Secrets are redacted and sensitive files (.env, keys) skipped before they reach the index. Works in air-gapped environments.
Pre-compute the structure once, then answer any question in microseconds.
Transitive impact analysis is impossible with grep. cartog impact --depth 3 traces callers-of-callers instantly. Know the blast radius before you change anything.
One refs call returns every caller, importer, and type reference — with file paths and line numbers. No parsing output, no false positives.
tree-sitter parsing, SQLite storage, local embeddings. No API keys, no telemetry, no cloud. Hardcoded secrets are redacted and sensitive files skipped before indexing. Works in air-gapped environments.
| grep / cat / find | Language server (LSP) | Cartog | |
|---|---|---|---|
| Transitive analysis | impossible | limited | impact --depth 3 |
| Query latency | multi-step | seconds | 8-450 μs |
| Setup | none | per-language server | single binary |
| Startup time | instant | seconds to minutes | instant |
| Language coverage | any | 1 per server | 12 languages |
| Semantic search | no | no | local ONNX / Ollama / OpenAI |
| Privacy | local | local | 100% local |
Measured across 13 scenarios, 10 languages. Benchmark suite →
Great for string literals and config values. But grep can't trace call chains, can't do transitive impact analysis, and floods your context with raw text. Cartog returns structured, ranked, deduplicated results — one refs call replaces 6+ discovery steps.
LSPs give perfect precision but require per-language setup, take seconds to start, and only cover one language at a time. Cartog covers 12 languages with one binary and answers in microseconds. When you need LSP precision, cartog uses it as an optional layer.
Most ship a runtime to install (Python, Node) and stop at keyword search. Cartog is a single static Rust binary with three things they lack: true embedding-based semantic search (vector KNN + cross-encoder re-ranking, not keyword matching), pluggable embedding providers (local ONNX, Ollama, or any OpenAI-compatible endpoint), and S3 index sync (cartog push / pull) to share a pre-built graph across a team or CI. All 100% local by default.
83% fewer tokens per query, 97% recall*. Your agent queries the graph instead of grepping blind.
Wires into your editor with cartog ide
Claude Code, VS Code, and Kiro get both project-scoped MCP files in your repo and user-scope configs; Cursor is project-scoped; the rest get user-scope configs in your home directory. Only editors actually installed are touched.
cartog ide writes cartog serve into installed editors (Cursor, VS Code, Codex CLI, Gemini CLI, OpenCode, Windsurf, Zed, Claude Desktop, Antigravity, Kiro, Hermes Agent). Idempotent merge, existing MCP servers preserved. Skip it if you only use the CLI.
cartog serve exposes cartog_map, cartog_search, cartog_refs, cartog_impact, cartog_rag_search, and 11 more. Each tool description tells the agent when (and when not) to use it.
The bundled skill teaches your agent when and how to use cartog — search routing, refactoring workflows, fallback heuristics — so it picks the right tool first.
| Integration | Setup | What it does |
|---|---|---|
| CLI bootstrap | cartog init + cartog index |
Scaffold .cartog.toml, then build the graph. CLI-only flow. |
| Editor MCP wiring (optional) | cartog ide [--client X] |
12 clients across 6 config shapes (incl. Codex TOML, Hermes YAML); idempotent, dry-run-able |
| Claude Code plugin | /plugin marketplace add jrollin/cartog/plugin install cartog@cartog-plugins |
Skill + MCP + auto-setup, all-in-one |
| MCP server (manual) | cartog serve --watch |
16 tools over stdio, live index + auto semantic embedding |
| Agent skill | npx skills add jrollin/cartog |
Behavioral rules for any compatible agent |
| CLI (any agent with bash) | cargo install cartog |
Direct commands — works with any tool-using LLM |
See MCP Server docs and Agent Skill docs for per-client setup. Supported clients: Claude Code (project + user), Claude Desktop, Codex CLI, Cursor, Gemini CLI, OpenCode, VS Code (project + user), Windsurf, Zed, Antigravity, Kiro (project + user), Hermes Agent.
cartog serve speaks the Model Context Protocol over stdio: 16 tools any MCP client launches as a subprocess. No HTTP port, no daemon, no API keys. The graph stays on your machine.
cartog ide is the only verb that writes MCP configs. It merges cartog serve into Claude Code, Cursor, VS Code, Codex CLI, Gemini CLI, OpenCode, Windsurf, Zed, Claude Desktop, Antigravity, Kiro, and Hermes Agent. Existing servers preserved, dry-run-able.
14 read tools (map, search, refs, impact, rag_search, …) ship readOnlyHint and declare an outputSchema, so clients skip approval prompts and get validated structuredContent. 2 write tools build the index.
--watch re-indexes on file changes and auto-refreshes semantic embeddings when the repo already has them (no --rag needed). cartog_index and cartog_rag_index emit MCP notifications/progress so the client can show a progress bar.
Full per-client JSON/TOML in the MCP Server docs →
A series on the internals, from the code graph to semantic search.
Parsing code with tree-sitter into a SQLite symbol graph, cutting the tokens an agent burns versus grep's line-by-line scans.
Local BGE-small embeddings, FTS5 + vector KNN fused with reciprocal rank fusion, then cross-encoder re-ranking, all on CPU.
Tapping language servers like rust-analyzer and pyright to lift edge-resolution precision from 25–37% to 44–81%.
Merkle hashing plus multi-level file filtering to re-index only changed symbols, dropping re-index time from seconds to milliseconds.
Pick one install method below — these are alternatives, not steps. Once cartog is on your PATH, run cartog init + cartog index in any repo.
Already in Claude Code? /plugin marketplace add jrollin/cartog bundles install + skill + MCP. Use any agent? npx skills add jrollin/cartog adds the behavioural skill alongside any install method above.
Open source, free forever. One command to install, one to wire it up.
Then cartog init + cartog index in your repo. Read the documentation →