AGENT SKILL
processing-docx
Processes Word document files (.docx). Creates, edits, annotates, tracks revisions, analyzes OOXML structure, and preserves formatting for contracts, policies, academic papers, and business documents. Use when working with .docx files or Word documents. Do NOT use for PDFs, spreadsheets, presentations, or plain text files.
- License 许可
- MIT
- 最近更新
- 2026-07-19
- Stars
- ★ 245
- Forks
- 35
01 前言 Front Matter
- name
- processing-docx
- description
- Processes Word document files (.docx). Creates, edits, annotates, tracks revisions, analyzes OOXML structure, and preserves formatting for contracts, policies, academic papers, and business documents. Use when working with .docx files or Word documents. Do NOT use for PDFs, spreadsheets, presentations, or plain text files.
- allowed-tools
- Bash, Read, Write, Edit, Glob
- argument-hint
- <file.docx | task>
- user-invocable
- false
02 资源文件 59
- 参考文档docx-js.md16.1 KB
- 参考文档ooxml.md22.8 KB
- 参考文档ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd1.9 KB
- 参考文档ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd2.5 KB
- 参考文档ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd2.8 KB
- 参考文档ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd1.3 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd73.2 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd6.8 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd50.1 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd624 B
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd148.5 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd1.2 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd8.7 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd14.4 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd81.7 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd1.2 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd7.2 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd6.2 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd1.2 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd880 B
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd2.5 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd3.4 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd7.3 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd22.8 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd1.3 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd236.6 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd25.5 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd24.7 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd535 B
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd5.6 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd3.9 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd167.4 KB
- 参考文档ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd4.5 KB
- 参考文档ooxml/schemas/mce/mc.xsd3.1 KB
- 参考文档ooxml/schemas/microsoft/wml-2010.xsd25.9 KB
- 参考文档ooxml/schemas/microsoft/wml-2012.xsd3.7 KB
- 参考文档ooxml/schemas/microsoft/wml-2018.xsd901 B
- 参考文档ooxml/schemas/microsoft/wml-cex-2018.xsd1.7 KB
- 参考文档ooxml/schemas/microsoft/wml-cid-2016.xsd1002 B
- 参考文档ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd600 B
- 参考文档ooxml/schemas/microsoft/wml-symex-2015.xsd745 B
- 脚本ooxml/scripts/pack.py5.5 KB
- 脚本ooxml/scripts/unpack.py1.0 KB
- 脚本ooxml/scripts/validate.py1.9 KB
- 脚本ooxml/scripts/validation/__init__.py336 B
- 脚本ooxml/scripts/validation/base.py39.0 KB
- 脚本ooxml/scripts/validation/docx.py9.8 KB
- 脚本ooxml/scripts/validation/pptx.py12.0 KB
- 脚本ooxml/scripts/validation/redlining.py10.9 KB
- 参考文档references/raw-xml-access.md1.1 KB
- 参考文档references/redlining.md3.9 KB
- 脚本scripts/__init__.py65 B
- 脚本scripts/document.py49.0 KB
- 脚本scripts/templates/comments.xml2.6 KB
- 脚本scripts/templates/commentsExtended.xml2.6 KB
- 脚本scripts/templates/commentsExtensible.xml2.7 KB
- 脚本scripts/templates/commentsIds.xml2.6 KB
- 脚本scripts/templates/people.xml147 B
- 脚本scripts/utilities.py13.4 KB
03 SKILL.md 正文
DOCX Processing
.docx is a ZIP archive of XML and resources. Different tasks have different tools and workflows.
Workflow Decision
| Intent | Workflow | Reference |
|---|---|---|
| Read/analyze text only | pandoc → markdown | raw-xml-access.md |
| Read structure, comments, media, formatting | unpack → raw XML | raw-xml-access.md |
| Create new document | docx-js (JS/TS) | docx-js.md |
| Edit own document, simple changes | Document library (Python) | ooxml.md |
| Edit someone else's document | Redlining (tracked changes) | redlining.md |
| Legal / academic / business / gov docs | Redlining — REQUIRED | redlining.md |
| Visual analysis | soffice → PDF → pdftoppm | raw-xml-access.md |
Text Extraction (Quick)
pandoc --track-changes=all path-to-file.docx -o output.md
# --track-changes=accept/reject/all
Create New Document
- MANDATORY — READ ENTIRE FILE:
docx-js.md(~500 lines). NEVER set range limits. - Create JS/TS file using Document, Paragraph, TextRun components.
- Export with
Packer.toBuffer().
Edit Existing Document (Own, Simple)
- MANDATORY — READ ENTIRE FILE:
ooxml.md(~600 lines). NEVER set range limits. python ooxml/scripts/unpack.py <office_file> <output_dir>- Run Python script using Document library.
python ooxml/scripts/pack.py <input_dir> <office_file>
Edit Someone Else's Document → Redlining
See redlining.md for full 6-step workflow with batching strategy and RSID preservation.
Code Style
- Write concise code, no verbose variable names, no unnecessary print statements.
Dependencies
| Package | Install | Purpose |
|---|---|---|
| pandoc | apt install pandoc |
Text extraction |
| docx | npm i -g docx |
Create new docs |
| LibreOffice | apt install libreoffice |
PDF conversion |
| Poppler | apt install poppler-utils |
pdftoppm for images |
| defusedxml | pip install defusedxml |
Secure XML parsing |