docxlisted
Install: claude install-skill TeiNam/my_harness_for_claude_code
# DOCX
`python-docx` reads and writes real Word files — no Word install, no COM. Reach
for a **template + fill** approach before building documents element-by-element:
it's less code and keeps styling in the hands of whoever owns the template.
## Template fill (recommended)
Author `template.docx` in Word with `{{placeholders}}`, then substitute. The
`docxtpl` library (Jinja2 over docx) is the clean way:
```python
from docxtpl import DocxTemplate
doc = DocxTemplate("template.docx")
doc.render({"client": "Acme", "date": "2026-07-09",
"items": [{"name": "Widget", "qty": 3}]}) # supports {% for %} loops in the doc
doc.save("out.docx")
```
Loops/conditionals live in the template as `{% for item in items %}` — the
document's styling stays in the template, code just supplies data.
## Build from scratch (python-docx)
```python
from docx import Document
from docx.shared import Pt, Inches
doc = Document()
doc.add_heading("Quarterly Report", level=0)
doc.add_paragraph("Summary paragraph.")
p = doc.add_paragraph("Bold intro: ")
p.add_run("emphasis").bold = True
# table
t = doc.add_table(rows=1, cols=2); t.style = "Light Grid Accent 1"
t.rows[0].cells[0].text, t.rows[0].cells[1].text = "Metric", "Value"
row = t.add_row().cells
row[0].text, row[1].text = "Revenue", "$1.2M"
doc.add_page_break()
doc.save("report.docx")
```
## Read / modify existing
```python
from docx import Document
doc = Document("in.docx")
text = "\n".join(p.text for p in doc.paragraphs)
for p in