Trail Code logo

Trail Code

Maps code dependencies and preserves team learnings for coding agents through a local MCP setup.

Install Trail Code

Pick your client, then add it in one click or paste the config.

STDIONode.js
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "trail-code": {
      "command": "npx",
      "args": [
        "-y",
        "@trailhq/trail-code"
      ]
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Install not yet sandbox-tested— we haven't run this command through our automated sandbox yet. Not a red flag; we're working through the catalog.

Overview

Trail-Code gives coding agents a local map of files, functions, and call relationships, alongside learnings captured from prior work. It builds the map with tree-sitter and refreshes it as the repository changes, including uncommitted edits. Agent hooks provide relevant code context before sessions and can surface dependency impact after edits. Reach for it when agents repeatedly rediscover repository structure, team decisions, or implementation conventions.

Use cases

  • Map a repository before making cross-file changes
  • Reuse team decisions across coding-agent sessions
  • Check edits against recorded project guidance
  • Orient agents in unfamiliar codebases

Key features

  • Tree-sitter code map of files, functions, and callers
  • Automatic refresh for code changes and uncommitted edits
  • Persistent shared and local learnings
  • Agent hooks with relevant code context
  • CLI search, mapping, checking, and visualization

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked Today

Recent health check succeeded.

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 1h ago via OSV.dev · @trailhq/trail-code (npm)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars10kStargazers on the source repository.
Last commitTodayMost recent push to the default branch.

How Trail Code works

What Trail-Code does

Trail-Code adds two forms of repository context for coding agents. The graft map indexes files, functions, and caller relationships, helping an agent identify relevant code and understand what may be affected by a change. Learnings preserve decisions, corrections, and working conventions from people and agents so later sessions can reuse them.

The map and learnings are intended for collaborative coding work. Code-related learnings can be committed with the repository, while personal learnings remain on the developer's machine. This gives teammates access to shared project knowledge without treating every piece of an individual's working context as repository content.

How it works

Running trail init parses the repository with tree-sitter and creates the local Trail setup. The map is generated from code on the developer's machine; it does not require a model or API key. Trail-Code refreshes the map when source files change and includes uncommitted edits.

Agent hooks point sessions toward relevant files and functions based on the prompt. After an edit, the agent can see the affected dependency context. During work, corrections and decisions can be saved as learnings for later sessions. Initial setup can also inspect past Claude Code sessions in the repository and turn repeated guidance into learnings.

The setup is file-based: it creates .trail/, updates agent configuration, and adds hooks and a Claude Code statusline. There is no daemon or background service to operate.

Setup and configuration

Install the CLI globally with npm, then initialize it from the repository root:

Terminal
npm install -g @trailhq/trail-code
trail init

Initialization asks which coding agents to configure, builds the graft map, creates the repository learning directory, and wires the available integrations. The generated setup can be committed so teammates receive the shared configuration. The generated map cache is placed in graft/ and added to .gitignore rather than committed.

Trail-Code is also available under its former graft command name. Existing graft commands continue to work after the rename.

Tools and capabilities

  • Build a repository map with trail init.
  • Locate relevant files and functions using the code map.
  • Inspect dependency and impact context around edits.
  • Preserve project decisions and corrections as readable learning files.
  • Check changes with trail check, including decisions that may conflict with established team guidance.
  • Search and orient through the CLI with trail grep and trail map.
  • Visualize the repository context with trail viz.

Limitations and notes

Trail-Code is designed for local, file-based operation, so repository context is read and maintained on the developer's machine. The map is a cache and is intentionally excluded from version control, while shared learning files can be committed. Its value depends on initializing each repository and allowing the configured agent hooks to provide context during sessions.

The project is aimed at coding agents, including Claude Code, Cursor, Codex, and Gemini. It also supports team workflows in which multiple agents or developers need to reuse decisions about the same codebase.

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Trail Code

Trail-Code is an MCP server that connects coding agents to local codebases and team learnings. Its main tools provide a code map, dependency and impact context, repository search and orientation, learning storage, and checks for changes that conflict with recorded project decisions.

Install it with `npm install -g @trailhq/trail-code`, then run `trail init` from the repository root. Initialization builds the code map, creates `.trail/`, asks which agents to configure, and adds the relevant hooks and agent configuration.

Yes, Trail-Code names Cursor as a supported coding agent. Running `trail init` lets you choose which coding agents to wire up, after which the configured agent can use the repository map and preserved learnings.

Code-related learnings are stored in the repository's `.trail/` directory and can be committed for teammates. Learnings about an individual developer remain on that developer's machine.

No, the code map is built locally without a model or API key, and the setup does not require a daemon. Trail-Code uses files, agent hooks, and local repository processing to provide context.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewTrail Code AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/trail-code?style=directory)](https://allmcps.com/mcp/trail-code)
HTML Embed
<a href="https://allmcps.com/mcp/trail-code"><img src="https://allmcps.com/api/badge/trail-code?style=directory" alt="Trail Code on AllMCPs" /></a>