Map your codebase and your coding agent finishes tasks 60% faster

6 min read
Bruce van Zyl
Bruce van ZylFounder
Map your codebase and your coding agent finishes tasks 60% faster

Every time you start a new session with Claude Code, Cursor or Codex, your agent starts from zero. It searches your project, opens a dozen files, reads half of them, and slowly works out how everything fits together. Then the session ends and all of that is gone.

Graft fixes that. It builds a map of your codebase once, keeps it up to date, and lets the agent look things up instead of rediscovering them. We added it to one of our production apps, Sabi And we immediately saw efficiency and speed improvements. Here's what Graft is, why it's worth adding, and a prompt you can copy/paste to setup.

Why agents burn through your usage

Ask an agent to make a button green and, before it can change anything, it has to find that button. So it searches for a word, reads the results, searches again, opens a file, reads a bit, and only then edits.

Every one of those steps is a round trip to the model, and each round trip resends everything the agent has read so far. The more it searches, the slower and more expensive each step gets. On a big task, most of your usage goes on reading, not building.

Here’s how Graft fixes this

Graft is a free, open source tool from the team at Trail. It works with Devin, Claude Code, Cursor, Codex, Gemini and most other coding agents.

It reads your code and writes down every meaningful part of your app, where it lives, and which parts use which. That becomes a map the agent can follow. Ask "what uses the checkout function?" and Graft answers with the exact files and lines.

A few things we like about it:

  • Building the map is free. It doesn't use an AI model, so there's no extra spend.
  • It stays up to date on its own. Before answering, Graft checks what changed and refreshes only that.
  • It stays out of your repo. The map lives in a local graft/ folder that isn't committed. Teammates run one command to build their own copy.
  • Plain-English explanations are optional. One extra command uses an AI model to write a short page describing each system in your app. Handy on a big codebase, skippable on a small one.

Why add it to your repo

Trail ran a controlled benchmark across 162 runs. Their numbers, not ours:

  • 46% fewer steps per task.
  • 42% less reading (input tokens).
  • 60% less time.
  • 32% lower cost on average, with accuracy up, not down.

Day to day:

Less rediscovery. The agent asks the map where something lives and gets a straight answer. No 10-file reading spree before it can start.

Fewer broken features. Before changing a function, the agent sees everything else that uses it. This is the big one for us. It stops breaking things it never opened.

Cheaper sessions. Fewer steps per task adds up fast when you have several agents running all day.

Easy to remove. It's a folder and a few config files. If it isn't earning its place, delete it.

Set it up With this prompt

Rather than doing it by hand, give this to your coding agent in the root of your project. It installs Graft, checks the map is right, and makes sure every agent uses it.

Set up Graft (https://github.com/NanoNets/graft) in this repo so you and every other coding agent use it as the first stop for questions about the codebase.

1. Install and initialise
   - Run `npm install -g @nanonets/graft` (or use `npx @nanonets/graft` if a global install is not possible).
   - Run `graft init --dry-run` first and show me the list of files it would write.
   - Then run `graft init` and wire up every coding agent this repo is used with. Let it finish building the graph.
   - Confirm `graft/` exists and is listed in `.gitignore`. It is a regenerable cache and must never be committed. The wiring files `init` created outside that folder should be committed.

2. Verify the map
   - Run `graft map` and confirm the main systems of this repo show up as clusters.
   - Run `graft ask "<a real question about how a core feature in this repo works>"` and check the answer points at the correct files and lines.
   - Run `graft callers <a widely used function>` and confirm the call sites are complete.
   - Run `graft check` and confirm the graph is not stale.
   - If anything is missing or wrong, re-run `graft build` and check again. Report what you found.

3. Make sure every agent uses it
   - Open the instruction file each agent reads (CLAUDE.md, AGENTS.md, .cursorrules or equivalent). Confirm the Graft section or skill that `init` wrote is present.
   - If this repo has a CLAUDE.md, add a short "Code map (Graft)" section pointing to the Graft skill, since `init` does not edit CLAUDE.md. Keep it under 10 lines with these rules:
     - Before grepping or opening files to understand the codebase, run `graft ask "<question>"` and follow the file:line references.
     - Use `graft grep <pattern>` instead of plain grep for symbol and pattern searches.
     - Before editing any function, run `graft callers <symbol>` and read every call site.
     - Use `graft skeleton <file>` to learn a file's shape before reading the whole thing.
     - Never edit or commit `graft/`. If results look stale, run `graft build`.

4. Optimise
   - If the map is noisy, rebuild with `graft build --extensions <the code extensions this repo actually uses>` so generated code, vendored dependencies and fixtures stay out. Confirm the map is cleaner.
   - If I have set GRAFT_PROVIDER and GRAFT_API_KEY in the environment, run `graft build --deep` once to add the plain-English concept pages. If not, skip this and tell me how to enable it.
   - Add a one-line note to the README or CONTRIBUTING file telling new developers to run `graft build` after cloning.

5. Finish
   - Summarise what you installed, what you changed, and 2 or 3 example `graft ask` questions that worked well on this repo.
   - Do not commit. Leave the changes for me to review.

Give it a try

Once it’s working, you’ll see a new line at the end of each task from the agent telling you how much more efficient it was with Graff.

If you try it, send me a reply and tell me how it goes! And if you want more of how we build with agents at Inovo, the rest of our articles are here.

Share this article