| name | docx |
| description | Create and edit Word documents (.docx) โ C# + OpenXML SDK for creation, WIR engine for editing/comments/tracked changes. Use for any .docx task including document creation, editing, comments, revisions, footnotes, TOC, and Markdown-to-Word conversion. |
Part 1: Routing
read file / cat only extracts plain text from .docx โ all formatting is lost. If the task involves appearance or structure, use WIR engine's session.read() instead.
Route = What You Have
1. WIR (references/wir-reference.md) โ A .docx exists whose format/style matters to the output.
The user provides a template, a document to edit/modify/review/annotate, or any file whose formatting should be preserved or referenced. This file is your output foundation โ read it, modify it, fill it.
If the .docx is merely a content/data source (e.g., reference papers, raw data exports) and its formatting is irrelevant, just read file to extract text โ that is NOT a WIR case.
.doc format โ convert first: libreoffice --headless --convert-to docx
2. md2docx (references/md2docx-reference.md) โ When you are the Orchestrator (you have create_subagent and dispatch task) and your sub-agents have returned .md files. Convert their output to a formatted Word document using the md2docx pipeline.
If you do NOT have create_subagent / task tools, you are not an Orchestrator and md2docx does not apply. Do not write markdown yourself and convert with pandoc โ the result is mediocre. Use Create (C#) for high-quality output.
3. Create (references/openxml-sdk-reference.md) โ Neither of the above.
No target .docx, no upstream .md. Build the document from scratch using C# + OpenXML SDK via ./scripts/docx build.
Part 2: Execution
File Structure
docx/
โโโ SKILL.md โ This file (routing + rules)
โโโ references/
โ โโโ openxml-sdk-reference.md โ Creation: patterns, traps, all you need
โ โโโ wir-reference.md โ WIR editing interface + patterns
โ โโโ md2docx-reference.md โ Citation pipeline โ Word conversion
โ โโโ chart-reference.md โ Native Word charts (pie, bar, line)
โ โโโ omml-reference.md โ OMML math equation patterns
โ โโโ matplotlib-guide.md โ Charts Word can't do natively
โโโ scripts/
โ โโโ docx โ Unified entry point (the only script to call)
โ โโโ engine/ โ WIR engine (editing core)
โ โโโ md2docx/ โ Citation โ Word pipeline
โ โโโ generate_backgrounds.py โ Style reference: Morandi curves (read for technique, don't call directly)
โ โโโ generate_inkwash_backgrounds.py โ Style reference: ink wash
โ โโโ generate_swiss_backgrounds.py โ Style reference: Swiss grid
โ โโโ generate_geometric_backgrounds.py โ Style reference: geometric blocks
โ โโโ generate_gradient_backgrounds.py โ Style reference: gradient ribbons
โ โโโ generate_formal_backgrounds.py โ Style reference: formal double border
โโโ assets/templates/
โโโ Example.cs โ English document demo (conditional required)
โโโ CJKExample.cs โ Chinese/CJK document demo (conditional required)
Validation
- Creation:
./scripts/docx build runs the full pipeline (compile โ generate โ auto-fix element order โ OpenXML validate โ business rules)
- Editing: The engine validates internally; after saving, spot-check high-risk areas
Hard Rules
- No manual markdown-to-docx. Do not write markdown then convert with pandoc. If you are the Orchestrator with upstream .md from sub-agents, use md2docx. Otherwise, always Create (C#).
- Target .docx exists (template, document to edit, format reference) โ always WIR, never rewrite from scratch.
- Clean up iteration artifacts โ no
v1/v2/final clutter in the output directory. Deliver clean, clearly named files only.
- Name output files by topic and match the user's language (e.g., Chinese query โ
ๅจ่ฝ็ต็ซๅๆๆฅๅ.docx, English query โ Energy_Storage_Report.docx). Never output.docx.
- Language consistency โ user's conversation language across all elements (body, headings, headers/footers, TOC, chart labels, filenames).
- Default to the skill's own toolchain; avoid external libraries unless necessary.
- After choosing a route, read the corresponding reference file in full before writing any code. Do not skim or skip sections โ traps and required patterns appear throughout.
Quality Standards
Low-saturation color palette. Pick ONE hue direction, build 3 tiers: Primary (headings) / Dark (body text) / Light (captions). Never pure #FF0000/#0000FF. Cover text color must contrast with its background AND be visually distinct from body text (larger size, different weight, generous spacing).
Cover/backcover backgrounds. If the document needs a cover, generate a unique background from scratch โ read one of the generate_*.py scripts to learn the Playwright + SVG technique, then write your own HTML/SVG with original shapes and colors matching the document's palette. Never reuse or directly call existing background scripts. Cover text must feel like a separate visual space from the body, not just a bigger first paragraph.
Content constraints. Word count target "Xๅญๅทฆๅณ" means ยฑ20% is acceptable.
Delivery checklist (verify before delivering):
- Document opens without errors
- OpenXML + business rule validation passes
- Headers, footers, page numbers present and correctly positioned
- No placeholder text remains (
[Company Name], TODO, etc.)
- All images render (build output shows
X images โ if 0, images were not inserted)
- Cover/backcover text visibly contrasts with background