
Document Skills
Generate valid Word (.docx) files from Node or browser scripts when your agent must ship contracts, specs, or reports—not markdown paste.
Overview
document-skills is an agent skill for the Build phase that teaches correct docx (JavaScript/TypeScript) patterns so agents generate non-corrupted .docx files.
Install
npx skills add https://github.com/travisjneuman/.claude --skill document-skillsWhat is this skill?
- End-to-end docx npm workflow: Document, Packer, sections, save via Node buffer or browser Blob
- Explicit anti-pattern: never use \n in TextRun—use separate Paragraph elements to avoid corrupt rendering
- Covers tables, images, headers/footers, TOC, hyperlinks, footnotes, page breaks, and alignment/orientation APIs
- Requires reading the full tutorial before edits—formatting pitfalls are called out up front
- Global or local install via npm install docx with copy-paste import map from the skill
- Tutorial mandates reading the entire document before starting to avoid corruption pitfalls
- Documents save via Packer.toBuffer (Node) or Packer.toBlob (browser)
Adoption & trust: 2.6k installs on skills.sh; 61 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need Word documents from code but naive TextRun and newline usage corrupts files and breaks tables, images, and pagination.
Who is it for?
Indie builders automating proposals, SOWs, or generated reports from Node or browser tooling with the docx package.
Skip if: Teams that only need markdown or PDF from static site generators with no programmatic Word requirement.
When should I use this skill?
Generate or edit .docx with JavaScript/TypeScript and the docx package.
What do I get? / Deliverables
After following the skill, your agent emits structurally valid .docx using Paragraph-centric layout and the documented Packer save path.
- .docx binary file
- Document composition code using Paragraph and section children
Recommended Skills
Journey fit
Canonical shelf is Build because the skill teaches programmatic document assembly as a product deliverable, not one-off chat formatting. Docs subphase fits skills that output structured documentation artifacts (.docx) alongside READMEs and specs.
How it compares
Use instead of asking the model to invent OOXML by hand or paste unverified docx snippets from chat.
Common Questions / FAQ
Who is document-skills for?
Solo and indie builders whose agents must output real .docx files via JavaScript or TypeScript and the docx npm library.
When should I use document-skills?
Use during Build/docs when generating client deliverables, spec packs, or mail-merge-style Word files; also when fixing corrupted docx from wrong Paragraph versus TextRun usage.
Is document-skills safe to install?
Review the Security Audits panel on this Prism page and treat filesystem writes from generated buffers like any local script output.
SKILL.md
READMESKILL.md - Document Skills
# 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: {