agentleFS
hdprajwalhdprajwal/agent-skills/skills/document-toolkit/SKILL.md

document-toolkit

Skill1 starsChanged 5 months agoMITView on GitHub

Read, extract, fill, and generate Office/PDF documents from Python — PDF (pypdf / pdfplumber), Word (.docx, python-docx), and Excel (.xlsx, openpyxl). Use whenever a .pdf, .docx, or .xlsx is the input or the desired output: extract text/tables, merge/split, fill forms, build a report, read or write a spreadsheet. Prefers libraries over brittle shell parsing.

  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Library over shell: Don't grep/sed a binary doc — use the library.

    line 88

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

Document Toolkit (PDF · DOCX · XLSX)

Handle documents with the right Python library, not regex over raw bytes. Install what you need:

pip install pypdf pdfplumber python-docx openpyxl

Pick by file type, then by task. Work on a copy; never overwrite the user's original without confirming.

PDF

Extract text/tables — pdfplumber is best for layout-aware text and tables:

import pdfplumber
with pdfplumber.open("in.pdf") as pdf:
    text = "\n".join(p.extract_text() or "" for p in pdf.pages)
    tables = pdf.pages[0].extract_tables()

Merge / split / rotate — pypdf:

from pypdf import PdfReader, PdfWriter
w = PdfWriter()
for f in ["a.pdf", "b.pdf"]:
    for page in PdfReader(f).pages:
        w.add_page(page)
with open("merged.pdf", "wb") as fh:
    w.write(fh)

Scanned PDFs need OCR first (ocrmypdf in.pdf out.pdf) before text extraction. Fill forms: read field names with reader.get_fields(), then writer.update_page_form_field_values(...).

Word (.docx)

from docx import Document
doc = Document("in.docx")                      # read
full = "\n".join(p.text for p in doc.paragraphs)
for table in doc.tables:
    for row in table.rows:
        print([c.text for c in row.cells])

out = Document()                               # create
out.add_heading("Report", level=1)
out.add_paragraph("Body text.")
t = out.add_table(rows=1, cols=2); t.style = "Light Grid"
out.save("out.docx")

python-docx covers headings, paragraphs, runs (bold/italic), tables, images (add_picture), and styles. It does not render to PDF — convert with libreoffice --headless --convert-to pdf out.docx if needed.

Excel (.xlsx)

from openpyxl import load_workbook, Workbook
wb = load_workbook("in.xlsx", data_only=True)  # data_only → values, not formulas
ws = wb.active
for row in ws.iter_rows(values_only=True):
    print(row)

wb2 = Workbook(); ws2 = wb2.active             # create
ws2.append(["Name", "Score"]); ws2.append(["A", 91])
ws2["C1"] = "=SUM(B2:B100)"                     # formulas as strings
wb2.save("out.xlsx")

openpyxl handles sheets, formulas, styles, number formats, charts, and freezing panes. For heavy numeric work, read with pandas.read_excel and write with df.to_excel.

Rules

  • Library over shell. Don't grep/sed a binary doc — use the library.
  • Work on a copy; confirm before overwriting an original.
  • Verify the output — open the produced file (extract its text / list its rows) and confirm it's what was asked, not just that the script ran.
  • For big batches, write a small script and run it once, rather than many ad-hoc one-liners.

Credit

Approach and library choices follow the pdf / docx / xlsx skills in anthropics/skills.

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.