file-reading
Reading Uploaded Files
Why this skill exists
When a user uploads a file in claude.ai, Claude Desktop, or Cowork,
the file is written to /mnt/user-data/uploads/<filename> and you are told the path
in an <uploaded_files> block. The content is not in your context.
You must go read it.
The naive thing — cat /mnt/user-data/uploads/whatever — is wrong for
most files:
- On a PDF it prints binary garbage.
- On a 100MB CSV it floods your context with rows you will never use.
- On a DOCX it prints the raw ZIP bytes.
- On an image it does nothing useful at all.
This skill tells you the right first move for each type, and when to
hand off to a deeper skill.
General protocol
- Look at the extension. That is your dispatch key.
- Stat before you read. Large files need sampling, not slurping.
```bash
stat -c '%s bytes, %y' /mnt/user-data/uploads/report.pdf
file /mnt/user-data/uploads/report.pdf
```
- Read just enough to answer the user's question. If they asked
"how many rows are in this CSV", don't load the whole thing into
pandas — wc -l gives a fast approximation (it counts newlines,
not CSV records, so it may over-count if quoted fields contain
embedded newlines).
- If a dedicated skill exists, go read it. The table below tells
you when. The dedicated skills cover editing, creating, and advanced
operations that this skill does not.
extract-text
For docx, odt, epub, xlsx, pptx, rtf, and ipynb the first move is
extract-text <file>. It emits markdown for docx/odt/epub (headings,
bold, lists, links, tables), tab-separated rows under ## Sheet:
headers for xlsx, text under ## Slide N headers for pptx, fenced
code cells for ipynb, and plain text for rtf. Pass --format <fmt>
when the extension is wrong or absent (e.g., --format xlsx on an
.xlsm). If it errors on a file, pandoc <file> -t plain is a
fallback; for xlsx/pptx, fall back to the dedicated skill's
Python-based approach (openpyxl / python-pptx).
Dispatch table
Where a dedicated skill is named below, invoke it by name if you have a
Skill tool, or Read its SKILL.md (listed in your available skills, or in
the same skills directory as this file).
| Extension | First move | Dedicated skill |
| --------------------------------- | ---------------------------------------------------- | --------------- |
| .pdf | Content inventory (see PDF section) | pdf-reading |
| .docx | extract-text | docx |
| .doc (legacy) | Convert to .docx first | docx |
| .xlsx | extract-text | xlsx |
| .xlsm | extract-text --format xlsx | xlsx |
| .xls (legacy) | pd.read_excel(engine="xlrd") — openpyxl rejects it | xlsx |
| .ods | pd.read_excel(engine="odf") — openpyxl rejects it | xlsx |
| .pptx | extract-text | pptx |
| .ppt (legacy) | Convert to .pptx first | pptx |
| .csv, .tsv | pandas with nrows | — (below) |
| .json, .jsonl | jq for structure | — (below) |
| .jpg, .png, .gif, .webp | Already in your context as vision input | — (below) |
| .zip, .tar, .tar.gz | List contents, do not auto-extract | — (below) |
| .gz (single file) | zcat \| head — no manifest to list | — (below) |
| .epub, .odt | extract-text | — (below) |
| .rtf | extract-text | — (below) |
| .ipynb | extract-text | — (below) |
| .txt, .md, .log, code files | wc -c then head or full cat | — (below) |
| Unknown | file then decide | — |
Never cat a PDF — it prints binary garbage.
Quick first move — get the page count and determine whether the PDF
has an extractable text layer:
pdfinfo /mnt/user-data/uploads/report.pdf
pdffonts /mnt/user-data/uploads/report.pdfpdffonts tells you whether text extraction will work before you try it:
- No fonts listed (empty table, just the header) → the PDF is a
scan or raster export. pdftotext and PdfReader.extract_text()
will return nothing useful. Go straight to page rasterization or OCR
— see the pdf-reading skill
