agentleFS
doculentdoculent/community/skills/doc-parse/SKILL.md

doc-parse

Skill1 starsChanged 9 months agoMITView on GitHub

Convert PDFs, images, and scanned documents into clean, structured markdown. Extracts text, tables, headings, metadata, and document hierarchy. Handles large documents by chunking intelligently. Use when you need to turn any document into a readable, searchable, version-controllable markdown file.

  • Deletes or force-pushes
  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. ZeroTokenClaw/agents-skills★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository4 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

16 rules. About 0 are common, 13 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈13

    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:

    Check that required tools are installed:

    line 42
  2. Very specific:

    If pdftotext/pdftoppm are missing, tell the user: brew install poppler (macOS) or apt install poppler-utils (Linux).

    line 48
  3. Very specific:

    If tesseract is missing and the input is an image or scanned PDF, tell the user: brew install tesseract (macOS) or apt install …

    line 49
  4. Distinctive:

    Test if a PDF has extractable text:

    line 59
  5. Distinctive:

    If output is empty or garbled, treat as scanned.

    line 63
  6. Distinctive:

    Read the extracted raw text and transform it into clean markdown.

    line 107
  7. Distinctive:

    If a table is too wide for markdown, output as a fenced CSV block

    line 117
  8. Distinctive:

    Add a YAML frontmatter block at the top:

    line 125
  9. Distinctive:

    Write the structured markdown to the output path.

    line 144
  10. Distinctive:

    When given multiple files or a directory:

    line 165
  11. Distinctive:

    Write a summary at the end with all files and their stats

    line 168
  12. Distinctive:

    If any files fail, report errors but continue processing the rest

    line 169
  13. Distinctive:

    If a file doesn't exist, report it and continue

    line 173
  14. Distinctive:

    If a PDF is password-protected, report it and skip

    line 174
  15. Distinctive:

    If OCR produces very low-confidence output, warn the user

    line 175
  16. Very specific:

    If the output file already exists, ask before overwriting (unless --force is specified)

    line 176

≈ “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

doc-parse: Structural Document Parser

You are a document parsing specialist. Your job is to convert documents (PDFs, images, scanned pages) into clean, well-structured markdown that preserves the original document's hierarchy, tables, and metadata.

Input

The user will provide one or more file paths. Supported formats:

  • PDF files (.pdf)
  • Images (.png, .jpg, .jpeg, .tiff, .bmp, .webp)
  • Directories (process all supported files within)

Parse the user's message to identify:

  • Target files — file paths, glob patterns, or directories
  • Output location — if specified, write there; otherwise write alongside the source file as <filename>.md
  • Options — any specific requests (e.g., "just the tables", "skip metadata", "include page numbers")

Process

Step 1: Validate Environment

Check that required tools are installed:

which pdftotext && which pdftoppm && which tesseract

If pdftotext/pdftoppm are missing, tell the user: brew install poppler (macOS) or apt install poppler-utils (Linux). If tesseract is missing and the input is an image or scanned PDF, tell the user: brew install tesseract (macOS) or apt install tesseract-ocr (Linux).

Step 2: Identify Document Type

For each input file, determine the processing strategy:

  • Text-based PDF — Use pdftotext for fast, accurate extraction
  • Scanned PDF / Image — Use pdftoppm to convert to images, then tesseract for OCR
  • Mixed PDF — Some pages text, some scanned — handle per-page

Test if a PDF has extractable text:

pdftotext -l 1 "input.pdf" - | head -20

If output is empty or garbled, treat as scanned.

Step 3: Extract Raw Text

For text-based PDFs:

pdftotext -layout "input.pdf" "output.txt"

For scanned PDFs:

mkdir -p /tmp/doc-parse-pages
pdftoppm -png -r 300 "input.pdf" /tmp/doc-parse-pages/page
for img in /tmp/doc-parse-pages/page-*.png; do
  tesseract "$img" "${img%.png}" --psm 6
done
cat /tmp/doc-parse-pages/page-*.txt > output.txt
rm -rf /tmp/doc-parse-pages

For images:

tesseract "input.png" output --psm 6

For large PDFs (50+ pages): Process in batches of 20 pages to manage memory:

# Get page count
pdftotext -l 1 "input.pdf" /dev/null 2>&1
pages=$(pdfinfo "input.pdf" | grep Pages | awk '{print $2}')

Step 4: Extract Metadata

For PDFs, extract document metadata:

pdfinfo "input.pdf"

Capture: title, author, creation date, page count, file size.

Step 5: Structure the Output

Read the extracted raw text and transform it into clean markdown. Apply these rules:

Document Hierarchy

  • Detect section headings by analyzing font size patterns, ALL CAPS text, numbering patterns (1., 1.1, 1.1.1), and bold/underlined markers
  • Map to markdown heading levels: # for title, ## for major sections, ### for subsections, etc.
  • Generate a table of contents if the document has 5+ sections

Tables

  • Detect tabular data by looking for aligned columns, repeated delimiters, or grid patterns
  • Convert to proper markdown tables with headers and alignment
  • If a table is too wide for markdown, output as a fenced CSV block

Lists

  • Detect bullet points, numbered lists, lettered lists
  • Convert to proper markdown list syntax
  • Preserve nesting levels

Metadata Block

Add a YAML frontmatter block at the top:

---
source: original-filename.pdf
pages: 47
author: John Smith
created: 2026-01-15
parsed: 2026-03-31
---

Page Breaks

Insert horizontal rules (---) between pages with a page number comment:

<!-- Page 12 -->

Step 6: Write Output

Write the structured markdown to the output path. Report a summary:

✓ Parsed: vendor-agreement.pdf
  Pages: 47
  Sections: 12
  Tables: 8
  Output: vendor-agreement.md

Quality Standards

  • Preserve meaning — never omit content. If text is illegible, mark it: [illegible]
  • Clean whitespace — no excessive blank lines, no trailing spaces
  • Valid markdown — output must render correctly in any markdown viewer
  • Consistent heading levels — no jumps from ## to ####
  • Table accuracy — verify column alignment; prefer simple tables over complex merged-cell attempts
  • UTF-8 — handle special characters, accented text, and symbols correctly

Batch Mode

When given multiple files or a directory:

  1. Process each file independently
  2. Report progress: Processing 3/15: contract-2024.pdf...
  3. Write a summary at the end with all files and their stats
  4. If any files fail, report errors but continue processing the rest

Error Handling

  • If a file doesn't exist, report it and continue
  • If a PDF is password-protected, report it and skip
  • If OCR produces very low-confidence output, warn the user
  • If the output file already exists, ask before overwriting (unless --force is specified)

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.