to-docx

to-docx is a skill for Claude Code from MidnightDarling/collate. It costs 217 tokens per session (1,762 once invoked), scanned A, original, Apache-2.0.

A document converter that turns corrected Markdown into a Word .docx file. Markdown is plain text with simple formatting marks, while .docx is the editable Microsoft Word format commonly used for submissions and editorial work.

In plain words
What is it for?
It helps prepare a checked manuscript for journal submission, academic exchange, or communication with an editor, including headings, footnotes, figures, tables, and references.
Why use it?
It applies consistent academic document formatting instead of requiring manual changes to fonts, spacing, margins, footnotes, quotations, captions, and references.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: positional $N argument; mentions Claude Code.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

Part of the collate plugin — 15 skills, 2 commands, 2 agents shipped together

Good fit It helps prepare a checked manuscript for journal submission, academic exchange, or…

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add MidnightDarling/collate
Claude Code
/plugin install collate

Made for: Claude Code.

Or install collate, the plugin that ships this one along with the rest of its 15 skills, 2 commands, 2 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for to-docx

README.md
[![agentmods](https://agentmods.dev/badge/skills/midnightdarling/collate/to-docx.svg)](https://agentmods.dev/skills/midnightdarling/collate/to-docx)
Your own site
<a href="https://agentmods.dev/skills/midnightdarling/collate/to-docx"><img src="https://agentmods.dev/badge/skills/midnightdarling/collate/to-docx.svg" alt="Measured on agentmods" height="20"></a>
Per session 217 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,762 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00217 $0.01762
Opus 5 $0.00109 $0.00881
Sonnet 5 $0.00043 $0.00352
Haiku 4.5 $0.00022 $0.00176

Measured 6d ago against content hash c19a1ee4e921, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

to-docx scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/extract_template_config.py, scripts/md_to_docx.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/to-docx/SKILL.md · 161 lines

How it starts

The opening of the file, as written. The whole thing — 161 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Markdown → Word

Task

把校对定稿的 Markdown 转成一份 .docx,供投稿、学界交流、编辑沟通使用。

输出规范(由 Alice 定义,所有输出一致):

元素 规范
正文字体 思源宋体 / Source Han Serif
标题字体 思源宋体加粗
正文字号 12 pt(小四)
一级标题 16 pt(三号)
二级标题 14 pt(四号)
段首缩进 2 字符
行距 1.2
字间距 0.2 pt
页边距 上下左右全部 2 cm
页码 底部居中
脚注 连续编号,思源宋体 9 pt
引号 中文「""''」

Process

Step 1:确认输入

INPUT="<markdown-path>"
test -f "$INPUT" || { echo "文件不存在"; exit 1; }

推荐用校对完的 final.md,不要直接用 raw.md(仍含 OCR 错)。

输出路径约定:输出 docx 固定落在 <workspace>/output/<title>_<author>_<year>_final.docx。脚本优先读 _internal/_import_provenance.json,缺失时再回退到 meta.json 与 Markdown 标题,不用显式指定。权威规范见插件的 references/workspace-layout.md

Step 2:优先尝试 Anthropic 的 docx skill

检查 Claude Code 环境里 anthropic-skills:docxdocx skill 是否可用。如可用:

  • <input>.md 内容
  • 按上表规范设置样式参数
  • 调 anthropic docx skill 生成含标题层级、段首缩进、字体、页边距的 .docx
  • 它能给出更精细的 OOXML 控制(真正的分页符、脚注链接、交叉引用)

Step 3:Fallback — 用 bundled 脚本

Anthropic docx skill 不可用时(非 Claude Code 运行时、脱机环境等),跑:

# --output 省略;脚本会根据 workspace 约定把 docx 放到 <ws>/output/<title>_<author>_<year>_final.docx
python3 "${CLAUDE_PLUGIN_ROOT}/skills/to-docx/scripts/md_to_docx.py" \
    --input "$INPUT" \
    --title-from-first-h1

脚本会打印一行 [md_to_docx] wrote <path>,用这行来拿到实际输出路径(见 Step 7)。若要强制自定义路径,仍可显式 --output <path>——主要给 CI / 回归测试用,日常不要手写。

脚本用 python-docx 实现。支持:

  • Markdown 标题 → 对应 Word Heading 样式
  • 段首缩进 + 思源宋体 + 1.2 行距 + 0.2 pt 字间距
  • 页边距上下左右全部 2 cm
  • 中文引号自动规范
  • 代码块 → Consolas 等宽
  • 图片内嵌(从 assets/ 读)
  • 表格 → Word Table
  • 脚注 [^1] → Word 原生脚注

Step 4:题注与图表

Markdown 里的图片:

![图 1:乾隆年间北京城图](assets/fig1.png)

脚本会:

  • 图片居中
  • 下方加题注"图 1:乾隆年间北京城图"(10 pt,居中)
  • 跟随引用自动连续编号

表格同理:

| 年份 | 事件 |
|------|------|
| 1840 | 鸦片战争 |

*表 1:近代史大事年表*

图表没有题注时不要自己编——留空让用户补。

Step 5:脚注

校对好的 Markdown 里可能用:

这是正文内容[^1]。

[^1]: 这是脚注内容。

脚本把 [^n] 变成 Word 原生脚注(每页底部显示,全文连续编号),不是 inline reference。

Read the full file on GitHub · 161 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 161 lines · 217 tokens per session scan A c19a1ee4e921

Subscribe to this mod's changes

to-docx is a skill published in the GitHub repository MidnightDarling/collate (6 stars, last pushed 3mo ago), licensed Apache-2.0. It adds 217 tokens to every session and 1,762 once invoked, about $0.0011 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.