--- name: docx description: Creates, reads and edits Word (.docx) documents so the result looks professionally formatted and existing formatting survives. Use when a user says "turn these notes into a Word doc", "make a memo", "edit this contract without breaking the formatting", "add comments to this document", "track my changes", or attaches a .docx. --- # Word Documents Handles the three jobs people actually have with Word files: building a clean new document, reading or extracting from an existing one, and editing an existing one without damaging it. Decide which job it is before touching anything. ## When to use this - The user wants a memo, report, letter, proposal or one-pager delivered as a .docx. - The user supplies a .docx and wants its text summarized, extracted or restructured. - The user wants specific edits, comments or tracked changes in an existing document. - Not for PDFs, slide decks or spreadsheets, and not when the user only wants text in chat. ## Procedure 1. **Classify the job.** Create, read, or edit. If editing, ask whether changes should appear as tracked changes and whether to keep the original file untouched. Default to saving a new copy. 2. **Gather the minimum brief for a new document.** Confirm audience, purpose, length, and any house style such as fonts, logo or required headings. If the user has a template .docx, build from it rather than from scratch. 3. **Plan the structure first.** Write the heading outline in chat for anything over one page. A one-page memo needs a summary line, the body, and next steps; longer documents need a title block, headings no more than three levels deep, and a clear order of importance. 4. **Build with a real library.** In Python use python-docx; in Node use the docx package. Apply built-in styles (Title, Heading 1-3, List Bullet, List Number) instead of manual bold and font sizes, so the document stays editable. Set margins, base font and spacing once at the document level. 5. **Handle the hard elements deliberately.** Use real tables with a header row and fixed column widths, real numbered lists rather than typed numbers, page numbers in the footer for multi-page files, and images with alt text and a stated width. 6. **For edits, work minimally.** Open the original, change only the targeted runs or paragraphs, and leave styles, headers, footers and numbering alone. When replacing text, check that a phrase split across several runs is replaced whole. If the library cannot do something, such as tracked changes or comments, edit the underlying XML inside the zipped package carefully and keep the other parts byte-identical. 7. **For tracked changes and comments,** attribute them to a clear author name (ask the user, or use "Claude" if unspecified), add a date, and never merge a suggestion silently into the body text. 8. **Verify the result.** Reopen the saved file, extract its text, and compare against the brief. If a converter such as LibreOffice is available, render to PDF and inspect the pages for overflow, orphaned headings and broken tables. 9. **Report back.** Give the file path, a three-line description of what the document contains or what changed, and anything left for the user to decide. ## Output format - A saved .docx file with a descriptive name such as `board-memo-2026-q3.docx`. - A short chat summary: what was produced, page count, styles used, and open questions. - For read-only jobs, deliver the extracted text or summary in chat, with headings preserved. ## Quality checks Before delivering, confirm each of these: - Every heading uses a built-in heading style, so the navigation pane and any table of contents work. - No manual line breaks or repeated spaces are used for layout. - Tables fit within the margins and their header rows repeat across pages. - Dates, names and figures match the user's notes exactly. - The document opens cleanly after saving, with no repair prompt. - The opening paragraph tells the reader what the document is for. ## Guardrails - Never overwrite the user's original; save as a new file unless told otherwise. - Do not invent facts, names, figures or quotes to fill a section. Mark gaps as "[to confirm]". - Keep styling restrained: one or two fonts, consistent heading sizes, no decorative clutter. - Do not strip comments, tracked changes or hidden text from a supplied file unless asked. - If the document contains sensitive material, keep processing local and do not paste it into external services. - If a requested layout is not achievable in Word, say what you did instead.