Overview
Graft attacks a specific waste in agentic coding: every task starts with the agent grepping and reading its way around the repository again, paying for the same exploration over and over. Graft does that work once and writes the result into the repo as a folder of linked markdown files — one node per system, API or concept — that agents read instead.
It builds the graph in two passes. The first is structural and deterministic: Tree-sitter extracts symbols, calls and imports, with no model and no API key required. The second is optional LLM enrichment, which adds summaries and groups related code across files using whichever provider you configure. Because the output is plain markdown, you can read and correct it yourself, and because it is a cache it is regenerable like `node_modules` — the README's recommendation is to gitignore it.
Graft is agent-agnostic. It wires into Claude Code, Cursor, Codex, Gemini, OpenCode and Copilot through a shared `AGENTS.md` instruction file plus agent-specific rule files, and also exposes an MCP server with native tools such as `graft_find_code`, `graft_file_api` and `graft_trace_calls`. The project reports up to 4× lower cost, 3× faster runs, 42% token savings, 46% fewer tool calls and +12 points on SWE-bench Verified; treat those as the maintainers' own published figures.
What it does
- Two-pass indexing: deterministic Tree-sitter parsing first, optional LLM enrichment second
- Output is a folder of linked markdown nodes — human-readable, correctable and regenerable
- Auto-detects and configures your agents during graft init, with no daemon or background service
- Claude Code integration adds a freshness statusline, auto-sync before queries, context injection and blast-radius warnings on edits
- MCP server exposing six native tools including graft_find_code, graft_file_api and graft_trace_calls
- 23 languages supported, including TypeScript, Python, Go, Java, Rust and C++
- Optional language servers (rust-analyzer, clangd, pyright) for compiler-grade precision
Getting started
Graft is a global npm CLI. Installing and initialising it in a repository is the whole setup — init detects your agents and writes their configuration for you.
Install the CLI
npm install -g @nanonets/graftInitialise it in your repository
Run this from the repo root. It performs the structural pass, writes the graph, and configures the agents it finds.
graft initAdd a provider key for enrichment (optional)
The structural pass needs no key. For summaries and cross-file grouping, configure a key for OpenAI, Anthropic, OpenRouter, Fireworks, Groq, or point it at a local model.
Keep the graph out of git
The graph is a regenerable cache, not source. Add its folder to .gitignore and let each machine rebuild it.
Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Reach for it on a large repository where agents burn most of their budget rediscovering structure before they change anything
- Reach for it when several different agents work on the same codebase and you want them to share one understanding of it
- Reach for it to get blast-radius warnings — which subsystems a file touches — before an agent edits something central
- Reach for it when you want the agent's map of your code to be something you can read and fix, not an opaque vector index
How Graft compares
Graft alongside other open-source code indexing & search tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| CodeGraph | ★ 74.3k | Builds a local SQLite knowledge graph of a codebase with a Rust tree-sitter kernel, keeps it in sync through a file watcher, and serves symbols, call paths and blast radius to coding agents over MCP. |
| GitNexus | ★ 47.9k | Indexes a codebase into a knowledge graph of dependencies, call chains and execution flows, then exposes it to Claude Code, Cursor and Codex through MCP tools. |
| codebase-memory-mcp | ★ 46.7k | A native MCP server that indexes a repository into a persistent tree-sitter knowledge graph of functions, call chains and routes, queried by agents through 15 tools. |
| code-review-graph | ★ 32.2k | A local-first code intelligence graph built with Tree-sitter that serves precise, incrementally-updated structural context to AI coding tools over MCP, so they read only the code a task needs. |
| Claude Context | ★ 12.6k | An MCP server that indexes your codebase into a vector database so AI coding agents can find relevant code by meaning instead of loading whole folders. |
| Graft | ★ 10.2k | Build your codebase's knowledge graph once, feed it to every coding agent |
| XERJ | ★ 7k | Single-binary, Elasticsearch-compatible search engine whose autoindex command turns any folder of code, docs, logs or PDFs into typed indices that AI coding agents query via CLI or MCP instead of grepping. |
| Semble | ★ 6.2k | A CPU-only code search library and MCP server that indexes a repository with tree-sitter chunking, Model2Vec embeddings and BM25, so an agent retrieves the few relevant snippets instead of grepping and reading whole files. |