Docx authoring

From event4u-app/agent-config · View interactive version

Docx authoring is an AI agent skill from the GitHub repository event4u-app/agent-config. When generating or editing a Word .docx — create, fill a template, or edit body XML via a consumer library; round-trip validated. Triggers on 'generate a docx', 'fill this Word template'.

How to use this skill

Skill file

docx-authoring

Wing-1 engineering skill for writing Word documents — the generation half of

the read→write cycle whose read side is CODE0.

Ships zero runtime in this package: the agent drives a library the consumer

already has (python-docx, or a zip+XML toolchain), exactly as markitdown wraps

a consumer-installed converter. Re-implements the pattern, never any

proprietary source.

When to use

Do NOT use for: reading a docx → Markdown (that is markitdown); slide decks

(html-deck, or the gated pptx surface); PDFs (pdf-tools).

Procedure

1. Pick the path by task

| Task | Path |

|---|---|

| Create from scratch / structured content | Library create (python-docx Document()) — build paragraphs, tables, styles programmatically |

| Fill a supplied template | Open the template, replace placeholder runs in place, save a copy — never mutate the original |

| Surgical edit of existing body | unpack → edit XML → pack-with-validate: a .docx is a ZIP of XML; unzip, edit word/document.xml, re-zip preserving the archive structure |

2. Honor the hard-won gotchas (encode as rules, not hope)

3. Validate — round-trip, do not trust the write

  1. Re-open the generated file with the SAME library; assert it parses (a corrupt ZIP or malformed XML throws here).
  2. Read back one written value (a heading text, a table cell) and assert it equals what was written.
  3. For the unpack→pack path: confirm the archive still contains [Content_Types].xml and word/document.xml (dropping either produces a file Word refuses to open).

Output format

  1. The generated/edited .docx path.
  2. The validation result: parses ✅, read-back value matched ✅, required parts present ✅.
  3. Any gotcha that applied (e.g. "set A4 explicitly; template used Letter").

Gotcha

The most common silent failure is a file that **saves without error but Word

refuses to open**: an unpack→pack cycle that re-zipped with a directory entry,

wrong compression, or a dropped [Content_Types].xml. The round-trip re-open in

step 3 is the only check that catches it — a green "file written" line does not.

Do NOT

Related Skills

WHEN to use this

WHEN NOT to use this

When the agent should load this

Output

  1. Generated document — the .docx path. Cite as docx-output.
  2. Validation receipt — parses on re-open ✅, read-back value matched ✅, required OOXML parts present ✅. Cite as docx-validation.
  3. Gotcha log — present only when a gotcha applied (page-size override, run-split for a template placeholder). Cite as docx-gotchas.
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.