mcpbeat Sign in

DOCX Format Replicator Skill for Claude

Extract formatting from existing Word documents and generate new documents with the same format but different content. Use this skill when users need to create multiple documents with consistent formatting, replicate document templates, or maintain corporate document standards across different content.

38k tokens
context cost
the whole folder, loaded on every use
7
files
ships runnable scripts
0
copies elsewhere
how many repositories repackaged it
303
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/iamzhihuix/happy-claude-skills --skill docx-format-replicator

The instruction itself

23 sections, as written by the author

DOCX Format Replicator

Overview

Extract formatting information from existing Word documents (.docx) and use it to generate new documents with identical formatting but different content. This skill enables creating document templates, maintaining consistent formatting across multiple documents, and replicating complex Word document structures.

When to Use This Skill

Use this skill when the user:

  • Wants to extract formatting from an existing Word document
  • Needs to create multiple documents with the same format
  • Has a template document and wants to generate similar documents with new content
  • Asks to "replicate", "copy format", "use the same style", or "create a document like"
  • Mentions document templates, corporate standards, or format consistency

Workflow

Step 1: Extract Format from Template

Extract formatting information from an existing Word document to create a reusable format configuration.

python scripts/extract_format.py <template.docx> <output.json>

Example:

python scripts/extract_format.py "HY研制任务书.docx" format_template.json

What Gets Extracted:

  • Style definitions (fonts, sizes, colors, alignment)
  • Paragraph and character styles
  • Numbering schemes (1, 1.1, 1.1.1, etc.)
  • Table structures and styles
  • Header and footer configurations

Output: JSON file containing all format information (see references/format_config_schema.md for details)

Step 2: Prepare Content Data

Create a JSON file with the actual content for the new document. The content must follow the structure defined in references/content_data_schema.md.

Content Structure:

{
  "metadata": {
    "title": "Document Title",
    "author": "Author Name",
    "version": "1.0",
    "date": "2025-01-15"
  },
  "sections": [
    {
      "type": "heading",
      "content": "Section Title",
      "level": 1,
      "number": "1"
    },
    {
      "type": "paragraph",
      "content": "Paragraph text content."
    },
    {
      "type": "table",
      "rows": 3,
      "cells": [
        ["Header 1", "Header 2"],
        ["Data 1", "Data 2"]
      ]
    }
  ]
}

Supported Section Types:

  • heading - Headings with optional numbering
  • paragraph - Text paragraphs
  • table - Tables with configurable rows and columns
  • page_break - Page breaks

See assets/example_content.json for a complete example.

Step 3: Generate New Document

Generate a new Word document using the extracted format and prepared content.

python scripts/generate_document.py <format.json> <content.json> <output.docx>

Example:

python scripts/generate_document.py format_template.json new_content.json output_document.docx

Result: A new .docx file with the format from the template applied to the new content.

Complete Example Workflow

User asks: "I have a research task document. I need to create 5 more documents with the same format but different content."

  • Extract the format:
python scripts/extract_format.py research_task_template.docx template_format.json
  • Create content files for each new document (content1.json, content2.json, etc.)
  • Generate documents:
python scripts/generate_document.py template_format.json content1.json document1.docx
python scripts/generate_document.py template_format.json content2.json document2.docx
# ... repeat for all documents

Common Use Cases

Corporate Document Templates

Extract format from a company template and generate reports, proposals, or specifications with consistent branding.

# One-time: Extract company template
python scripts/extract_format.py "Company Template.docx" company_format.json

# For each new document:
python scripts/generate_document.py company_format.json new_report.json "Monthly Report.docx"

Technical Documentation Series

Create multiple technical documents (specifications, test plans, manuals) with identical formatting.

# Extract from specification template
python scripts/extract_format.py spec_template.docx spec_format.json

# Generate multiple specs
python scripts/generate_document.py spec_format.json product_a_spec.json "Product A Spec.docx"
python scripts/generate_document.py spec_format.json product_b_spec.json "Product B Spec.docx"

Research Task Documents

The included example template (assets/hy_template_format.json) demonstrates a complete research task document format with:

  • Approval/review table in header
  • Multi-level numbering (1, 1.1, 1.1.1)
  • Technical specification tables
  • Structured sections

Use this as a starting point for similar technical documents.

Advanced Usage

Customizing Extraction

Modify scripts/extract_format.py to extract additional properties not covered by default:

  • Custom XML elements
  • Advanced table features (merged cells, borders)
  • Embedded objects
  • Custom properties

Extending Content Types

Add new section types in scripts/generate_document.py:

  • Images with captions
  • Bulleted or numbered lists
  • Footnotes and endnotes
  • Custom content blocks

See references/content_data_schema.md for extension guidelines.

Batch Processing

Create a wrapper script to generate multiple documents:

import json
import subprocess

format_file = "template_format.json"
content_files = ["content1.json", "content2.json", "content3.json"]

for i, content_file in enumerate(content_files, 1):
    output = f"document_{i}.docx"
    subprocess.run([
        "python", "scripts/generate_document.py",
        format_file, content_file, output
    ])

Dependencies

The scripts require:

  • Python 3.7+
  • python-docx library: pip install python-docx

No additional dependencies are needed for the core functionality.

Resources

scripts/

  • extract_format.py - Extract formatting from Word documents
  • generate_document.py - Generate new documents from format + content

Both scripts include built-in help:

python scripts/extract_format.py --help
python scripts/generate_document.py --help

references/

  • format_config_schema.md - Complete schema for format configuration files
  • content_data_schema.md - Complete schema for content data files

Read these for detailed information on file structures and available options.

assets/

  • hy_template_format.json - Example extracted format from a technical research task document
  • example_content.json - Example content data showing all section types

Use these as references when creating your own format and content files.

Troubleshooting

Missing styles in output: Ensure style IDs in content data match those in format config. Check format.json for available style IDs.

Table formatting issues: Verify table dimensions (rows/columns) match between content data and format config. See format_config_schema.md for table structure.

Font not displaying correctly: Some fonts may not be available on all systems. Check that referenced fonts are installed.

Dependencies missing: Install required Python packages:

pip install python-docx

Tips

  • Test with examples first: Use the included hy_template_format.json and example_content.json to understand the workflow before extracting your own formats.
  • Start simple: Begin with basic headings and paragraphs, then add tables and complex formatting.
  • Validate JSON: Use a JSON validator to check content data files before generating documents.
  • Keep format configs: Store extracted format configurations for reuse across multiple projects.
  • Version control: Track both format configs and content data in version control for reproducible document generation.

Other skills for the same job

different authors, same section of the catalogue
DOCX
by anthropics
vendor ×16

Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks

7k tokens
PDF
by anthropics
vendor ×16

Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.

13k tokens scripts
PPTX
by JayZeeDesign
×15

Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks

308k tokens scripts
Canvas Design
by anthropics
vendor ×13

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.

1388k tokens
PDF
by anthropics
vendor ×10

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

15k tokens scripts
DOCX
by w95
×6

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.

5k tokens
PPTX
by w95
×4

Use this skill any time a .pptx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates, layouts, speaker notes, or comments. Trigger whenever the user mentions \"deck,\" \"slides,\" \"presentation,\" or references a .pptx filename, regardless of what they plan to do with the content afterward. If a .pptx file needs to be opened, created, or touched, use this skill.

2k tokens
Obsidian Markdown
by ZhanlinCui
×3

Create and edit Obsidian Flavored Markdown with wikilinks, embeds, callouts, properties, and other Obsidian-specific syntax. Use when working with .md files in Obsidian, or when the user mentions wikilinks, callouts, frontmatter, tags, embeds, or Obsidian notes.

3k tokens

How to use it

Copy the folder

Take iamzhihuix/docx-format-replicator from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.

Install what it needs

The instructions reference pip. Without those the skill loads but fails at the first command.