Skip to content
Agentmart
Submit a tool

docx-handling

Create, read, and edit Word (.docx) documents.

Skill by caestrella1

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/caestrella1-docx-handling

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Create, read, and edit Word (.docx) documents. Use when a task involves a .docx file as input or output.

Use cases: documents, writing, productivity

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/docx-handling

What's inside

Skill name
docx-handling
Description
Create, read, and edit Word (.docx) documents. Use when a task involves a .docx file as input or output.
License
MIT
Compatibility
Requires Python 3 with python-docx; pandoc optional. Installing them needs network access.
Instructions
102 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# DOCX handling

## Purpose

Read, create, and modify `.docx` files without losing formatting. Use `python-docx` for structured edits and `pandoc` for fast text extraction or conversion.

## When to use

- The user shares a `.docx` file or asks for one as output
- "Summarize this Word doc", "fill in this template", "convert this to Word"
- Find-and-replace, adding tables, or updating headings in an existing document

## When not to use

- `.doc` (legacy binary) files: convert first with `soffice --headless --convert-to docx file.doc`
- Google Docs, PDFs, or spreadsheets
- The user only wants plain text or Markdown output and never mentions Word

## Setup

```bash
pip install python-docx
# optional, for conversion/extraction
apt-get install -y pandoc   # or: brew install pandoc
```

## Steps

### Reading

1. For a quick text dump, run `pandoc input.docx -t markdown -o input.md`. This keeps headings, lists, and tables.
2. For structured access, walk the document in `python-docx`:

   ```python
   from docx import Document
   doc = Document("input.docx")
   for p in doc.paragraphs:
       print(p.style.name, "|", p.text)
   for table in doc.tables:
       for row in table.rows:
           print([cell.text for cell in row.cells])
   ```

### Creating

1. Start from a template (`Document("template.docx")`) when the output must match a house style. Otherwise start from `Document()`.
2. Use built-in styles (`Heading 1`, `List Bullet`, `Table Grid`) rather than manual font changes, so the document stays consistent and editable.
3. Save under a new filename. Never overwrite the user's original unless they asked you to.

```python
from docx import Document
from docx.shared import Pt

doc = Document()
doc.add_heading("Quarterly Report", level=1)
doc.add_paragraph("Revenue grew 12% quarter over quarter.")
doc.add_paragraph("New customers: 48", style="List Bullet")

table = doc.add_table(rows=1, cols=2, style="Table Grid")
table.rows[0].cells[0].text, table.rows[0].cells[1].text = "Region", "Revenue"
for region, revenue in [("North", "$1.2M"), ("South", "$0.9M")]:
    row = table.add_row().cells
    row[0].text, row[1].text = region, revenue

doc.save("report.docx")
```

### Editing

1. **Find and replace:** Word splits text into *runs*, so `{{NAME}}` may span several runs. Replace at the paragraph level, then rewrite the runs:

   ```python
   def replace_in_paragraph(p, old, new):
       if old not in p.text:
           return
       text = p.text.replace(old, new)
       for run in p.runs[1:]:
           run.text = ""
       p.runs[0].text = text  # keeps the first run's formatting
   ```

   Apply it to `doc.paragraphs` *and* to every cell paragraph in `doc.tables`, plus headers and footers (`doc.sections[i].header.paragraphs`).
2. **Verify** by re-reading the saved file (step 1 of Reading) and confirming each change landed.

## Pitfalls

| Issue | Fix |
|---|---|
| Placeholder not replaced | It spans runs. Use paragraph-level replace (above). |
| Formatting lost after edit | You assigned `p.text = ...`, which drops runs. Edit `p.runs` instead. |
| Images/charts missing in text dump | Expected: `pandoc` extracts text only. Use `--extract-media=./media` to pull images. |
| Tracked changes ignored | `python-docx` doesn't expose them. Accept or reject them in Word first, or parse `word/document.xml` directly. |

## Examples

### Example 1

**Input:** "Fill in `offer_template.docx` with name Jane Doe and start date March 3."

**Output:** Load the template, replace `{{NAME}}` and `{{START_DATE}}` in body, tables, and headers, then save as `offer_jane_doe.docx`. Re-read the file to confirm neither placeholder is left.

From caestrella1/clankerlib, MIT.

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Sep 24, 2026 (1 month ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from caestrella1

Cite this page

docx-handling skill. Agent Mart. https://agentmart.dev/skills/caestrella1-docx-handling (last updated 2026-10-24)