docx_skill
- Python
10
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill bahayonghang/my-claude-code-settings --skill docx- SKILL.md16.8 KB
Overview
This skill handles creation, reading, editing, and manipulation of Word .docx documents. It produces polished Word files with correct page size, styles, tables, images, headers/footers, and table of contents. Use it for programmatic generation, precise XML-level edits, tracked changes, comments, and conversions to images or PDF-ready output.
How this skill works
The skill works by creating or unpacking the .docx ZIP container, editing the underlying WordprocessingML XML, and repacking a valid .docx. For new documents it generates content through a docx library, applying explicit page sizes, numbering, table widths, and image metadata. For edits it unpacks the package, lets you make minimal XML changes (with tracked-change markup and smart-quote entities), then repacks and validates the package.
When to use it
- When you need a professionally formatted Word document (.docx): reports, memos, letters, templates.
- When inserting, replacing, or sizing images with required alt text and file type.
- When creating tables that must render consistently across Word and Google Docs.
- When you must apply tracked changes, comments, or precise XML edits with author attribution.
- When converting legacy .doc to .docx or exporting pages as images/PDF.
Best practices
- Always set page size explicitly (docx default is A4; use DXA units for US Letter).
- Never use unicode bullets or literal \n for paragraphs—use numbering configs and separate Paragraph elements.
- For tables set both the table width and each cell width in DXA; use ShadingType.CLEAR and cell margins for padding.
- Specify image type (png/jpg/etc) and include altText title/description/name for each ImageRun.
- Use smart-quote XML entities for new text and use "Claude" as the tracked-change author unless a different name is requested.
- Validate the final .docx and repair or fix XML issues if validation fails.
Example use cases
- Generate a US Letter report with a table of contents, styled headings, and page numbers.
- Replace product images across a document and adjust sizes while preserving captions and alt text.
- Edit contract terms with tracked insertions and deletions attributed to a named author.
- Create a responsive two-column table that renders properly in Word and Google Docs by using DXA widths.
- Unpack a damaged .docx, fix XML runs/spacing, then repack and validate the repaired document.
FAQ
Yes. The library defaults to A4; explicitly set DXA dimensions for consistent US Letter output.
How should I add bullets or numbered lists?
Use the numbering configuration with LevelFormat.BULLET or LevelFormat.DECIMAL. Do not insert unicode bullet characters.