mcpField
D
docx

docx

github.com/moizibnyousafDocuments1.2k164 installsUpdated 5w ago
Repository

About docx

A skill for reading, creating, editing, and converting DOCX documents. It outlines different workflows for document content, OOXML changes, tracked edits, and image conversion.

Key features

  1. 01Extract text with Pandoc
  2. 02Inspect raw document XML
  3. 03Create documents with docx-js
  4. 04Edit OOXML and tracked changes
  5. 05Convert DOCX pages to images

Use cases

  1. 01Extracting text and tracked changes
  2. 02Creating a new DOCX document
  3. 03Editing business or legal documents
  4. 04Preparing document page images

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/moizibnyousaf/ai-agent-skills --skill docx

After installing, type/docxin Claude Code to confirm it loaded.

Details

From the project README

DOCX Processing

Workflow Decision Tree

  • Reading/Analyzing: Use text extraction or raw XML access
  • Creating New Document: Use docx-js (JavaScript)
  • Editing Existing: Use OOXML editing or redlining workflow

Reading Content

Text Extraction with Pandoc
# Convert to markdown with tracked changes
pandoc --track-changes=all file.docx -o output.md
Raw XML Access
# Unpack document
unzip document.docx -d unpacked/
# Key files:
# word/document.xml - Main content
# word/comments.xml - Comments
# word/media/ - Images

Creating New Documents (docx-js)

import { Document, Paragraph, TextRun, Packer } from 'docx';
import fs from 'fs';

const doc = new Document({
  sections: [{
    children: [
      new Paragraph({
        children: [
          new TextRun({ text: "Hello ", bold: true }),
          new TextRun({ text: "World", italics: true })
        ]
      })
    ]
  }]
});

const buffer = await Packer.toBuffer(doc);
fs.writeFileSync('document.docx', buffer);

Editing Existing Documents

Simple Edits
  1. Unpack: unzip doc.docx -d unpacked/
  2. Edit word/document.xml
  3. Repack: cd unpacked && zip -r ../edited.docx .
Tracked Changes (Redlining)

For professional documents, use tracked changes:

<!-- Deletion -->
<w:del w:author="Author" w:date="2025-01-01T00:00:00Z">
  <w:r><w:delText>old text</w:delText></w:r>
</w:del>

<!-- Insertion -->
<w:ins w:author="Author" w:date="2025-01-01T00:00:00Z">
  <w:r><w:t>new text</w:t></w:r>
</w:ins>

Converting to Images

# DOCX to PDF
soffice --headless --convert-to pdf document.docx

# PDF to images
pdftoppm -jpeg -r 150 document.pdf page

Best Practices

  • Use Pandoc for text extraction
  • Use docx-js for creating new documents
  • For legal/business docs, always use tracked changes
  • Preserve original RSIDs when editing

Comments

Markdown supported