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.
In this repository38 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- api-contract-validationSkill
- architecture-scannerSkill
- auto-approve-policySkill
- auto-learningSkill
- backend-patternsSkill
- branch-syncSkill
- browser-testSkill
- browseSkill
- build-checkSkill
- cache-refreshSkill
- codebase-explainerSkill
- coding-standardsSkill
- commit-styleSkill
- context-switchingSkill
- continuous-learningSkill
- db-preflightSkill
- env-preflightSkill
- eval-harnessSkill
- feature-completenessSkill
- file-indexSkill
- frontend-patternsSkill
- idev-initSkill
- import-graphSkill
- lessons-learnedSkill
- post-creation-verifySkill
- pre-ship-verifySkill
- project-mapSkill
- self-reviewSkill
- session-resumeSkill
- skill-benchmarkSkill
- skilloptSkill
- smart-contextSkill
- strategic-compactSkill
- task-journalSkill
- tdd-workflowSkill
- test-coverageSkill
- test-mapSkill
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
- Distinctive: line 9
Read only the exact function/method body from a large file instead of the entire file.
- Distinctive: line 38
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.
- Distinctive: line 44
Do NOT read entire files when you only need one function
- Distinctive: line 45
Do NOT guess line numbers — use the Function Index or grep
- Distinctive: line 46
Do NOT read more than ~200 lines in a single extract (if the function is that big, read the whole file)
- Distinctive: line 47
Do NOT use this for small files (<100 lines) — just read the whole file
- Distinctive: line 48
Do NOT skip the few context lines before the function (imports/comments are useful)
≈ “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.
Files
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 linesOption 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
- Do NOT read entire files when you only need one function
- Do NOT guess line numbers — use the Function Index or grep
- Do NOT read more than ~200 lines in a single extract (if the function is that big, read the whole file)
- Do NOT use this for small files (<100 lines) — just read the whole file
- Do NOT skip the few context lines before the function (imports/comments are useful)
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
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.

