How to Create Claude Skills That Handle DOCX, PDF, and XLSX Files
To create Claude Skills that work with multiple file types like DOCX, PDF, and XLSX, define a SKILL.md descriptor for each format alongside scripts that implement format-specific logic using toolchains such as pandoc, docx-js, pypdfium2, and pandas.
The ComposioHQ/awesome-claude-skills repository provides reference implementations for office document processing. Each format resides in its own document-skills/ subdirectory and follows a standardized architecture where descriptors route requests to specialized workflows, enabling Claude to create, edit, and analyze documents through executable scripts.
Understanding the Claude Skill Architecture
Claude skills operate through a descriptor-script pattern defined in SKILL.md files. According to the repository structure, each document format exposes a common invocation pattern:
- Intent Detection: The skill description lists supported actions (create, edit, read, analyze)
- Toolchain Selection: A Workflow Decision Tree routes requests to specific sub-workflows
- Script Execution: Skills run inside a container at
/mnt/skills/<skill-name>, settingPYTHONPATHfor Python workflows or invoking Node scripts for JavaScript-based ones - Result Return: Output files (e.g.,
output.docx,output.pdf) are written back to the workspace, optionally converted to markdown for further Claude processing
The template-skill/SKILL.md file provides a scaffold for building new skills, while format-specific implementations reside under document-skills/docx/, document-skills/pdf/, and document-skills/xlsx/.
Handling DOCX Files with Claude Skills
The DOCX implementation in document-skills/docx/SKILL.md supports three primary workflows: text extraction, document creation, and advanced editing.
Text Extraction Using Pandoc
For quick text extraction from Word documents, the skill utilizes pandoc with track-changes preservation. This approach converts DOCX content to markdown while maintaining revision history.
import subprocess
import pathlib
docx_path = "input.docx"
md_path = "extracted.md"
subprocess.run([
"pandoc", "--track-changes=all", docx_path, "-o", md_path
], check=True)
print(open(md_path).read())
Document Creation with docx-js
For generating DOCX files from scratch, the repository recommends docx-js (JavaScript/TypeScript). The detailed reference in document-skills/docx/docx-js.md defines the API for assembling document structures programmatically.
const { Document, Packer, Paragraph, TextRun } = require("docx");
const fs = require("fs");
const doc = new Document({
sections: [{
properties: {},
children: [
new Paragraph({
children: [new TextRun("Hello from Claude!")]
})
]
}]
});
Packer.toBuffer(doc).then(buffer => {
fs.writeFileSync("greeting.docx", buffer);
});
Advanced Editing via OOXML
For redlining and structural editing, the skill unpacks the OOXML archive using python ooxml/scripts/unpack.py, manipulates the XML with the Document library, and repacks via python ooxml/scripts/pack.py. The document-skills/docx/ooxml.md file documents this low-level workflow for scenarios requiring precise control over document internals.
Processing PDF Documents
The PDF implementation detailed in document-skills/pdf/reference.md provides tiered processing capabilities from rendering to text extraction.
Rendering and Image Extraction
For visual analysis or OCR preprocessing, pypdfium2 renders PDF pages to bitmaps with configurable scale factors.
import pypdfium2 as pdfium
pdf = pdfium.PdfDocument("report.pdf")
for i, page in enumerate(pdf):
bitmap = page.render(scale=2.0)
bitmap.to_pil().save(f"page_{i+1}.png")
Text Extraction Strategies
The reference implementation supports multiple extraction libraries depending on precision requirements:
- pdfplumber: Layout-preserving text extraction with bounding box metadata
- pypdf: Lightweight text retrieval for simple documents
- pdftotext: Command-line extraction maintaining spatial layout
PDF Creation and Manipulation
For merging, splitting, or creating PDFs programmatically, the skill employs pdf-lib (JavaScript) or reportlab (Python). The following snippet merges two PDFs using pdf-lib:
import { PDFDocument } from "pdf-lib";
import fs from "fs";
async function merge() {
const pdf1 = await PDFDocument.load(fs.readFileSync("a.pdf"));
const pdf2 = await PDFDocument.load(fs.readFileSync("b.pdf"));
const merged = await PDFDocument.create();
const pages1 = await merged.copyPages(pdf1, pdf1.getPageIndices());
pages1.forEach(p => merged.addPage(p));
const pages2 = await merged.copyPages(pdf2, pdf2.getPageIndices());
pages2.forEach(p => merged.addPage(p));
const bytes = await merged.save();
fs.writeFileSync("merged.pdf", bytes);
}
merge();
Managing XLSX Spreadsheets
The XLSX workflow in document-skills/xlsx/SKILL.md centers on pandas for data manipulation while preserving formulas and formatting.
Reading and Writing with Pandas
Standard read/write operations use pd.read_excel and df.to_excel, with explicit dtype hints for performance optimization.
import pandas as pd
df = pd.read_excel("budget.xlsx")
df["Total"] = df["Qty"] * df["UnitPrice"]
df.to_excel("budget_updated.xlsx", index=False)
print("Updated spreadsheet written.")
Formula Preservation and Recalculation
To maintain formula integrity across edits, the skill implements column-wise reading for large files and a helper script (python recalc.py) to trigger formula recalculation after modification.
Combining Multiple File Types in One Skill
To build a multi-format Claude skill, create a composite SKILL.md that imports sections from the individual format descriptors. Copy the relevant workflow definitions from document-skills/docx/SKILL.md, document-skills/pdf/reference.md, and document-skills/xlsx/SKILL.md into a single descriptor, adjusting the name and description fields to reflect the combined capability.
Place the supporting scripts for each format in appropriate subdirectories within /mnt/skills/<skill-name>, ensuring dependencies (pandoc, docx-js, pypdfium2, pandas, etc.) are installed as specified in the respective source files.
Summary
- SKILL.md descriptors define the interface and workflow routing for each file type in the ComposioHQ/awesome-claude-skills repository
- DOCX processing uses pandoc for extraction, docx-js for creation, and OOXML scripts for advanced editing
- PDF handling leverages pypdfium2 for rendering, pdfplumber/pypdf for text extraction, and pdf-lib for document assembly
- XLSX workflows rely on pandas for data manipulation with specific attention to formula preservation via recalc.py
- Multi-format skills are constructed by composing multiple SKILL.md descriptors into a unified skill container
Frequently Asked Questions
How do I install dependencies for Claude Skills that process office documents?
Install the toolchains specified in each format's SKILL.md file: pandoc for DOCX conversion, docx-js via npm for Word document creation, pypdfium2 and pdfplumber via pip for PDF processing, and pandas with openpyxl for XLSX manipulation. The skill container environment must have these available in the PATH or Python environment before execution.
Can I combine DOCX, PDF, and XLSX processing in a single Claude Skill?
Yes. Create a composite SKILL.md that imports the workflow sections from document-skills/docx/SKILL.md, document-skills/pdf/reference.md, and document-skills/xlsx/SKILL.md. Adjust the skill name and description fields, then place all supporting scripts in the skill container directory structure. The unified descriptor can route requests to the appropriate toolchain based on file extension or user intent.
What is the difference between using docx-js and OOXML scripts for DOCX editing?
docx-js provides a high-level JavaScript API for creating new documents from scratch, ideal for document generation workflows. The OOXML scripts (unpack.py and pack.py) expose the underlying Open XML structure for advanced editing scenarios such as redlining, track-changes manipulation, or modifying existing document properties that require direct XML manipulation.
How do I handle large XLSX files without running out of memory?
Use pandas with column-wise reading and explicit dtype hints as recommended in document-skills/xlsx/SKILL.md. Specify the usecols parameter in pd.read_excel to load only necessary columns, and define dtypes to prevent inappropriate memory allocation. For formula-heavy workbooks, run the recalc.py helper script to update calculations without loading the entire dependency graph into memory.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →