agentleFS
npownpow/claude-skills/docx/SKILL.md

docx

Skill4 starsChanged 6 months agoApache-2.0View on GitHub

Use when creating, reading, editing, or producing Word documents (.docx) — including reports, memos, letters, templates with TOCs, headings, page numbers, or letterheads; extracting or reorganizing .docx content; find-and-replace; inserting/replacing images; accepting, rejecting, or authoring tracked changes and redlines; adding comments; validating docx structure; fixing 'invalid docx' or content-type / schema errors; converting .doc→.docx. Do NOT use for PDFs, spreadsheets, Google Docs, or coding tasks unrelated to Word documents.

  • Installs packages

194 other projects use a version of this, 71 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use Video Generation, VLM and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • huang-x-hSkill

    Video Generation

    Implement AI-powered video generation capabilities using the z-ai-web-dev-sdk. Use this skill when the user needs to generate videos from text prompts or images, create video content programmatically, or build applications that produce video outputs. Supports asynchronous task management with status polling and result retrieval.

    Also in 6 projects that use this

  • huang-x-hSkill

    VLM

    Implement vision-based AI chat capabilities using the z-ai-web-dev-sdk. Use this skill when the user needs to analyze images, describe visual content, or create applications that combine image understanding with conversational AI. Supports image URLs and base64 encoded images for multimodal interactions.

    Also in 6 projects that use this

  • dav-niu474Skill

    gift-evaluator

    The PRIMARY tool for Spring Festival gift analysis and social interaction generation. Use this skill when users upload photos of gifts (alcohol, tea, supplements, etc.) to inquire about their value, authenticity, or how to respond socially. Integrates visual perception, market valuation, and HTML card generation.

    Also in 5 projects that use this

  • dav-niu474Skill

    Podcast Generate

    Generate podcast episodes from user-provided content or by searching the web for specified topics. If user uploads a text file/article, creates a dual-host dialogue podcast (or single-host upon request). If no content is provided, searches the web for information about the user-specified topic and generates a podcast. Duration scales with content size (3-20 minutes, ~240 chars/min). Uses z-ai-web-dev-sdk for LLM script generation and TTS audio synthesis. Outputs both a podcast script (Markdown) and a complete audio file (WAV).

    Also in 5 projects that use this

  • Liang-MHSkill

    stock_analysis

    获取 A 股、基金和港股的实时行情和技术分析数据

    Also in 5 projects that use this

  • SeifBenayedSkill

    file-reading

    Use this skill when a file has been uploaded but its content is NOT in your context — only its path at /mnt/user-data/uploads/ is listed in an uploaded_files block. This skill is a router: it tells you which tool to use for each file type (pdf, docx, xlsx, csv, json, images, archives, ebooks) so you read the right amount the right way instead of blindly running cat on a binary. Triggers: any mention of /mnt/user-data/uploads/, an uploaded_files section, a file_path tag, or a user asking about an uploaded file you have not yet read. Do NOT use this skill if the file content is already visible in your context inside a documents block — you already have it.

    Also in 5 projects that use this

  • +1 more from huang-x-h
  • +5 more from dav-niu474

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 189 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    CRITICAL: Use smart quotes for new content: When adding text with apostrophes or quotes, use XML entities to produce smart quotes:

    line 70
  2. Very specific:

    Adding comments: Use comment.py to handle boilerplate across multiple XML files (text must be pre-escaped XML):

    line 82
  3. Very specific:

    Replace entire <w:r> elements: When adding tracked changes, replace the whole <w:r>...</w:r> block with <w:del>...<w:ins>...

    line 105

“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

Where to look

TaskGo to
Create a new .docx (reports, memos, letters, formatted output)references/docx-js.md
Edit an existing .docx (find-replace, tweak XML, add tracked changes)## Editing Existing Documents below
Raw OOXML / schema (tracked changes, comments, images at XML level)references/ooxml.md
Accept all tracked changesscripts/accept_changes.py
Add a commentscripts/comment.py
Unpack / repack / validatescripts/office/{unpack,pack,validate}.py

Overview

A .docx file is a ZIP archive containing XML. Read it with pandoc, edit it by unpacking the XML and repacking, or create a new one with the docx npm package.

Common Operations

# Extract text as markdown (accepts tracked changes by default)
pandoc document.docx -o out.md

# Extract preserving tracked changes as markup
pandoc --track-changes=all document.docx -o out.md

# Convert legacy .doc → .docx (required before editing)
python scripts/office/soffice.py --headless --convert-to docx document.doc

# Convert to images (via PDF)
python scripts/office/soffice.py --headless --convert-to pdf document.docx
pdftoppm -jpeg -r 150 document.pdf page

# Accept all tracked changes
python scripts/accept_changes.py input.docx output.docx

# Unpack for raw XML editing
python scripts/office/unpack.py document.docx unpacked/

Editing Existing Documents

Follow all 3 steps in order.

Step 1: Unpack

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

Extracts XML, pretty-prints, merges adjacent runs, and converts smart quotes to XML entities (&#x201C; etc.) so they survive editing. Use --merge-runs false to skip run merging.

Step 2: Edit XML

Edit files in unpacked/word/. See references/ooxml.md for element patterns (tracked changes, comments, images, schema rules).

Use "Claude" as the author for tracked changes and comments, unless the user explicitly requests use of a different name.

Use the Edit tool directly for string replacement. Do not write Python scripts. Scripts introduce unnecessary complexity. The Edit tool shows exactly what is being replaced.

CRITICAL: Use smart quotes for new content. When adding text with apostrophes or quotes, use XML entities to produce smart quotes:

<!-- Use these entities for professional typography -->
<w:t>Here&#x2019;s a quote: &#x201C;Hello&#x201D;</w:t>
EntityCharacter
&#x2018;' (left single)
&#x2019;' (right single / apostrophe)
&#x201C;" (left double)
&#x201D;" (right double)

Adding comments: Use comment.py to handle boilerplate across multiple XML files (text must be pre-escaped XML):

python scripts/comment.py unpacked/ 0 "Comment text with &amp; and &#x2019;"
python scripts/comment.py unpacked/ 1 "Reply text" --parent 0  # reply to comment 0
python scripts/comment.py unpacked/ 0 "Text" --author "Custom Author"  # custom author name

Then add markers to document.xml (see the Comments section in references/ooxml.md).

Step 3: Pack

python scripts/office/pack.py unpacked/ output.docx --original document.docx

Validates with auto-repair, condenses XML, and creates DOCX. Use --validate false to skip.

Auto-repair will fix:

  • durableId >= 0x7FFFFFFF (regenerates valid ID)
  • Missing xml:space="preserve" on <w:t> with whitespace

Auto-repair won't fix:

  • Malformed XML, invalid element nesting, missing relationships, schema violations

Common Pitfalls

  • Replace entire <w:r> elements: When adding tracked changes, replace the whole <w:r>...</w:r> block with <w:del>...<w:ins>... as siblings. Don't inject tracked change tags inside a run.
  • Preserve <w:rPr> formatting: Copy the original run's <w:rPr> block into your tracked change runs to maintain bold, font size, etc.

Dependencies

  • pandoc — text extraction (brew install pandoc)
  • docx npm package — creating new documents (bun install -g docx)
  • LibreOffice — PDF conversion and accepting tracked changes; scripts/office/soffice.py auto-configures it for sandboxed environments (brew install --cask libreoffice)
  • Poppler — pdftoppm for image conversion (brew install poppler)
  • defusedxml — used by unpack.py, pack.py, comment.py, and the run/redline helpers. Declared inline via uv script metadata — uv run scripts/... installs on first run.

Scripts & Templates

The helpers referenced throughout this skill live under scripts/ next to SKILL.md — not embedded in this document.

Python scripts (scripts/):

PathPurpose
accept_changes.pyAccept all tracked changes via LibreOffice
comment.pyAdd comments to a DOCX
office/unpack.pyUnpack DOCX/PPTX/XLSX for XML editing
office/pack.pyRepack an unpacked directory into a valid DOCX/PPTX/XLSX
office/soffice.pyLibreOffice wrapper with sandbox-friendly env setup
office/validate.pyValidate DOCX structure and content
office/helpers/merge_runs.pyMerge adjacent runs with identical formatting
office/helpers/simplify_redlines.pyCollapse adjacent w:ins / w:del
office/validators/base.pyShared BaseSchemaValidator (XML, namespace, ID-uniqueness, XSD, relationship checks)
office/validators/docx.pyDOCXSchemaValidator — full WordprocessingML schema + tracked-change + relationship validation
office/validators/pptx.pyPPTXSchemaValidator — PresentationML schema validation (shared code used by the pptx/xlsx skills too)
office/validators/redlining.pyRedliningValidator — tracked-change integrity (accept-all round-trip test)

XML templates (scripts/templates/): comments.xml, commentsExtended.xml, commentsExtensible.xml, commentsIds.xml, people.xml — minimal valid root documents used when bootstrapping a new comments payload.

Invoke scripts with uv run scripts/<path> (deps auto-install from each script's inline metadata) or python scripts/<path> if you've pre-installed defusedxml. Scripts add their parent dir to sys.path at import time, so running from the skill root, the scripts/ dir, or any other cwd all work.

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.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.