docxlisted
Install: claude install-skill smith-network-solutions/threadknot
# 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:
| Need | Route |
| --- | --- |
| Write a document, edit text, add tables/images/styles | **python-docx** (`scripts/` here) |
| Tracked changes, comments, footnotes, content controls, anything python-docx has no API for | **raw 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:
```python
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.ad