Skip to content
Back to search

word-format-skill

Claude Code skill: replicate a reference Word (.docx) typography onto new content via HTML bridge — browser render → clipboard → Word paste. Append-mode preserves page setup / styles / theme / headers 100%. macOS only.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/yeap531--word-format-skill/badge.svg)](/listings/yeap531--word-format-skill)

HTML

<a href="/listings/yeap531--word-format-skill"><img src="/api/listings/yeap531--word-format-skill/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

通过 Claude Code 插件商店

/plugin marketplace add yeap531/word-format-skill
/plugin install word-format@word-format-skill

或手动 clone

git clone https://github.com/yeap531/word-format-skill.git

---

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 21 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. {
  2. "name": "word-format-skill",
  3. "owner": {
  4. "name": "yeap531"
  5. },
  6. "metadata": {
  7. "description": "Replicate a reference Word .docx's full typography (字体/字号/缩进/行距/页面设置/样式表/主题/页眉页脚) onto new content via the HTML bridge: drive Word + a browser through AppleScript on macOS, render Filtered HTML in the browser, push HTML+RTF through the system clipboard, paste into Word. Append-mode preserves the reference doc 100%.",
  8. "version": "2.0.0"
  9. },
  10. "plugins": [
  11. {
  12. "name": "word-format",
  13. "description": "Copy a reference Word .docx's complete typographic profile onto new content. Two modes: append (recommended) preserves page setup, style table, theme, headers/footers, font table verbatim by piggybacking on a copy of the reference doc; new-doc mode preserves only character/paragraph properties. macOS only — requires Microsoft Word for Mac + Chrome or Safari + Accessibility/Automation TCC permissions.",
  14. "source": "./",
  15. "strict": false,
  16. "skills": [
  17. "./skills/word-format"
  18. ]
  19. }
  20. ]
  21. }
README.md · README · 141 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # word-format-skill
  2. > 一个 Claude Code skill:把一份参考 Word (`.docx`) 的排版样式(字体 / 字号 / 缩进 / 行距 / 对齐 / **页面设置 / 样式表 / 主题 / 页眉页脚**)**视觉一致地**复刻到新内容上。
  3. 仅在 macOS 工作(依赖 Microsoft Word + 浏览器 + System Events 的 UI 自动化)。
  4. ---
  5. ## 它解决什么问题
  6. 让 AI 写一份 Word 文档时,最痛苦的不是写内容,而是排版——把 AI 输出的 Markdown / 纯文本粘进 Word,字体、字号、缩进总会乱。
  7. 这个 skill 不让 AI 凭空生成 HTML / OOXML,而是:**让 Word 自己导出一份 inline-CSS 的 Filtered HTML,AI 在这份"原件"上只改文字内容,所有样式标签原样保留。** 然后浏览器把它渲染成富文本,进系统剪贴板,粘进 Word。
  8. ```
  9. 参考 .docx
  10. │ ① docx_to_html.py(驱动 Word 自己另存为筛选过的网页)
  11. ▼
  12. Word Filtered HTML(所有样式以 inline CSS 写入每个标签)
  13. │ ② Claude 在原件上增删改文字(保留所有 inline style)
  14. ▼
  15. edited.html / append.html
  16. │ ③ render_and_paste.sh
  17. │ 浏览器渲染 → 系统剪贴板(HTML+RTF)→ Word 粘贴 → 保存
  18. ▼
  19. 最终 .docx
  20. ```
  21. 不走「AI 生成 HTML 代码」这条路,AI 始终编辑的是 Word 自己产出的"标准模板"——这是当前所知 AI → Word 损失最小的链路。
  22. ---
  23. ## 两种工作模式
  24. | 模式 | 命令 | 能保留 |
  25. |---|---|---|
  26. | **B. 续写(推荐)** | `--append-to <reference.docx>` | **100% 模板**:页面设置、样式表、主题、页眉页脚、字体表 + 字符级排版 |
  27. | A. 新建 | (不带 `--append-to`) | 仅字符 / 段落级排版(字体 / 字号 / 缩进 / 行距 / 对齐) |
  28. > 想 100% 保留模板格式 → **必须用模式 B**。诀窍是把原 `.docx` 副本作为承载文档,新内容只追加到末尾,原文档的页面设置 / 样式表 / 主题原封不动地继承下来——浏览器粘贴管线本身只能传字符级直接属性,不传 `@page` / 样式表 / theme1.xml。
  29. ---
  30. ## 环境要求
  31. - **OS**:macOS
  32. - **Microsoft Word for Mac**(`/Applications/Microsoft Word.app`)
  33. - **浏览器**:Google Chrome(首选)或 Safari
  34. - **Python 3**:系统自带,无第三方依赖
  35. 首次运行须开启系统授权:
  36. - 系统设置 → 隐私与安全性 → **自动化**:勾选允许「终端宿主进程(Terminal / iTerm / Ghostty / Claude Code)」控制 Microsoft Word、Chrome(或 Safari)、System Events
  37. - 系统设置 → 隐私与安全性 → **辅助功能**:启用同一个宿主进程
  38. 环境检查:
  39. ```bash
  40. bash skills/word-format/scripts/verify_env.sh
  41. ```
  42. ---
  43. ## 安装
  44. ### 通过 Claude Code 插件商店
  45. ```
  46. /plugin marketplace add yeap531/word-format-skill
  47. /plugin install word-format@word-format-skill
  48. ```
  49. ### 或手动 clone
  50. ```bash
  51. git clone https://github.com/yeap531/word-format-skill.git
  52. ```
  53. ---
  54. ## 快速开始
  55. ```bash
  56. # 1. 把参考 docx 导出为 inline-CSS HTML
  57. python3 skills/word-format/scripts/docx_to_html.py "/path/to/reference.docx"
  58. # → 产物:~/Library/Caches/word-format-skill/<basename>.html
  59. # 2. (Claude 这一步)从原件挑一段同类型段落作模板,复制完整 inline style,
  60. # 在 ~/Library/Caches/word-format-skill/append.html 写要追加的新内容
  61. # 所有 inline style 原样保留,只换文字。
  62. # 3. 续写模式:复制原 docx 副本 → 末尾粘贴 → 保存
  63. bash skills/word-format/scripts/render_and_paste.sh \
  64. --append-to "/path/to/reference.docx" \
  65. ~/Library/Caches/word-format-skill/append.html \
  66. ~/Desktop/最终输出.docx
  67. ```
  68. 第 2 步 Claude 必须遵守的 8 条硬约束(inline CSS / pt 单位 / 表格 `align="center"` / `<body>` 无 padding margin / 字体白名单 等)见 [`skills/word-format/SKILL.md`](skills/word-format/SKILL.md)。
  69. ⚠️ 第 3 步运行期间(约 5~7 秒)不要动鼠标键盘,UI 自动化在跑。脚本结束会把焦点还给运行前的前台应用。
  70. ---
  71. ## 文件结构
  72. ```
  73. word-format-skill/
  74. ├── .claude-plugin/
  75. │ └── marketplace.json # Claude Code 插件商店配置
  76. ├── skills/
  77. │ └── word-format/
  78. │ ├── SKILL.md # Skill 核心指令(8 条契约 + 完整流程 + 故障排查)
  79. │ └── scripts/
  80. │ ├── docx_to_html.py # 步骤 ①:参考 docx → Filtered HTML
  81. │ ├── render_and_paste.sh # 步骤 ③:渲染 + 粘贴 + 保存(支持续写模式)
  82. │ └── verify_env.sh # 环境检查
  83. ├── README.md
  84. └── LICENSE # Apache 2.0
  85. ```
  86. ---
  87. ## 致谢
  88. 核心思路源自 linux.do 社区的这篇帖子:
  89. > [**AI 快速排版 Word 文章的一个通用思路**](https://linux.do/t/topic/1217729)
  90. >
  91. > 作者提出「让 AI 生成带 inline CSS 的 HTML → 浏览器中转 → 粘贴进 Word」的排版方案,以及一套 8 条 prompt 硬约束(inline CSS / pt 单位 / 表格 `align="center"` 等)。
  92. 本 skill 在此基础上做了两点关键调整:
  93. 1. **不让 AI 凭空写 HTML**——而是用 Word 自己导出的 Filtered HTML 作为样式模板,AI 只改文字内容、保留所有 inline style 标签。这样能避免 AI 生成 HTML 时的字体名误用、单位混用等隐性问题。
  94. 2. **支持"续写"模式**——把原 `.docx` 副本作为承载文档,新内容粘到末尾,从而 100% 继承原文档的页面设置 / 样式表 / 主题 / 页眉页脚(这些信息浏览器粘贴管线传不过去)。
  95. ---
  96. ## License
  97. Apache 2.0 — 详见 [LICENSE](./LICENSE)

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.