DEV Community

gentic news
gentic news

Posted on • Originally published at gentic.news

Graft: Replace MCP Tool Calls with a Semantic Code Map That Cuts Agent

Install Graft via npm, run graft init, and Claude Code gets a persistent semantic map via hooks — cutting exploration tool calls and boosting SWE-bench Verified to 66%.

What Changed

NanoNets just open-sourced Graft — a CLI that builds a persistent semantic map of your codebase and wires it into Claude Code (plus Cursor, Codex, and Gemini) using hooks instead of MCP tools. The premise is simple: your coding agent re-explores the repo from scratch on every single task. Graft eliminates that overhead.

The numbers come from a 162-run controlled benchmark: same agent, same file tools, only the context differs. Graft resolved 66% of SWE-bench Verified instances vs 54% for cold Claude Code. That's a 12-point jump from context alone.

What It Means For You

Every time Claude Code starts a task, it greps, opens files, follows imports, backs out, and tries again — rebuilding a mental model it already had an hour ago. That rediscovery burns most of a run's tool calls, tokens, and latency. And it's pure waste: repeated per task, discarded per session, unshared across teammates.

Graft fixes this by building that understanding once and writing it into your repo as a folder of linked markdown files. Each node describes a system, API, or concept in plain English — not a dump of function names. It's the explanation a senior engineer would give, which is exactly what the agent needs to skip exploration.

Try It Now

Setup is two commands:

Graft — open-source context layer for large codebases

npm install -g @nanonets/graft
cd your-repo && graft init
Enter fullscreen mode Exit fullscreen mode

graft init asks which agents to wire up, builds the graft/ folder from your code, and drops a statusline and hooks into .claude/. From the next session, Graft rides along: it pulls matching node context into each prompt and rebuilds the graph in the background after every turn. No daemon, no re-indexing, nothing to maintain.

Safety first — run graft init --dry-run to see every file it touches, or graft init --agents claude to skip the prompt. The tool auto-adds graft/ to .gitignore (it's a regenerable cache, like node_modules). Share the wiring by committing .claude/; each teammate runs graft build to generate their own graph.

Why Hooks Beat MCP Here

The HN title says it: "Claude Code kept ignoring our MCP tools, so we used hooks instead." MCP servers are great for external APIs, but for codebase context, agents often skip them — the tools add latency, and the agent doesn't know which one to call. Hooks inject context unconditionally at the right moment. No tool selection, no missed calls.

The same task, 'fix the auth bug', run two ways. A cold Claude Code session re-reads the repo and wanders file to file; Claude Code + graft loads its

What's In The Box

  • graft grep / graft map — search and orient commands for humans too
  • graft viz — visualize the graph
  • Monorepo support — handles multi-repo folders
  • MCP server mode — if you prefer the MCP route for other agents

Two commands — npm install and graft init — then Graft rides along in a Claude Code session, statusline synced

The Tradeoff

One HN commenter flagged the cost concern: summarizing every source file with an LLM could get expensive or low-quality on huge repos. Graft mitigates this by rebuilding only what changed in the background, but if you have a massive monorepo, test it on a slice first with --dry-run.

Bottom line: if you're watching Claude Code burn tokens re-exploring a codebase it already knows, Graft is worth a weekend try. The SWE-bench delta is real, and the setup cost is two commands.


Source: github.com


Originally published on gentic.news

Top comments (0)