{"slug":"docx-6","title":"docx","summary":"Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, ","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-15T18:24:40.094087Z","repo":{"url":"https://github.com/shajith003/awesome-claude-skills","stars":25,"forks":1,"license":null,"updatedAt":"2026-10-10T07:07:58Z"},"bodyHtml":"<hr>\n<h2>name: docx\ndescription: \"Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks\"\nlicense: Proprietary. LICENSE.txt has complete terms</h2>\n<h1>DOCX creation, editing, and analysis</h1>\n<h2>Overview</h2>\n<p>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.</p>\n<h2>Workflow Decision Tree</h2>\n<h3>Reading/Analyzing Content</h3>\n<p>Use \"Text extraction\" or \"Raw XML access\" sections below</p>\n<h3>Creating New Document</h3>\n<p>Use \"Creating a new Word document\" workflow</p>\n<h3>Editing Existing Document</h3>\n<ul>\n<li><p><strong>Your own document + simple changes</strong>\nUse \"Basic OOXML editing\" workflow</p>\n</li>\n<li><p><strong>Someone else's document</strong>\nUse <strong>\"Redlining workflow\"</strong> (recommended default)</p>\n</li>\n<li><p><strong>Legal, academic, business, or government docs</strong>\nUse <strong>\"Redlining workflow\"</strong> (required)</p>\n</li>\n</ul>\n<h2>Reading and analyzing content</h2>\n<h3>Text extraction</h3>\n<p>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:</p>\n<pre><code># Convert document to markdown with tracked changes\npandoc --track-changes=all path-to-file.docx -o output.md\n# Options: --track-changes=accept/reject/all\n</code></pre>\n<h3>Raw XML access</h3>\n<p>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.</p>\n<h4>Unpacking a file</h4>\n<p><code>python ooxml/scripts/unpack.py &lt;office_file&gt; &lt;output_directory&gt;</code></p>\n<h4>Key file structures</h4>\n<ul>\n<li><code>word/document.xml</code> - Main document contents</li>\n<li><code>word/comments.xml</code> - Comments referenced in document.xml</li>\n<li><code>word/media/</code> - Embedded images and media files</li>\n<li>Tracked changes use <code>&lt;w:ins&gt;</code> (insertions) and <code>&lt;w:del&gt;</code> (deletions) tags</li>\n</ul>\n<h2>Creating a new Word document</h2>\n<p>When creating a new Word document from scratch, use <strong>docx-js</strong>, which allows you to create Word documents using JavaScript/TypeScript.</p>\n<h3>Workflow</h3>\n<ol>\n<li><strong>MANDATORY - READ ENTIRE FILE</strong>: Read <a href=\"docx-js.md\"><code>docx-js.md</code></a> (~500 lines) completely from start to finish. <strong>NEVER set any range limits when reading this file.</strong> Read the full file content for detailed syntax, critical formatting rules, and best practices before proceeding with document creation.</li>\n<li>Create a JavaScript/TypeScript file using Document, Paragraph, TextRun components (You can assume all dependencies are installed, but if not, refer to the dependencies section below)</li>\n<li>Export as .docx using Packer.toBuffer()</li>\n</ol>\n<h2>Editing an existing Word document</h2>\n<p>When editing an existing Word document, use the <strong>Document library</strong> (a Python library for OOXML manipulation). The library automatically handles infrastructure setup and provides methods for document manipulation. For complex scenarios, you can access the underlying DOM directly through the library.</p>\n<h3>Workflow</h3>\n<ol>\n<li><strong>MANDATORY - READ ENTIRE FILE</strong>: Read <a href=\"ooxml.md\"><code>ooxml.md</code></a> (~600 lines) completely from start to finish. <strong>NEVER set any range limits when reading this file.</strong> Read the full file content for the Document library API and XML patterns for directly editing document files.</li>\n<li>Unpack the document: <code>python ooxml/scripts/unpack.py &lt;office_file&gt; &lt;output_directory&gt;</code></li>\n<li>Create and run a Python script using the Document library (see \"Document Library\" section in ooxml.md)</li>\n<li>Pack the final document: <code>python ooxml/scripts/pack.py &lt;input_directory&gt; &lt;office_file&gt;</code></li>\n</ol>\n<p>The Document library provides both high-level methods for common operations and direct DOM access for complex scenarios.</p>\n<h2>Redlining workflow for document review</h2>\n<p>This workflow allows you to plan comprehensive tracked changes using markdown before implementing them in OOXML. <strong>CRITICAL</strong>: For complete tracked changes, you must implement ALL changes systematically.</p>\n<p><strong>Batching Strategy</strong>: Group related changes into batches of 3-10 changes. This makes debugging manageable while maintaining efficiency. Test each batch before moving to the next.</p>\n<p><strong>Principle: Minimal, Precise Edits</strong>\nWhen implementing tracked changes, only mark text that actually changes. Repeating unchanged text makes edits harder to review and appears unprofessional. Break replacements into: [unchanged text] + [deletion] + [insertion] + [unchanged text]. Preserve the original run's RSID for unchanged text by extracting the <code>&lt;w:r&gt;</code> element from the original and reusing it.</p>\n<p>Example - Changing \"30 days\" to \"60 days\" in a sentence:</p>\n<pre><code># BAD - Replaces entire sentence\n'&lt;w:del&gt;&lt;w:r&gt;&lt;w:delText&gt;The term is 30 days.&lt;/w:delText&gt;&lt;/w:r&gt;&lt;/w:del&gt;&lt;w:ins&gt;&lt;w:r&gt;&lt;w:t&gt;The term is 60 days.&lt;/w:t&gt;&lt;/w:r&gt;&lt;/w:ins&gt;'\n\n# GOOD - Only marks what changed, preserves original &lt;w:r&gt; for unchanged text\n'&lt;w:r w:rsidR=\"00AB12CD\"&gt;&lt;w:t&gt;The term is &lt;/w:t&gt;&lt;/w:r&gt;&lt;w:del&gt;&lt;w:r&gt;&lt;w:delText&gt;30&lt;/w:delText&gt;&lt;/w:r&gt;&lt;/w:del&gt;&lt;w:ins&gt;&lt;w:r&gt;&lt;w:t&gt;60&lt;/w:t&gt;&lt;/w:r&gt;&lt;/w:ins&gt;&lt;w:r w:rsidR=\"00AB12CD\"&gt;&lt;w:t&gt; days.&lt;/w:t&gt;&lt;/w:r&gt;'\n</code></pre>\n<h3>Tracked changes workflow</h3>\n<ol>\n<li><p><strong>Get markdown representation</strong>: Convert document to markdown with tracked changes preserved:</p>\n<pre><code>pandoc --track-changes=all path-to-file.docx -o current.md\n</code></pre>\n</li>\n<li><p><strong>Identify and group changes</strong>: Review the document and identify ALL changes needed, organizing them into logical batches:</p>\n<p><strong>Location methods</strong> (for finding changes in XML):</p>\n<ul>\n<li>Section/heading numbers (e.g., \"Section 3.2\", \"Article IV\")</li>\n<li>Paragraph identifiers if numbered</li>\n<li>Grep patterns with unique surrounding text</li>\n<li>Document structure (e.g., \"first paragraph\", \"signature block\")</li>\n<li><strong>DO NOT use markdown line numbers</strong> - they don't map to XML structure</li>\n</ul>\n<p><strong>Batch organization</strong> (group 3-10 related changes per batch):</p>\n<ul>\n<li>By section: \"Batch 1: Section 2 amendments\", \"Batch 2: Section 5 updates\"</li>\n<li>By type: \"Batch 1: Date corrections\", \"Batch 2: Party name changes\"</li>\n<li>By complexity: Start with simple text replacements, then tackle complex structural changes</li>\n<li>Sequential: \"Batch 1: Pages 1-3\", \"Batch 2: Pages 4-6\"</li>\n</ul>\n</li>\n<li><p><strong>Read documentation and unpack</strong>:</p>\n<ul>\n<li><strong>MANDATORY - READ ENTIRE FILE</strong>: Read <a href=\"ooxml.md\"><code>ooxml.md</code></a> (~600 lines) completely from start to finish. <strong>NEVER set any range limits when reading this file.</strong> Pay special attention to the \"Document Library\" and \"Tracked Change Patterns\" sections.</li>\n<li><strong>Unpack the document</strong>: <code>python ooxml/scripts/unpack.py &lt;file.docx&gt; &lt;dir&gt;</code></li>\n<li><strong>Note the suggested RSID</strong>: The unpack script will suggest an RSID to use for your tracked changes. Copy this RSID for use in step 4b.</li>\n</ul>\n</li>\n<li><p><strong>Implement changes in batches</strong>: Group changes logically (by section, by type, or by proximity) and implement them together in a single script. This approach:</p>\n<ul>\n<li>Makes debugging easier (smaller batch = easier to isolate errors)</li>\n<li>Allows incremental progress</li>\n<li>Maintains efficiency (batch size of 3-10 changes works well)</li>\n</ul>\n<p><strong>Suggested batch groupings:</strong></p>\n<ul>\n<li>By document section (e.g., \"Section 3 changes\", \"Definitions\", \"Termination clause\")</li>\n<li>By change type (e.g., \"Date changes\", \"Party name updates\", \"Legal term replacements\")</li>\n<li>By proximity (e.g., \"Changes on pages 1-3\", \"Changes in first half of document\")</li>\n</ul>\n<p>For each batch of related changes:</p>\n<p><strong>a. Map text to XML</strong>: Grep for text in <code>word/document.xml</code> to verify how text is split across <code>&lt;w:r&gt;</code> elements.</p>\n<p><strong>b. Create and run script</strong>: Use <code>get_node</code> to find nodes, implement changes, then <code>doc.save()</code>. See <strong>\"Document Library\"</strong> section in ooxml.md for patterns.</p>\n<p><strong>Note</strong>: Always grep <code>word/document.xml</code> immediately before writing a script to get current line numbers and verify text content. Line numbers change after each script run.</p>\n</li>\n<li><p><strong>Pack the document</strong>: After all batches are complete, convert the unpacked directory back to .docx:</p>\n<pre><code>python ooxml/scripts/pack.py unpacked reviewed-document.docx\n</code></pre>\n</li>\n<li><p><strong>Final verification</strong>: Do a comprehensive check of the complete document:</p>\n<ul>\n<li>Convert final document to markdown:\n<pre><code>pandoc --track-changes=all reviewed-document.docx -o verification.md\n</code></pre>\n</li>\n<li>Verify ALL changes were applied correctly:\n<pre><code>grep \"original phrase\" verification.md  # Should NOT find it\ngrep \"replacement phrase\" verification.md  # Should find it\n</code></pre>\n</li>\n<li>Check that no unintended changes were introduced</li>\n</ul>\n</li>\n</ol>\n<h2>Converting Documents to Images</h2>\n<p>To visually analyze Word documents, convert them to images using a two-step process:</p>\n<ol>\n<li><p><strong>Convert DOCX to PDF</strong>:</p>\n<pre><code>soffice --headless --convert-to pdf document.docx\n</code></pre>\n</li>\n<li><p><strong>Convert PDF pages to JPEG images</strong>:</p>\n<pre><code>pdftoppm -jpeg -r 150 document.pdf page\n</code></pre>\n<p>This creates files like <code>page-1.jpg</code>, <code>page-2.jpg</code>, etc.</p>\n</li>\n</ol>\n<p>Options:</p>\n<ul>\n<li><code>-r 150</code>: Sets resolution to 150 DPI (adjust for quality/size balance)</li>\n<li><code>-jpeg</code>: Output JPEG format (use <code>-png</code> for PNG if preferred)</li>\n<li><code>-f N</code>: First page to convert (e.g., <code>-f 2</code> starts from page 2)</li>\n<li><code>-l N</code>: Last page to convert (e.g., <code>-l 5</code> stops at page 5)</li>\n<li><code>page</code>: Prefix for output files</li>\n</ul>\n<p>Example for specific range:</p>\n<pre><code>pdftoppm -jpeg -r 150 -f 2 -l 5 document.pdf page  # Converts only pages 2-5\n</code></pre>\n<h2>Code Style Guidelines</h2>\n<p><strong>IMPORTANT</strong>: When generating code for DOCX operations:</p>\n<ul>\n<li>Write concise code</li>\n<li>Avoid verbose variable names and redundant operations</li>\n<li>Avoid unnecessary print statements</li>\n</ul>\n<h2>Dependencies</h2>\n<p>Required dependencies (install if not available):</p>\n<ul>\n<li><strong>pandoc</strong>: <code>sudo apt-get install pandoc</code> (for text extraction)</li>\n<li><strong>docx</strong>: <code>npm install -g docx</code> (for creating new documents)</li>\n<li><strong>LibreOffice</strong>: <code>sudo apt-get install libreoffice</code> (for PDF conversion)</li>\n<li><strong>Poppler</strong>: <code>sudo apt-get install poppler-utils</code> (for pdftoppm to convert PDF to images)</li>\n<li><strong>defusedxml</strong>: <code>pip install defusedxml</code> (for secure XML parsing)</li>\n</ul>\n","files":[{"path":"docx-js.md","sizeBytes":16509,"isText":true},{"path":"LICENSE.txt","sizeBytes":1467,"isText":true},{"path":"ooxml.md","sizeBytes":23572,"isText":true},{"path":"ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd","sizeBytes":1963,"isText":false},{"path":"ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd","sizeBytes":2515,"isText":false},{"path":"ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd","sizeBytes":2856,"isText":false},{"path":"ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd","sizeBytes":1344,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd","sizeBytes":6956,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd","sizeBytes":74984,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd","sizeBytes":51302,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd","sizeBytes":624,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd","sizeBytes":152039,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd","sizeBytes":1231,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd","sizeBytes":8862,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd","sizeBytes":14795,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd","sizeBytes":83612,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd","sizeBytes":1269,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd","sizeBytes":7328,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd","sizeBytes":6382,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd","sizeBytes":1248,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd","sizeBytes":880,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd","sizeBytes":2608,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd","sizeBytes":3507,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd","sizeBytes":7507,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd","sizeBytes":23313,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd","sizeBytes":1367,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd","sizeBytes":242277,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd","sizeBytes":26148,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd","sizeBytes":25279,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd","sizeBytes":535,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd","sizeBytes":5712,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd","sizeBytes":4010,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd","sizeBytes":171367,"isText":false},{"path":"ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd","sizeBytes":4646,"isText":false},{"path":"ooxml/schemas/mce/mc.xsd","sizeBytes":3127,"isText":false},{"path":"ooxml/schemas/microsoft/wml-2010.xsd","sizeBytes":26549,"isText":false},{"path":"ooxml/schemas/microsoft/wml-2012.xsd","sizeBytes":3745,"isText":false},{"path":"ooxml/schemas/microsoft/wml-2018.xsd","sizeBytes":901,"isText":false},{"path":"ooxml/schemas/microsoft/wml-cex-2018.xsd","sizeBytes":1778,"isText":false},{"path":"ooxml/schemas/microsoft/wml-cid-2016.xsd","sizeBytes":1002,"isText":false},{"path":"ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd","sizeBytes":600,"isText":false},{"path":"ooxml/schemas/microsoft/wml-symex-2015.xsd","sizeBytes":745,"isText":false},{"path":"ooxml/scripts/pack.py","sizeBytes":5596,"isText":true},{"path":"ooxml/scripts/unpack.py","sizeBytes":1037,"isText":true},{"path":"ooxml/scripts/validate.py","sizeBytes":1959,"isText":true},{"path":"ooxml/scripts/validation/base.py","sizeBytes":39892,"isText":true},{"path":"ooxml/scripts/validation/docx.py","sizeBytes":9996,"isText":true},{"path":"ooxml/scripts/validation/__init__.py","sizeBytes":336,"isText":true},{"path":"ooxml/scripts/validation/pptx.py","sizeBytes":12327,"isText":true},{"path":"ooxml/scripts/validation/redlining.py","sizeBytes":11179,"isText":true},{"path":"scripts/document.py","sizeBytes":50409,"isText":true},{"path":"scripts/__init__.py","sizeBytes":65,"isText":true},{"path":"scripts/templates/commentsExtended.xml","sizeBytes":2643,"isText":false},{"path":"scripts/templates/commentsExtensible.xml","sizeBytes":2739,"isText":false},{"path":"scripts/templates/commentsIds.xml","sizeBytes":2651,"isText":false},{"path":"scripts/templates/comments.xml","sizeBytes":2635,"isText":false},{"path":"scripts/templates/people.xml","sizeBytes":147,"isText":false},{"path":"scripts/utilities.py","sizeBytes":13694,"isText":true},{"path":"SKILL.md","sizeBytes":10150,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-15T18:27:34.62576Z","sha256":"CE5C51AB79488FA30A2573E2764EF7A217276F748F775B0717EEDCFF4ECBACEB","sizeBytes":170470},"review":null,"source":{"repositoryUrl":"https://github.com/shajith003/awesome-claude-skills","path":"document-skills/docx","license":null,"commit":"65820933dc2081a7d92b0e7e3fc91049dcc98365","subtreeSha":"77CF962AFF99711CF38807BEDB53E2901E9AEC163E070BBC78390080165F3F67","lastSyncedAt":"2026-11-14T00:38:57.446792Z"},"reviewedAt":"2026-09-15T18:34:32.606098Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/shajith003/awesome-claude-skills/tree/main/document-skills/docx"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install shajith003-awesome-claude-skills@llmmart"},{"target":"git","command":"git clone https://github.com/shajith003/awesome-claude-skills.git"}]}