
Docx Official
Programmatically generate polished Word (.docx) deliverables from Node or TypeScript agents without hand-editing Office.
Overview
DOCX Official is an agent skill for the Build phase that teaches solo builders how to generate Microsoft Word .docx files programmatically with the docx JavaScript/TypeScript library.
Install
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill docx-officialWhat is this skill?
- End-to-end docx npm setup with Document, Packer, and save paths for Node.js buffers and browser blobs
- Explicit formatting guardrails—never use \n inside TextRun; use separate Paragraph elements for line breaks
- Covers core composition APIs: Paragraph, TextRun, Table/TableRow/TableCell, ImageRun, headers, footers, and TOC helpers
- Documents alignment, spacing, indent, headings, hyperlinks, footnotes, page breaks, and page-number runs from the offici
- Reference-oriented workflow: read the full tutorial before generating files to avoid corruption and rendering issues
- Explicit rule: never use \n inside TextRun—use separate Paragraph elements for line breaks
Adoption & trust: 1 installs on skills.sh; 40.1k GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
What problem does it solve?
You need agent-ready, valid Word documents from code but the docx API is easy to misuse in ways that corrupt files or break layout.
Who is it for?
Indie builders automating reports, proposals, or export templates from Node/TypeScript who must deliver real .docx files.
Skip if: Teams that only publish Markdown or PDF and never need Word-compatible binaries, or workflows that should use human templates in Word Desktop instead of code generation.
When should I use this skill?
The user or task requires creating, fixing, or extending programmatic .docx output with the docx npm package in JavaScript or TypeScript.
What do I get? / Deliverables
After following the skill, your agent emits structurally correct .docx using Paragraph-centric patterns and Packer save flows you can drop into scripts or repos.
- Valid .docx binary written via Packer (Node buffer or browser blob)
- Reusable Document/section/Paragraph composition patterns for future templates
Recommended Skills
Journey fit
Canonical shelf is Build because the skill’s job is producing document artifacts (reports, specs, exports) while shipping product or internal docs. Docs subphase fits best: output is structured written deliverables in .docx form, not app UI or API code.
How it compares
Use this procedural docx tutorial in the agent instead of improvising Office XML or one-off chat snippets that break on tables and page layout.
Common Questions / FAQ
Who is docx-official for?
Solo and indie developers shipping document automation with Claude Code, Cursor, or Codex who need reliable .docx generation from JavaScript or TypeScript.
When should I use docx-official?
Use it during Build docs work when you are creating programmatic Word exports, fixing corrupted docx output, or scaffolding tables, headers, and TOC in Node; it is less central during pure frontend UI or database-only backend tasks.
Is docx-official safe to install?
Treat it as documentation and example code you review before running; check this listing’s Security Audits panel and avoid piping untrusted buffers straight into production paths without your own review.
SKILL.md
READMESKILL.md - Docx Official
# DOCX Library Tutorial Generate .docx files with JavaScript/TypeScript. **Important: Read this entire document before starting.** Critical formatting rules and common pitfalls are covered throughout - skipping sections may result in corrupted files or rendering issues. ## Setup Assumes docx is already installed globally If not installed: `npm install -g docx` ```javascript const { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell, ImageRun, Media, Header, Footer, AlignmentType, PageOrientation, LevelFormat, ExternalHyperlink, InternalHyperlink, TableOfContents, HeadingLevel, BorderStyle, WidthType, TabStopType, TabStopPosition, UnderlineType, ShadingType, VerticalAlign, SymbolRun, PageNumber, FootnoteReferenceRun, Footnote, PageBreak } = require('docx'); // Create & Save const doc = new Document({ sections: [{ children: [/* content */] }] }); Packer.toBuffer(doc).then(buffer => fs.writeFileSync("doc.docx", buffer)); // Node.js Packer.toBlob(doc).then(blob => { /* download logic */ }); // Browser ``` ## Text & Formatting ```javascript // IMPORTANT: Never use \n for line breaks - always use separate Paragraph elements // ❌ WRONG: new TextRun("Line 1\nLine 2") // ✅ CORRECT: new Paragraph({ children: [new TextRun("Line 1")] }), new Paragraph({ children: [new TextRun("Line 2")] }) // Basic text with all formatting options new Paragraph({ alignment: AlignmentType.CENTER, spacing: { before: 200, after: 200 }, indent: { left: 720, right: 720 }, children: [ new TextRun({ text: "Bold", bold: true }), new TextRun({ text: "Italic", italics: true }), new TextRun({ text: "Underlined", underline: { type: UnderlineType.DOUBLE, color: "FF0000" } }), new TextRun({ text: "Colored", color: "FF0000", size: 28, font: "Arial" }), // Arial default new TextRun({ text: "Highlighted", highlight: "yellow" }), new TextRun({ text: "Strikethrough", strike: true }), new TextRun({ text: "x2", superScript: true }), new TextRun({ text: "H2O", subScript: true }), new TextRun({ text: "SMALL CAPS", smallCaps: true }), new SymbolRun({ char: "2022", font: "Symbol" }), // Bullet • new SymbolRun({ char: "00A9", font: "Arial" }) // Copyright © - Arial for symbols ] }) ``` ## Styles & Professional Formatting ```javascript const doc = new Document({ styles: { default: { document: { run: { font: "Arial", size: 24 } } }, // 12pt default paragraphStyles: [ // Document title style - override built-in Title style { id: "Title", name: "Title", basedOn: "Normal", run: { size: 56, bold: true, color: "000000", font: "Arial" }, paragraph: { spacing: { before: 240, after: 120 }, alignment: AlignmentType.CENTER } }, // IMPORTANT: Override built-in heading styles by using their exact IDs { id: "Heading1", name: "Heading 1", basedOn: "Normal", next: "Normal", quickFormat: true, run: { size: 32, bold: true, color: "000000", font: "Arial" }, // 16pt paragraph: { spacing: { before: 240, after: 240 }, outlineLevel: 0 } }, // Required for TOC { id: "Heading2", name: "Heading 2", basedOn: "Normal", next: "Normal", quickFormat: true, run: { size: 28, bold: true, color: "000000", font: "Arial" }, // 14pt paragraph: { spacing: { before: 180, after: 180 }, outlineLevel: 1 } }, // Custom styles use your own IDs { id: "myStyle", name: "My Style", basedOn: "Normal", run: { size: 28, bold: true, color: "000000" }, paragraph: { spacing: { after: 120 }, alignment: AlignmentType.CENTER } } ], characterStyles: [{ id: "myCharStyle", name: "My Char Style", run: { color: "FF0000", bold: true, underline: { type: UnderlineType.SINGLE } } }] }, sections: [{ properties: { page: { margin: { top: 1440, right: 1440, bottom: 1440, left: 1440 } } }, children: [ new Paragraph({ heading: HeadingLevel.TITLE, children: [new TextRun("Document Title")] }), // U