askill
document-docx

document-docxSafety 100Repository

Create, edit, and analyze Microsoft Word documents with tracked changes, formatting, styles, tables, headers/footers, and template-based generation. Supports .docx format using python-docx, mammoth.js, and docx libraries for Node.js and Python workflows.

0 stars
1.2k downloads
Updated 2/5/2026

Package Files

Loading files...
SKILL.md

Document DOCX Skill — Quick Reference

This skill enables creation, editing, and analysis of Word documents programmatically. Claude should apply these patterns when users need to generate reports, contracts, proposals, documentation, or any structured Word documents from data or templates.


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
Track changespython-docxPythonReview workflows, redlining

When to Use This Skill

Claude should invoke this skill when a user requests:

  • Generate Word documents from data or templates
  • Create formatted reports with tables, headers, styles
  • Extract content from existing DOCX files
  • Convert DOCX to HTML or other formats
  • Implement mail merge or template filling
  • Add tracked changes or comments
  • Create document automation workflows

Core Operations

Create Document (Python)

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)

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)

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

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)

Document Structure Patterns

Report Template

REPORT STRUCTURE
├── Title Page (heading level 0, centered)
├── Table of Contents (auto-generated)
├── Executive Summary (heading level 1)
├── Body Sections (heading levels 1-3)
│   ├── Introduction
│   ├── Findings (with tables, charts)
│   └── Recommendations
├── Appendices
└── Footer (page numbers, date)

Contract Template

CONTRACT STRUCTURE
├── Header (parties, date)
├── Recitals (WHEREAS clauses)
├── Definitions
├── Terms and Conditions (numbered sections)
├── Signatures Block
└── Exhibits/Schedules

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()

Navigation

Resources

Templates

Related Skills

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

95/100Analyzed 2/12/2026

A comprehensive and highly actionable skill for programmatic Word document manipulation across Python and Node.js, featuring clear triggers and code examples.

100
98
95
95
98

Metadata

Licenseunknown
Version-
Updated2/5/2026
Publishermajiayu000

Tags

github-actionsllm