Chuyển đến nội dung
Skillpedia
Lập trình chung11k · #11832

graft

Skill này làm gì

Skill này cho phép AI tra cứu cách các phần của một repository hoạt động bằng một bản đồ dựng sẵn. Skill dành cho lập trình viên muốn tìm code và xem một thay đổi có thể ảnh hưởng đến điều gì.

Khi nào nên dùng

  • ✓Khi bạn muốn biết một tính năng hoặc hàm nằm ở đâu trong repo.
  • ✓Khi bạn muốn xem một thay đổi có thể ảnh hưởng đến điều gì trước khi chỉnh sửa.
  • ✓Khi bạn cần hiểu cách một phần của code hoạt động.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/trailhq/Trail-Code/blob/main/.claude/skills/graft/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Trong repo này, giới hạn tốc độ (rate limiting) được xử lý ở đâu, và cái gì gọi đến nó?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

AI đặt câu hỏi cho công cụ đồ thị và nhận lại các vị trí code liên quan nhất, kèm số file và số dòng, cùng các đoạn code ngắn. Cách này nhanh hơn việc đọc nhiều file mã nguồn đầy đủ.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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.

2 · graft grep "<pattern>": exhaustive find

Regex (or --fixed for a literal) over every indexed file, hits grouped by enclosing symbol and ranked by coupling; it also reports files it couldn't read.

  • Use it when you need every occurrence: all call sites, all uses of a constant, all providers. ask is ranked top-N and will miss instances; grep won't. One grep replaces a spray of asks.
  • Search a short symbol name or literal, not a full guessed signature: an over-specific regex (func (s *Server) GenerateHandler) 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 graft grep — do NOT switch to raw grep -rn, which is slower and unranked.
  • -i case-insensitive; --in <path> scopes to a subtree. Raw grep -rn is only for files graft genuinely doesn't index (docs, configs, brand-new files).

3 · graft skeleton <file>: a file's API at a glance

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 map already named.

4 · graft callers <symbol>: the exact edges

Precomputed call/reference edges, not a text search. Symbol can be bare (Foo), qualified (Class.method), or package-qualified (pkg.Fn).

  • default --direction in: who calls/references this; run before you rename, delete, or change its signature.
  • --direction out: what this symbol itself calls/depends on (the old callees).
  • --depth N: walk transitively N hops for the full blast radius (the old impact); --depth 2 is the usual "what breaks if I touch this".
  • --depth all: 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.

5 · graft map: orientation for an unfamiliar repo or area

A 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". map alone is the answer: read the hub cards it names; do NOT then skeleton or ask your way through every subsystem it lists. --max-dirs N widens it.

6 · Lifecycle: graft build / graft check

Every 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 build after editing.

One caveat, if you grep the markdown under graft/ directly: those cards are a projection, rebuilt at the end of the turn rather than

Câu hỏi thường gặp

Skill có cần API key không?

Không. Skill nói rằng các lệnh của nó không cần API key và chạy cục bộ.

Skill có thay thế việc đọc code không?

Không. Nó cung cấp ngữ cảnh có mục tiêu trước, để AI có thể đọc ít file đầy đủ hơn.

Các lệnh nhanh cỡ nào?

Skill mô tả mỗi lệnh trả về trong chưa đầy một giây.

Chi tiết

Mô tả gốc của tác giả

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.

repo: trailhq/Trail-Code

Độ phổ biến

Sao GitHub
11k
Vị trí xếp hạng
#11832
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Skill tương tự