Graft
Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.
Install / Use
npx skills add trailhq/GraftInstalls into whichever agent you are using.
CLAUDE.md
Claude Code project instructions
Quality Score
Category
AI & Machine LearningSupported Platforms
Our assessment of Graft
Graft scores 88/100 on our quality scale, 452nd of 957 AI & Machine Learning skills we index (top 48%).
Its CLAUDE.md is 42 KB long, well organised into 31 sections with 9 code examples: long enough that it reads more like full documentation than a focused instruction file, which agents can find harder to follow.
With 9,835 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated today, so Graft is actively maintained.
- Our last check on 2026-09-24 found the source still online.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-09-24. Automated pattern scan on 2026-09-24. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
Graft compared with similar skills
All 4 of these similar skills score higher than Graft; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| Graft (this skill)by trailhq | 88 | 9.8k | today | CLAUDE.md |
| claude-memby thedotmack | 100 | 98.9k | today | CLAUDE.md |
| Agent-Reachby Panniantong | 100 | 94.6k | 1d ago | CLAUDE.md |
| Understand-Anythingby Egonex-AI | 100 | 85.7k | today | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 74.8k | today | CLAUDE.md |
Frequently asked questions
- How do I install Graft?
- Run
npx skills add trailhq/Graft. The install tabs above show the steps for each supported agent. - Which AI agents does Graft work with?
- It is written for Claude Code, Cursor, Gemini CLI and OpenAI Codex, as a CLAUDE.md file. Other agents that read the same format can often use it too.
- Is Graft safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is Graft still maintained?
- The repository was last updated today, so Graft is actively maintained.
Skill content
View source on GitHubTurbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.
<a href="https://trendshift.io/repositories/92209?utm_source=trendshift-badge&utm_medium=badge&utm_campaign=badge-trendshift-92209" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/trendshift/repositories/92209/daily?language=TypeScript" alt="trailhq/Graft | Trendshift" width="250" height="55"/></a>
<p> <a href="https://github.com/NanoNets/Graft"><img src="https://img.shields.io/github/stars/NanoNets/Graft?style=for-the-badge&logo=github&logoColor=white&label=Star%20on%20GitHub&color=FFC83D" /></a> <a href="https://trailhq.com/graft"><img src="https://img.shields.io/badge/website-trailhq.com/graft-E5484D?style=for-the-badge" /></a> <a href="https://discord.gg/zxmKweAA29"><img src="https://img.shields.io/badge/Discord-join-5865F2?style=for-the-badge&logo=discord&logoColor=white" /></a> <a href="https://www.npmjs.com/package/@nanonets/graft"><img src="https://img.shields.io/npm/v/%40nanonets%2Fgraft?style=for-the-badge&logo=npm&logoColor=white&label=npm" /></a> <a href="https://www.npmjs.com/package/@nanonets/graft"><img src="https://img.shields.io/npm/dm/%40nanonets%2Fgraft?style=for-the-badge&logo=npm&logoColor=white&label=downloads" /></a> <a href="https://nodejs.org"><img src="https://img.shields.io/node/v/%40nanonets%2Fgraft?style=for-the-badge&logo=nodedotjs&logoColor=white" /></a> <img src="https://img.shields.io/badge/TypeScript-strict-3178C6?style=for-the-badge&logo=typescript&logoColor=white" /> <img src="https://img.shields.io/badge/License-MIT-20C997?style=for-the-badge" /> <a href="TELEMETRY.md"><img src="https://img.shields.io/badge/telemetry-anonymous%2C%20opt--out-546FFF?style=for-the-badge" /></a> <a href="https://scorecard.dev/viewer/?uri=github.com/NanoNets/Graft"><img src="https://img.shields.io/ossf-scorecard/github.com/NanoNets/Graft?style=for-the-badge&label=openssf%20scorecard" /></a> <a href="https://app.trailhq.com/get-started?step=repo"><img src="https://img.shields.io/badge/Trail%20Brain-try%20it-E5484D?style=for-the-badge&logoColor=white" /></a> </p>Up to 4× cheaper and 3× faster, with better or no loss of correctness.
| Metric | Cold Claude Code | Claude Code with graft | |---|---|---| | Tool-call reduction | Baseline | +46% | | Token savings | Baseline | +42% | | Time savings | Baseline | +60% | | Correctness | 54% | 66% (+12 pts) |
</div> <p align="center"> <b>Stop repeating yourself to your coding agent.</b><br/> You correct it, and by the next session it has forgotten. Trail Brain manages your CLAUDE.md and AGENTS.md so it doesn't. </p> <p align="center"> • Every correction you make becomes a rule your agent keeps.<br/> • The ones that can't break get a hook that blocks it, not a note it ignores. </p> <p align="center"> <a href="https://app.trailhq.com/get-started?step=repo"><img src="https://img.shields.io/badge/Try%20it%20on%20your%20repo%20%E2%86%92-E5484D?style=for-the-badge" alt="Try it on your repo" height="34"/></a> </p> <p align="center"> <img src="assets/graft-comparison-demo.gif" alt="Side-by-side comparison of a coding agent working with and without graft" width="820"/> </p>Contents
- Quick start
- The problem
- What Graft does
- Benchmark
- SWE-bench Verified
- How the graph gets built
- Supported languages
- What's in a node
- What runs where
- Agent integration — MCP server · Claude Code (deep integration)
- CLI
- Search & orient (
graft grep/graft map) - Monorepos & multi-repo folders
- Visualize it (
graft viz) - Tested on your popular repos
- Development
- License
Quick start
npm install -g @nanonets/graft # install the CLI, once
graft init # build the graph + wire it into Claude Code
That is the whole setup. graft init asks which of your coding agents to wire up, builds graft/ from your code, and drops a statusline and hooks into .claude/, so from the next session on Graft rides along in Claude Code: it pulls the matching nodes into each prompt and rebuilds the graph in the background after every turn. No daemon, no re-indexing to remember, nothing to run or maintain by default — the graph is just files.
Nothing is written until you pick. Run graft init --dry-run to see every file it would touch first, or graft init --agents claude to skip the prompt and wire Claude Code alone.
graft build adds graft/ to your .gitignore automatically — the graph is a local, regenerable cache (like node_modules), not something you commit. What you share is the wiring init dropped into .claude/; each teammate runs graft build to generate their own graph:
git add .claude && git commit -m "wire in graft"
Prefer not to install globally? npx @nanonets/graft init works the same way.
The problem
Every task, your coding agent starts blind. Before it changes anything, it re-explores the repo: grep a term, open a file, follow an import, back out, try again. It is rebuilding a picture of a codebase it mapped an hour ago and threw away. That rediscovery burns most of a run's tool calls, tokens, and latency, and it is pure overhead:
- Repeated. Every task pays the exploration cost again, from zero.
- Discarded. Whatever the agent figured out dies with the session.
- Unshared. The next teammate, and their agent, start from scratch too.
Humans onboard to a codebase once. Agents onboard every single time.
<p align="center"> <img src="assets/graft-site-act-demo.gif" alt="A no-map agent's exploration trail wandering file to file before it finds what it needs" width="820"/> </p>What Graft does
Graft builds that understanding once and writes it into your repo as a folder of linked markdown files, one node per system, API, or concept.
- Real explanations, not a list of symbols. Each node says, in plain English, what a part of the system does and how it connects to the rest, the way a senior engineer would explain it. That is the part an agent actually needs so it can skip the exploration. It is not a dump of function names.
- A real graph you can read. No embeddings, no similarity search, no index to keep warm. The graph is a set of linked files your agent opens, greps, and follows, exactly the way it reads any other file in the repo.
- A local cache, not a committed artifact.
graft buildwritesgraft/and adds it to.gitignore— it's a regenerable local cache, likenode_modules. What you commit is the small wiringgraft initdrops in (.claude/,AGENTS.md, the MCP config); each teammate runsgraft buildto generate their own graph. No database, no server, no setup. - Always fresh, automatically. Every query rebuilds the graph against the working tree first — structural,
$0, ~3ms when nothing moved — soask/grep/callers/skeleton/mapdescribe the code as it is right now, including uncommitted edits.graft checkis a local freshness signal; there's no stale index to babysit. - Your provider, your key, your model. Summaries are written by any provider you choose — OpenAI, Anthropic (native), OpenRouter, Fireworks, Groq, OrcaRouter, a LiteLLM proxy, or a local model — under your own key. The structural code graph (
graft build,graft check) is deterministic tree-sitter and never calls a model at all.
Benchmark
An agent that reads the graph should be cheaper and faster without getting more answers wrong. That's the whole claim, so we measured it instead of asserting it.
The harness ran three variants of the same Claude Sonnet 5 agent with the same file tools: cold (explores from zero), Graft (a graft ask --source bundle pushed up front), and pull (graft_find_code/graft_file_api tools, nothing injected — context paid for only when asked). An Opus 4.8 judge scored correctness with a required-keyword floor, so a fast-but-wrong answer couldn't win by being fast. Cost is cache-aware: reads ≈0.1×, writes 1.25×, the billing model agents actually run under.
162 runs, two repos (graft itself and a real Node/Express auth service), 3 trials each, tasks split between single-file and multi-file questions.
| Metric (mean/task) | Cold Claude Code | Claude Code with graft | |---|---|---| | Cost savings ($) | 0.0429 | 0.0292 (+32%) | | Token savings | 8,070 | 4,650 (+42%) | | Tool-call savings | 4.2 | 2.3 (+46%) | | Latency savings (s) | 39.8 | 15.8 (+60%) | | Correctness | 93% | 93% (equal) |
Graft never answered worse than cold, on any corpus. The pull variant gave up most of that speed for something bigger: correctness jumped to 98%, +5 points over cold, the strongest single result in the sweep. Push when speed is what you need; pull when being right matters more.
SWE-bench Verified
The sweep above is our harness measuring our mechanism. So we ran the industry-standard one too — SWE-bench Verified, real GitHub issues from real repos, graded by the official swebench harness. No judge model, no similarity score: your patch is applied, the maintainers' own tests are run, and you either flip the failing test without breaking the passing ones or you don't.
50 instances, same model on both arms — Claude Sonnet 5 — same Docker images, same turn limits. The only difference is whether graft is wired in.
| Correctness & efficiency | Cold Claude Code | Claude Code with graft | Improvement | |---|---|---|---| | Correctness | 27 / 50 (54%) | 33 / 50 (66%) | +12 pts | | Token savings | 142.0M | 109.4M | +23% | | Cost savings | $52.34 | $42.43 | +19% | | Tool-call savings | 1,370 | 1,031 | +25% | | API-request savings | 2,455 | 1,875 | +24% | | Wall-clock savings | 13,094s | 8,922s | +32% |
graft resolved 33 of 50 instances against Cold Claude Code's 27 — and got there with 25% fewer tool calls, 23% fewer tokens, and 32% less wall-clock time. Every correctness win has the same shape: the baseline patches one file and misses its siblings. On django-11532 it patched 1 of the 5 files the fix requires and broke 18 previously-passing tests, twice over. On django-16263 it patched 1 of 4 and scored 102 / 103. graft found the rest — and on django-16263 did it in half the tokens and half the time.
Two harnesses, two claims: the controlled sweep says graft is cheaper and faster, SWE-bench says it's also more correct.
<sub>Correctness over all instances; tokens, cost and calls over the instances both arms resolved, for a like-for-like comparison. Official SWE-bench V
Truncated for display — read the full file on GitHub.
Related Skills
claude-mem
98.9kPersistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
Agent-Reach
94.6kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
Understand-Anything
85.7kGraphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
headroom
74.8kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
