Docx handler
[COLM'26] SkillLearnBench is the first benchmark for evaluating continual learning methods that automatically generate agent skills.
npx -y skills add cxcscmu/SkillLearnBench --skill docx-handlerAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
What its author says it does
Copied from the file, not written here
Handles reading, populating, and saving .docx files using the python-docx library. Use this skill for any tasks involving template filling or modifying Word documents.
SKILL.md
1.5 KB, as published. Nobody here has run it
DOCX Handler
Use this skill when you need to manipulate .docx files.
Basic Workflow
- Load document:
doc = Document('path/to/template.docx') - Iterate paragraphs/tables and replace placeholder text.
- Save document:
doc.save('path/to/output.docx')
Handling Placeholders
Use a simple text replacement for paragraphs and tables:
from docx import Document
def replace_text(doc, old_text, new_text):
for paragraph in doc.paragraphs:
if old_text in paragraph.text:
paragraph.text = paragraph.text.replace(old_text, new_text)
for table in doc.tables:
for row in table.rows:
for cell in row.cells:
for paragraph in cell.paragraphs:
if old_text in paragraph.text:
paragraph.text = paragraph.text.replace(old_text, new_text)
doc = Document('template.docx')
replace_text(doc, '{{NAME}}', 'John Doe')
doc.save('output.docx')
Handling Conditional Blocks
For conditional sections (e.g., {{IF_TAG}}...{{END_IF_TAG}}):
- Identify the paragraph(s) containing the opening and closing tags.
- If condition is true: remove tags, keep content.
- If condition is false: remove paragraph(s) containing the tags and everything between them.