Word Document (DOCX) Manipulation for Openclaw

An advanced automation skill for creating, editing, and validating professional Word documents (.docx) via programmatic libraries and direct XML restructuring.

fslong520
v1.0.0
Jun 7, 2026
0
565
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install wordpro

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install wordpro using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Word Document (DOCX) Manipulation?

The docx tool, a premium entry in the Openclaw Skills ecosystem, gives your AI agents complete and robust programmatic command over Microsoft Word documents (.docx files). Instead of relying on brittle, high-level text representations, this skill enables programmatic generation using docx-js alongside direct XML-level unpacking, editing, and repackaging. This dual approach ensures your automated document workflows maintain structural and visual integrity, matching professional enterprise styling guidelines.

By incorporating this capability from Openclaw Skills, you can automate complex document workflows, perform deep structural searches, accept or reject tracked changes, and handle conversions between .doc, .docx, and PDF formats. It enforces best design principles—including precise grid layouts, explicit page setup, typographic hierarchies, and proper table formatting—making it indispensable for automated report generation, contract analysis, and content publishing.

Word Document (DOCX) Manipulation Use Cases

  • Automated Report and Invoice Generation: Create professionally formatted reports, memos, and letters with automated tables of contents, explicit page sizes, and embedded images.
  • Document Analysis and Redaction: Extract text or clean templates using pandoc and direct XML inspection to locate and remove placeholders or sensitive information.
  • Tracked Changes and Comments Management: Programmatically insert, accept, or reject track changes and handle collaborative comments using custom author attributes.
  • Format Conversion Workflows: Smoothly convert legacy .doc documents to modern .docx files, export finalized drafts to PDF, or split documents into high-resolution images for previews.
  • Dynamic XML Patching: Unpack document archives, perform precise XML text replacements, and validate the resulting structure to fix internal styling and layout issues.

How Word Document (DOCX) Manipulation Works

  1. Trigger and Goal Identification: The AI agent detects keywords such as .docx, report, or tracked changes and loads this option from the library of Openclaw Skills.
  2. Prerequisite Check and Initialization: The system verifies the availability of npm docx, LibreOffice, pandoc, and pdftoppm to ensure all creation, conversion, and extraction engines are ready.
  3. New Document Creation (JS Execution): For fresh documents, a custom JavaScript runtime uses docx-js to construct pages, margins, headers, footers, tables, and styles utilizing explicit DXA spacing and layout constraints.
  4. Existing Document Modification (XML Lifecycle): To edit files, the skill unpacks the .docx ZIP archive, merges adjacent runs, applies target XML edits or tracked changes, and repackages the archive using an automated pack script.
  5. Validation and Quality Assurance: The updated document is validated against Open XML schemas using structural validation scripts to automatically repair minor errors and ensure compliance.
  6. Export and Verification Loop: The system optionally generates a PDF or text representation to check for placeholders or orphaned headers, looping through edits until zero defects remain.

Word Document (DOCX) Manipulation Setup

System Prerequisites

Ensure your system has the required global binaries installed. On Windows, verify these are added to your system PATH.

# Install the docx library globally for document generation
npm install -g docx

# Install pandoc for Markdown and text extraction
# On Debian/Ubuntu:
sudo apt-get install pandoc poppler-utils libreoffice

Directory Navigation

Always run your scripts within the local skill environment context:

cd {this_skill_dir}

Document Conversion Command

Convert legacy .doc files to modern XML format:

python scripts/office/soffice.py --headless --convert-to docx document.doc

Unpacking for XML Edits

Unpack your files before modifying raw XML:

python scripts/office/unpack.py document.docx unpacked/

Validating Output

Run structural verification checks after packing files:

python scripts/office/validate.py document.docx

Word Document (DOCX) Manipulation Data Schema & Taxonomy

This skill organizes its operations through raw XML schemas, temporary unpacked directory structures, and a dedicated scripts repository. Below is the file and metadata schema utilized when using this tool from Openclaw Skills:

Core Schema Units (DXA)

Most layout specifications inside Word documents use DXA (twips), where 1440 DXA = 1 inch.

Attribute / Element Target Value (US Letter) Target Value (A4) Description
Page Width 12,240 DXA 11,906 DXA Width of the document canvas
Page Height 15,840 DXA 16,838 DXA Height of the document canvas
Default Margins 1,440 DXA 1,440 DXA Explicit 1-inch margins around the text area
Body Width 9,360 DXA 9,026 DXA Available width for full-width tables or layouts

File Structure Taxonomy

When unpacking or modifying a .docx package, the following files and paths are critical:

  • word/document.xml: Main XML structure containing the actual text paragraphs (<w:p>), runs (<w:r>), and tables (<w:tbl>).
  • word/comments.xml: Holds document collaboration commentary and replies.
  • word/_rels/document.xml.rels: Tracks image relationships and embedded hypermedia pointers.
  • word/media/: Directory where all embedded images, logos, and illustrations are stored.
  • [Content_Types].xml: Maps media extensions (e.g., png, jpeg) to their official XML content-type definitions.

Word Document (DOCX) Manipulation Advanced Features

  • Precise Table Grid Alignment: Enforces dual-width table and cell configurations using DXA, eliminating table sizing breakdowns inside third-party editors like Google Docs.
  • Native Tracked Changes: Implements insertion (<w:ins>) and deletion (<w:del>) markup elements seamlessly, complete with customizable authoring metadata and date attributes.
  • Multi-Level Collaboration: Leverage helper tools to inject threaded document comments and nested reply chains programmatically.
  • Table of Contents Automation: Automatically builds structural TOC indexes using outline levels, removing the need for manual navigation structures.
  • Intelligent Post-Processing QA: Includes a validation loop using check scripts to catch missing alt-texts, bad heading levels, and orphaned placeholders before delivery.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*