agentleFS
TheArchitectitTheArchitectit/awesome-cline-skills/skills/docx/SKILL.md

docx

Skill8 starsChanged 3 months agoApache-2.0View on GitHub

Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. This skill should be used when Cline needs to work with professional documents (.docx files) for creating new documents, modifying or editing content, working with tracked changes, adding comments, or any other document tasks.

  • Installs packages

We split this skill into the rules it gives an agent

10 rules. 0 are common, 10 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 189 edited versions we read keep these.

  • 10

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use "Text extraction" or "Raw XML access" sections below

    line 15
  2. Distinctive:

    Use "Creating a new Word document" workflow

    line 18
  3. Distinctive:

    If you just need to read the text contents of a document, convert the document to markdown using pandoc:

    line 29
  4. Distinctive:

    When creating a new Word document from scratch, use docx-js, which allows you to create Word documents using JavaScript/TypeScript.

    line 61
  5. Distinctive:

    Create a JavaScript/TypeScript file using Document, Paragraph, TextRun components

    line 65
  6. Distinctive:

    When editing an existing Word document, work with the underlying XML directly.

    line 104
  7. Distinctive:

    When implementing tracked changes, only mark text that actually changes.

    line 140
  8. Distinctive:

    IMPORTANT: When generating code for DOCX operations:

    line 201
  9. Distinctive:

    Avoid verbose variable names and redundant operations

    line 203
  10. Distinctive:

    Avoid unnecessary print statements

    line 204

“Common” is measured: kept by at least 6 in 10 of the 189 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

DOCX Creation, Editing, and Analysis

Overview

A user may ask Cline 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 can be read or edited. Different tools and workflows are available for different tasks.

Workflow Decision Tree

Reading/Analyzing Content

Use "Text extraction" or "Raw XML access" sections below

Creating New Document

Use "Creating a new Word document" workflow

Editing Existing Document

  • Own document + simple changes → Use "Basic OOXML editing" workflow
  • Someone else's document → Use "Redlining workflow" (recommended default)
  • Legal, academic, business, or government docs → Use "Redlining workflow" (required)

Reading and Analyzing Content

Text Extraction

If you just need to read the text contents of a document, convert the document to markdown using pandoc:

# Convert document to markdown with tracked changes
pandoc --track-changes=all path-to-file.docx -o output.md
# Options: --track-changes=accept/reject/all

Raw XML Access

Raw XML access is needed for: comments, complex formatting, document structure, embedded media, and metadata. Unpack the document to read its raw XML contents.

Unpacking a File

# Unpack using Python zipfile
python3 -c "
import zipfile
with zipfile.ZipFile('document.docx') as z:
    z.extractall('unpacked/')
"

Key File Structures

  • word/document.xml — Main document contents
  • word/comments.xml — Comments referenced in document.xml
  • word/media/ — Embedded images and media files
  • Tracked changes use <w:ins> (insertions) and <w:del> (deletions) tags

Creating a New Word Document

When creating a new Word document from scratch, use docx-js, which allows you to create Word documents using JavaScript/TypeScript.

Workflow

  1. Create a JavaScript/TypeScript file using Document, Paragraph, TextRun components
  2. Export as .docx using Packer.toBuffer()

Example

const { Document, Packer, Paragraph, TextRun, HeadingLevel } = require("docx");
const fs = require("fs");

const doc = new Document({
  sections: [{
    properties: {},
    children: [
      new Paragraph({
        text: "Report Title",
        heading: HeadingLevel.HEADING_1,
      }),
      new Paragraph({
        children: [
          new TextRun("This is the body text of the document."),
        ],
      }),
    ],
  }],
});

Packer.toBuffer(doc).then((buffer) => {
  fs.writeFileSync("output.docx", buffer);
});

Dependencies

npm install docx

Editing an Existing Word Document

When editing an existing Word document, work with the underlying XML directly.

Workflow

  1. Unpack the document using Python zipfile
  2. Modify the XML in word/document.xml
  3. Repack the document

Unpack/Repack Pattern

import zipfile
import os

# Unpack
with zipfile.ZipFile('document.docx') as z:
    z.extractall('unpacked/')

# ... Edit files in unpacked/ ...

# Repack
with zipfile.ZipFile('output.docx', 'w', zipfile.ZIP_DEFLATED) as zout:
    for root, dirs, files in os.walk('unpacked/'):
        for file in files:
            file_path = os.path.join(root, file)
            arcname = os.path.relpath(file_path, 'unpacked/')
            zout.write(file_path, arcname)

Redlining Workflow for Document Review

This workflow creates comprehensive tracked changes using OOXML. CRITICAL: For complete tracked changes, implement ALL changes systematically.

Batching Strategy: Group related changes into batches of 3-10 changes. This makes debugging manageable while maintaining efficiency. Test each batch before moving to the next.

Principle: Minimal, Precise Edits When implementing tracked changes, only mark text that actually changes. Break replacements into: [unchanged text] + [deletion] + [insertion] + [unchanged text].

Example — Changing "30 days" to "60 days":

<!-- BAD - Replaces entire sentence -->
<w:del><w:r><w:delText>The term is 30 days.</w:delText></w:r></w:del>
<w:ins><w:r><w:t>The term is 60 days.</w:t></w:r></w:ins>

<!-- GOOD - Only marks what changed -->
<w:r w:rsidR="00AB12CD"><w:t>The term is </w:t></w:r>
<w:del><w:r><w:delText>30</w:delText></w:r></w:del>
<w:ins><w:r><w:t>60</w:t></w:r></w:ins>
<w:r w:rsidR="00AB12CD"><w:t> days.</w:t></w:r>

Tracked Changes Workflow

  1. Get markdown representation:
    pandoc --track-changes=all path-to-file.docx -o current.md
  2. Identify and group changes: Review the document and identify ALL changes needed, organizing them into logical batches
  3. Unpack and modify:
    python3 -c "
    import zipfile
    with zipfile.ZipFile('document.docx') as z:
        z.extractall('unpacked/')
    "
  4. Implement changes in batches: Group changes logically and implement them together in a single script per batch
  5. Repack the document:
    python3 repack.py unpacked/ reviewed-document.docx
  6. Final verification:
    pandoc --track-changes=all reviewed-document.docx -o verification.md

Converting Documents to Images

To visually analyze Word documents, convert them to images:

  1. Convert DOCX to PDF:
    soffice --headless --convert-to pdf document.docx
  2. Convert PDF pages to JPEG images:
    pdftoppm -jpeg -r 150 document.pdf page

Code Style Guidelines

IMPORTANT: When generating code for DOCX operations:

  • Write concise code
  • Avoid verbose variable names and redundant operations
  • Avoid unnecessary print statements

Dependencies

Required dependencies (install if not available):

  • pandoc: sudo apt-get install pandoc (for text extraction)
  • docx: npm install docx (for creating new documents)
  • LibreOffice: sudo apt-get install libreoffice (for PDF conversion)
  • Poppler: sudo apt-get install poppler-utils (for pdftoppm)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.