agentleFS
smith-network-solutionssmith-network-solutions/threadknot/skills/docx/SKILL.md

docx

Skill8 starsChanged 4 months agoApache-2.0View on GitHub

Create, read and edit Microsoft Word .docx documents — reports, letters, contracts, formatted multi-section documents with headings, tables, images, headers/footers and styles. Also covers reading an existing .docx to extract or modify its content, filling a .docx template, converting to PDF, and the raw OOXML route for things python-docx cannot reach (tracked changes, comments, footnotes). Use whenever a .docx file must be produced, inspected or altered.

  • Installs packages

195 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use context7-efficient, file-reading and 9 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.
  • hfzarslanSkill

    context7-efficient

    Token-efficient library documentation fetcher using Context7 MCP with 86.8% token savings through intelligent shell pipeline filtering. Fetches code examples, API references, and best practices for JavaScript, Python, Go, Rust, and other libraries. Use when users ask about library documentation, need code examples, want API usage patterns, are learning a new framework, need syntax reference, or troubleshooting with library-specific information. Triggers include questions like "Show me React hooks", "How do I use Prisma", "What's the Next.js routing syntax", or any request for library/framework documentation.

    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 6 projects that use this

  • SeifBenayedSkill

    pdf-reading

    Use this skill when you need to read, inspect, or extract content from PDF files — especially when file content is NOT in your context and you need to read it from disk. Covers content inventory, text extraction, page rasterization for visual inspection, embedded image/attachment/table/form-field extraction, and choosing the right reading strategy for different document types (text-heavy, scanned, slide-decks, forms, data-heavy). Do NOT use this skill for PDF creation, form filling, merging, splitting, watermarking, or encryption — use the pdf skill instead.

    Also in 6 projects that use this

  • jjyaoaoSkill

    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 4 projects that use this

  • jjyaoaoSkill

    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 4 projects that use this

  • unicorn-pluginsSkill

    product-self-knowledge

    Anthropic 제품 지식 — Claude Code, Claude API, Claude.ai 관련 정확한 정보 제공

    Also in 7 projects that use this

  • +2 more from jjyaoao

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 189 edited versions we read keep these.

  • 2

    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. Very specific:

    Never hand-write a whole .docx as XML from nothing.

    line 17
  2. Distinctive:

    Write a short Python script using python-docx.

    line 31
  3. Very specific:

    If uv is genuinely unavailable, fall back to a venv — but check for uv first.

    line 92
  4. Distinctive:

    Do not hand over a document you have not looked at.

    line 143

“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

Word documents (.docx)

A .docx is a ZIP archive of XML parts. Two ways in, and picking the right one is most of the job:

NeedRoute
Write a document, edit text, add tables/images/stylespython-docx (scripts/ here)
Tracked changes, comments, footnotes, content controls, anything python-docx has no API forraw OOXML — scripts/ooxml.py unpack, edit the XML, pack

Never hand-write a whole .docx as XML from nothing. Start from a real file — either one python-docx produced or one the user supplied — and modify it.

Before editing an existing file, look at it

scripts/inspect_docx.py report.docx

Prints every paragraph with its index and style, every table with its dimensions, section/page setup, headers and footers, and the document's declared styles. Do this first on any file you did not create. Paragraph indices from this listing are what the editing recipes below address.

Creating a document

Write a short Python script using python-docx. The API worth remembering:

from docx import Document
from docx.shared import Pt, Inches, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH

doc = Document()                      # or Document("template.docx") to build on one

doc.add_heading("Quarterly Report", level=1)
p = doc.add_paragraph("Ordinary body text. ")
run = p.add_run("Bold tail.")         # runs carry the character formatting
run.bold = True
p.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY

table = doc.add_table(rows=1, cols=3)
table.style = "Table Grid"            # without a style the table has NO borders
hdr = table.rows[0].cells
hdr[0].text, hdr[1].text, hdr[2].text = "Region", "Q1", "Q2"
for region, q1, q2 in data:
    cells = table.add_row().cells
    cells[0].text = region
    cells[1].text = f"{q1:,.0f}"

doc.add_picture("chart.png", width=Inches(6))
doc.add_page_break()
doc.save("report.docx")

Points that cost time if you learn them the hard way:

  • All measurements are typed. Pt, Inches, Cm, Emu — never a bare number. Internally everything is EMU (914400 per inch).
  • Formatting lives on runs, not paragraphs. paragraph.text = "x" destroys the paragraph's runs and their formatting. To change text while keeping formatting, assign to run.text on the existing runs.
  • A table with no .style has no visible borders. "Table Grid" is the usual intent.
  • Styles must already exist in the document. Building on a user's template inherits their styles; Document() gives you the default set. Check with inspect_docx.py before referencing a style by name.
  • add_heading(level=0) produces a Title, not a heading.

Writing your own script

The scripts here declare their dependencies inline (PEP 723) and run under uv, so they work with nothing installed. Do the same for scripts you write rather than pip-installing or building a venv — on a modern distro the system Python is PEP-668 managed and pip install fails outright:

#!/usr/bin/env -S uv run --quiet --script
# /// script
# requires-python = ">=3.10"
# dependencies = ["python-docx>=1.1"]
# ///

Then chmod +x build.py && ./build.py, or just uv run --with 'python-docx>=1.1' python build.py (quote the spec — > and [ are shell metacharacters). If uv is genuinely unavailable, fall back to a venv — but check for uv first.

Editing an existing document

doc = Document("in.docx")

# Replace text without losing formatting: edit runs, not the paragraph.
for para in doc.paragraphs:
    for run in para.runs:
        if "{{CLIENT}}" in run.text:
            run.text = run.text.replace("{{CLIENT}}", "Acme Ltd")

doc.save("out.docx")

A placeholder split across runs (Word does this often, especially after editing) will not match. scripts/replace.py handles that case — it merges runs within a paragraph before substituting, and reports anything it could not find:

scripts/replace.py in.docx out.docx --set CLIENT="Acme Ltd" --set DATE=2026-04-01

Tables, headers and footers hold paragraphs too, and are missed by a naive walk of doc.paragraphs. replace.py covers all of them.

The raw OOXML route

For features python-docx does not model:

scripts/ooxml.py unpack contract.docx /tmp/contract/    # ZIP -> XML tree
# edit /tmp/contract/word/document.xml
scripts/ooxml.py pack /tmp/contract/ contract-v2.docx   # back to .docx
scripts/ooxml.py validate contract-v2.docx              # parse check

unpack pretty-prints each XML part so it is diffable and editable; pack rewrites it as a valid archive ([Content_Types].xml first, stored, no directory entries). Body text lives in word/document.xml; styles in word/styles.xml; the relationship targets for images and links in word/_rels/document.xml.rels.

Word's namespaces are verbose but consistent — the main one is w = http://schemas.openxmlformats.org/wordprocessingml/2006/main. A paragraph is <w:p>, containing runs <w:r>, containing text <w:t>. Whitespace-bearing text needs xml:space="preserve" or Word silently trims it.

Always validate after a raw edit. Word refuses to open a malformed document with an unhelpful error, and a stray unclosed tag is invisible until then.

Verify what you produced

Do not hand over a document you have not looked at. Two levels:

scripts/inspect_docx.py out.docx        # structure is what you intended
scripts/topdf.py out.docx out.pdf --png # renders, and gives you pages to look at

topdf.py is also the answer when the user asked for a PDF: build the .docx, then convert. Rendering catches what inspection cannot — a table running off the page, an image at the wrong scale, a style that did not exist and silently fell back.

Reading content out

For extracting text rather than editing, inspect_docx.py --text prints the document body as plain text with tables rendered as TSV.

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.