| name | docx-xml-surgeon |
| description | Skill for decompressing .docx archives, inspecting inner WordprocessingML XML structures (document.xml, styles.xml, numbering.xml, settings.xml), and applying surgical regex/node replacements. |
WordprocessingML XML Decompression & Surgery Skill
This skill provides advanced guidance for decompressing .docx zip archives in memory, diagnosing low-level OpenXML structures, and applying surgical regex/node replacements.
1. Inner XML Structure Map
word/document.xml: Main body content, paragraphs (w:p), runs (w:r), text (w:t), tables (w:tbl), and section properties (w:sectPr).
word/styles.xml: Style hierarchies (Normal, Heading 1..6), default font families (w:rFonts), and paragraph spacing rules.
word/numbering.xml: List formatting and multi-level outline numbering.
word/settings.xml: Document-level RTL properties (w:bidi), track changes, and compatibility options.
word/header1.xml / word/footer1.xml: Header and footer section XML structures containing dynamic page number fields (w:fldSimple w:instr="PAGE").
2. Tool Execution Workflow
{
"tool": "decompress_and_modify_word_xml",
"arguments": {
"filePath": "path/to/document.docx",
"targetXmlPath": "word/document.xml",
"searchPattern": "<w:jc w:val=\"left\"/>",
"replacementValue": "<w:jc w:val=\"right\"/>",
"outputPath": "path/to/repaired_document.docx"
}
}
3. Safety & Integrity Guidelines
- Always verify that replacement XML tags are balanced and correctly namespaced (
xmlns:w="...").
- Use
inspect_word_document or convert_word_to_markdown after modifications to confirm document readability.