# DOCX

Use this skill whenever the user wants to create, read, edit, or manipulate Word...

- Repository: https://github.com/mateaix/mateclaw (1176 stars)
- Category: Documents
- License: Apache-2.0
- Last updated: 2026-10-30
- Runs scripts: yes, review before use

## Install

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

## Description

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). For CREATING new documents (report, memo, letter, résumé, contract from scratch), call the built-in tool `renderDocx` instead, it renders Markdown to .docx in milliseconds without forking Node.js. This skill remains authoritative for EDITING existing .docx (unpack/edit XML/pack), tracked changes, comments, image manipulation, find-and-replace, and conversions. Triggers include: \"Word doc\", \"word document\", \".docx\", or requests to edit/extract/restructure existing Word files. Do NOT use for PDFs, spreadsheets, or general coding tasks unrelated to document generation.

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

> **Important:** All `scripts/` paths are relative to this skill directory.
> Use `run_skill_script` tool to execute scripts, or run with: `cd {this_skill_dir} && python scripts/...`

# DOCX creation, editing, and analysis

## Quick Start, Pick the Right Tool

| Task | Recommended Tool |
|------|------------------|
| **Create** a new document (report / résumé / contract / memo) | `renderDocx()`, millisecond render, no subprocess |
| **Edit** an existing .docx (content / formatting) | unpack → edit XML → pack workflow below |
| Add tracked changes / comments | unpack → edit XML → pack workflow below |
| GB/T 9704 official document | `writeGongwen()` (BmacClaw only) |

### Create a new document (recommended path)

Call the in-process Java tool, no Node.js install, no fork, no disk round-trip:

```
renderDocx(
  markdown="# Title\n\nBody paragraph...",
  filename="monthly-report",
  pageSize="A4"
)
```

Returns a clickable link of the form
`[monthly-report.docx](/api/v1/files/generated/<uuid>)` valid for 10 minutes.
The user clicks it to download, no follow-up Agent step needed.

`renderDocx` supports headings (`#` `##` `###`), bold (`**text**`), bullet
lists (`- item`), numbered lists (`1. item`), pipe-style tables, and plain
paragraphs. For images, headers/footers, or precise OOXML control, fall back
to the docx-js workflow below.

## Prerequisites

- **python-docx** (`pip install python-docx`): direct structure reading and light editing (paragraphs, styles, tables)
- **docx** (`npm install -g docx`): new document creation
- **LibreOffice** (`soffice`): `.doc` -> `.docx` conversion, tracked-changes acceptance, and PDF export
- **pandoc**: text extraction
- **pdftoppm** (poppler-utils): document-to-image workflows
- If `pdftoppm` is unavailable, a Python fallback path may use `pdf2image`.
- On Windows, dependencies must be installed and available in `PATH`; if missing, report the dependency issue and stop (do not keep retrying).

## Overview

The rest: https://github.com/mateaix/mateclaw/blob/HEAD/mateclaw-server/src/main/resources/skills/docx/SKILL.md
