python-docx-batch-document-generation
Sub-skill of python-docx: Batch Document Generation.
Best use case
python-docx-batch-document-generation is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Sub-skill of python-docx: Batch Document Generation.
Teams using python-docx-batch-document-generation should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/batch-document-generation/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How python-docx-batch-document-generation Compares
| Feature / Agent | python-docx-batch-document-generation | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Sub-skill of python-docx: Batch Document Generation.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Batch Document Generation
## Batch Document Generation
```python
"""
Generate multiple documents from a data source.
"""
from docx import Document
from docx.shared import Pt, Inches
from typing import List, Dict, Any
from pathlib import Path
import csv
from concurrent.futures import ThreadPoolExecutor, as_completed
def generate_single_document(
template_path: str,
output_dir: Path,
data: Dict[str, Any],
filename_field: str = 'id'
) -> str:
"""Generate a single document from template."""
doc = Document(template_path)
# Replace placeholders
for para in doc.paragraphs:
for key, value in data.items():
placeholder = f'{{{{{key}}}}}'
if placeholder in para.text:
for run in para.runs:
if placeholder in run.text:
run.text = run.text.replace(placeholder, str(value))
# Generate filename
filename = f"{data.get(filename_field, 'document')}.docx"
output_path = output_dir / filename
doc.save(str(output_path))
return str(output_path)
def batch_generate_documents(
template_path: str,
csv_data_path: str,
output_dir: str,
max_workers: int = 4
) -> List[str]:
"""Generate multiple documents from CSV data."""
output_path = Path(output_dir)
output_path.mkdir(parents=True, exist_ok=True)
# Read CSV data
with open(csv_data_path, 'r') as f:
reader = csv.DictReader(f)
records = list(reader)
generated_files = []
# Generate documents in parallel
with ThreadPoolExecutor(max_workers=max_workers) as executor:
futures = {
executor.submit(
generate_single_document,
template_path,
output_path,
record
): record
for record in records
}
for future in as_completed(futures):
try:
result = future.result()
generated_files.append(result)
print(f"Generated: {result}")
except Exception as e:
print(f"Error generating document: {e}")
return generated_files
# Usage
# batch_generate_documents(
# 'invoice_template.docx',
# 'clients.csv',
# 'generated_invoices/'
# )
```Related Skills
python-import-path-mismatch-debugging
Diagnose and fix ModuleNotFoundError when a package is installed but imports still fail due to environment/path mismatches
python-import-path-debugging
Diagnose ModuleNotFoundError when a package is installed but still fails to import
multi-source-tax-document-reconciliation
Verify generated tax forms against source documents by line-by-line comparison, not just totals
label-driven-prompt-generation-architecture
Pattern for building automation scripts that classify GitHub issues into prompt templates using label-based routing and extract contextual data for batch processing
batch-syntax-repair-from-injection-errors
Detect and fix systematic syntax errors caused by line-injection scripts that split multiline constructs
batch-syntax-fix-with-regex-line-based-fallback
Fix repeated syntax errors across many files using regex, then fall back to line-based parsing when regex fails
batch-syntax-fix-regex-iteration
Iteratively fix widespread syntax errors across many files using regex refinement when initial patterns fail
batch-syntax-fix-pattern
Identify and repair cascading import/syntax errors across multiple files using regex-based line-scanning and verification
batch-regex-fix-import-syntax
Detect and fix mid-import blank-line syntax breaks across multiple files using line-based regex
agent-team-prompt-generation
Create self-contained execution prompts that define multi-role workflows for Codex sessions without external dependencies
gtm-workflow-gif-generation
Generate workflow-style GTM GIFs from validated HTML demo reports using synthetic scene slides plus Playwright/Pillow scroll capture, with Python 3.12 fallback and GIF size optimization.
gtm-demo-workflow-gif-generation
Generate GTM demo GIF assets from validated HTML reports, including both report-scroll GIFs and one higher-fidelity workflow-style GIF, while avoiding Playwright/Python environment traps.