Comprehensive Microsoft Word (.docx) document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction
A user may ask you to create, edit, or analyze the contents of a .docx file. A .docx file is essentially a ZIP archive containing XML files and other resources that you can read or edit. You have different tools and workflows available for different tasks.
Use "Text extraction" or "Raw XML access" sections below
Use "Creating a new Word document" workflow
Your own document + simple changes Use "Basic OOXML editing" workflow
Someone else's document Use "Redlining workflow" (recommended default)
Legal, academic, business, or government docs Use "Redlining workflow" (required)
If you just need to read the text contents of a document, you should convert the document to markdown using pandoc. Pandoc provides excellent support for preserving document structure and can show tracked changes:
# Convert document to markdown with tracked changes
pandoc --track-changes=all path-to-file.docx -o output.md
# Options: --track-changes=accept/reject/all
You need raw XML access for: comments, complex formatting, document structure, embedded media, and metadata. For any of these features, you'll need to unpack a document and read its raw XML contents.
python ooxml/scripts/unpack.py <office_file> <output_directory>
word/document.xml - Main document contentsword/comments.xml - Comments referenced in document.xmlword/media/ - Embedded images and media files<w:ins> (insertions) and <w:del> (deletions) tagsWhen creating a new Word document from scratch, use docx-js, which allows you to create Word documents using JavaScript/TypeScript.
docx-js.md (~500 lines) completely from start to finish. NEVER set any range limits when reading this file. Read the full file content for detailed syntax, critical formatting rules, and best practices before proceeding with document creation.When editing an existing Word document, you need to work with the raw Office Open XML (OOXML) format. This involves unpacking the .docx file, editing the XML content, and repacking it.
ooxml.md (~500 lines) completely from start to finish. NEVER set any range limits when reading this file. Read the full file content for detailed syntax, critical validation rules, and patterns before proceeding.python ooxml/scripts/unpack.py <office_file> <output_directory>word/document.xml and word/comments.xml)python ooxml/scripts/validate.py <dir> --original <file>python ooxml/scripts/pack.py <input_directory> <office_file>This workflow allows you to plan comprehensive tracked changes using markdown before implementing them in OOXML. CRITICAL: For complete tracked changes, you must implement ALL changes systematically.
Get markdown representation: Convert document to markdown with tracked changes preserved:
pandoc --track-changes=all path-to-file.docx -o current.md
Create comprehensive revision checklist: Create a detailed checklist of ALL changes needed, with tasks listed in sequential order.
[ ] format[ ] Section 8: Change "30 days" to "60 days" (grep: "notice period of.*days prior")<w:t> elements due to formattingrevision-checklist.mdSetup tracked changes infrastructure:
python ooxml/scripts/unpack.py <office_file> <output_directory>python skills/docx/scripts/setup_redlining.py <unpacked_directory>word/people.xml with Claude as author (ID 0)[Content_Types].xml to include people.xml content typeword/_rels/document.xml.rels to add people.xml relationship<w:trackRevisions/> to word/settings.xmlApply changes from checklist systematically:
ooxml.md (~500 lines) completely from start to finish. NEVER set any range limits when reading this file. Pay special attention to the section titled "Tracked Change Patterns".ooxml.md before making any XML editsword/document.xmlw:r tags and are invalid on w:del or w:ins tags)<w:ins w:id="X" w:author="Claude" w:date="...">, deletions use <w:del w:id="X" w:author="Claude" w:date="...">MANDATORY - Review and complete checklist:
pandoc --track-changes=all <packed_file.docx> -o verification.md
grep -E "pattern" verification.md # Check for each updated term
Final validation and packaging:
python ooxml/scripts/validate.py <directory> --original <file>python ooxml/scripts/pack.py <input_directory> <office_file>To visually analyze Word documents, convert them to images using a two-step process:
Convert DOCX to PDF:
soffice --headless --convert-to pdf document.docx
Convert PDF pages to JPEG images:
pdftoppm -jpeg -r 150 document.pdf page
This creates files like page-1.jpg, page-2.jpg, etc.
Options:
-r 150: Sets resolution to 150 DPI (adjust for quality/size balance)-jpeg: Output JPEG format (use -png for PNG if preferred)-f N: First page to convert (e.g., -f 2 starts from page 2)-l N: Last page to convert (e.g., -l 5 stops at page 5)page: Prefix for output filesExample for specific range:
pdftoppm -jpeg -r 150 -f 2 -l 5 document.pdf page # Converts only pages 2-5
IMPORTANT: When generating code for DOCX operations:
Required dependencies (install if not available):
sudo apt-get install pandoc (for text extraction)npm install -g docx (for creating new documents)sudo apt-get install libreoffice (for PDF conversion)sudo apt-get install poppler-utils (for pdftoppm to convert PDF to images)npx skills add michelg10/Word Document Handler下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer