# Generating Word Docs

> Creates Word documents (.docx) for reports, briefs, letters, and other documents meant to be read rather than edited as code. Use whenever the deliverable is a written document and a polished, human-readable format is expected instead of markdown.

- Skill: `aaravriyer193/generating-word-docs` (Agent Skill)
- Install (CLI): `npx skillmds@latest add aaravriyer193/generating-word-docs`
- Raw SKILL.md: https://api.skillmd.com/api/skills/aaravriyer193/generating-word-docs/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Docs & Writing
- Author: aaravriyer193 (https://skillmd.com/u/aaravriyer193)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/aaravriyer193/generating-word-docs

---


# Generating Word documents

Never hand-write .docx with write_file — it's a zipped XML format and will corrupt. Build it with python-docx instead.

```bash
pip install python-docx
```

```python
from docx import Document

doc = Document()
doc.add_heading("Title", level=1)
doc.add_paragraph("Body text.")
doc.add_heading("Section", level=2)
doc.add_paragraph("More text.", style="List Bullet")
doc.save("/home/user/report.docx")
```

Write this as a script with write_file, run it with shell, then present_file the .docx — never the script.

For tables:
```python
table = doc.add_table(rows=1, cols=3)
table.style = "Light Grid Accent 1"
hdr = table.rows[0].cells
hdr[0].text, hdr[1].text, hdr[2].text = "Name", "Value", "Notes"
```

For a cover page or letterhead, add a page break with `doc.add_page_break()` and keep the first page minimal.

