Skip to content
Skills Library
Documents & office · Building & coding

docx

/docx

Create, edit, check and convert Word documents (.docx) - reports, memos, letters, contracts, minutes. Use it to build a new .docx (JSON spec builder with default styling, real table of contents, single-line "Title · Page X of Y" footer), to change an existing document while keeping its styles (cross-run find/replace, template filling, sections, tables, images, TOC), to accept/reject or produce tracked changes, and to convert to PDF. To only read or summarise a .docx, call read_file on it; you do not need this skill for that.

Repository
harness ↗
Licence
MIT
Last repository change
05.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
16
Scripts
13
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 05.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What to check before installing
  • 13 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: scripts/blocks.py, scripts/cross_check.py, scripts/edit_docx.py, scripts/fill_toc.py, scripts/footer.py, scripts/inspect_docx.py, scripts/lo.py, scripts/new_document.py, scripts/opserr.py, scripts/render_pages.py, scripts/replace.py, scripts/to_pdf.sh, scripts/tracked_changes.py

What it does and when to use it

Create, edit, check and convert Word documents (.docx) - reports, memos, letters, contracts, minutes. Use it to build a new .docx (JSON spec builder with default styling, real table of contents, single-line "Title · Page X of Y" footer), to change an existing document while keeping its styles (cross-run find/replace, template filling, sections, tables, images, TOC), to accept/reject or produce tracked changes, and to convert to PDF. To only read or summarise a .docx, call read_file on it; you do not need this skill for that.

Triggers from the description

Title · Page X of Y
Original author description

Create, edit, check and convert Word documents (.docx) - reports, memos, letters, contracts, minutes. Use it to build a new .docx (JSON spec builder with default styling, real table of contents, single-line "Title · Page X of Y" footer), to change an existing document while keeping its styles (cross-run find/replace, template filling, sections, tables, images, TOC), to accept/reject or produce tracked changes, and to convert to PDF. To only read or summarise a .docx, call read_file on it; you do not need this skill for that.

How it works

  1. 0. Decide
  2. 1. Structure of an existing document
  3. 2. Create
  4. 3. Edit an existing document (keep its formatting)
  5. 4. Tracked changes
  6. 5. Convert
  7. 6. Verify (the FINISH GATE in detail)
  8. 7. Deliver
  9. Pitfalls
Original SKILL.md headings · 189 lines, 1,767 words
SKILL.md preview
---
name: docx
description: Create, edit, check and convert Word documents (.docx) - reports, memos, letters, contracts, minutes. Use it to build a new .docx (JSON spec builder with default styling, real table of contents, single-line "Title · Page X of Y" footer), to change an existing document while keeping its styles (cross-run find/replace, template filling, sections, tables, images, TOC), to accept/reject or produce tracked changes, and to convert to PDF. To only read or summarise a .docx, call read_file on it; you do not need this skill for that.
---

# Word documents (.docx)

**FINISH GATE - do this before you say anything about the document to the user.**
1. Check: `python3 /skills/docx/scripts/inspect_docx.py --check /workspace/outputs/FILE.docx`.
   The runtime already runs it after every tool call that changes a file in `/workspace/outputs/` and adds the
   verdict to that call's result (`verification`): when the verdict of your last change is there, do not run it again.
2. If it is `"ok": false` (exit code 2): fix every check with `"ok": false` (its `detail` says how),
   save, and check again. At most 3 rounds.
3. When it is `"ok": true`: call `view_file` on `/workspace/outputs/FILE.docx` once and look at the pages:
   footer, tables, images, TOC, page count, language. Fix what looks wrong (then steps 1-3 again).
   If `view_file` answers that this model cannot view images, skip this step and say so; if it cannot
   render the file, say "could not view: <its reason>".
4. Cross-check the content against the files it comes from:
   `python3 /skills/docx/scripts/cross_check.py /workspace/outputs/FILE.docx SOURCE [SOURCE ...]` lists the
   figures, dates and names that are in none of them. Check each one in the source (`search_files` /
   `read_file`) and fix the wrong ones; also check that nothing the user asked for is missing.
5. Page citations of a PDF ("(p. 12)"): `python3 /skills/pdf/scripts/check_citations.py SOURCE.pdf
   /workspace/outputs/FILE.docx` (load the `pdf` skill if `/skills/pdf` is missing; the runtime also runs it
   with the check of step 1 when the thread has an uploaded PDF). Every claim it lists: use the figure
   printed on that page, cite the page where it is printed, or remove the claim.
6. Never say the document is done, ready or created while `"ok": false`. After 3 rounds, tell
   the user exactly which checks still fail. In your answer, say what you cross-checked against which
   file (and which figures are your own computations).

Only a changed file needs a new check or view: a passing check and a `view_file` after a file's last change stay
valid. Never check or view again a file you did not change since (one `view_file` per file after its last change).

**Files.** Save the final document in `/workspace/outputs/` (or the path the user asked for).
Never put a deliverable in `/workspace/.work/` and never link a file there: it is scratch space
(specs, charts, renders) and is not kept. In your answer, only link files under `/workspace/outputs/`.

In a Python script you write, take the output path from `sys.argv[1]` and pass it on the command line (`python3 /workspace/.work/build.py /workspace/outputs/report.docx`): on some backends `/workspace` exists only in command lines, so a path typed inside the file fails.

**Reading.** `read_file` returns the text of a .docx directly. Use `inspect_docx.py` only when you
need structure: paragraph indices and styles, fields, tracked changes, sections.

Scripts are in `/skills/docx/scripts/`; run them with `python3` (or `bash` for `.sh`) from
`/workspace`. They print JSON; on bad input they exit non-zero with an `error` message.

## 0. Decide

| The user wants | Do |
|---|---|
| A new document | §2 Create (the spec builder first) |
| Changes to an existing document | §3 Edit |
| Tracked changes (list, accept, reject, propose) | §4 |
| A PDF of a document | §5 Convert |
| Always, at the end | the FINISH GATE (§6), then §7 Deliver |

## 1. Structure of an existing document

```bash
python3 /skills/docx/scripts/inspect_docx.py IN.docx          # JSON: outline, styles, tables, fields, tracked changes, checks
python3 /skills/docx/scripts/inspect_docx.py IN.docx --text   # "[index] (style) text" per paragraph (cut at 200 chars: …(+n chars)), then the tables
python3 /skills/docx/scripts/inspect_docx.py IN.docx --text --range 40-60 --full   # only those paragraphs, whole text
```
A long document: list the outline first, then read only the range you will change.
`.doc`/`.odt`/`.rtf`: `soffice --headless --convert-to docx --outdir /workspace/.work IN.doc` first.

## 2. Create

### 2a. Default: JSON spec -> `new_document.py`
```bash
python3 /skills/docx/scripts/new_document.py --example > /workspace/.work/spec.json      # the format
python3 /skills/docx/scripts/new_document.py --spec /workspace/.work/spec.json --out /workspace/outputs/report.docx
```
- Long text: write Markdown and build it directly, no JSON:
  `python3 /skills/docx/scripts/new_document.py --md /workspace/.work/report.md --out /workspace/outputs/report.docx`
  (`#` headings, lists, `|` tables, `> ` callouts, `![caption](path)`, `[TOC]`, `---` page break, front matter
  `title/subtitle/author/date/locale/footer`; the full syntax is in the script's `--help`).
- Blocks: `heading{text,level}`, `paragraph{text,align}`, `bullets{items}`, `numbered{items}`,
  `table{columns,rows,widths_cm,numeric_cols,caption}`, `image{path,width_cm,caption}`,
  `callout{text,kind}`, `toc{title}`, `page_break`. Inline `**bold**`, `*italic*`, `` `code` ``, `[label](url)`.
- Each block can be `{"type": "heading", "text": "Intro", "level": 1}`, `{"heading": {"text": "Intro"}}`
  or `{"heading": "Intro"}`; a bare string is a paragraph. The same spec builds a PDF with
  `/skills/pdf/scripts/build_pdf.py`. A bad spec stops with the accepted shapes: fix the spec.
- Top level: `locale` (fr|en), `title`, `subtitle`, `author`, `date` (any text: "2026-10-06",
  "14 octobre 2025" are written as a date in the locale, other text as is), `title_page`, `header`,
  `footer`, `landscape`, `template` (a .docx whose styles you inherit).
- The footer is ONE paragraph "`footer` · Page X of Y" ("Page X sur Y" in French). Never add page numbers yourself.
- A `toc` block is filled with real entries and page numbers automatically.
- Charts: make a PNG with the `charts` skill in `/workspace/.work/`, then an `image` block
  (`width_cm` 16 = full A4 text width).

### 2b. Custom layouts: python-docx code
Write `/workspace/.work/make_doc.py` and run it. Tested patterns in `reference/python-docx.md`:
fonts (`set_font`), page setup, tables (`set_col_widths`), merged cells, images, sections,
headers/footers, TOC field, hyperlinks, insert after a paragraph. Then:
- footer with page numbers: `python3 /skills/docx/scripts/footer.py OUT.docx --text "Title" --locale en --inplace`
  (or `from footer import set_footer` after `sys.path.insert(0, "/skills/docx/scripts")`);
- table of contents: `python3 /skills/docx/scripts/fill_toc.py OUT.docx --inplace`.

### 2c. docx (npm) alternative
`require("docx")` works (global). Use it for native footnotes or complex numbering:
`reference/docx-js.md`. Give tables `columnWidths`; run `fill_toc.py` on the result if it has a TOC.

### Writing rules
- Real styles: `Heading 1-3` for headings, `List Bullet`/`List Number` for lists, `Caption` for
  captions. Never fake a heading with bold text, never type "1." by hand, never use empty
  paragraphs or spaces for layout (use spacing or a page break).
- One font family; body 10.5-11 pt; A4 portrait, 2-2.5 cm margins, unless the user's template differs.
- Tables: header row, numbers right-aligned with the same decimals, units in the header.
- Write in the user's language; dates and numbers in their locale (fr `6 octobre 2026`, `1 234,5`).

## 3. Edit an existing document (keep its formatting)

1. Copy first: `cp /workspace/in.docx /workspace/outputs/in_v2.docx`; never overwrite the upload.
2. `inspect_docx.py FILE --text` to find paragraph indices, styles and tables.
3. Use the least invasive tool:
   - Text anywhere (body, tables, headers, footers, text boxes, words split across runs):
     ```bash
     python3 /skills/docx/scripts/replace.py FILE.docx --inplace --find "{{client}}" --replace "Contoso"
     python3 /skills/docx/scripts/replace.py FILE.docx --inplace --pairs /workspace/.work/pairs.json   # {"old": "new"}
     ```
     Read `counts` / `not_found`. A miss usually means typographic quotes, a no-break space or another spelling.
   - Structure (insert, rewrite or delete paragraphs, headings, lists, tables) by the paragraph index of
     `inspect_docx.py FILE --text`, with the document's own styles, all-or-nothing:
     ```bash
     echo '[{"op":"set_text","index":3,"text":"Revenue grew **15%**."},
            {"op":"insert_after","index":3,"blocks":[{"heading":"Risks"},{"bullets":["Delay","Cost"]}]},
            {"op":"delete","range":"9-10"}]' | python3 /skills/docx/scripts/edit_docx.py FILE.docx --ops - --inplace
     python3 /skills/docx/scripts/edit_docx.py --index            # the ops (--op NAME: one op with an example)
     python3 /skills/docx/scripts/edit_docx.py FILE.docx --ops ops.json --dry-run   # the plan, nothing written
     ```
     Indexes are those you read before the batch (they do not shift inside it). A rejected op leaves the file
     untouched: the failure gives `reason`, `valid_range` / `available` / `did_you_mean`: fix that op and resend all.
     Images, TOC and unusual layouts: python-docx code that inserts next to an existing paragraph
     (`reference/python-docx.md` "Insert after a paragraph"); `doc.add_paragraph()` always appends at the END.
   - Repeating table rows: copy a row with `copy.deepcopy(row._tr)` (reference "Tables").
4. Do not change fonts, styles, margins or numbering the user did not ask to change.
5. Headings changed and there is a TOC: `fill_toc.py FILE --inplace`.
Say what you cannot do: python-docx does not edit embedded charts/OLE objects, SmartArt or equations.

## 4. Tracked changes

```bash
python3 /skills/docx/scripts/tracked_changes.py IN.docx --list
python3 /skills/docx/scripts/tracked_changes.py IN.docx --accept-all --out /workspace/outputs/clean.docx
python3 /skills/docx/scripts/tracked_changes.py IN.docx --reject-all --out /workspace/outputs/original.docx
python3 /skills/docx/scripts/tracked_changes.py IN.docx --accept-all --strip-comments --out /workspace/outputs/final.docx
python3 /skills/docx/scripts/replace.py IN.docx --out /workspace/outputs/proposal.docx --find "old" --replace "new" --track --author "Agent"
```
Edits made with python-docx code are NOT tracked; say so if the user expects tracked changes.

## 5. Convert

```bash
bash /skills/docx/scripts/to_pdf.sh /workspace/outputs/report.docx /workspace/outputs      # prints {"pdf", "pages"}
pandoc IN.md -o /workspace/outputs/OUT.docx --reference-doc=/workspace/.work/template.docx   # Markdown -> docx with a template's styles
```
Keep a template you only borrow styles from in `/workspace/.work/` (or use the user's file where it is),
not in `/workspace/outputs/`. Check the PDF with `python3 /skills/pdf/scripts/extract.py --check` if the pdf skill is loaded.

## 6. Verify (the FINISH GATE in detail)

`inspect_docx.py --check FILE` runs these checks; fix a failing one like this:

| Check | Fails when | Fix |
|---|---|---|
| `opens` | the file is not a valid .docx | rebuild it |
| `content` | the body is empty | add the content |
| `headings` | more than 500 words and no Heading style | use heading blocks / `doc.add_heading` |
| `empty_paragraphs` | 3+ empty paragraphs in a row | delete them; use spacing or a page break |
| `footer` | page number glued to text, two page numbers, numbers typed as text | `footer.py FILE --text "Title" --inplace` |
| `toc` | a TOC field shows no entries or "update the table" | `fill_toc.py FILE --inplace` |
| `table_widths` | no column grid, columns < 0.5 cm, table wider than the text | `widths_cm` / `set_col_widths` / `columnWidths` |
| `images` | an image is larger than the text area | give a width that fits (`width_cm` <= 16 on A4) |
| `placeholders` | `{{...}}`, Lorem ipsum, TODO, TBD, FIXME, `[Insert ...]` left | replace them with real content |

For edits, also compare before and after (`inspect_docx.py --text` on both) and confirm only the
intended changes happened.

## 7. Deliver

Reply with a short summary (what the document contains, anything you could not do or verify) and
link each file: `[report.docx](workspace-file:///workspace/outputs/report.docx)`. Link only files
that exist under `/workspace/outputs/`. Do not paste the document into the chat.

## Pitfalls
- `font.name` alone does not change Heading/Title fonts: their theme attributes win. Use `set_font`
  (`reference/python-docx.md`), which also removes the theme attributes.
- Column widths set only on cells are ignored by LibreOffice and the PDF export: use `set_col_widths` (sets the grid).
- `paragraph.text = "..."` deletes the runs (formatting, images, fields) of that paragraph; prefer `replace.py`.
- Images: always give a width (`Cm(16)` max on A4 portrait with 2.2 cm margins).
- `doc.tables` lists top-level tables only; nested tables are `cell.tables`.
- Fonts not installed are substituted and change the page count: use Arial, Times New Roman,
  Courier New, Calibri or Cambria.
Files in this package (16)
  • SKILL.md 13 KB
  • reference/docx-js.md 4 KB
  • reference/python-docx.md 10 KB
  • scripts/blocks.py 6 KB
  • scripts/cross_check.py 24 KB
  • scripts/edit_docx.py 13 KB
  • scripts/fill_toc.py 16 KB
  • scripts/footer.py 5 KB
  • scripts/inspect_docx.py 25 KB
  • scripts/lo.py 4 KB
  • scripts/new_document.py 20 KB
  • scripts/opserr.py 3 KB
  • scripts/render_pages.py 3 KB
  • scripts/replace.py 10 KB
  • scripts/to_pdf.sh 1 KB
  • scripts/tracked_changes.py 10 KB

Versions

RepositoryScoreLicence
This page · 7ar-chat/harness100MIT
rongxinzy/rongxinai100AGPL-3.0
mateaix/mateclaw100Apache-2.0
neromtoobad/creator-skills100MIT
TerminalSkills/skills100Apache-2.0
okou-ai/okou-skills100MIT
openbmb/pilotdeck100AGPL-3.0
wrongstack/wrongstack100MIT
asgeirtj/system_prompts_leaks100CC0-1.0

Database snapshot: 13.11.2026 · package version 47c3a8f3a13f (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90docx-skill
    All-in-one Word document (.docx) read / write / convert / review. Trigger scenarios: summarize a docx, read paragraphs / outline / tables / images / comments / tracked changes, replace body text, insert images, change page settings, rebuild table of contents, add comments or…
  • 100word-documents
    Use when creating, reading, or editing Word documents (.docx). Covers document generation with styles and structure, extracting content, find-and-replace, tracked changes, and templates. Trigger on "generate a word document", "find and replace in this docx", "fill this word…
  • 90documents
    Create, inspect, edit, review, import, and export durable document artifacts and explicit DOCX file boundaries. Use when the user asks for a document, asks to edit one, or the result is too long for chat (forms, tables, sections, headers, footers, comments and tracked changes),…
  • 90word-docx
    Create, inspect, and edit Microsoft Word documents and DOCX files with reliable styles, numbering, tracked changes, tables, sections, and compatibility checks. Use when (1) the task is about Word or `.docx`; (2) the file includes tracked changes, comments, fields, tables,…
  • 100docx-cli
    Edits, redlines, and comments on Word .docx files in place, keeping their formatting — prefer it over unzipping and hand-editing the XML. Use for tracked changes (redline, accept/reject), comments (add/reply/resolve), filling contracts/NDAs/forms, restyling headings/fonts,…
  • 100word-read-write
    Create and read Microsoft Word (.docx) documents. Use this skill when you need to generate reports/letters/templates as .docx or extract readable text from existing .docx files.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.