Trail-code

Updated Published

Trail-code (formerly graft) is an MIT-licensed CLI that gives coding agents a map of your codebase and a set of team learnings, kept as files in your repo.

Trail-code was called graft until its rename in version 0.22.0 (October 2026). The npm package @nanonets/graft still works and gets every release alongside @trailhq/trail-code, and the graft command still runs. Trail-code is the open-source coding CLI from Trail, whose rules platform has its own profile.

Best for: developer teams who want Claude Code, Codex, Cursor and other coding agents to start from what the team already decided

Trail-code official site

What is Trail-code?

Trail-code, formerly graft, is an open-source CLI that gives coding agents such as Claude Code, Codex and Cursor a map of your codebase and a shared set of team learnings. Both live as files in your repo, and learnings are reviewed in pull requests like the code they describe.

It has two parts, and both run on your machine. The graft map is a tree-sitter parse of every file, function and caller, written as linked markdown the agent can open and grep. Learnings are short markdown files. trail init seeds the first ones from your past sessions and PR reviews; after that the README says the agent saves one when you ask or correct it, and never on its own. Learnings about the code are committed with it; learnings about you stay local. Sharing runs through git today; the README lists a cross-repo Trail workspace as coming soon, and the changelog describes an early sign-in to it.

How does Trail-code work?

  1. Install with npm install -g @trailhq/trail-code and run trail init in the repo.
  2. trail init asks which coding agents to wire up, builds the graft map, creates .trail/ for the repo's learnings and adds hooks and a statusline to Claude Code.
  3. On day one, trail init starts you off with what you told Claude more than once in past sessions in the repo and, when gh is signed in, what reviewers flagged on more than one of the repo's last 50 merged PRs.
  4. When you say "save this as a learning", the agent writes a markdown file in .trail/learnings/; the README says it never saves one on its own or offers to. It never edits an existing learning, and when it goes against one it says why in the commit.
  5. Commit .trail/ and every clone gets the learnings, reviewed in the pull request. trail check flags a change that goes against a recorded decision before the PR, quoting who decided it and why; before a commit it warns rather than stops.

How much does Trail-code cost?

As of 31 October 2026, Trail-code is free and MIT licensed, and we found no paid tier for it on /trail-code or /pricing, and no price for the Trail workspace. An API key is optional and only adds written summaries from trail build --deep. Reading past Claude Code sessions during setup runs under your own Claude login and counts toward your Claude usage.

Who is Trail-code for, and who is it not for?

Trail-code suits a team that uses several coding agents on one repo and is tired of re-explaining the same conventions in every session. Because learnings are plain files reviewed in pull requests, it fits teams that already review everything through git and want no server to run.

It does not cover company knowledge outside the repo. The README still lists the cross-repo workspace as coming soon, so a team that wants a shared view across many repos or a central admin view should check its status first. We found no connectors to company documents, wikis or chat tools.

What does Trail-code do well?

  • MIT licensed and free, with no account, server or API key needed
  • Learnings are markdown files in .trail/learnings/, reviewed in the pull request and shared through git
  • The code map is built with tree-sitter across 24 languages, with no model and no network
  • Wires many coding agents from one install, including Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Kiro
  • Personal learnings stay on your machine and are never committed or uploaded

Trail-code on our criteria

Trail-code: what we found, by criterion
CriterionWhat we found
Pricing Free: the CLI is MIT licensed, and no paid tier for Trail-code is listed; no price is published for the Trail workspace Verified
Free plan Yes: the CLI is free, and the map, hooks, learnings and trail check work with no sign-in and no API key Verified
Open source Yes, MIT (trailhq/Trail-Code) Verified
Human approval Apart from what trail init seeds on day one, a learning is saved when you ask or correct your agent; the README says the agent never saves one on its own. Repo learnings are markdown files reviewed in the pull request like code Verified
Cites sources Partial: trail check flags a change that goes against a learning, quoting who decided it and why; before a commit it warns rather than stops Verified
Versioning and history Per changelog 0.24.0, trail note --replaces supersedes an old learning. Otherwise history lives in git, and the README says the agent never edits an existing learning; we found no other rollback described Verified
Shared across agents Yes: learnings committed in .trail/ reach every clone through git, for Claude Code, Codex, Cursor, Gemini CLI, Copilot, Kiro and any MCP agent Verified
Context graph Code map only: tree-sitter map of files, functions and callers as linked markdown, with no embeddings Verified
Enterprise sources Not publicly documented
Deployment Local CLI with no server or daemon, sharing learnings through git. The changelog (0.24.1 onward) describes connecting a machine to a Trail workspace at team.trailhq.com, while the README still lists the cross-repo workspace as coming soon Verified
Compliance Not publicly documented
Interface CLI (trail, with graft still working), files in the repo, an MCP server that trail init also writes into .mcp.json for Claude Code, and hooks and a statusline for Claude Code Verified

What Trail-code reports

What are Trail-code's limits?

  • Sharing runs through git today: the README lists the cross-repo Trail workspace as coming soon, the changelog describes an early sign-in to it at team.trailhq.com, and no price is published for it
  • trail check before a commit warns rather than stops, because per changelog 0.28.0 it can flag a word match that is not a real conflict
  • No docs site: /trail-code/docs returns 404, and the /trail-code page links to the GitHub README instead. The README still says the map lives in graft/ and marks Skills as soon, while the changelog moved the map to .trail/cache/ (0.23.0) and turned Skills on by default (0.25.0)
  • Anonymous usage telemetry is on unless you turn it off, and official builds send it to events.nanonets.com; the trailhq.com homepage block for graft still says no telemetry
  • No GitHub Releases are published, and the latest git tag (v0.21.1) lags the npm version (0.28.1 as of 31 October 2026)
  • Built for code repos; we found no mention of connectors to company documents, wikis or chat tools

FAQ

Is Trail-code the same as graft?

Yes. The README says Trail-code is graft's new name, and graft lives on inside it as the graft map. The old package @nanonets/graft and the graft command still work, and graft upgrade adds the trail command next to it.

Does Trail-code send my code or learnings to Trail?

The README says the map, hooks, learnings and trail check all run on your machine, and no learning goes to Trail until you connect a Trail workspace, which it lists as coming soon; the changelog says the repo's learnings are handed to you for review before anything is uploaded. Anonymous usage telemetry is on by default and limited to buckets and fixed labels; turn it off with trail telemetry disable or DO_NOT_TRACK=1.

Does Trail-code need an API key?

No. The graft map, the hooks, learnings and trail check all work without one. A key only adds the written summaries from trail build --deep.

Sources checked

Show 6 sources