Skip to content
gentic.news — AI News Intelligence Platform
Connecting to the Living Graph…

Listen to today's AI briefing

Daily podcast — 5 min, AI-narrated summary of top stories

A developer's terminal screen showing Graft CLI building a semantic code map with colorful graph nodes and hook…
Open SourceScore: 92

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%.

·1d ago·3 min read··17 views·AI-Generated·Report error
Share:
Source: github.comvia hn_claude_code, gn_mcp_protocol, devto_mcp, reddit_anthropicWidely Reported
How do I use Graft to give Claude Code a persistent semantic map of my codebase?

Graft is an npm CLI that builds a semantic graph of your codebase as linked markdown files, then wires into Claude Code via hooks and a statusline. It resolves 66% of SWE-bench Verified instances vs 54% for cold Claude Code, cutting exploration overhead by injecting matching node context into every prompt.

TL;DR

Graft builds a persistent markdown graph of your codebase, wiring into Claude Code via hooks so agents skip re-exploration and cut tool calls drastically.

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

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

Source: gentic.news · · author= · citation.json

AI-assisted reporting. Generated by gentic.news from multiple verified sources, fact-checked against the Living Graph of 4,300+ entities. Edited by Ala SMITH.

Following this story?

Get a weekly digest with AI predictions, trends, and analysis — free.

AI Analysis

Claude Code users should rethink how they provide codebase context. The default assumption is that MCP servers are the best integration point — but Graft demonstrates that hooks can be more reliable for internal context because they fire unconditionally. If you've built custom MCP tools for repo navigation and Claude Code ignores them, consider converting that logic into a hook that injects a pre-built summary into the system prompt. Second, adopt the "build once, reuse forever" mental model. Instead of letting Claude Code re-discover your architecture every session, invest in generating a persistent semantic map (Graft or a hand-maintained CLAUDE.md). The 12-point SWE-bench improvement shows context quality matters as much as model capability. Pair Graft with a strong CLAUDE.md — the graph gives structural understanding, the markdown file gives conventions and preferences. Finally, benchmark your own workflow. Run the same task with and without Graft, count tool calls and tokens. The 162-run controlled benchmark is the right methodology — same agent, same tools, only context differs. If you're not measuring context overhead, you're flying blind on token spend.
This story is part of
The AI Infrastructure War Shifts from Chips to Developer Tools
Nvidia's enterprise pivot and AWS's OpenAI bet collide with Cursor's quiet ascent
Compare side-by-side
Claude Code vs Graft
Enjoyed this article?
Share:

AI Toolslive

Five one-click lenses on this article. Cached for 24h.

Pick a tool above to generate an instant lens on this article.

Related Articles

From the lab

The framework underneath this story

Every article on this site sits on top of one engine and one framework — both built by the lab.

More in Open Source

View all