# Word Document Editor

Reads, creates, and edits .docx files, including tables, comments, and tracked changes.

- Repository: https://github.com/HKUDS/DeepTutor (53613 stars)
- Category: Documents
- License: Apache-2.0
- Last updated: 2026-10-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add HKUDS/DeepTutor --skill docx -g -a claude-code -y`
Codex: `npx skills add HKUDS/DeepTutor --skill docx -g -a codex -y`
Cursor: `npx skills add HKUDS/DeepTutor --skill docx -g -a cursor -y`
Gemini CLI: `npx skills add HKUDS/DeepTutor --skill docx -g -a gemini-cli -y`

## Description

Read, create, or edit Microsoft Word .docx files, extract/summarize text and tables, generate reports/letters/memos with headings, tables, images, TOC and page numbers, do find-and-replace, or apply tracked changes (redlines) and comments. Use whenever the user has a .docx or wants a Word deliverable. Not for PDF, .xlsx, .pptx, or Google Docs.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# DOCX (Microsoft Word)

A `.docx` is a ZIP of XML parts. Body text lives in `word/document.xml`. Two tiers:

- **Default, `python-docx`** (preinstalled): create, read, and simple edits. Use for almost everything.
- **Advanced, raw OOXML via `zipfile`**: only for what python-docx cannot express, tracked changes (redlines), comments, and exact-fidelity edits that must preserve every untouched byte. See [Raw OOXML](#raw-ooxml-advanced).

## Runtime

Use `exec` with complete Python source (`language: python`). `python-docx` is
preinstalled. Prefer creating, saving, reopening, and validating the deliverable
in one call; later calls can revise the same relative filename. Follow the
turn's **User workspace** instructions for locating inputs, output boundaries,
and presenting the finished file. When editing, write a new output unless the
user explicitly requested an authorized replacement.

## Read / extract

```python
from docx import Document

doc = Document("in.docx")
text = "\n".join(p.text for p in doc.paragraphs)  # body paragraphs
for tbl in doc.tables:  # tables
    for row in tbl.rows:
        print([c.text for c in row.cells])
```

`doc.paragraphs` skips text inside tables, headers/footers, and text boxes, iterate `doc.tables` and `doc.sections[i].header/.footer` for those. Each paragraph's style: `p.style.name` (e.g. `"Heading 1"`).

To read **tracked changes**, parse the XML directly, `python-docx` ignores `<w:ins>`/`<w:del>`:

```python
import zipfile, re

xml = zipfile.ZipFile("in.docx").read("word/document.xml").decode("utf-8")
# inserted text = <w:ins>…<w:t>…  deleted = <w:del>…<w:delText>…
print(re.findall(r"<w:t[^>]*>(.*?)</w:t>", xml))
```

## Create

```python
from docx import Document
from docx.shared import Pt, Inches, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH

The rest: https://github.com/HKUDS/DeepTutor/blob/HEAD/deeptutor/skills/builtin/docx/SKILL.md
