
Docx
Generate polished Word (.docx) reports, specs, and handoffs programmatically with the docx npm library instead of manual formatting.
Overview
docx is an agent skill most often used in Build (also Validate, Launch) that generates .docx files with the JavaScript docx library using correct paragraph and table structure.
Install
npx skills add https://github.com/ailabs-393/ai-labs-claude-skills --skill docxWhat is this skill?
- End-to-end docx JS API: Document, Packer, Paragraph, TextRun, tables, headers, footers
- Hard rule: never use \n in TextRun—use separate Paragraph elements to avoid corrupt files
- Node and browser save paths via Packer.toBuffer and Packer.toBlob
- Covers TOC, hyperlinks, footnotes, page breaks, and table formatting primitives
- Explicit no-\n-in-TextRun formatting rule to prevent corrupted .docx output
Adoption & trust: 764 installs on skills.sh; 399 GitHub stars; 1/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need professional Word documents from your agent or script but Markdown exports or bad line breaks produce broken or unstyled .docx files.
Who is it for?
Solo builders automating proposals, specs, compliance packets, or launch collateral as Word without hand-editing layouts.
Skip if: Teams that only need PDF or HTML and have no requirement to deliver native Office formats.
When should I use this skill?
User asks to create, update, or automate Microsoft Word .docx files with JavaScript or TypeScript and the docx npm package.
What do I get? / Deliverables
You get a valid .docx buffer or download built from explicit Paragraph, Table, and style primitives that open cleanly in Word.
- .docx file on disk or downloadable blob
- Structured sections with paragraphs, tables, and optional TOC
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Formal document output most often ships from Build when you produce specs and customer-facing files, even though the same skill supports validate and launch artifacts. The shelf is docs because the skill’s entire workflow is authoring structured Word documents, not app UI or API logic.
Where it fits
Emit a scoped feature summary as a styled .docx for a client or cofounder review.
Generate an internal API or runbook document with headings, tables, and page breaks.
Produce a formatted press or partner brief as Word for teams that refuse Markdown.
How it compares
Code-first Word generation—not a GUI template designer or Google Docs API integration.
Common Questions / FAQ
Who is docx for?
Developers and solo founders who want agents to output contract-ready or stakeholder-ready Word files from Node or browser JavaScript.
When should I use docx?
In Validate for scoped proposal docs, in Build for technical specs and runbooks, and in Launch for press kits or formatted release notes—whenever .docx is the deliverable format.
Is docx safe to install?
The skill describes file generation and npm usage; review the Security Audits panel on this Prism page and vet any global npm install in your environment.
SKILL.md
READMESKILL.md - Docx
# 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