# Trail-Code [Health: Active]

**Category:** 🤖 Coding Agents  
**Repository:** https://github.com/trailhq/Trail-Code  
**GitHub Stars:** 10867  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/trail-code

## Description
Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "trail-code": {
    "command": "npx",
    "args": ["-y","@trailhq/trail-code"]
  }
}
```

## Documentation

## 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:

```bash
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.

_Full upstream README: https://allmcps.com/mcp/trail-code/readme_

