Graft Code Context Layer
Build a searchable code graph for coding agents so they spend less time and context rediscovering a repository.
- Source repo
- trailhq/Trail-Code
- Stars
- ★ 12k
- Last updated
- 14d ago
- FARS reviewed
- Nov 07, 2026
- License
- MIT
- Primary language
- TypeScript
- FA score
- 52/100 · Major gaps
At a glance
- How it runs
- Works with
- Universal · cross-platformCodex · Claude Code · OpenAI API · Claude API
- Cost
- Free software; you pay for model usage
- Setup effort
- Low · running in minutes
- You'll need
- Typical use
- A developer joining a large unfamiliar repository can run graft map and let a coding agent use graft ask to identify subsystems, entry points, and relevant files.
- Not a fit if
- Teams wanting a committed shared index instead of each member running graft build
- Codebases in unlisted languages, whose files are skipped entirely
- Website
- trailhq.com/trail-code ↗ set on GitHub
- Maintenance
- Commits in the last 30 dayslast commit 2026-11-19+14.0 ★/day over 7 days
- Source review
- 52/100 · Major gaps
What does this agent do, and when should you use it?
Graft is an open-source repository context layer for coding agents including Claude Code, Cursor, Codex, and Gemini. It uses tree-sitter locally to build a symbol-level code graph, per-file cards, and call relationships, while an optional LLM-powered deep build adds concept nodes, summaries, and crux excerpts. Its output lives under the local graft/ directory and is exposed through a CLI, an MCP server, and native instruction files for supported agents. Commands such as graft ask, grep, skeleton, callers, and map locate implementations, summarize API surfaces, trace dependencies, and orient an agent within a repository; graft viz provides a local interactive viewer. Structural builds and queries require no model, key, or network, while deep enrichment uses a user-selected OpenAI-compatible endpoint, Anthropic's native API, or another documented provider path. It is a fit for teams that want persistent, refreshable repository knowledge for coding agents while keeping the structural graph on the local filesystem.
When graft build runs, Graft reads source files in supported languages, extracts functions, classes, methods, imports, and call edges with tree-sitter, and writes graft/.graph/wiring.json plus file cards that mirror the source tree. graft build --deep asks the configured model to summarize files, groups those summaries into linked concept nodes, and adds per-symbol summaries and crux excerpts; results are cached by content or body hash. graft ask returns ranked nodes with exact file:line locations, graft skeleton lists signatures from one file, graft callers walks incoming or outgoing dependencies, graft grep groups regex matches by enclosing symbol, and graft map reports directory clusters, hubs, and hotspots. Before most queries, it compares the working tree with the last fingerprint and performs a model-free incremental structural refresh when files have changed. graft init can update AGENTS.md, GEMINI.md, Cursor rules, and other native agent files, register six MCP tools, and install Claude Code project skills, a status line, and synchronization hooks; selecting the agents host can also alter user-level Codex configuration. graft viz serves local Context, Code, and Outline views on localhost.
- A developer joining a large unfamiliar repository can run graft map and let a coding agent use graft ask to identify subsystems, entry points, and relevant files.
- A team making cross-file changes with Claude Code or Codex can use graft callers or graft_trace_calls to inspect callers and estimate a symbol's blast radius.
- An engineer trying to reduce prompt size can use graft skeleton or graft_file_api to provide signatures without sending complete function bodies.
- A team maintaining a monorepo or a directory of separate Git repositories can use automatic project discovery and narrow searches with --in.
- A maintainer performing an exhaustive migration can use graft grep or graft_find_all to collect every regex match, grouped by symbol and ranked by coupling.
- A team that cannot send structural code analysis to a hosted service can use the local tree-sitter build, search, and freshness checks, enabling LLM enrichment only when acceptable.
Key setup facts
Pulled from the install and usage notes below. The project README has the current values.
- Install / run
npm install -g @nanonets/graftnpx @nanonets/graft init
- Environment variables
GRAFT_API_KEYGRAFT_MODELGRAFT_BASE_URL
How do you install or deploy this agent?
Node.js and npm or npx are required. Install the CLI globally and initialize the current repository with:
npm install -g @nanonets/graft
graft initTo avoid a global installation, run:
npx @nanonets/graft initIn CI or another non-TTY environment, init writes nothing unless the selection is explicit; use a command such as graft init --agents claude or graft init --yes. Preview every prospective write with graft init --dry-run, and add --no-global if ~/.codex/ must remain untouched. The basic graft build needs no API key. For graft build --deep, configure GRAFT_PROVIDER, GRAFT_API_KEY, and GRAFT_MODEL; with the OpenAI wire format, GRAFT_BASE_URL can target OpenAI, OpenRouter, Fireworks, Groq, LiteLLM, or a local compatible endpoint.
How do you use this agent?
For a minimal workflow, run graft build at the repository root, then use graft map for orientation or graft ask "task description" to find relevant code. Run graft skeleton <file> to inspect an API surface, graft callers <symbol> -d N to analyze transitive impact, and graft grep "<regex>" for exhaustive pattern search. After configuring provider credentials, use graft build --deep when concept nodes and model-written symbol context are wanted. Run graft check to detect drift and graft viz to open the localhost viewer. Agents can consume Graft through files and MCP configuration installed by graft init, or the server can be registered manually with npx -y @nanonets/graft mcp. Queries refresh changed structural data by default; --no-refresh or GRAFT_NO_REFRESH=1 disables that behavior.
Safety boundaries, hardening & integrations
Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.
Declared capability surface (blast radius)
Can run terminal commands; pair with approval gates or container/OS sandboxing.
Modifies local files; work on a clean Git branch or dedicated worktree.
What are this agent's strengths and limitations?
- The base graph, call edges, builds, drift checks, and queries run deterministically with tree-sitter on the local machine, without a model key or network connection.
- It exposes the same repository context through a CLI, six MCP tools, agent instruction files, and a local visualization interface.
- It goes beyond a file index by extracting symbols and cross-file calls and imports, with dedicated callers, skeleton, grep, and map operations.
- Content-hash caching and query-time incremental refreshes account for staged, unstaged, and uncommitted source changes.
- Deep enrichment supports both OpenAI-compatible endpoints and Anthropic's native API, with the model, key, and endpoint controlled by the user.
- The project reports controlled measurements and SWE-bench Verified results covering correctness, tokens, calls, cost, and elapsed time.
- Model-written concept nodes, file summaries, and symbol cruxes require the adopter's own provider credentials and usage budget; automatic synchronization does not update this deep layer.
- Hand-written full-fidelity extraction is limited to TypeScript/JavaScript, Python, Go, and Java; other listed languages use the broader generic tier, and unlisted languages are skipped.
- Compiler-grade call edges require a matching language server on PATH and are documented as a best-effort optional enhancement.
- Initialization may touch several repository files and, for the agents host, machine-wide files under ~/.codex/, so adopters should use --dry-run and --no-global where appropriate.
- The graph is a local regenerable cache, so each teammate must run graft build rather than relying on a hosted shared index.
- The reported efficiency and correctness gains come from specific models, repositories, tasks, and harness settings and do not establish the same gains for every codebase.
How does this agent compare with similar options?
Compared with a cold Claude Code session that repeatedly greps, opens files, and follows imports from scratch, Graft builds and reuses a repository graph. In the documented 162-run controlled sweep, the pushed-context Graft arm averaged 46% fewer tool calls, 42% fewer tokens, and 60% lower latency while both arms scored 93% correctness; the pull-tool variant was slower but reached 98% correctness. On 50 SWE-bench Verified instances, Claude Code with Graft resolved 33 cases versus 27 for cold Claude Code while using fewer tokens, calls, and wall-clock time. These are project-reported results for the stated test configurations, not a guarantee for every repository.
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| Graft Code Context Layer This agent | 52 · Major gaps | CLIFree + model costs | ★ 12k | 14d ago | TypeScript | Codex · Claude Code · OpenAI API · Claude API |
| GraphMind Code Graph | 55 · Major gaps | Desktop appFreemium | ★ 219 | 2d ago | Rust | Claude Code · Claude.ai |
| mex Project Memory | 84 · Good | CLIFree | ★ 1.8k | 14d ago | TypeScript | Codex · Claude Code |
| Graphicle | 84 · Good | CLIFree + model costs | ★ 638 | 2d ago | Rust | Codex · Claude Code |
How does FollowAgents rate this agent?
Why each dimension lost points
The README describes where code maps, personal learnings, and repository learnings live, and discloses boundaries for network use, past Claude sessions, PR comments, optional workspace connection, and anonymous telemetry. Initial migration reads historical content and some features contact external services; redaction, opt-out controls, and stated purposes help, but do not eliminate that deduction. `trail init --dry-run` previews agent wiring and `--agents` narrows its scope, but the sample does not establish per-action confirmation for all writes or external effects. The dependency manifest does not establish dependency security. The README gives save, check, and upgrade paths, while external-effect and rollback details remain limited. Attribution and maintenance responsibility are only partly traceable.
The README describes deterministic local parsing, refresh on changes, and language support; the source shows a public API, and the test samples cover telemetry accounting and agent-text boundaries. The packet does not suffice to reconcile all product behavior with the documentation claims, and provides little evidence on dependency availability or recovery from dependency failures. Some error situations have guidance, but general CLI failure messages and recovery paths are not shown, so these criteria receive partial support.
The product targets individuals and teams using coding agents such as Claude Code, Cursor, and Codex, with code location, impact analysis, and cross-session learnings as scenarios. The README separates local code maps, optional model summaries, and learning scopes, and states Node requirements and agent options. The sample does not establish complete trigger rules; the skill directs agents to query graft for any task, which is broad, so trigger precision is only partially supported.
The README has a clear structure with quick start, topical sections, reference material, FAQ, commands, and environment requirements. The MIT license text is complete. Migration guidance documents the graft/Trail-code transition, while README and package metadata retain inconsistent old and new package names, reducing naming stability. A package version is present but no changelog is in the sample. The security policy identifies the latest-release support approach and a vulnerability reporting route, but publisher identity and ongoing maintenance responsibility are not fully established.
The code map, call relationships, learning files, and check command offer context an agent can consume directly. The README states benchmark gains and describes measurement methods, but the supplied material leaves those results largely as claims without independent corroboration. The map and learnings could reduce repeated exploration; model summaries, historical-session reads, and workspace features add cost and operational burden, so cost-benefit is not fully established.
The README points to a public telemetry field contract and explains the code-map mechanism; source and test samples provide some corroboration for telemetry accounting and agent-text constraints. Performance and correctness benchmarks include sample counts, comparison methods, and some results, but the packet lacks complete benchmark artifacts or independent verification. Documentation generally distinguishes mechanism descriptions from quantitative claims, though several capabilities have only one supporting source.
- Before enabling migration or workspace features, confirm that the stated access and sharing scope for past sessions, PR comments, and learnings fits team requirements; the README describes redaction and limits, but the packet does not include the full implementation.
- The supplied material does not independently verify the README's performance and correctness benchmarks; treat them as project-reported results.
FAQ
Does basic use require an LLM or API key?
Where is source code processed?
What can initialization modify?
Must the graph be rebuilt manually after every edit?
Which repository layouts and languages are supported?
Thanks — we use this to improve the page.
Subscribe to the FollowAgents RSS feed, or save this agent to your browser shortlist to compare on your next visit.