docx
DOCX Creation, Editing, and Analysis
Quick Setup
bash "$SKILL_DIR/setup.sh" # Interactive environment check + installLocal-font-first. Inspect fonts available in the user's local environment and prefer a suitable
installed font. Use bundled or downloaded fonts only as fallbacks; do not install fonts without the
user's confirmation.
Overview
A .docx file is a ZIP archive containing XML files. This skill provides tools for creating, editing, reading, and reviewing Word documents.
Original File Preserved
User-provided input files are read-only by default. Deliverables go to new files
(<stem>_updated.docx next to the input); edit an original in place only when the user explicitly
asks — and then copy it to <stem>_backup.docx next to it (never /tmp) first. See
routes/edit.md for the full workflow.
Quick Route — Read This First
Step 1: Determine task type → load the corresponding route file
Step 2: Determine business scene → load the corresponding scene file (if applicable)
Step 3: Load references/design-system.md for cover recipes, palettes, and chart colors
Step 4: Load references/common-rules.md for shared layout, font, and quality rules
Step 5: Execute per route instructions
Step 6: Run the post-generation checklist
⚠️ MANDATORY — Cover Recipe Enforcement (Step 3):
When creating a document that needs a cover page, you MUST use one of the 7 validated cover recipes (R1–R7) from design-system.md. Free-form cover code is FORBIDDEN. The recipe provides the wrapper table, background, layout structure, border settings, and spacing — do not reinvent any of these.
Workflow: (1) Call selectCoverRecipe(docType, industry) to get recipe + palette → (2) Use the corresponding buildCoverRX() function code from design-system.md → (3) Pass your config (title, subtitle, metaLines, etc.) into the recipe builder. If you skip this and write cover code from scratch, the cover WILL have compatibility issues (blank pages in MS Office, missing borders, overflow, etc.).
Script Path Setup (MANDATORY before any script call)
All CLI tools live in scripts/ relative to this skill's directory. Before calling any script, resolve the absolute path once:
DOCX_SCRIPTS="<skill_directory>/scripts" # ← parent directory of this SKILL.md
# Then all commands use $DOCX_SCRIPTS:
python3 "$DOCX_SCRIPTS/postcheck.py" output.docx
python3 "$DOCX_SCRIPTS/add_toc_placeholders.py" output.docx --autoFor Python imports (when generation code needs to import skill modules):
import sys, os
DOCX_SCRIPTS = os.path.join("<skill_directory>", "scripts")
if DOCX_SCRIPTS not in sys.path:
sys.path.insert(0, DOCX_SCRIPTS)⚠️ NEVER use bare python3 scripts/... — it only works if cwd happens to be the skill directory. Always use the absolute $DOCX_SCRIPTS path.
Task Router
| User Intent | Route | Files to Load |
|-------------|-------|---------------|
| Create/write/generate (no attachment) | Create | routes/create.md + references/docx-js-core.md |
| Edit/modify/revise (has attachment) | Edit | routes/edit.md + references/ooxml.md |
| Format/layout/font/margin | Format | routes/format.md |
| Comment/annotate/review | Comment | routes/comment.md |
| Read/analyze/extract | Read | routes/read.md |
Scene Router (Optional — load after route)
| User Keywords | Scene | File |
|---------------|-------|------|
| thesis, academic, research, paper, dissertation, abstract, journal | Academic | scenes/academic.md |
| report, analysis, experiment, testing, survey, review, summary, proposal, feasibility, competitor, industry, operations | Report | scenes/report.md |
| contract, agreement, terms, transfer, NDA, confidential, framework, cooperation, service terms, user agreement, procurement | Contract | scenes/contract.md |
| resume, CV, job application | Resume | scenes/resume.md |
| exam, test, quiz, paper (exam context), lesson plan | Exam | scenes/exam.md |
| official document, notice, letter, reply, minutes, red header, government, issuance | Official | scenes/official-doc.md |
| broadcast script, product copy, livestream, speech, presentation script, video script | Copywriting | scenes/copywriting.md |
| plan, proposal (if not report context) | Report | scenes/report.md |
| policy, regulation, standard, management rules | Official | scenes/official-doc.md |
If no scene matches, use default design rules from references/design-system.md and references/common-rules.md.
Formatting Standards (Always Apply)
→ See references/common-rules.md for full font profiles, spacing, indent, and layout rules.
Key rules (quick reference):
- Line spacing: 1.3x (
line: 312) — MANDATORY. Exceptions: resume 1.15x, official doc 28pt fixed, copywriting400, contract 1.5x - CJK body: Justified + 2-char indent (
firstLine: 480SimSun /420YaHei) - Tables:
marginsset,ShadingType.CLEAR,tableHeader: true,cantSplit: true, titlekeepNext: true - Images:
typeparameter required, preserve aspect ratio viaimage-size, PageBreak inside Paragraph - Full-page Table row: `rule: "exact"
