AI Agent Hub
Back to skills
📁

Word Document Processing

Office Efficiency Updated 2026.08.30

Paste the following prompt into your AI chat to install this skill:

Please follow https://skillhub.cn/install/skillhub.md and install @kunlungrowth/kg-docx.

About this skill

Problem

A .docx file is a ZIP package of XML, so naive string replacement can miss w:ins, w:del, comments, and original RSID values, producing unreadable redlines or broken formatting. This skill targets engineers who need to create, read, and review Word documents in automated workflows, with a focus on verifiable output rather than ad hoc text substitution.

How It Works

  • Read/analyze: extract Markdown with pandoc, using --track-changes=all to preserve tracked changes; when comments, media, or complex structure matter, unpack and inspect word/document.xml, word/comments.xml, and word/media/.
  • Create documents: build and export .docx files with the Node docx library using Document, Paragraph, and TextRun components.
  • Edit existing documents: plan the redline first, group changes into 3 to 10 batches by section or type, unpack the document, apply replacements with an OOXML document library, preserve original RSID for unchanged text, split replacements into unchanged + deleted + inserted + unchanged, repackage, and verify by converting back to Markdown.

Boundaries

It fits new documents, text extraction, legal/contract redlines, and structural analysis; complex layout tweaks are best confirmed in a desktop client. Output includes a DocArtifact and redline notes, suitable for downstream PDF conversion or multimodal understanding.

Use Cases

  • Review a contract term and change only “30 days” to “60 days” with tracked changes.
  • Extract `.docx` to Markdown to verify section structure and clause text for scripts.
  • Create a product spec Word document with headings, paragraphs, and text runs via `docx`.
  • Unpack `word/comments.xml` to confirm how comments map to body XML content.

Best For

  • Legal engineers who need contract redlines as auditable OOXML tracked changes.
  • Document automation developers who need to read `.docx`, extract text, and emit structured artifacts.
  • Technical writing maintainers who need to create standardized Word docs with paragraph and text-run structure.
  • Content reviewers who need to inspect comments, media, and body XML mappings.