DOCX Skill
When to use
- Read or review DOCX content where layout matters (tables, diagrams, pagination).
- Create or edit DOCX files with professional formatting.
- Validate visual layout before delivery.
Workflow
- Prefer visual review (layout, tables, diagrams).
- If
soffice and pdftoppm are available, convert DOCX -> PDF -> PNGs.
- Or use
scripts/render_docx.py (requires pdf2image and Poppler).
- If these tools are missing, install them or ask the user to review rendered pages locally.
- Use
python-docx for edits and structured creation (headings, styles, tables, lists).
- After each meaningful change, re-render and inspect the pages.
- If visual review is not possible, extract text with
python-docx as a fallback and call out layout risk.
- Keep intermediate outputs organized and clean up after final approval.
Temp and output conventions
- Use
tmp/docs/ for intermediate files; delete when done.
- Write final artifacts under
output/doc/ when working in this repo.
- Keep filenames stable and descriptive.
Dependencies (install if missing)
Prefer uv for dependency management.
Python packages:
uv pip install python-docx pdf2image
If uv is unavailable:
python3 -m pip install python-docx pdf2image
System tools (for rendering):
# macOS (Homebrew)
brew install libreoffice poppler
# Ubuntu/Debian
sudo apt-get install -y libreoffice poppler-utils
If installation isn't possible in this environment, tell the user which dependency is missing and how to install it locally.
Environment
No required environment variables.
Rendering commands
DOCX -> PDF:
soffice -env:UserInstallation=file:///tmp/lo_profile_$$ --headless --convert-to pdf --outdir $OUTDIR $INPUT_DOCX
PDF -> PNGs:
pdftoppm -png $OUTDIR/$BASENAME.pdf $OUTDIR/$BASENAME
Bundled helper:
python3 scripts/render_docx.py /path/to/file.docx --output_dir /tmp/docx_pages
Quality expectations
- Deliver a client-ready document: consistent typography, spacing, margins, and clear hierarchy.
- Avoid formatting defects: clipped/overlapping text, broken tables, unreadable characters, or default-template styling.
- Charts, tables, and visuals must be legible in rendered pages with correct alignment.
- Use ASCII hyphens only. Avoid U+2011 (non-breaking hyphen) and other Unicode dashes.
- Citations and references must be human-readable; never leave tool tokens or placeholder strings.
Final checks
- Re-render and inspect every page at 100% zoom before final delivery.
- Fix any spacing, alignment, or pagination issues and repeat the render loop.
- Confirm there are no leftovers (temp files, duplicate renders) unless the user asks to keep them.
1---2name: doc-73description: Use when the task involves reading, creating, or editing `.docx` documents, especially when formatting or layout fidelity matters; prefer `python-docx` plus the bundled `scripts/render_docx.py` for visual checks.4license: MIT5---6
7
8# DOCX Skill
9
10## When to use
11- Read or review DOCX content where layout matters (tables, diagrams, pagination).
12- Create or edit DOCX files with professional formatting.
13- Validate visual layout before delivery.
14
15## Workflow
161. Prefer visual review (layout, tables, diagrams).
17 - If `soffice` and `pdftoppm` are available, convert DOCX -> PDF -> PNGs.
18 - Or use `scripts/render_docx.py` (requires `pdf2image` and Poppler).
19 - If these tools are missing, install them or ask the user to review rendered pages locally.
202. Use `python-docx` for edits and structured creation (headings, styles, tables, lists).
213. After each meaningful change, re-render and inspect the pages.
224. If visual review is not possible, extract text with `python-docx` as a fallback and call out layout risk.
235. Keep intermediate outputs organized and clean up after final approval.
24
25## Temp and output conventions
26- Use `tmp/docs/` for intermediate files; delete when done.
27- Write final artifacts under `output/doc/` when working in this repo.
28- Keep filenames stable and descriptive.
29
30## Dependencies (install if missing)
31Prefer `uv` for dependency management.
32
33Python packages:
34```
35uv pip install python-docx pdf2image
36```
37If `uv` is unavailable:
38```
39python3 -m pip install python-docx pdf2image
40```
41System tools (for rendering):
42```
43# macOS (Homebrew)
44brew install libreoffice poppler
45
46# Ubuntu/Debian
47sudo apt-get install -y libreoffice poppler-utils
48```
49
50If installation isn't possible in this environment, tell the user which dependency is missing and how to install it locally.
51
52## Environment
53No required environment variables.
54
55## Rendering commands
56DOCX -> PDF:
57```
58soffice -env:UserInstallation=file:///tmp/lo_profile_$$ --headless --convert-to pdf --outdir $OUTDIR $INPUT_DOCX
59```
60
61PDF -> PNGs:
62```
63pdftoppm -png $OUTDIR/$BASENAME.pdf $OUTDIR/$BASENAME
64```
65
66Bundled helper:
67```
68python3 scripts/render_docx.py /path/to/file.docx --output_dir /tmp/docx_pages
69```
70
71## Quality expectations
72- Deliver a client-ready document: consistent typography, spacing, margins, and clear hierarchy.
73- Avoid formatting defects: clipped/overlapping text, broken tables, unreadable characters, or default-template styling.
74- Charts, tables, and visuals must be legible in rendered pages with correct alignment.
75- Use ASCII hyphens only. Avoid U+2011 (non-breaking hyphen) and other Unicode dashes.
76- Citations and references must be human-readable; never leave tool tokens or placeholder strings.
77
78## Final checks
79- Re-render and inspect every page at 100% zoom before final delivery.
80- Fix any spacing, alignment, or pagination issues and repeat the render loop.
81- Confirm there are no leftovers (temp files, duplicate renders) unless the user asks to keep them.