agentleFS
benmartebenmarte/codemunch/skills/fetch/SKILL.md

fetch

Skill7 starsChanged 9 months agoMITView on GitHub

Fetch the exact source code of a named symbol (function, class, method, type) from the codebase using the codemunch index. Reads only the lines for that symbol — not the whole file. Uses LSP for hover docs and type info when available. This is the core token-saving operation.

6 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use setup.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • VercelSkill

    setup

    Set up Vercel CLI and project configuration. Use when the user says "set up Vercel", "configure Vercel", "link to Vercel", or "vercel init".

    Also in 3 projects that use this

  • Other versions6 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 6

    1. browserbase/skills★ 3.7ksame name
    2. grainulation/grainulator★ 86same name
    3. vibesurf-ai/claude-surf★ 24same name
    4. shidoyu/scout★ 3same name
    5. danielbrodie/skill-tree★ 2same name
    6. jtfasulo7/ClaudeCode★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository8 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If no index exists: the staleness-gate skill will have already built it before this skill runs.

    line 30
  2. Distinctive:

    If multiple matches (e.g. overloaded methods or same name in different files), show a disambiguation list and ask which one.

    line 32
  3. Very specific:

    Use the start_line and end_line from the index entry to read only those lines:

    line 36
  4. Distinctive:

    If LSP is configured for this language, additionally fetch:

    line 56
  5. Very specific:

    If end_line is null (rg fallback didn't have it), use a smart heuristic:

    line 96

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Fetch Skill

Retrieve the exact source of a named symbol. Read 20 lines instead of 800.

Usage

Called with a symbol name, e.g.: validateToken, AuthService, getUserById, Invoice

Step 1 — Look up in index

# Read the index
cat .claude/codemunch/index.json | python3 -c "
import json, sys
idx = json.load(sys.stdin)
name = '$SYMBOL_NAME'
matches = [s for s in idx['symbols'] if s['name'].lower() == name.lower()]
print(json.dumps(matches, indent=2))
" 2>/dev/null

# Or with jq if available
jq --arg n "$SYMBOL_NAME" '[.symbols[] | select(.name | ascii_downcase == ($n | ascii_downcase))]' \
  .claude/codemunch/index.json 2>/dev/null

If no index exists: the staleness-gate skill will have already built it before this skill runs.

If multiple matches (e.g. overloaded methods or same name in different files), show a disambiguation list and ask which one.

Step 2 — Extract the symbol source

Use the start_line and end_line from the index entry to read only those lines:

FILE="src/auth/tokens.ts"
START=142
END=163

# Add a few lines of context before (for decorators, comments, annotations)
CONTEXT_BEFORE=3
ACTUAL_START=$((START - CONTEXT_BEFORE))
[ $ACTUAL_START -lt 1 ] && ACTUAL_START=1

sed -n "${ACTUAL_START},${END}p" "$FILE"

Token count for this operation: ~20-40 tokens Token count for reading the full file: ~5,000-15,000 tokens

Step 3 — Enrich with LSP (when available)

If LSP is configured for this language, additionally fetch:

Hover information — type signature, documentation:

Use Claude Code's /lsp tool:
  textDocument/hover
  position: { line: START_LINE, character: 0 }

Type signature — already in index if built with LSP, but refresh if stale

Find references count — how many places call this symbol:

Use /lsp:
  textDocument/references (just count, don't fetch all)

Step 4 — Display

Show the symbol in this format:

📍 validateToken  [function]  src/auth/tokens.ts:142-163
   Engine: LSP  |  Signature: validateToken(token: string): Promise<User | null>
   Container: AuthService  |  References: 14
   ─────────────────────────────────────────
   [source code lines 139-163]
   ─────────────────────────────────────────
   Tokens used: ~35  (vs ~8,400 to read full file — 99.6% savings)

Step 5 — Update usage stats

Append to .claude/codemunch/session.log:

fetch|validateToken|src/auth/tokens.ts:142-163|35 tokens|lsp

Fallback for missing end_line (rg-indexed symbols)

If end_line is null (rg fallback didn't have it), use a smart heuristic:

# Read from start_line until we find the closing brace at the same indent level
# or until the next function/class declaration
# Max 60 lines to avoid reading too much
awk -v start=$START_LINE -v max=60 '
  NR==start { depth=0; capture=1 }
  capture {
    print
    # Count opening and closing braces/blocks
    for(i=1;i<=length($0);i++) {
      c=substr($0,i,1)
      if(c=="{" || c=="(" || c=="[") depth++
      if(c=="}" || c==")" || c=="]") depth--
    }
    if(NR>start && depth<=0) exit
    if(NR>start+max) exit
  }
' "$FILE"

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.