Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

document-processing-expert

БесплатноБез исполняемых скриптовНе проверен

Read, generate and modify office documents and PDFs from code: PDF extraction and forms, Word documents, Excel workbooks and PowerPoint decks. Use when the…

personamanagmentlayerот personamanagmentlayer★ 46 звёзд на GitHub

Об этом скилле

Document Processing Expert

Working with the formats people actually exchange. The recurring mistake is treating a document as text: these are structured containers, and the structure is where the meaning lives.

Core Concepts

Read the Format, Not the Bytes

.docx, .xlsx and .pptx are ZIP archives of XML parts. PDF is a page description language, not a document model. Using a library that understands the format is not a convenience — string manipulation on these files produces output that opens corrupted.

Extraction Is Lossy; Decide What Matters

Every extraction discards something: layout, styling, reading order, or the relationship between a heading and its table. Decide up front whether you need text, structure, or fidelity, and choose the tool accordingly.

Generation Is About Templates

Building a document element by element in code produces unmaintainable output that a designer cannot touch. Fill a template that a human authored, in the tool they authored it in.

Untrusted Documents Are Untrusted Input

Documents carry macros, external entities, embedded files and remote references. A parsing library is an attack surface. Treat every uploaded document as hostile.

PDF

Extracting text

import pdfplumber

def extract_pages(path: str) -> list[str]:
    with pdfplumber.open(path) as pdf:
        return [page.extract_text() or "" for page in pdf.pages]

pdfplumber preserves layout well and extracts tables; pypdf is faster for plain text and page manipulation. If extract_text() returns empty on a page that clearly has content, the page is an image — you need OCR, not a different parser.

Extracting tables

with pdfplumber.open(path) as pdf:
    for page in pdf.pages:
        for table in page.extract_tables():
            header, *rows = table
            records = [dict(zip(header, row)) for row in rows]

Table extraction is unreliable on borderless or multi-page tables. Validate the result — column count, expected types, totals that reconcile — rather than trusting it.

Manipulating pages

from pypdf import PdfReader, PdfWriter

def extract_range(src: str, dst: str, start: int, end: int) -> None:
    reader, writer = PdfReader(src), PdfWriter()
    for page in reader.pages[start:end]:
        writer.add_page(page)
    with open(dst, "wb") as fh:
        writer.write(fh)

Note that removing a page does not remove content another page references, and redacting by drawing a black rectangle leaves the text underneath fully extractable. Real redaction removes the content stream — use a tool that does.

Forms

reader = PdfReader("form.pdf")
fields = reader.get_fields()                     # discover names first

writer = PdfWriter(clone_from="form.pdf")
writer.update_page_form_field_values(
    writer.pages[0], {"applicant_name": "A. Dupont", "amount": "1234.50"}
)

Flatten the form after filling if the values must not be editable; otherwise the recipient can change them and the file still looks official.

Excel

Reading

import openpyxl

wb = openpyxl.load_workbook("report.xlsx", data_only=True, read_only=True)
sheet = wb["Sales"]
rows = [dict(zip([c.value for c in sheet[1]], [c.value for c in row]))
        for row in sheet.iter_rows(min_row=2)]

data_only=True returns the last cached formula result; without it you get the formula string. If the file was never opened in Excel, that cache is empty — None for every computed cell. This is the most common surprise in spreadsheet processing.

read_only=True streams rather than loading the workbook into memory; use it for anything above a few thousand rows.

Writing

For data, pandas is the shortest path. For anything a person will read — formatting, formulas, multiple sheets — use openpyxl or xlsxwriter directly.

from openpyxl.styles import Font
from openpyxl.utils import get_column_letter

ws.append(["Product", "Units", "Revenue"])
for cell in ws[1]:
    cell.font = Font(bold=True)

for row in data:
    ws.append([row.product, row.units, row.revenue])

ws.freeze_panes = "A2"
for i, width in enumerate([32, 10, 14], start=1):
    ws.column_dimensions[get_column_letter(i)].width = width

Write numbers as numbers and dates as dates, then apply a number format. A right-aligned string that looks like a total cannot be summed, and every recipient will try.

Word

from docx import Document

doc = Document("template.docx")

for paragraph in doc.paragraphs:
    for key, value in context.items():
        if f"{{{{{key}}}}}" in paragraph.text:
            replace_preserving_runs(paragraph, f"{{{{{key}}}}}", value)

Naive paragraph.text = ... destroys all formatting in the paragraph, because text is split across runs that carry the styling. Word also splits a placeholder across runs unpredictably, which is why {{name}} often fails to match. For anything beyond trivial substitution use `doc

Полный SKILL.md на GitHub

Установить document-processing-expert в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Write
Edit
Bash(python:*, python3:*, pip:*, pdftotext:*, qpdf:*, libreoffice:*)
Grep
Glob

Вложенные файлы

references/LIBRARIES.md

FAQ

Что делает скилл document-processing-expert?

Read, generate and modify office documents and PDFs from code: PDF extraction and forms, Word documents, Excel workbooks and PowerPoint decks. Use when the user mentions PDF, DOCX, XLSX, PPTX, Word, Excel, PowerPoint or spreadsheets, wants data extracted from documents, needs a report or invoice generated as a file, must fill a form, or when the task involves parsing scanned documents, merging or splitting files, or producing a document a person will open.

Как установить скилл document-processing-expert?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл document-processing-expert запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить document-processing-expert с