zerograph

v0.7.1MITmacOS arm64 · Linux x64 · Windows x64

A project knowledge graph that costs zero API tokens to build, keep fresh, and query.

zerograph reads a repository's markdown and code in 24 languages and extracts the structure the authors already wrote. It answers questions about that structure in a few lines of text.

npm install -g zerograph

Zero tokens by default

Build, refresh and query all run locally. ask --rerank is the only thing that spends model tokens, and only when asked.

Finds the entry point from plain words

Exact id, BM25 and local dense retrieval find it in about 200 tokens an answer.

Built for agents

Every reader takes --json, there is an MCP server, and a session hook keeps the graph fresh.

Get started

Five lines, from nothing to an agent that asks the graph first.

  1. Install

    One global binary. Or pnpm add -D zerograph to pin it per project.

    npm install -g zerograph
  2. Ignore the store

    The graph is built per checkout and never committed.

    echo .zerograph/ >> .gitignore
  3. Build

    The first run downloads the embedding model; after that only changed files are re-read.

    zerograph build
  4. Ask

    Plain words in, path:line out. It stays fresh with your edits.

    zerograph ask cancellation policy
  5. Wire your agent

    Optional: the Claude Code plugin. Also --codex, --cursor, --copilot, --gemini, --opencode.

    zerograph install-agent --claude

In action

Output from zerograph's own checkout. Each line reads path:line [ID] headline; └ lines are neighbours one hop away.

$ zerograph ask writer lock
src/store.rs:531  Store.lock_writer
  └ src/store.rs:6  Store
src/lib.rs:2114  tests::a_poll_skips_its_cycle_while_a_refresh_holds_the_writer_lock
src/store.rs:520  Store.try_lock_writer
$ zerograph impact Store.try_lock_writer
sym:src/store.rs::Store.try_lock_writer  src/store.rs:520
d=1  will break (1)
  sym:src/lib.rs::Watcher.poll  src/lib.rs:565  Calls → sym:src/store.rs::Store.try_lock_writer
importers (7): src/ask.rs, src/bench.rs, src/dump.rs, src/families.rs, src/index/dense.rs, src/mcp.rs, src/status.rs
risk: MEDIUM — 1 direct, 1 total, 8 files
$ zerograph trace Watcher.poll Store.try_lock_writer
sym:src/lib.rs::Watcher.poll  src/lib.rs:565
  → sym:src/store.rs::Store.try_lock_writer  src/store.rs:520
$ zerograph explain Store.try_lock_writer
sym:src/store.rs::Store.try_lock_writer  src/store.rs:520  Symbol  Store.try_lock_writer
  Declares ← sym:src/store.rs::Store  src/store.rs:520
  Calls ← sym:src/lib.rs::Watcher.poll  src/lib.rs:565
  Calls → sym:src/store.rs::Store.lock_file  src/store.rs:520
  Calls → sym:src/store.rs::Store.lock_label  src/store.rs:520
  Calls → sym:src/store.rs::WriterLock  src/store.rs:520

Also: zerograph changes --base main says what the diff touches and who reaches it. All commands

How it works

The hard part is not building a better graph, it is building a better door onto it.

A repository's ids, imports and calls already form a dense, human-authored graph. zerograph extracts it and finds the right entry point from a question phrased in ordinary words.

  1. Exact id or symbolA name like FR-PAY-22 or StaffService goes straight to its node.
  2. BM25 over passagesLexical search over what the docs and code actually say.
  3. Local dense listAn embedding model on your machine, interleaved with the lexical list rank by rank.
  4. One hop over the graphThe surviving seeds bring their neighbours, rendered as path:line ID headline.

What it reads

Requirement ids, cross-references, exports, imports, calls, decorators, and ids quoted in comments, from markdown and:

What each language reads, and what it does not

Agents

The Claude Code plugin starts zerograph's MCP server for the session, briefs each session and subagent on the index, answers a concept grep from the graph before it runs, and names the callers an edit can break.

◇ zerograph · in sync

  • Claude Code
  • Codex
  • Cursor
  • Copilot
  • Gemini
  • opencode
$ zerograph install-agent --claude
# also --codex --cursor --copilot --gemini --opencode

# or, inside Claude Code
/plugin install zerograph --marketplace devmaxxx/zerograph

Measured

keyword 40/40, paraphrase 20/30, code 12/12 at 222 p90 tokens

The recorded 82 cases on the bench fixture: 908 files, about 8.3k nodes, default embedder, 0.6.3. How it is measured

zerograph vs graphify vs GitNexus

Same repository, same questions. The full results and method

Questions answered out of 82
zerograph · no embedder58
zerograph · e5-small61
zerograph · gemma (default)72
zerograph · gemma + rerank82
graphify32
GitNexus12

Rerank (sonnet) is opt-in and the only step that spends model tokens, about 14k a question.

LLM tokens to build the graph lower is better
zerograph0
graphify14.6 M
GitNexus0

graphify, a cold build, reads every file with a model; zerograph and GitNexus build locally.

Answer size median characters, lower is better
zerograph593
graphify6 688
GitNexus6 246

What an agent reads per question: about 150 tokens against 1.6k.

Answer time median ms, lower is better
zerograph346
graphify1 467
GitNexus1 424

A fresh process per question; zerograph serve answers in 66 ms.

Impact: files found out of 123
zerograph123
graphify57
GitNexus78

16 change targets: every file that reaches each one.

Call chains traced out of 8
zerograph8
graphify5
GitNexus2

Shortest call chain between two symbols, including 2 correct refusals.

Size on disk MB, lower is better
zerograph32
graphify123
GitNexus598

The whole index for one checkout.

Worktrees

Each checkout keeps its own graph and index in .zerograph/, so worktrees, clones and branches never share state. The only thing shared is a cache of embeddings. Parallel agents are safe: one writer lock per checkout.

1.5 sto build a clone of zerograph itself, instead of 46 s, with the same answers.

Where it fits, and where it does not

Good at

  • Costing nothing. Build, refresh and query all run locally, for zero API tokens.
  • Short answers. About 200 tokens of path:line, not a dump of files.
  • Ids, symbols and keywords. 40/40 keyword and 12/12 code on the recorded bench.
  • Staying fresh. A session hook refreshes the graph, and a refresh re-reads only the files that changed.
  • Parallel agents. A graph per checkout and one writer lock, so worktrees never wait on each other.
  • Being checkable. The risk label is four fixed thresholds printed with the counts they came from.

Know before you trust it

  • Loose wording misses a third of the time. Paraphrase reads 20/30. ask --rerank helps, and it is the one step that spends tokens.
  • It records only what a file proves. A call through a chained expression or a callback has no edge, so a "nothing uses this" wants an rg -l beside it.
  • Grep is still right for a literal. The graph is for concepts, callers and ids.
  • Three platforms. macOS arm64, Linux x64 and Windows x64.
  • A model download. The first build fetches the embedding model, about 200 MB on disk.
  • Depth varies by language. Swift is read without imports or calls, and Razor is opt-in.

Questions

Does anything leave my machine?

Build, refresh and query all run locally. ask --rerank is the only thing that spends model tokens, and only when asked.

How does it stay fresh?

The agent's session hook refreshes the graph per checkout, and a resident serve polls and re-reads only the files that changed. An answer given while files are behind says so itself. Keeping fresh

Do worktrees and branches share a graph?

No. Each checkout keeps its own graph and index in .zerograph/. The only thing shared is a cache of embeddings, text hash to vector, which is why a new worktree builds in seconds.

Which embedding model does it use?

By default the 4-bit ONNX export of embeddinggemma-300m, run on your machine. Another model can be pinned in zerograph.toml. Embeddings

Does it replace grep?

No. Ask the graph for a concept, a caller or an id; grep is still right for a literal string.