# Graft Code Index

Looks up code context in the graft index before grepping for symbols or edit scope.

- Repository: https://github.com/trailhq/Trail-Code (11009 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add trailhq/Trail-Code --skill graft -g -a claude-code -y`
Codex: `npx skills add trailhq/Trail-Code --skill graft -g -a codex -y`
Cursor: `npx skills add trailhq/Trail-Code --skill graft -g -a cursor -y`
Gemini CLI: `npx skills add trailhq/Trail-Code --skill graft -g -a gemini-cli -y`

## Description

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.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# graft

`graft/` holds a graph of this repo: small markdown nodes that each explain one
part in prose and name the exact `file:line` spans they cover, plus a wiring
graph of who-calls-what. Querying a node costs a few hundred tokens; rebuilding
that understanding by reading source costs thousands, and misses the edges.

Every command below is `$0`, 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.**

## The tools

### 1 · `graft ask "<question>" --source`: locate + understand (the default)
Ranked retrieval over the graph, routed automatically between prose nodes and
the wiring graph, returning the top hits with exact `file:line`.
- `--source` 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
  `--full` only when the crux is too small to act on.
- `--in <path>` narrows to a subtree before ranking; `-n N` caps results (default 8).
- **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.

The rest: https://github.com/trailhq/Trail-Code/blob/HEAD/.claude/skills/graft/SKILL.md
