Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
vasilyu1983 avatar

Document Docx

  • 365 installs
  • 73 repo stars
  • Updated July 13, 2026
  • vasilyu1983/ai-agents-public

document-docx is an agent skill that creates, edits, and parses Microsoft Word .docx files using python-docx, docxtpl, mammoth.js, and the Node docx library for developers generating reports, contracts, and template-driv

About

document-docx is an agent skill from vasilyu1983/ai-agents-public that enables programmatic creation, editing, and analysis of Microsoft Word .docx files for reports, contracts, proposals, and template-driven outputs. The skill routes tasks to python-docx and docxtpl in Python for structural edits and mail-merge templates, the Node.js docx library for TypeScript server-side generation, and mammoth.js for DOCX-to-HTML conversion and text extraction. Developers reach for document-docx when generating styled Word reports, filling docxtpl templates non-developers can edit in Word, extracting tables and metadata, or inspecting tracked changes via OOXML tooling. document-docx notes that legacy .doc files require LibreOffice conversion first, python-docx cannot create true tracked changes reliably, and tables of contents refresh only after opening in Word. Install with npx skills add vasilyu1983/ai-agents-public --skill document-docx when automating document pipelines that must output .docx artifacts instead of PDF-only exports.

  • document-docx
  • Documentation
  • AI-coding skill

Document Docx by the numbers

  • 365 all-time installs (skills.sh)
  • +5 installs in the week ending Jul 27, 2026 (Skillselion tracking)
  • Ranked #423 of 1,879 Documentation skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/vasilyu1983/ai-agents-public --skill document-docx

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs365
repo stars73
Last updatedJuly 13, 2026
Repositoryvasilyu1983/ai-agents-public

How do you generate Word docx files programmatically?

Helps with documentation tasks.

Who is it for?

Developers automating Word report, contract, or mail-merge workflows in Python or Node.js who need library-specific guidance.

Skip if: Teams needing native .doc legacy editing or reliable tracked-change authoring purely through python-docx without Word or OOXML tooling.

When should I use this skill?

User asks to create, edit, parse, or convert .docx files, Word reports, contracts, docxtpl templates, or mammoth HTML extraction.

What you get

Styled .docx files, template-filled documents, extracted text or tables, and optional DOCX-to-HTML conversions.

  • Generated .docx files
  • Template-filled documents
  • Extracted text or HTML output

By the numbers

  • Covers 7 document task types across Python and Node.js libraries
  • Supports python-docx, docxtpl, mammoth.js, and Node docx workflows

Files

SKILL.mdMarkdownGitHub ↗

Document DOCX Skill - Quick Reference

This skill enables creation, editing, and analysis of .docx files for reports, contracts, proposals, documentation, and template-driven outputs.

Modern best practices (2026):

  • Prefer templates + styles over manual formatting.
  • Treat .docx as the editable source; treat PDF as a release artifact.
  • If distributing externally, include basic accessibility hygiene (headings, table headers, alt text).

Quick Reference

TaskTool/LibraryLanguageWhen to Use
Create DOCXpython-docxPythonReports, contracts, proposals
Create DOCXdocxNode.jsServer-side document generation
Convert to HTMLmammoth.jsNode.jsWeb display, content extraction
Parse DOCXpython-docxPythonExtract text, tables, metadata
Template filldocxtplPythonMail merge, template-based generation
Review workflowWord compare, comments/highlightsAnyHuman review without OOXML surgery
Tracked changesOOXML inspection, docx4j/OpenXML SDK/AsposeAnyTrue redlines or parsing tracked changes

Tool Selection

  • Prefer docxtpl when non-developers must edit layout/design in Word.
  • Prefer python-docx for structural edits (paragraphs/tables/headers/footers) when formatting complexity is moderate.
  • Prefer docx (Node.js) for server-side generation in TypeScript-heavy stacks.
  • Prefer mammoth for text-first extraction or DOCX-to-HTML (best effort; may drop some layout fidelity).

Known Limits (Plan Around These)

  • .doc (legacy) is not supported by these libraries; convert to .docx first (e.g., LibreOffice).
  • python-docx cannot reliably create true tracked changes; use Word compare or specialized OOXML tooling.
  • Tables of Contents and many fields are placeholders until opened/updated in Word.

Core Operations

Create Document (Python - python-docx)

from docx import Document
from docx.shared import Inches, Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH

doc = Document()

# Title
title = doc.add_heading('Document Title', 0)
title.alignment = WD_ALIGN_PARAGRAPH.CENTER

# Paragraph with formatting
para = doc.add_paragraph()
run = para.add_run('Bold and ')
run.bold = True
run = para.add_run('italic text.')
run.italic = True

# Table
table = doc.add_table(rows=3, cols=3)
table.style = 'Table Grid'
for i, row in enumerate(table.rows):
    for j, cell in enumerate(row.cells):
        cell.text = f'Row {i+1}, Col {j+1}'

# Image
doc.add_picture('image.png', width=Inches(4))

# Save
doc.save('output.docx')

Create Document (Node.js - docx)

import { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell } from 'docx';
import * as fs from 'fs';

const doc = new Document({
  sections: [{
    properties: {},
    children: [
      new Paragraph({
        children: [
          new TextRun({ text: 'Bold text', bold: true }),
          new TextRun({ text: ' and normal text.' }),
        ],
      }),
      new Table({
        rows: [
          new TableRow({
            children: [
              new TableCell({ children: [new Paragraph('Cell 1')] }),
              new TableCell({ children: [new Paragraph('Cell 2')] }),
            ],
          }),
        ],
      }),
    ],
  }],
});

Packer.toBuffer(doc).then((buffer) => {
  fs.writeFileSync('output.docx', buffer);
});

Template-Based Generation (Python - docxtpl)

from docxtpl import DocxTemplate

doc = DocxTemplate('template.docx')
context = {
    'company_name': 'Acme Corp',
    'date': '2025-01-15',
    'items': [
        {'name': 'Widget A', 'price': 100},
        {'name': 'Widget B', 'price': 200},
    ]
}
doc.render(context)
doc.save('filled_template.docx')

Extract Content (Python - python-docx)

from docx import Document

doc = Document('input.docx')

# Extract all text
full_text = []
for para in doc.paragraphs:
    full_text.append(para.text)

# Extract tables
for table in doc.tables:
    for row in table.rows:
        row_data = [cell.text for cell in row.cells]
        print(row_data)

Styling Reference

ElementPython MethodNode.js Class
Heading 1add_heading(text, 1)HeadingLevel.HEADING_1
Boldrun.bold = TrueTextRun({ bold: true })
Italicrun.italic = TrueTextRun({ italics: true })
Font sizerun.font.size = Pt(12)TextRun({ size: 24 }) (half-points)
AlignmentWD_ALIGN_PARAGRAPH.CENTERAlignmentType.CENTER
Page breakdoc.add_page_break()new PageBreak()

Do / Avoid (Dec 2025)

Do

  • Use consistent heading levels and a table of contents for long docs.
  • Capture decisions and action items with owners and due dates.
  • Store docs in a versioned, searchable system.

Avoid

  • Manual formatting instead of styles (breaks consistency).
  • Docs with no owner or review cadence (stale quickly).
  • Copy/pasting without updating definitions and links.

Output Quality Checklist

  • Structure: consistent heading hierarchy, styles, and (when needed) an auto-generated table of contents.
  • Decisions: decisions/actions captured with owner + due date (not buried in prose).
  • Versioning: doc ID + version + change summary; review cadence defined.
  • Accessibility hygiene: headings/reading order are correct; table headers are marked; alt text for non-decorative images.
  • Reuse: use assets/doc-template-pack.md for decision logs and recurring doc types.

Optional: AI / Automation

Use only when explicitly requested and policy-compliant.

  • Summarize meeting notes into decisions/actions; humans verify accuracy.
  • Draft first-pass docs from outlines; do not invent facts or quotes.

Navigation

Resources

  • references/docx-patterns.md - Advanced formatting, styles, headers/footers
  • references/template-workflows.md - Mail merge, batch generation
  • references/tracked-changes.md - Tracked changes: what is feasible, and what is not
  • references/accessibility-compliance.md - WCAG 2.2 AA, reading order, alt text, EU EAA
  • references/cross-platform-compatibility.md - Rendering across Word, Google Docs, LibreOffice
  • references/document-automation-pipelines.md - CI/CD batch generation, quality gates
  • data/sources.json - Library documentation links

Scripts

  • scripts/docx_inspect_ooxml.py - Dependency-free OOXML inspection (including tracked changes signals)
  • scripts/docx_extract.py - Extract text/tables to JSON (requires python-docx)
  • scripts/docx_render_template.py - Render a docxtpl template (requires docxtpl)
  • scripts/docx_to_html.mjs - Convert .docx to HTML (requires mammoth)

Templates

  • assets/report-template.md - Standard report structure
  • assets/contract-template.md - Legal document structure
  • assets/doc-template-pack.md - Decision log, meeting notes, changelog templates

Related Skills

  • ../document-pdf/SKILL.md - PDF generation and conversion
  • ../docs-codebase/SKILL.md - Technical writing patterns

Fact-Checking

  • Use web search/web fetch to verify current external facts, versions, pricing, deadlines, regulations, or platform behavior before final answers.
  • Prefer primary sources; report source links and dates for volatile information.
  • If web access is unavailable, state the limitation and mark guidance as unverified.

Related skills

FAQ

Which libraries does document-docx use?

document-docx routes creation to python-docx or Node docx, template filling to docxtpl, HTML extraction to mammoth.js, and tracked-change inspection to OOXML tooling such as docx4j or OpenXML SDK.

Does document-docx support legacy .doc files?

document-docx targets .docx only. Legacy .doc files must be converted to .docx first, for example with LibreOffice, before python-docx or mammoth.js can process them.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.