1
---
2
name: convert-word-to-md
3
description: 'Converts Word (.docx) documents into Markdown so their contents can be accurately analyzed, summarized, searched, or extracted from. Use this skill whenever the user shares, references, or asks about a .docx file — even if they don''t say "convert" or "markdown" explicitly. This includes requests to "read", "summarize", "review", "extract data from", "compare", or "analyze" a Word document, resume, report, contract, or proposal. Always run the bundled conversion script to produce Markdown first; do not attempt to parse .docx content directly or write ad-hoc conversion code. Also use this skill for batch requests involving a whole folder of Word documents. IMPORTANT: When the user references a folder or set of documents containing multiple file types (.pdf, .docx, .xlsx), invoke ALL three sibling skills — convert-pdf-to-md, convert-word-to-md, and convert-excel-to-md — so no file type is silently skipped.'
4
---
5
6
# Convert Word to Markdown
7
8
## When to use this skill
9
10
Trigger this skill any time there is a `.docx` file that needs to be
11
understood or processed — for example, a user attaches a Word document and
12
asks questions about it, wants a summary, wants specific data pulled out, or
13
wants multiple Word documents in a folder processed together. Word's native
14
`.docx` format is a zipped XML bundle that is not reliably readable as plain
15
text, so always convert it to Markdown first using the script in this
16
skill rather than trying to open or parse the file directly.
17
18
This skill only supports `.docx`. If asked to convert a legacy `.doc` file,
19
tell the user it isn't supported and ask them to re-save it as `.docx`
20
(Word: File > Save As > Word Document (.docx)) first.
21
22
**Mixed file types:** When the user references a folder or set of documents
23
containing multiple supported file types (`.pdf`, `.docx`, `.xlsx`), this
24
skill handles only `.docx` files. The agent MUST also invoke the sibling
25
skills in parallel:
26
- `convert-pdf-to-md` for any `.pdf` files
27
- `convert-excel-to-md` for any `.xlsx` files
28
29
Never process a folder and silently skip a supported file type. All three
30
skills must be invoked together when mixed types are present.
31
32
## Setup (once per environment)
33
34
Before the first conversion in a given environment, follow
35
[`references/setup.md`](references/setup.md) step by step to ensure Python,
36
pip, and the `markitdown` package are installed. Do this proactively rather
37
than guessing whether the environment is ready — the script itself will
38
also fail with a clear pointer back to that file if `markitdown` turns out
39
to be missing, so it's safe to just try the conversion first if you're
40
reasonably confident setup was already done.
41
42
## Usage
43
44
The conversion script lives at `scripts/convert_word_to_md.py`.
45
46
**Output structure:** MarkItDown embeds images as a truncated `data:image/png;base64...` URI
47
placeholder (not real image data), so the script
48
extracts real images directly from the `.docx` and writes a self-contained
49
folder per document instead of a single loose `.md` file:
50
51
```
52
<name>/
53
img/
54
img001.<ext>
55
img002.<ext>
56
...
57
<name>.md (image references are relative: img/imgNNN.ext)
58
```
59
60
If the document has no embedded images, no `img/` folder is created.
61
62
**Single file:**
63
64
```powershell
65
# Windows
66
python scripts\convert_word_to_md.py "C:\path\to\document.docx"
67
```
68
69
```bash
70
# macOS / Linux
71
python scripts/convert_word_to_md.py "/path/to/document.docx"
72
```
73
74
This creates a `document\` folder next to the source file (containing
75
`document.md` and, if present, `document\img\`). To control the destination
76
folder explicitly:
77
78
```powershell
79
python scripts\convert_word_to_md.py "C:\path\to\document.docx" -o "C:\path\to\output_folder"
80
```
81
82
**A folder of Word documents (batch mode):**
83
84
```powershell
85
python scripts\convert_word_to_md.py "C:\path\to\folder"
86
```
87
88
Add `--recursive` to also include subfolders:
89
90
```powershell
91
python scripts\convert_word_to_md.py "C:\path\to\folder" --recursive
92
```
93
94
Each `.docx` found gets its own `<name>\` output folder next to it by
95
default. Pass `-o "C:\path\to\output_parent"` to collect all the generated
96
`<name>\` folders under a separate parent directory instead (subfolder
97
structure is preserved when combined with `--recursive`).
98
99
After conversion, read the resulting `.md` file(s) to perform the actual
100
analysis the user asked for — the script's job is only to produce accurate
101
Markdown (and images), not to interpret the content.
102
103
## Deciding where output goes
104
105
**Default — always output next to the source file.** The `<name>/` folder
106
is created in the same directory as the source `.docx`. This is the required
107
default for every case. Do NOT override it unless the user explicitly asks
108
for a different location.
109
110
**Only use `-o` when** the user explicitly provides an output path (e.g.,
111
"save the output to `C:\output`", "put the results in `D:\work`"). Do NOT
112
pass `-o` based on the agent's current working directory, the session state
113
folder, or any implied location.
114
115
**If the source file path cannot be fully resolved** — for example, the
116
user provides only a filename with no directory, or the path is ambiguous —
117
use `ask_user` to confirm the full absolute path before running the
118
conversion. Never guess or assume the directory.
119
120
## Troubleshooting
121
122
| Symptom | Likely cause | Fix |
123
|---|---|---|
124
| `ModuleNotFoundError: No module named 'markitdown'` / exit code 2 | MarkItDown not installed | Follow `references/setup.md` |
125
| `ERROR: Unsupported file type '.doc'` / exit code 3 | Legacy `.doc`, not `.docx` | Ask the user to re-save as `.docx` |
126
| `ERROR: Input path not found` / exit code 3 | Wrong path, or file moved | Confirm the correct path with the user |
127
| `FAILED <file> -> ...` in batch output | That specific file is corrupt, password-protected, or otherwise unreadable | Report which file(s) failed; other files in the batch still succeed |
128
| `NOTE: skipped N non-.docx file(s)` | Folder contains non-Word files | Expected — those files are intentionally ignored |
129
| `WARNING: found N image placeholder(s) ... but extracted M image file(s)` | Mismatch between MarkItDown's placeholder count and images found in `word/media/` (unusual/malformed docx) | Placeholders are left unreplaced rather than risk wrong images; inspect the source file's media manually if images are needed |
130