docx
Installation
SKILL.md
docx
Core Rules
- DXA Dual-Width Invariant for Tables: When generating Word documents using
docx-jsor OOXML, every table must declarecolumnWidthson the table element AND matchingwidthon every individualTableCellusingWidthType.DXA($1\text{ in} = 1440\text{ DXA}$, $1\text{ pt} = 20\text{ DXA}$). Never use percentage widths, as they collapse in Google Docs and web office viewers. - Template Preservation via XML Unzipping: To modify existing styled documents or corporate templates, unzip the
.docxarchive, perform surgical edits inword/document.xmlorword/styles.xml, and re-zip. Never attempt full-document regeneration withdocx-jsif preserving corporate typography and headers. - Dual-Pass Reading: When extracting or reviewing document content, convert
.docxto Markdown viapandoc -f docx -t markdownfor structural reading. For comment threads and tracked revisions, inspectword/comments.xmlandword/document.xml(<w:ins>,<w:del>) directly. - Standard Page Geometry: Enforce A4 ($11906 \times 16838\text{ DXA}$) or US Letter ($12240 \times 15840\text{ DXA}$) with explicit $1\text{ in}$ ($1440\text{ DXA}$) margins on all section properties (
<w:sectPr>). - Contract Manifest Verification: After creating or modifying a document, emit a valid
document-manifest.jsoncapturing file checksums, page estimates, and font configurations.
Suggested Process
- Intake & Discovery: Determine whether the task requires creating a new document from scratch or modifying an existing
.docxtemplate. - Reading & Inspection: Convert existing files using
pandoc -f docx -t markdown input.docx -o content.mdto review prose structure. - Generation / Surgical Modification:
- For scratch generation, author a Node.js script using
docx(Packer.toBuffer). - For template editing, unpack via
unzip input.docx -d unpacked/, modifyunpacked/word/document.xml, verify XML well-formedness, and repack viazip -r output.docx *.
- For scratch generation, author a Node.js script using
- Table Formatting: Calculate column widths in DXA (e.g. 3-column table on US Letter: $4680, 2340, 2340\text{ DXA}$ summing to $9360\text{ DXA}$ printable width). Apply both table-level and cell-level widths.
- Validation & Delivery: Inspect rendering via LibreOffice conversion to PDF, verify layout fidelity, and emit
document-manifest.json.