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.
In this repository9 other files it gives its agents.
- answer-cacheSkill
- api-contractSkill
- codemapSkill
- diff-summarySkill
- git-digestSkill
- log-extractSkill
- run-quietSkill
- session-handoffSkill
- test-failures-onlySkill
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
- Distinctive: line 27
Do NOT invoke when:
- Very specific: line 70
If refresh=true was passed, skip the cache check and proceed to compute.
- Very specific: line 151
Write it to <cache-dir>/<sha8>-<basename>.md (unless nocache=true).
- Very specific: line 170
If the file is binary (sha256 succeeds but head returns gibberish), bail out with file-summary: <path> looks binary — skipping and stop.
≈ “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.
Files
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
Reada 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
Readit). - 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 directReadwhen you need exact bodies.
Cache layout
- Directory:
<repo-root>/.claude/summaries/(find the repo root withgit rev-parse --show-toplevel; if not in a git repo, use the file's parent directory). - One entry per source file:
<sha8>-<basename>.mdsha8= 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() # PowerShellRecord 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)
| Command | Yields |
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 20For TS/JS imports:
grep -nE '^import\s' "<path>" | head -n 20For 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.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.

