Docx

From kortix-ai/suna · View interactive version

Docx is an AI agent skill from the GitHub repository kortix-ai/suna. Use for creating, editing, extracting, converting, and reviewing Word documents.

How to use this skill

Skill file

Word Document Skill

Under the hood, .docx is a ZIP container holding XML parts. Creation, reading, and modification all operate on this XML structure.

Visual and typographic standards: Consult skills/design-foundations/SKILL.md for color palette, typeface selection, and layout principles (single accent color with neutral tones, no decorative graphics, WCAG-compliant contrast). Use widely available sans-serif typefaces like Arial or Calibri as your baseline.

Choosing an approach

| Objective | Technique | Reference |

|-----------|-----------|-----------|

| Create a document from scratch | docx npm module (JavaScript) | See CREATION.md |

| Edit an existing file | Unpack to XML, modify, repack | See EDITING.md |

| Pull out text | anydoc document.docx -o output.md | For redline content use pandoc document.docx -o output.md --track-changes=all |

| Handle legacy .doc format | soffice --headless --convert-to docx file.doc | Convert before any XML work |

| Rebuild from a PDF | Run pdf2docx, then patch issues | See below |

| Export pages as images | soffice to PDF, then pdftoppm | See below |

| Flatten tracked changes | python3 skills/docx/scripts/accept_changes.py in.docx out.docx | Requires LibreOffice |

System tools such as anydoc, pandoc, soffice, and pdftoppm are installed in the sandbox. Python packages such as lxml, python-docx, and pdf2docx are pre-installed — run scripts with python3. Use uv run --with <package> only for a package that is not pre-installed.

Editing professional documents

Finance, legal, and other corporate documents carry conventions that are easy to break without noticing. Honor these whenever you create or edit one — violating them is what makes output read as obviously machine-generated:

PDF to Word

Start by running pdf2docx to get a baseline .docx, then correct any artifacts. Never skip the automated conversion and attempt to rebuild manually.

pdf2docx is pre-installed — run the conversion code with python3.

from pdf2docx import Converter

parser = Converter("source.pdf")
parser.convert("converted.docx")
parser.close()

Once you have the converted file, address any problems (misaligned tables, broken hyperlinks, shifted images) by unpacking and editing the XML directly (see EDITING.md).

Image rendering

soffice --headless --convert-to pdf document.docx
pdftoppm -jpeg -r 150 document.pdf page
ls page-*.jpg   # always ls to discover actual filenames — zero-padding varies by page count

After generating the document, run a verification pass yourself: inspect extracted text, render preview images when useful, and fix issues before delivering the file.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.