Word Document Skill
Create and edit .docx files programmatically.
Setup
Install the python-docx library before starting:
pip install python-docx
Creating a document
Use python-docx to build the document. Add headings, paragraphs, and tables through the Document API, then save to disk.
from docx import Document
doc = Document()
doc.add_heading("Title", level=1)
doc.add_paragraph("Body text goes here.")
doc.save("output.docx")
Editing an existing document
Open the file with Document(path), iterate doc.paragraphs, modify runs in
place, and save under a new name so the original is preserved.
Output format
Always save the result as a .docx file and tell the user the absolute path.