Loading...
Loading...
Create and manipulate Word DOCX files programmatically. Use when the user needs to generate documents, modify DOCX templates, extract document content, or automate Word document workflows. Supports both template-based generation (for branding compliance) and from-scratch creation. Keywords: Word, DOCX, document, report, template, contract, letter, corporate, branding.
npx skill4agent add jwynia/agent-skills docx-generator{{TITLE}}${author}{{PLACEHOLDERS}}deno run --allow-read scripts/analyze-template.ts corporate-template.docx > inventory.json{
"filename": "corporate-template.docx",
"paragraphCount": 25,
"tableCount": 2,
"imageCount": 1,
"paragraphs": [
{
"index": 0,
"style": "Title",
"fullText": "{{DOCUMENT_TITLE}}",
"runs": [
{ "text": "{{DOCUMENT_TITLE}}", "bold": true, "fontSize": 28 }
]
}
],
"placeholders": [
{ "tag": "{{DOCUMENT_TITLE}}", "location": "paragraph", "paragraphIndex": 0 },
{ "tag": "{{AUTHOR}}", "location": "footer-default", "paragraphIndex": 0 },
{ "tag": "${date}", "location": "table", "tableIndex": 0, "cellLocation": "R1C2" }
]
}replacements.json{
"textReplacements": [
{ "tag": "{{DOCUMENT_TITLE}}", "value": "Q4 2024 Financial Report" },
{ "tag": "{{AUTHOR}}", "value": "Finance Department" },
{ "tag": "${date}", "value": "December 15, 2024" },
{ "tag": "{{COMPANY}}", "value": "Acme Corporation" }
],
"includeHeaders": true,
"includeFooters": true
}deno run --allow-read --allow-write scripts/generate-from-template.ts \
corporate-template.docx replacements.json output.docxspec.json{
"title": "Quarterly Report",
"creator": "Finance Team",
"styles": {
"defaultFont": "Calibri",
"defaultFontSize": 11
},
"sections": [
{
"header": {
"paragraphs": [
{ "text": "Acme Corporation", "alignment": "right" }
]
},
"footer": {
"paragraphs": [
{ "text": "Confidential", "alignment": "center" }
]
},
"content": [
{
"text": "Q4 2024 Financial Report",
"heading": 1,
"alignment": "center"
},
{
"runs": [
{ "text": "Executive Summary: ", "bold": true },
{ "text": "This report provides an overview of our financial performance for Q4 2024." }
]
},
{ "pageBreak": true },
{
"text": "Revenue Breakdown",
"heading": 2
},
{
"rows": [
{
"cells": [
{ "content": [{ "text": "Category" }], "shading": "DDDDDD" },
{ "content": [{ "text": "Amount" }], "shading": "DDDDDD" },
{ "content": [{ "text": "Change" }], "shading": "DDDDDD" }
],
"isHeader": true
},
{
"cells": [
{ "content": [{ "text": "Product Sales" }] },
{ "content": [{ "text": "$1,250,000" }] },
{ "content": [{ "text": "+15%" }] }
]
},
{
"cells": [
{ "content": [{ "text": "Services" }] },
{ "content": [{ "text": "$750,000" }] },
{ "content": [{ "text": "+8%" }] }
]
}
],
"width": 100,
"borders": true
}
]
}
]
}deno run --allow-read --allow-write scripts/generate-scratch.ts spec.json output.docx# 1. Analyze template for replaceable content
deno run --allow-read scripts/analyze-template.ts contract-template.docx --pretty
# 2. Create replacements.json with client data
# 3. Generate contract
deno run --allow-read --allow-write scripts/generate-from-template.ts \
contract-template.docx replacements.json acme-contract.docx{
"title": "Sales Report",
"sections": [{
"content": [
{ "text": "Monthly Sales Report", "heading": 1 },
{ "text": "January 2025", "heading": 2 },
{
"runs": [
{ "text": "Total Sales: ", "bold": true },
{ "text": "$125,000", "color": "2E7D32" }
]
}
]
}]
}{
"sections": [{
"header": {
"paragraphs": [
{ "text": "ACME CORPORATION", "alignment": "center", "runs": [{"text": "ACME CORPORATION", "bold": true, "fontSize": 16}] },
{ "text": "123 Business Ave, City, ST 12345", "alignment": "center" }
]
},
"content": [
{ "text": "December 15, 2024", "alignment": "right" },
{ "text": "" },
{ "text": "Dear Valued Customer," },
{ "text": "" },
{ "text": "Thank you for your continued business..." },
{ "text": "" },
{ "text": "Sincerely," },
{ "text": "John Smith" },
{ "runs": [{ "text": "CEO", "italic": true }] }
],
"footer": {
"paragraphs": [
{ "text": "www.acme.com | contact@acme.com", "alignment": "center" }
]
}
}]
}| Script | Purpose | Permissions |
|---|---|---|
| Extract text, tables, placeholders from DOCX | |
| Replace placeholders in templates | |
| Create DOCX from JSON specification | |
| Property | Type | Description |
|---|---|---|
| string | Simple text content |
| array | Formatted text runs (for mixed formatting) |
| 1-6 | Heading level |
| string | |
| boolean | Bulleted list item |
| boolean | Numbered list item |
| object | |
| object | |
| boolean | Insert page break before paragraph |
| Property | Type | Description |
|---|---|---|
| string | Text content |
| boolean | Bold formatting |
| boolean | Italic formatting |
| boolean | Underline formatting |
| boolean | Strikethrough |
| number | Font size in points |
| string | Font family name |
| string | Text color (hex, no #) |
| string | Highlight color |
| boolean | Superscript |
| boolean | Subscript |
| Property | Type | Description |
|---|---|---|
| array | Array of row specifications |
| number | Table width as percentage |
| boolean | Show table borders |
| Property | Type | Description |
|---|---|---|
| string | Link text |
| string | Target URL |
| boolean | Bold formatting |
| boolean | Italic formatting |
{{PLACEHOLDER}}analyze-template.tsincludeHeadersincludeFooterscontentshadingverticalAlign