When to Use This Skill
- User mentions a
.docx or .docm file and wants to read, extract, or inspect its content
- Text extraction: extract text from paragraphs with heading detection
- Table extraction: extract tables as markdown, JSON, or CSV
- Metadata inspection: author, title, creation date, word count, structure
- Image extraction: extract embedded images from the document
- Markdown conversion: convert the full document to Markdown format
Legacy .doc files: This skill handles .docx and .docm (modern Word formats). For legacy .doc files, the script will suggest converting to .docx first using LibreOffice (libreoffice --headless --convert-to docx file.doc) or an online converter.
Prerequisites
python-docx — install with: pip install python-docx
Pre-flight check:
python3 -c "import docx; print(docx.__version__)"
Install if missing:
pip install python-docx
Workflow
- Determine what the user wants (read text, extract tables, inspect metadata, convert to markdown, extract images)
- Run the appropriate script subcommand
- Read the output (text, markdown table, JSON, or confirmation) and present it to the user
- For multi-step tasks, chain subcommands in sequence
All commands use:
python3 scripts/word_ops.py <subcommand> [options] <file>
The script path is relative to this skill directory.
Command Reference
Inspect document metadata
python3 scripts/word_ops.py info document.docx
Shows file size, title, author, subject, creation/modification dates, paragraph count, table count, word count, section count, and heading outline.
Extract text
# Extract all text
python3 scripts/word_ops.py text document.docx
# Extract first 50 paragraphs
python3 scripts/word_ops.py text document.docx --limit 50
# Skip empty paragraphs
python3 scripts/word_ops.py text document.docx --skip-empty
Headings are shown with # markers for visual hierarchy.
Extract tables
# Extract all tables as markdown (default)
python3 scripts/word_ops.py tables document.docx
# Extract as JSON
python3 scripts/word_ops.py tables document.docx --format json
# Extract as CSV (one file per table)
python3 scripts/word_ops.py tables document.docx --format csv --output-dir ./tables/
Extract embedded images
# Extract all images to a directory
python3 scripts/word_ops.py extract-images document.docx --output-dir ./images/
Output files are named <stem>_image_1.png, <stem>_image_2.png, etc.
Convert to Markdown
# Print to stdout
python3 scripts/word_ops.py to-markdown document.docx
# Save to file
python3 scripts/word_ops.py to-markdown document.docx -o document.md
Preserves heading hierarchy, bold/italic formatting, and tables.
Composing Multi-Step Workflows
The commands above are building blocks. Combine them to accomplish complex user requests. Examples:
"What's in this Word document?":
info to see page count, title, author, etc.
text --limit 30 to read the first 30 paragraphs for a quick overview
"Extract the tables and save as CSV":
tables --format csv --output-dir ./tables/ to extract and save
"Convert this docx to markdown and show me":
to-markdown to convert and print the full document
"Read this Word doc and summarize it":
info to understand the structure
text to extract all content
- Summarize based on the extracted text
Guidelines
- Read before manipulate: always
info or text --limit 10 first to understand the document
- Large documents: use
--limit to avoid overwhelming output
- Legacy .doc: the script handles
.docx only; for .doc files, convert first with LibreOffice
- Tables: first row is treated as the header in markdown/JSON output
- Images: extracted in their original format (PNG, JPEG, etc.)
1---2name: word3description: Read, extract, and inspect Word documents (.docx/.docm) via a bundled Python script. Supports text extraction, table extraction (to markdown/JSON/CSV), metadata inspection, image extraction, and Markdown conversion. Trigger whenever the user asks to read, inspect, extract, or convert a Word document, or says phrases like "read docx", "extract text from word", "word to text", "word tables", "word to markdown", "read word doc", "打开 word", "读 docx", "看看这个 docx", "word 说了什么", "提取 word 文字", "word 转 markdown", "docx 表格", "word 内容". Also trigger when the user mentions a .docx or .docm file path and wants to inspect, read, or process it.4license: Apache-2.05---67# When to Use This Skill89- User mentions a `.docx` or `.docm` file and wants to read, extract, or inspect its content10- Text extraction: extract text from paragraphs with heading detection11- Table extraction: extract tables as markdown, JSON, or CSV12- Metadata inspection: author, title, creation date, word count, structure13- Image extraction: extract embedded images from the document14- Markdown conversion: convert the full document to Markdown format1516> **Legacy .doc files**: This skill handles `.docx` and `.docm` (modern Word formats). For legacy `.doc` files, the script will suggest converting to `.docx` first using LibreOffice (`libreoffice --headless --convert-to docx file.doc`) or an online converter.1718# Prerequisites1920- `python-docx` — install with: `pip install python-docx`2122Pre-flight check:2324```bash25python3 -c "import docx; print(docx.__version__)"26```2728Install if missing:2930```bash31pip install python-docx32```3334# Workflow35361. Determine what the user wants (read text, extract tables, inspect metadata, convert to markdown, extract images)372. Run the appropriate script subcommand383. Read the output (text, markdown table, JSON, or confirmation) and present it to the user394. For multi-step tasks, chain subcommands in sequence4041All commands use:4243```bash44python3 scripts/word_ops.py <subcommand> [options] <file>45```4647The script path is relative to this skill directory.4849# Command Reference5051## Inspect document metadata5253```bash54python3 scripts/word_ops.py info document.docx55```5657Shows file size, title, author, subject, creation/modification dates, paragraph count, table count, word count, section count, and heading outline.5859## Extract text6061```bash62# Extract all text63python3 scripts/word_ops.py text document.docx6465# Extract first 50 paragraphs66python3 scripts/word_ops.py text document.docx --limit 506768# Skip empty paragraphs69python3 scripts/word_ops.py text document.docx --skip-empty70```7172Headings are shown with `#` markers for visual hierarchy.7374## Extract tables7576```bash77# Extract all tables as markdown (default)78python3 scripts/word_ops.py tables document.docx7980# Extract as JSON81python3 scripts/word_ops.py tables document.docx --format json8283# Extract as CSV (one file per table)84python3 scripts/word_ops.py tables document.docx --format csv --output-dir ./tables/85```8687## Extract embedded images8889```bash90# Extract all images to a directory91python3 scripts/word_ops.py extract-images document.docx --output-dir ./images/92```9394Output files are named `<stem>_image_1.png`, `<stem>_image_2.png`, etc.9596## Convert to Markdown9798```bash99# Print to stdout100python3 scripts/word_ops.py to-markdown document.docx101102# Save to file103python3 scripts/word_ops.py to-markdown document.docx -o document.md104```105106Preserves heading hierarchy, bold/italic formatting, and tables.107108# Composing Multi-Step Workflows109110The commands above are building blocks. Combine them to accomplish complex user requests. Examples:111112**"What's in this Word document?":**1131. `info` to see page count, title, author, etc.1142. `text --limit 30` to read the first 30 paragraphs for a quick overview115116**"Extract the tables and save as CSV":**1171. `tables --format csv --output-dir ./tables/` to extract and save118119**"Convert this docx to markdown and show me":**1201. `to-markdown` to convert and print the full document121122**"Read this Word doc and summarize it":**1231. `info` to understand the structure1242. `text` to extract all content1253. Summarize based on the extracted text126127# Guidelines128129- **Read before manipulate**: always `info` or `text --limit 10` first to understand the document130- **Large documents**: use `--limit` to avoid overwhelming output131- **Legacy .doc**: the script handles `.docx` only; for `.doc` files, convert first with LibreOffice132- **Tables**: first row is treated as the header in markdown/JSON output133- **Images**: extracted in their original format (PNG, JPEG, etc.)