← 返回列表
全部 Skill›内容与媒体 Content & Media›file-reading

file-reading

作者 @asgeirtj · 语言 en
Use this skill when a file has been uploaded but its content is NOT in your context — only its path at /mnt/user-data/uploads/ is listed in an uploaded_files block. This skill is a router: it tells you which tool to use for each file type (pdf, docx, xlsx, csv, json, images, archives, ebooks) so you read the right amount the right way instead of blindly running cat on a binary. Triggers: any mention of /mnt/user-data/uploads/, an uploaded_files section, a file_path tag, or a user asking about an uploaded file you have not yet read. Do NOT use this skill if the file content is already visible in your context inside a documents block — you already have it.
内容与媒体 Content & Media文档处理需海外环境执行命令读写文件待翻译
最近源活动
—
检测 SKILL.md 语言
en
星标 ★
72,578
分支 Fork
0
安装选项
提示
指令
使用 AI 助手安装
将下面的提示复制到你正在使用的 AI 助手中。
下载完整 Skill 目录(含全部配套文件)。 下载压缩包 ↓
SKILL.md 原文预览

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

  1. Look at the extension. That is your dispatch key.
  2. 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

```

  1. 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).

  1. 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 | — |


PDF

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.pdf

pdffonts 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

评论
Aasgeirtj
asgeirtj
asgeirtj/system_prompts_leaks
查看 GitHub 仓库 查看作者的其他 Skill
来源信息
作者@asgeirtj
所属大类内容与媒体 Content & Media / 文档处理
国内可用性需海外环境
最近源活动—
风险提示执行命令、读写文件
提示:风险标签为程序静态扫描结果,仅作提示,不代表安全认证。安装前请阅读 SKILL.md 及其引用的脚本、权限,自行判断是否可信。