Tech News

Graft: The Open Source Tool That Maps Your Code for AI Agents

Your AI agent reopens the same repository for the tenth time in a day, and as always, it starts from scratch: it searches for a term, opens a file, follows an import, backtracks, and starts over. Graft, an open source tool released by Nanonets under the MIT license, aims to provide a concrete answer by turning your code into a map that the agent reads before acting.

A repository map, written in Markdown

Humans onboard to a codebase once. Agents onboard every single time. That is what you can read on Graft's GitHub page. Indeed, a human developer gets familiar with a project once, whereas an AI agent rediscovers it every session. This repeated exploration burns tokens and time, while also calling on tools each time.

This is where Graft comes in. It builds that understanding once and writes it into a graft/ folder, as interconnected Markdown files. The idea is to create a map of the repository to help the AI navigate it more effectively. It then creates one node per subsystem, API, or concept. Each node contains a natural-language explanation of what the code does, the few lines that actually hold the logic, the list of source files tracked by content fingerprint, and typed links to the other nodes.

This is a different approach compared with vector indexes, because here there are no embeddings, no similarity search, and no index to maintain. The structural analysis relies on tree-sitter and remains deterministic. At the moment, Graft can perform this discovery work for 21 languages, with fine-grained resolution of cross-file calls for TypeScript, JavaScript, Python, Go, and Java. It is more generic for about fifteen other languages (Rust, C, C++, C#, Ruby, PHP, Kotlin, Swift, and others).

This tool itself needs AI to work, but only for the summary layer, where it relies on a model. You are free to provide the API key of a Cloud provider or to use a local model.

Promised gains, but measured by the vendor

All the figures published about Graft come from benchmarks run by Nanonets, the vendor behind the open source Graft tool. That said, they do give an idea of the benefits you may get from using it.

Nanonets ran an initial test series based on 162 executions and two repositories, with a Claude Sonnet 5 agent using the same tools in each configuration:

  • Tool calls: 2.3 per task versus 4.2 without Graft, down 46%.
  • Uncached input tokens: 4,650 versus 8,070, down 42%.
  • Latency: 15.8 seconds versus 39.8 seconds, down 60%.
  • Accuracy: 93% in both cases, so it is even.

On PocketBase, a Go project with about 350 files, the vendor reports a 21% lower cost and a 14% lower execution time across fifteen tasks. That is still a meaningful gain, especially for those where every token saving matters.

Graft is still a very young project, with its first release on npm on July 15, 2026, but I like the approach; it is promising. If you want to try it, installation takes just two lines (requires Node.js 20 or later):

npm install -g @nanonets/graft
graft init

The graft init command is used to detect installed agents and write their instruction files. Several are supported, including Claude Code, Cursor, Codex, Gemini, and GitHub Copilot. Find more information on the Graft GitHub repository and the official Graft website.

author avatar
Florian Burnel Co-founder of IT-Connect
Systems and network engineer, co-founder of IT-Connect and Microsoft MVP "Cloud and Datacenter Management". I'd like to share my experience and discoveries through my articles. I'm a generalist with a particular interest in Microsoft solutions and scripting. Enjoy your reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.