graft
Original:🇺🇸 English
Translated
This repo is indexed by graft/. For ANY task here, whether understanding how something works, finding where code lives, tracing what calls a symbol or what a change breaks, or scoping an edit, get your context from graft before grepping or reading source files.
3installs
Sourcetrailhq/trail-code
Added on
NPX Install
npx skill4agent add trailhq/trail-code graftTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →graft
graft/file:lineEvery command below is , needs no API key, and returns in under a second.
There are six of them. Pick the one that fits the task, run it, act on the
answer; don't chain tools hoping for more. Most tasks need one call.
$0The tools
1 · graft ask "<question>" --source
: locate + understand (the default)
graft ask "<question>" --sourceRanked retrieval over the graph, routed automatically between prose nodes and
the wiring graph, returning the top hits with exact .
file:line- inlines the code at each hit, the ≤8-line crux of each definition, so the result IS the code you need, no follow-up file read. Add
--sourceonly when the crux is too small to act on.--full - narrows to a subtree before ranking;
--in <path>caps results (default 8).-n N - Use it when the question is conceptual or locational: "how does auth work", "where is rate-limiting handled", "what assembles the request pipeline".
- One ask usually answers. A genuinely multi-part question needs one ask per distinct sub-aspect, never the same question reworded. Few or weak hits mean switch tool (grep / skeleton / callers), don't re-ask.
2 · graft grep "<pattern>"
: exhaustive find
graft grep "<pattern>"Regex (or for a literal) over every indexed file, hits grouped by
enclosing symbol and ranked by coupling; it also reports files it couldn't read.
--fixed- Use it when you need every occurrence: all call sites, all uses of a
constant, all providers. is ranked top-N and will miss instances; grep won't. One grep replaces a spray of asks.
ask - Search a short symbol name or literal, not a full guessed signature: an
over-specific regex () returns nothing even when the code is indexed. If a grep misses, loosen it (drop the receiver and signature, keep the bare name) and retry
func (s *Server) GenerateHandler— do NOT switch to rawgraft grep, which is slower and unranked.grep -rn - case-insensitive;
-iscopes to a subtree. Raw--in <path>is only for files graft genuinely doesn't index (docs, configs, brand-new files).grep -rn
3 · graft skeleton <file>
: a file's API at a glance
graft skeleton <file>Signatures-only view of one file (every function / method / type with its span)
in ~200 tokens, ~10x cheaper than reading the file.
- Use it when you need "what's in this file / what can I call here" before
editing or wiring into it. One skeleton is the whole answer for a file; don't
re-skeleton the same file, and don't skeleton every file already named.
map
4 · graft callers <symbol>
: the exact edges
graft callers <symbol>Precomputed call/reference edges, not a text search. Symbol can be bare
(), qualified (), or package-qualified ().
FooClass.methodpkg.Fn- default : who calls/references this; run before you rename, delete, or change its signature.
--direction in - : what this symbol itself calls/depends on (the old
--direction out).callees - : walk transitively N hops for the full blast radius (the old
--depth N);impactis the usual "what breaks if I touch this".--depth 2 - : the entire connected closure — every source reachable through the edges. Reach for this before a refactor, rename, or any multi-file change: it surfaces the sibling and downstream files (platform variants, a module you must split out) that a single-file edit would miss.
--depth all
5 · graft map
: orientation for an unfamiliar repo or area
graft mapA token-budgeted tour: directory clusters, per-directory hubs, and global
hotspots, straight from the wiring graph.
- Use it when you land in a repo cold or are asked for "the architecture".
alone is the answer: read the hub cards it names; do NOT then skeleton or ask your way through every subsystem it lists.
mapwidens it.--max-dirs N
6 · Lifecycle: graft build
/ graft check
graft buildgraft checkEvery tool above refreshes the graph itself before answering, so what those tools
return always describes the code as it is right now — including edits you just made
and have not committed. You do not need to run after editing.
buildOne caveat, if you the markdown under directly: those cards are a
projection, rebuilt at the end of the turn rather than on each query, so after an edit
they can lag. The tools above never do — prefer them, and treat a card's spans as
stale if you have edited that file this turn.
grepgraft/build--deepcheckgraft/Scenarios: the shortest path through a coding task
| When you're… | Reach for | Calls |
|---|---|---|
| Onboarding / "explain this codebase" | | 1 |
| Understanding a flow ("how does X work") | | 1 |
| Finding where a change belongs | | 1 |
| Editing a symbol you can already name | | 1 |
| Renaming / deleting / changing a signature | | 1 |
| Refactor / multi-file change (before editing) | | 1 |
| "What does this depend on?" | | 1 |
| Finding every occurrence of a pattern | | 1 |
| "What's the API of this file?" | | 1 |
| Debugging a failure in area X | | 1–2 |
| Judging a diff's risk before merge | | 1 / symbol |
| Working inside one repo of a monorepo | add | n/a |
In a multi-repo workspace, graft ranks fairly so the biggest repo can't drown
the rest, and every hit carries a label naming its sub-project; when
you already know where you're working, narrow with .
[scope/]graft ask "<task>" --in <scope>/Spend the fewest calls
- A node's list already gives exact
covers:for every symbol, so cite straight from it. The spans are generated from source and authoritative; don't re-open or re-grep files to "double-check".file:line - When the task already names the file or symbol to change, go straight there:
for the exact
graft grep "<symbol>", then edit. Reservefile:linefor when you don't yet know where the code lives — angraft askround-trip is wasted on a target you can already name.ask - Trust the answer and act. Reach for a second tool only when the first genuinely fell short: weak hits, a truncated span, or a need to be exhaustive.
- If graft names a path that isn't on disk, its index is ahead of your checkout
(a branch switch or unpulled move). Don't read the missing file — the symbol to find where it lives now, or run
graft grepto refresh.graft build
Report what graft saved, every turn
Each retrieval tool opens its output with a line:
the estimated tokens that call saved versus reading the files it covers whole.
Whenever you used any graft tool in a turn, close your reply with a one-line
tally summing those numbers across every graft call you made, e.g.
. A call with no such line
(tiny files, where the pointers cost as much as the source) saved nothing, so
skip it. This is the per-turn figure; the statusline carries the running
session total.
[graft] tokens saved ≈ N🌱 graft saved ~12,400 tokens this turn (3 calls)Never pipe a graft command through , , or . Every tool
is already capped and states what it dropped; clipping it costs you hits you
asked for, and it silently drops the savings line the statusline's running
total is parsed from.
headtailsed -nWhen graft isn't enough
- Span truncated ("+N more lines"): open the file at that exact range.
- A node lacks a detail: ask a more specific question; only then read source at
the exact , never a whole file to rebuild understanding graft gives.
file:line - You may also grep / ls / cat inside directly (plain markdown;
graft/indexes the nodes), but the tools above are faster and exhaustive where it matters, so reach for them first.graft/INDEX.md
When the graft MCP server is connected, these are exposed as tools too:
, , , (with
/ ), , . Use whichever surface is
available; the guidance is identical.
graft_find_codegraft_find_allgraft_file_apigraft_trace_callsdirectiondepthgraft_repo_mapgraft_check_freshness