agentleFS
flonatflonat/flonat-research/skills/docx/SKILL.md

docx

Skill150 starsChanged 9 days agoMITView on GitHub

Create, read, edit, or convert Microsoft Word documents while preserving professional document structure. Use when a .docx file is a primary input or requested output, including tracked changes, comments, images, headings, page furniture, or polished reports and letters. Not for PDFs, spreadsheets, Google Docs, or unrelated coding tasks.

  • 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

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 189 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. 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 124

“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 .docx file is a ZIP archive containing XML files.

Quick Reference

TaskApproach
Read/analyze contentpandoc or unpack for raw XML
Create new documentUse docx-js — see references/docx-js-patterns.md
Edit existing documentUnpack → edit XML → repack — see Editing below

Converting .doc to .docx

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

Reading Content

# Text extraction with tracked changes
pandoc --track-changes=all document.docx -o output.md

# Raw XML access
uv run python scripts/office/unpack.py document.docx unpacked/

Converting to Images

uv run python scripts/office/soffice.py --headless --convert-to pdf document.docx
pdftoppm -jpeg -r 150 document.pdf page

Accepting Tracked Changes

uv run python scripts/accept_changes.py input.docx output.docx

Creating New Documents

Generate .docx files with JavaScript using docx-js. Install: npm install -g docx

Full code patterns (setup, page size, styles, lists, tables, images, hyperlinks, footnotes, tab stops, multi-column layouts, TOC, headers/footers): references/docx-js-patterns.md

Critical Rules for docx-js

  • Set page size explicitly — defaults to A4; use US Letter (12240 x 15840 DXA) for US documents
  • Landscape: pass portrait dimensions — docx-js swaps width/height internally
  • Never use \n — use separate Paragraph elements
  • Never use unicode bullets — use LevelFormat.BULLET with numbering config
  • PageBreak must be in Paragraph — standalone creates invalid XML
  • ImageRun requires type — always specify png/jpg/etc
  • Always set table width with DXA — never use WidthType.PERCENTAGE (breaks in Google Docs)
  • Tables need dual widths — columnWidths array AND cell width, both must match
  • Use ShadingType.CLEAR — never SO[Project] for table shading
  • Never use tables as dividers — use border on Paragraph instead; for two-column footers, use tab stops
  • TOC requires HeadingLevel only — no custom styles on heading paragraphs
  • Override built-in styles — use exact IDs: "Heading1", "Heading2", etc.
  • Include outlineLevel — required for TOC (0 for H1, 1 for H2, etc.)

Validation

uv run python scripts/office/validate.py doc.docx

Editing Existing Documents

Follow all 3 steps in order.

Step 1: Unpack

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

Extracts XML, pretty-prints, merges adjacent runs, and converts smart quotes to XML entities. Use --merge-runs false to skip run merging.

Step 2: Edit XML

Edit files in unpacked/word/. Use "Claude" as the author for tracked changes and comments.

Use the Edit tool directly for string replacement. Do not write Python scripts.

Use smart quotes for new content:

EntityCharacter
&#x2018;' (left single)
&#x2019;' (right single / apostrophe)
&#x201C;" (left double)
&#x201D;" (right double)

Adding comments:

uv run python scripts/comment.py unpacked/ 0 "Comment text with &amp; and &#x2019;"
uv run python scripts/comment.py unpacked/ 1 "Reply text" --parent 0

Then add markers to document.xml.

Full XML patterns (tracked changes, comments, images): references/xml-reference.md

Step 3: Pack

uv run 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.

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.
  • Preserve <w:rPr> formatting: Copy the original run's <w:rPr> block into your tracked change runs.

Dependencies

  • pandoc: Text extraction
  • docx: npm install -g docx (new documents)
  • LibreOffice: PDF conversion (auto-configured via scripts/office/soffice.py)
  • Poppler: pdftoppm for images

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.