Graft builds a context layer for a codebase so a coding agent does not re-explore it on every task. graft build parses the repository with tree-sitter into a per-symbol wiring graph and per-file cards; graft build --deep adds a language-model layer that summarises each file and groups those summaries into a curated set of markdown nodes — one per subsystem, API, or concept — with typed links between them. The graph is written to graft/ and added to .gitignore as a regenerable local cache; what a team commits is the wiring graft init drops in.
A node is one markdown file. It holds a plain-English summary of what that part of the system does, a crux of the few lines that carry the logic — stored as the code itself rather than as line numbers, so it survives unrelated edits above it — the content-hashed source files it was built from, typed [[wikilink]] connections such as depends_on and produces, and any notes you write below the generated block, which survive regeneration.
Every query refreshes the graph against the working tree first: a structural check of roughly 3 ms that never calls a model, so ask, grep, callers, skeleton, and map describe the code as it is right now, uncommitted edits included. Only the --deep layer calls a model, through whichever provider, key, model, and base URL you configure.
Two measurements compare the same agent with and without Graft: a 162-run sweep across two repositories, using a Claude Sonnet 5 agent scored by a separate Opus 4.8 judge against a required-keyword floor, and 50 SWE-bench Verified instances on the same model, images, and turn limits, graded by the official harness.
| Measure | Cold Claude Code | Claude Code with Graft |
|---|---|---|
| Tool calls per task (sweep) | 4.2 | 2.3 |
| Tokens per task (sweep) | 8,070 | 4,650 |
| Latency per task (sweep) | 39.8 s | 15.8 s |
| Correctness (sweep) | 93% | 93% |
| SWE-bench Verified resolved | 27 / 50 | 33 / 50 |
graft init detects the coding agents on the machine and writes each one's native instruction or rule file — a marker-fenced section in AGENTS.md, GEMINI.md, or .github/copilot-instructions.md, or an owned skill file for Claude Code, Cursor, Kiro, Windsurf, Grok, and AdaL — then registers a Model Context Protocol server exposing six tools.
Features
- Two-tier graph: a deterministic tree-sitter wiring graph plus an optional model-written concept layer
- Markdown nodes: summary, crux, content-hashed sources, typed wikilinks, and preserved user notes per node
- Fresh on every query: a structural restat rebuilds only what moved, so answers cover uncommitted edits
- CLI: ask, grep, callers, skeleton, and map for search, blast radius, file API surfaces, and repository orientation
- MCP tools: graftfindcode, graftfileapi, grafttracecalls, graftfindall, graftrepomap, and graftcheckfreshness
- Agent wiring: graft init writes instruction or skill files for Claude Code, Codex, Cursor, Gemini, Copilot, Kiro, Windsurf, Grok, AdaL, and other CLIs, with --dry-run and --agents for control
- Claude Code hooks: a statusline with graph size and staleness, background re-sync after each turn, and blast-radius warnings when a file is edited
- Language coverage: 23 languages — scope-aware extractors for TypeScript/JavaScript, Python, Go, Java, Kotlin, PHP, Swift, and R, plus broad symbol and call extraction for Rust, C, C++, C#, Ruby, Scala, Elixir, Solidity, and others
- Optional compiler-grade edges: graft build --lsp adds resolved call edges via rust-analyzer, clangd, gopls, pyright, or typescript-language-server
- Provider choice: the --deep layer runs against OpenAI, the native Anthropic API, OpenRouter, Fireworks, Groq, OrcaRouter, a LiteLLM proxy, or a local model
- Content-hash caching: every pass replays unchanged files, so a rebuild after one edit is a fraction of a cold build
Integrates with
Claude Code
Terminal-based agentic coding tool that reads your codebase and runs tasks through natural-language commands
Codex
Lightweight coding agent that runs in your terminal
LiteLLM
Open-source AI gateway exposing 100+ LLM providers through one OpenAI-compatible interface, as a Python SDK or self-hosted proxy
Model Context Protocol
Open protocol plus SDKs for connecting agents to tools and data sources.
