Duyệt miễn phí mỗi ngày. Lên Pro để cài đặt và dùng Airsc MCP không giới hạn.

Xem gói Pro
MCP serverCẩn thậnQuy trình & bộ nhớ agentCần cài đặt chút

Trail-Code

trailhq · trailhq/Trail-Code

Một MCP server giúp tối ưu hóa ngữ cảnh cho agent, giảm chi phí token và cải thiện độ chính xác thông qua lập bản đồ mã nguồn.

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

11k sao953Giấy phép: MITCập nhật Hôm qua0 lượt mở

Xem trước

▍

Bạn có thể làm gì với nó

  • Tự động quản lý CLAUDE.md để giữ cho các quy tắc luôn nhất quán giữa các phiên làm việc của agent.
  • Giảm lượng token tiêu thụ bằng cách cung cấp cho agent một bản đồ nén của mã nguồn thay vì toàn bộ tệp.
  • Thiết lập các hook để ngăn agent thực hiện các thay đổi bị cấm cụ thể trong một monorepo.

Kiểm tra an toàn

Cẩn thận

Dùng được, nhưng nên đọc ghi chú trước.

  • ●Gói npm tự chạy script khi cài đặt.package.json

Quét tự động các file trong repo. Luôn xem lại code trước khi chạy.

Trích từ README

The self-learning context layer for coding agents.

Trail-code gives Claude Code, Cursor, Codex and other coding agents a map of your code, and what your team has learned about it.

Code map (previously graft)Learnings
What is it?An index of your code: every function and who calls it, so your agent sees what a change can breakWhat you, your agents and your team have learned and decided
What does it do for your agent?Takes it straight to the right filesLets it pick up where you and your team left off
Where does it come from?Your code, read on your machineYour conversations, as you work

46% fewer tool calls, 60% less time, and more real issues solved.

Cold agentAgent with the graft map
Tool calls, 162 runsbaseline46% fewer
Uncached input tokens, 162 runsbaseline42% fewer
Time, 162 runsbaseline60% less
SWE-bench Verified, 50 real issues27 solved (54%)33 solved (66%)
npm install -g @trailhq/trail-code && trail init

[!NOTE] Graft is now Trail-code. Graft lives on as the graft map, and every graft command still works. What's new is learnings. What changed


What changes in your agent

Without Trail-codeWith Trail-code
Greps and opens file after file to find the code it needsGets the right files and functions with your prompt
Re-explores code a teammate already figured out last weekStarts from their learning: what they decided, what they ruled out, what to watch out for
Undoes a teammate's decision, because it never knew about ittrail check flags it before the PR, quoting who decided it and why
Finds out at merge time that a teammate changed the same codeSays so right after it edits code a teammate's open branch also changes, and whether the two clash
Has to be told the same things every sessionStarts from what you've told it before: trail init finds what you said more than once in your past sessions
You write and update CLAUDE.md by handLearnings are saved from your conversations, in files you can read

Same model, more tasks solved. On SWE-bench Verified (real GitHub issues, graded by the maintainers' own tests), Claude Sonnet 5 solved 33 of 50 issues with the graft map and 27 of 50 without it, using 23% fewer tokens. Details

Cheaper and faster. Across 162 runs of the same agent on the same tasks: 32% lower cost, 42% fewer uncached input tokens, 60% less time, and the same share of correct answers. On PocketBase, 15 real tasks ran 21% cheaper and 14% faster. Details


Contents


How it works

Trail-code has two parts. Both run on your machine.

  1. The graft map: your code. trail init parses your repo with tree-sitter into a map of every file, function and who calls what. No model, no API key. It refreshes itself when the code changes, uncommitted edits included. Your agent gets pointers to the matching files and functions with each prompt, and sees what depends on a file right after it edits it.
  2. Learnings: what you, your agents and your team know. When a session works something out, or you correct how something is done, your agent saves it as a learning. The next session on that code, yours or a teammate's, starts from it instead of digging again. Learnings about the code are committed with the code; learnings about you stay on your machine. On day one, trail init starts you off with what you told Claude more than once in your past sessions, and what reviewers flagged on more than one of the repo's merged PRs.

The graft map tells your agent where things are. Learnings tell it why they are that way, and how the work gets done here.


Quick start

npm install -g @trailhq/trail-code   # install the CLI, once
trail init                      # in your repo: build the graft map, set up .trail/, wire your agents

That is the whole setup. trail init asks which of your coding agents to wire up, builds the graft map from your code, creates .trail/ for the repo's learnings, and adds a statusline and hooks to Claude Code. It also reads your past Claude Code sessions in the repo, once, for what you told Claude more than once, and saves those as learnings. Your own Claude Code does that reading, in about a minute. Then work the way you always do. No daemon, no server, nothing to babysit: it is all files.

Commit the setup so your teammates get it too. The graft map itself, in graft/, is a local cache like node_modules and is added to .gitignore, so it stays out of the commit:

git add .claude .mcp.json .trail .gitignore .ignore && git commit -m "set up Trail-code"

Team

Xem mã nguồn trên GitHub