Sources: trailhq/Trail-Code on GitHub (MIT, about 11.4k stars at filing), formerly the graft code map from Nanonets. Surfaced by André Lindenberg's post.
The problem it targets
When a developer and a coding agent work out why something is the way it is (for example, why a retry count stays at 4), the reasoning usually lives in that one chat session. A teammate's agent later rediscovers it at full token cost, or worse, undoes it. Hand-maintained CLAUDE.md-style files help, but they drift and rarely capture per-module decisions.
Architecture
Two local parts, both stored as files:
Code map (the graft map). Tree-sitter parses the repo into a graph of files, functions and callers across 24 languages, with no model and no network. It refreshes on change, including uncommitted edits. Hooks in Claude Code add matching files and functions to each prompt, and after an edit they show what depends on the file. Codex and Pi get the same hook events; Cursor and other agents use MCP tools and instruction files. It is a local cache, gitignored.
Learnings. Short Markdown files under
.trail/learnings/, with front matter (title, author, date, token cost of working it out, and atoucheslist of files) and three sections: Decided, Tried and ruled out, Watch out. Repo learnings are committed and reviewed in PRs like code. Personal learnings stay in the user's home directory.
Workflow hooks:
Seeding. On setup, the tool reads the user's own messages in past agent sessions for that repo and keeps what was said in two or more sessions. It also reads review comments repeated across the last 50 merged PRs. Secrets are scrubbed, and the user's own agent does this reading.
Retrieval. Learnings whose
touchesmatch the code being worked on are injected above the code in the prompt.trail check. Before a commit or PR, it compares the diff with the relevant learnings and flags contradictions, quoting who decided what and why. The agent must fix the change or explain the override in the commit message.Branch-clash notice. After an edit, it flags when a teammate's unmerged branch changes the same code in a conflicting way.
Append-only. Agents never edit an existing learning; an override gets a new one only on request.
Reported results
In the vendor's own harness (162 runs, two repos, Claude Sonnet 5), injecting the map cut cost 32%, uncached input tokens 42%, tool calls 46% and latency 60%, with equal correctness (93%). Retrieval on demand instead of injection raised correctness to 98%.
On 50 SWE-bench Verified instances with the official grader, Claude Code with the map resolved 33 against 27 without it, using 23% fewer tokens.
Both were run by the authors. Fifty instances is a small sample, and token comparisons count only the issues both arms solved.
Tradeoffs and failure modes
Stale decisions. A learning stays authoritative until someone writes a newer one. Without expiry or ownership, old constraints block valid changes, or get overridden by habit.
Saved wrong reasons. An agent's explanation can be plausible and wrong. Committing it as a learning makes the error durable, so PR review of learnings matters.
False conflicts.
trail checkreads diffs against prose, so expect noise. If developers learn to wave conflicts away, it stops protecting anything.Privacy of seeding. Mining past transcripts and PR comments is local, but whatever is committed becomes visible to the whole repo audience.
Hook coupling. The deepest integration is with one agent; others get thinner MCP access.
Optional cloud workspace. Connecting it sends committed learnings to the vendor; it is off by default.
Review checklist before adopting
Who reviews and owns learnings, and when do they expire?
Is
trail checkadvisory or blocking in CI, and how are overrides recorded?Run the code map against your own tasks: does it cut tool calls without lowering correctness?
Audit seeded learnings from past sessions before committing them.
Confirm telemetry settings and whether any workspace sync is on.
Related entries
R134 CodeGraph: a local code graph queried over MCP, and the limits of its benchmark.
R076 Graphify: a tree-sitter code graph agents query instead of grep.
R159 SelfGraph: versioned knowledge that tells an agent what it can't answer.
R088 MemCredit: choosing agent memories by decision utility.