R199 · Knowledge for agents › Docs-as-code and project memory

Trail-code: team decisions as files in the repo, checked before every commit

Read the original

Authors André Lindenberg (shared)

agent-memorycoding-agentscode-graphteam-practice

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:

  1. 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.

  2. Learnings. Short Markdown files under .trail/learnings/, with front matter (title, author, date, token cost of working it out, and a touches list 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:

Reported results

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

Review checklist before adopting

Cited in field guides

Connections

See R199 on the knowledge map

Part of the Research notes on nowucca.com. Figures and claims are the source's own unless the summary says otherwise.