assignment-word
Skill8 starsChanged 3 months agoMITView on GitHub
Edit and fill Word (.docx) documents — inspect structure, replace text, batch fill placeholders, insert images, and fill tables. Use when user mentions "assignment-word", "docx_editor", "填Word", "填docx", "Word填写", "replace docx", "fill docx", or needs to programmatically modify a Word document.
- Installs packages
In this repository32 other files it gives its agents.
- ai-genSkill
- any2mdSkill
- cheatsheatSkill
- claude2antiSkill
- claude2codexSkill
- codex2claudeSkill
- fincomp-deckSkill
- github-trendingSkill
- git-pushSkill
- html2mdSkill
- html2pdfSkill
- html2texSkill
- html-slidesSkill
- img-readerSkill
- latex-beamerSkill
- markitdownSkill
- md2docxSkill
- md2texSkill
- mergeSkill
- notesSkill
- paper-html-onepageSkill
- paper-reproSkill
- pdf2wordSkill
- pdf-readerSkill
- posterSkill
- repo-docsSkill
- repo-docs-zhSkill
- resume-builderSkill
- web-search-fallbackSkill
- word2htmlSkill
- word2mdSkill
- word2pdfSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 0 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
After converting PDF to Word with pdf2word, need to fill in content
- Very specific: line 74
Use info to inspect document structure and find placeholder text
- Very specific: line 75
Use replace for simple text substitutions
- Very specific: line 76
Use fill for batch replacements from a JSON file
- Very specific: line 77
Use image to insert images at specific locations
- Very specific: line 78
Use table to fill specific table cells with data
- Very specific: line 82
Always use PYTHONIOENCODING=utf-8 on Windows
- Very specific: line 83
Default behavior is in-place edit with .bak backup
- Very specific: line 84
Use -o to save to a new file instead of modifying the original
- Very specific: line 87
Chinese font fix: Always use set_run_font(run) instead of run.font.name = '宋体' — python-docx's font.name only sets Western fonts …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Assignment Word Editor (docx_editor.py)
Programmatically edit Word (.docx) documents using python-docx. Supports text replacement (preserving formatting), batch placeholder filling, image insertion, and table data filling.
When to Use
- User mentions: "assignment-word", "docx_editor", "填Word", "填docx", "Word填写", "replace docx"
- Need to inspect, fill, or modify a Word document programmatically
- After converting PDF to Word with
pdf2word, need to fill in content
Dependencies
python -m pip install python-docx 2>&1 | tail -3Commands
info — Print document structure
Prints paragraphs, tables, headers/footers with index numbers for targeting edits.
PYTHONIOENCODING=utf-8 python "<LOCAL_USER>/.claude/skills/assignment-word/docx_editor.py" info "<docx_path>"replace — Find and replace text (preserving formatting)
PYTHONIOENCODING=utf-8 python "<LOCAL_USER>/.claude/skills/assignment-word/docx_editor.py" replace "<docx_path>" --old "OLD_TEXT" --new "NEW_TEXT" [-o output.docx]fill — Batch replace placeholders from JSON
JSON format: { "placeholder1": "value1", "placeholder2": "value2" }
PYTHONIOENCODING=utf-8 python "<LOCAL_USER>/.claude/skills/assignment-word/docx_editor.py" fill "<docx_path>" --data replacements.json [-o output.docx]image — Insert image after matching text
PYTHONIOENCODING=utf-8 python "<LOCAL_USER>/.claude/skills/assignment-word/docx_editor.py" image "<docx_path>" --after "图1" --img "figure.png" [-o output.docx]table — Fill table data from JSON
JSON format: { "cells": { "0,0": "value", "1,2": "value" } } (row,col → value)
PYTHONIOENCODING=utf-8 python "<LOCAL_USER>/.claude/skills/assignment-word/docx_editor.py" table "<docx_path>" --idx 0 --data table_data.json [-o output.docx]Arguments
| Argument | Description |
-o, --output | Output file path. Default: in-place edit (original backed up as .bak) |
--old | Old text to find (for replace) |
--new | New replacement text (for replace) |
--data | Path to JSON data file (for fill and table) |
--after | Text to search for, image inserted after this paragraph (for image) |
--img | Image file path to insert (for image) |
--idx | Table index (0-based, for table) |
Workflow
- Use
infoto inspect document structure and find placeholder text - Use
replacefor simple text substitutions - Use
fillfor batch replacements from a JSON file - Use
imageto insert images at specific locations - Use
tableto fill specific table cells with data
Rules
- Always use
PYTHONIOENCODING=utf-8on Windows - Default behavior is in-place edit with
.bakbackup - Use
-oto save to a new file instead of modifying the original - Text replacement preserves original run formatting (bold, italic, font, size)
- For
fill, placeholders like{{姓名}}will be matched and replaced - Chinese font fix: Always use
set_run_font(run)instead ofrun.font.name = '宋体'— python-docx'sfont.nameonly sets Western fonts (ascii/hAnsi), NOT East Asian (w:eastAsia). Without setting eastAsia, Chinese characters render in Word's default font causing garbled text
Chinese Font Fix (Critical)
python-docx's run.font.name = '宋体' only sets w:ascii and w:hAnsi attributes. Chinese characters use w:eastAsia which must be set via XML:
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
def set_run_font(run, font_name='宋体'):
run.font.name = font_name
rPr = run._element.get_or_add_rPr()
rFonts = rPr.find(qn('w:rFonts'))
if rFonts is None:
rFonts = OxmlElement('w:rFonts')
rPr.insert(0, rFonts)
rFonts.set(qn('w:eastAsia'), font_name)
rFonts.set(qn('w:ascii'), font_name)
rFonts.set(qn('w:hAnsi'), font_name)This applies to:
- Creating new documents from scratch (every run)
- Setting default style font (
set_style_font()) - Filling table cells (
set_tc_text()already includes this fix) - Any code that sets
run.font.namefor Chinese content
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

