agentleFS
camilo-acevedocamilo-acevedo/claude-skills/file-summary/SKILL.md

file-summary

Skill0 starsChanged 7 months agoMITView on GitHub

Produce or recall a compact summary of a single file (purpose, exported symbols with line ranges, notable sections). The summary is cached under <repo>/.claude/summaries/ keyed by file hash, so repeated reads of the same file cost ~200 tokens instead of the full file's contents. Use before reading a large source file you only need an overview of.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do NOT invoke when:

    line 27
  2. Very specific:

    If refresh=true was passed, skip the cache check and proceed to compute.

    line 70
  3. Very specific:

    Write it to <cache-dir>/<sha8>-<basename>.md (unless nocache=true).

    line 151
  4. Very specific:

    If the file is binary (sha256 succeeds but head returns gibberish), bail out with file-summary: <path> looks binary — skipping and stop.

    line 170

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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

file-summary

A Markdown-only skill — no Python, no scripts. You (Claude) hash the target file (sha256sum or Get-FileHash), check the cache, and if it's a miss run grep against the file to extract exported symbols.

When to invoke

Invoke file-summary when ANY of these apply:

  • You are about to Read a file > 300 lines and only need an overview.
  • The user asks "what's in this file?" or "summarize this file".
  • You need to know which symbols a file exports (without their bodies).
  • You expect to revisit this file across sessions — the cache amortizes the cost.

Do NOT invoke when:

  • You need the actual implementation of a specific function (just Read it).
  • The file is short (< 100 lines) — direct read is cheaper.
  • The file is data (CSV / JSON / images) — use the right tool.

Trade-off vs the old Python parser

The Markdown recipe uses grep instead of an AST parser. That means:

  • Multi-line declarations, decorators, and dynamic exports may be missed.
  • Symbol line ranges are start-only (no end line) — the recipe doesn't try to track braces / indentation.
  • For Python, ast-based parsing would catch more — but for a navigation overview, the grep recipe is adequate. Fall back to a direct Read when you need exact bodies.

Cache layout

  • Directory: <repo-root>/.claude/summaries/ (find the repo root with git rev-parse --show-toplevel; if not in a git repo, use the file's parent directory).
  • One entry per source file: <sha8>-<basename>.md
    • sha8 = first 8 hex chars of sha256 of the file's bytes.
    • basename = the file's filename (no path).

How to run

Step 1 — hash the file

sha256sum "<path>" | awk '{print $1}'    # bash
(Get-FileHash -Algorithm SHA256 "<path>").Hash.ToLower()    # PowerShell

Record the full hex digest. The first 8 chars are sha8.

Step 2 — check the cache

Glob <cache-dir>/<sha8>-*.md. If exactly one file matches AND its frontmatter contains the same full sha256 → cache hit. Print the file's body and stop.

If refresh=true was passed, skip the cache check and proceed to compute.

Step 3 — compute the summary

Detect language

By extension (same table as codemap):

  • .py → Python
  • .ts, .tsx, .mts, .cts → TypeScript
  • .js, .jsx, .mjs, .cjs → JavaScript
  • .go → Go
  • anything else → generic fallback

Gather pieces (single parallel Bash batch)

CommandYields
wc -l "<path>"Total line count.
head -n 30 "<path>"First 30 lines (for purpose + imports).
tail -n 10 "<path>"Last 10 lines (for __all__, exports block, etc.).
Language-specific symbol greps (see codemap SKILL.md)Exported top-level symbols.

For Python imports, grep:

grep -nE '^(from\s+\S+\s+import|import\s+\S)' "<path>" | head -n 20

For TS/JS imports:

grep -nE '^import\s' "<path>" | head -n 20

For Go imports:

grep -nE '^import\s' "<path>"

Plus the multi-line import ( … ) block (look for ^import\s*\($ then read until matching ^)$).

Extract the file's purpose

Same rule as codemap (first docstring / JSDoc / package comment / humanized filename).

Cap symbols at max=N (default 40).

Step 4 — render

---
path: <path>
sha256: <full digest>
generated_at: <UTC timestamp>
language: <python|typescript|javascript|go|other>
lines: <count>
---

# <path> — <one-line purpose>

<lines> lines • <Language>

## Imports
- <module> (<symbols if any>)
- …

## Exports
- L<N>  <signature snippet>
- L<N>  <signature snippet>
- …

## Head (first 10 lines)
<head> ```

Tail (last 5 lines)

<tail>

Write it to `<cache-dir>/<sha8>-<basename>.md` (unless `nocache=true`).
Then print the body (without frontmatter) to the user.

## Supported arguments

| Argument | Default | Purpose |
|----------|---------|---------|
| `path` (first positional) | required | File to summarize. |
| `root=<path>` | nearest `.git` ancestor or file's parent | Cache base. |
| `refresh=true` | off | Ignore cache, regenerate. |
| `max=N` | `40` | Cap on listed symbols. |
| `nocache=true` | off | Compute and print without writing the cache. |

## Notes

- The `.claude/summaries/` folder should be in `.gitignore` (or just
  `.claude/`).
- Stale cache entries from earlier versions of a file accumulate over time.
  Periodic cleanup is fine — but optional, since matching is by full sha256.
- If the file is binary (sha256 succeeds but `head` returns gibberish),
  bail out with `file-summary: <path> looks binary — skipping` and stop.

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.