agentleFS
TheophilusChinomonaTheophilusChinomona/idev/skills/function-extract/SKILL.md

function-extract

Skill0 starsChanged 5 months agoMITView on GitHub

Reads only the needed function from a large file (300+ lines) instead of the entire file, using grep/index line numbers. Use when one function is needed from a big file.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read only the exact function/method body from a large file instead of the entire file.

    line 9
  2. Distinctive:

    If the read window doesn't reach the end of the function (no closing brace / dedent), extend the read by ~50 lines, at most twice.

    line 38
  3. Distinctive:

    Do NOT read entire files when you only need one function

    line 44
  4. Distinctive:

    Do NOT guess line numbers — use the Function Index or grep

    line 45
  5. Distinctive:

    Do NOT read more than ~200 lines in a single extract (if the function is that big, read the whole file)

    line 46
  6. Distinctive:

    Do NOT use this for small files (<100 lines) — just read the whole file

    line 47
  7. Distinctive:

    Do NOT skip the few context lines before the function (imports/comments are useful)

    line 48

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Function Extract Skill

Purpose

Read only the exact function/method body from a large file instead of the entire file. Reduces token usage when files are 300+ lines but you only need one function. This is a technique, not a data store — no cache needed.


Technique

Core idea: find the function's start line, then Read with offset/limit instead of reading the whole file.

Option A: Function Index (fastest)

If .claude/idev/backend-patterns/cache.md or frontend-patterns/cache.md has a
"Function Index" section (functionName — file:line — purpose):
  1. Look up the function's file and line number
  2. Read from line N-5 (context) with a limit of ~80 lines

Option B: Grep for the signature

Grep the file for the function signature, e.g.:
  C#/Java: "public.*{FunctionName}\("
  TS/JS:   "const {FunctionName}|function {FunctionName}|{FunctionName} ="
  Python:  "def {FunctionName}\("
  Go:      "func.*{FunctionName}\("
  Ruby:    "def {FunctionName}"

Use the returned line number as the start, then Read with offset/limit
(start-5, limit ~80; larger for React components).

If the read window doesn't reach the end of the function (no closing brace / dedent), extend the read by ~50 lines, at most twice. If still incomplete, fall back to reading the whole file.


Anti-Patterns

  1. Do NOT read entire files when you only need one function
  2. Do NOT guess line numbers — use the Function Index or grep
  3. Do NOT read more than ~200 lines in a single extract (if the function is that big, read the whole file)
  4. Do NOT use this for small files (<100 lines) — just read the whole file
  5. Do NOT skip the few context lines before the function (imports/comments are useful)

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.