trailhq/Trail-Code
Local code graph and Git-shared memory for coding agents, accessible over MCP
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
Trail-code is a local TypeScript/Node.js CLI with an MCP tool interface and two separate stores. The graft map uses Tree-sitter to extract symbols, imports, and calls into linked Markdown under graft/. A query checks the working tree and rebuilds only what changed, including uncommitted edits. The map is disposable; durable decisions live in repository .trail/ files or personal ~/.trail/ files. A normal checkout needs neither a database nor a background index server.
The manifest includes tree-sitter-wasm and web-tree-sitter, Commander for CLI argument handling, and vscode-jsonrpc plus vscode-languageserver-protocol for optional language-server integration. Claude Code hooks can supply relevant code at prompt time and surface dependents after an edit. MCP clients can instead request targeted symbol and file context on demand. The manifest also includes Anthropic and OpenAI SDKs; the default parsing path does not require a model or API key.
Key Capabilities & Differentiators
Dedicated extractors provide scope-aware cross-file call and import resolution for TypeScript/JavaScript, Python, Go, Java, Kotlin, PHP, Swift, and R. The generic tier can emit symbols and name-matched call edges for languages such as Rust and C++; OCaml, Zig, GLSL, and Bash currently provide symbols without call edges. Vue, Svelte, and Astro script content goes through the TypeScript extractor. trail build --lsp can add more precise edges with language servers such as rust-analyzer, clangd, or gopls; --deep adds model-generated summaries under a configured provider key.
Agents can save corrections and decisions as learnings, and trail check can flag conflicts with recorded decisions before a PR. In a 162-run Claude Sonnet 5 benchmark across two repositories, upfront context cut mean cost from $0.0429 to $0.0292 and latency from 39.8 s to 15.8 s at 93% aggregate correctness, though one corpus lost three points. On-demand queries reached 98% correctness with less of the speed gain. A separate 50-issue SWE-bench Verified run solved 33 issues with the map versus 27 without it.
Trade-offs & Limitations
Compared with grep and a hand-maintained CLAUDE.md, the map reduces repeated navigation across files and lets decision notes be reviewed alongside code. In return, teams maintain agent wiring and need to curate what gets treated as durable guidance. Static edges are useful for narrowing an investigation, not proving impact: name matching can be ambiguous, coverage varies by language, and opt-in LSP resolution adds local dependencies and processing. Use compiler or language-server results and tests when validating a risky refactor.
Upfront context saves retrieval turns but spends prompt budget before the agent knows what it needs. On-demand MCP queries avoid that upfront payload at the cost of more retrieval turns. The benchmark favors different modes on different metrics and is not a workload-independent estimate. Local indexing removes hosted-model cost from the default map, not from the coding agent or optional summaries. Review session-derived learnings before committing them: repository notes are visible to anyone with a clone. Cross-repository team workspaces are planned, not a current substitute for centralized governance.
Hardware & Deployment Guide
The current quick start is npm install -g @trailhq/trail-code, then trail init from the repository. The supplied manifest still lists the legacy @nanonets/graft package and graft binary, with a Node.js engine range of ^20.16.0 || >=22.3.0. The naming transition preserves the old package and command; graft upgrade adds trail. No GitHub release is listed, so there is no release milestone to pin the migration to. Use trail init --dry-run to inspect proposed agent wiring, and --no-global to avoid changes to user-level files. In particular, narrowing --agents can remove Trail-code wiring for clients left off the list.
Commit the intended team configuration and .trail/ learnings, not the generated graft/ cache. Personal mode keeps setup out of Git; the core workflow requires no model key or dedicated GPU. Optional LSP indexing needs a supported server on PATH, while deep summaries need provider credentials. The Dockerfile targets the GitHub App, not routine CLI/MCP setup. It needs Git at runtime to fetch PR refs and separates dependency installation from the project build to avoid invalidating the grammar build layer on source edits.
graft/ is a regenerable cache of linked Markdown nodes; queries refresh changed inputs, including uncommitted edits..trail/ for sharing via Git, while personal learnings stay in ~/.trail/.trail build --lsp adds language-server-resolved edges; trail build --deep adds provider-generated summaries.Teams whose coding agents repeatedly trace cross-file dependencies and rediscover decisions already made in the same repository. Pilot on one representative repo, review the generated configuration and learnings, and compare push and pull on real tasks.
Search and a small instruction file already suffice, or your rollout requires a complete compiler-accurate call graph, centralized cross-repository memory today, or no client configuration changes.
Quick Start & Installation
npm install -g @trailhq/trail-code && trail init
Comparison vs. Top Coding, Skills & MCP Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| Trail-Code ★ | 11.6k | +83 | TypeScript | MIT | Local code graph and Git-shared memory for coding agents, accessible over MCP |
| graphify | 156.8k | +2.4k | Python | Apache-2.0 | Local AST graphs for dependency tracing, with CLI and MCP access. |
| codebase-memory-mcp | 49.6k | +335 | C | MIT | A local code graph for tracing code, docs, and infrastructure via MCP. |
| taste-skill | 125.3k | +2.9k | JavaScript | MIT | An agent skill for directing company website design and checking builds in a bro |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/trailhq/Trail-Code.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about Trail-Code
How does an agent get current code context and shared decisions?
trail_find_code and trail_file_api. Repository learnings travel separately through Git.Does local indexing require a GPU, and how should I size it?
trail build --deep uses the model provider you configure and can incur API charges. No fixed CPU or RAM sizing figures are available.Can a company run and redistribute Trail-code under MIT?
.trail/ files, how session-derived notes are produced, and what any optional model provider receives.When is Trail-code worth adding to grep, an LSP, and a hand-maintained `CLAUDE.md`?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy