Purpose
Graft (now renamed Trail-code) is a self-learning context layer for coding agents. It gives coding agents such as Claude Code, Cursor, Codex, and Gemini a code map, along with the understanding the team has already accumulated about that code, so they can complete tasks faster and more cheaply.
Trail-code consists of two parts, both of which run on the user's local machine:
- graft map (code graph): through
trail initparses the repository with tree-sitter and generates a graph of every file, function, and call relationship. No model and no API key are required. When the code changes (including uncommitted modifications), it refreshes automatically. On each prompt, the agent receives matching file and function pointers, and after an edit it immediately sees what depends on that file. - Learnings: when a session reaches a conclusion, or the user corrects an approach, the agent saves it as a learning. The next session (whether by the same person or a team member) starts from there instead of figuring it out again. Learnings about code are committed together with the code; personal learnings stay on the local machine.
trail initalso reads information that repeatedly appeared in past Claude Code sessions as initial learnings.
Main capabilities
- Code graph: tree-sitter parsing generates a symbol and call relationship graph, deterministic, model-free, network-free, and supports 23 languages.
- Provide relevant code with prompts: in Claude Code, hooks add matching files and functions to each prompt, and after an edit show the "blast radius" of files that depend on it. Cursor, Codex, and others get the same graph through MCP tools and instruction files.
- Always kept up to date: each query first checks the working tree and rebuilds only the changed parts, including uncommitted edits.
- Pure file form: linked markdown nodes that agents can open and search like ordinary files, without using vector embeddings.
- Optional summaries:
trail build --deepuses the model provider and key chosen by the user to generate plain-language summaries of each part of the system. - Learnings: divided into personal and repo storage locations, and decision and preference content types; saved as short markdown files under
.trail/learnings/and reviewed together with the PR. - Team sharing: learnings spread through git, with no server required.
trail teamshows what the team learned in the last 7 days and where work overlaps.trail checkcompares changes with the team's existing learnings before committing, pushing, or opening a PR. - Does not rewrite history: the agent will not edit existing learnings; if there is a conflict, it explains the reason in the commit and saves a new learning.
How to use
Just run trail init. It will ask which coding agents to wire up, build the graft map from the code, create .trail/ to store the repository's learnings, and add a status line and hooks for Claude Code. It will also read past Claude Code sessions in that repository once, find things you have said more than twice, and save them as learnings; this read is done by the local Claude Code and takes about a minute. After that, just work as usual: no daemon, no server, everything is files.
It is recommended to commit this configuration so team members can use it too. The graft map itself is located in graft/, is a local cache similar to node_modules, and should be added to .gitignore.
Related commands:
trail init --dry-run: show the agent wiring that will be written.trail init --agents claude: wire up Claude Code only.graft grep、graft map、graft viz: The original graft command is still available.trail build --deep: Generate a deep summary.trail check: Checks before committing.trail team: View the team's activity over the past 7 days.trail telemetry disableor the environment variableDO_NOT_TRACK=1: Disable anonymous usage statistics.
Migrating from graft: the code graph is now called graft map;graft and @nanonets/graft run the same code as trail , and the output remains unchanged. Existing graft users who run graft upgrade will add the trail command alongside it. Repositories configured by graft will be migrated automatically the first time Claude Code is opened in that repository after the trail command is installed; you can also run trail init to migrate immediately.
Effectiveness data (officially provided)
- On SWE-bench Verified, with the same model (Claude Sonnet 5) compared: with graft map, 33 of 50 problems were solved; without it, 27 were solved; tool calls decreased by 25%, tokens decreased by 23%, and time decreased by 32%. The text mentions that Claude Sonnet 5 solved 33/50 with graft map and 27/50 without it, and used 23% fewer tokens.
- In 162 runs of the same task with the same agent: cost decreased by 32%, uncached input tokens decreased by 42%, time decreased by 60%, and the correct ratio was the same. The text also mentions 46% fewer tool calls, 42% token savings, 60% less time, and an improvement in accuracy for cold Claude Code.
- On PocketBase, 15 real tasks cost 21% less and were 14% faster.
- In the hashicorp/go-retryablehttp example, one learning can give a teammate's agent a "head start" of about 27k tokens.
Note: The comparison figures in different paragraphs are not entirely consistent (for example, 23% vs. 42% token savings, and different benchmarks); all are listed as in the original text.
Privacy and data boundaries
- Code: graft map is built locally with tree-sitter, with no model and no network. The optional
trail build --deepsummary is sent to the model provider chosen by the user, using the user's own key. - Personal learnings: stored in
~/.trail, never committed, never uploaded. - Repository learnings: files located in the repository, shared through git like other files.
- Historical sessions:
trail initreads your own messages in that repository's Claude Code records locally, completed by local Claude Code (Claude Sonnet, your login); messages are sent only to Anthropic and count toward your Claude usage, and are not sent to Trail. - If connected to a Trail workspace: no learnings are uploaded before connecting; after connecting, learnings in the selected repositories will be uploaded to Trail, including content on branches already pushed by teammates, as well as a record of each search and check (search text, files, whose learnings were shown).
- Anonymous usage statistics: only bucketing and fixed labels are used, and never the title, text, or path of a learning;
TELEMETRY.mdlists each field, and you can usetrail telemetry disableorDO_NOT_TRACK=1Close.
Use cases
- Use coding agents in large or unfamiliar codebases, hoping to reduce repeated exploration.
- Team collaboration: want members' agents to share decisions and conventions about the code, and for this content to propagate with PR reviews and with git.
- Monorepo scenarios (the text mentions support for monorepos; see the official reference for details).
- When you need to understand the scope of impact of changes (blast radius).
Limitations and information not yet provided
- For the specific configuration, task list, and complete results of each benchmark, see the benchmark documentation in the official repository.
- The Trail workspace team page (cross-repository view, who is learning what, learning reuse frequency, work overlap) is marked as "coming soon" and is not yet provided.
- The official materials do not state pricing, billing methods, or commercial licensing models.
- Details not provided, including installation command details, specific MCP configuration examples, the complete list of 23 supported languages, specific node contents, and where each part runs, all require consulting the official reference documentation.
- Not all features take effect for all agents: Claude Code integrates via hooks, while Cursor, Codex, and others integrate via MCP tools and instruction files.
- Anonymous statistics can be disabled via configuration.