Skip to content

duyunzhoudyz/dyz-gongwen-skills / skills/gongwen-format

gongwen-format

Verified

按 GB/T 9704-2012 把公文正文排成 Word,有红头、信函、纪要、命令(令)、白头、材料、简报七种版式,支持联合行文版头、附件另面、预印红头纸套打;检查、修复 docx 的页边距、字体、行距、页码;把核稿意见写成 Word 批注;无 Python 时给手动设置清单。用户说“排版”“套红头”“转成 Word”“按国标调格式”“格式乱了帮我改”“页码怎么设”时使用。只管格式不改内容:起草转对应起草 skill,压缩改写转 gongwen-polish,去 AI 味转 gongwen-humanize,去免责对冲转 gongwen-direct,核稿转 gongwen-review。

FileKindSize
README.mdmarkdown10.0 KB
SKILL.mdskill md21.1 KB
assets/gbt9704_params.jsonconfig20.0 KB
evals/evals.jsonconfig18.7 KB
evals/files/交接卡-平安建设总结-正文.txtmarkdown965 B
evals/files/信函-正文.txtmarkdown611 B
evals/files/信函-版式信息.jsonconfig166 B
evals/files/医院-单位画像.mdmarkdown805 B
evals/files/医院-院内通知-正文.txtmarkdown700 B
evals/files/卫健简报-两篇稿件.txtmarkdown1016 B
evals/files/国企-单位画像.mdmarkdown624 B
evals/files/国企-通知-正文.txtmarkdown646 B
evals/files/学校-监考安排-正文.txtmarkdown688 B
evals/files/学校-通知-正文.txtmarkdown585 B
evals/files/年终总结-正文.txtmarkdown1.2 KB
evals/files/核稿意见.jsonconfig1.4 KB
evals/files/格式混乱的情况报告.docxbinary36.3 KB
evals/files/涉密材料-正文.txtmarkdown221 B
evals/files/白头请示-正文.txtmarkdown701 B
evals/files/社区-情况报告-正文.txtmarkdown577 B
evals/files/简报-正文.txtmarkdown1.0 KB
evals/files/简报-版式信息.jsonconfig364 B
evals/files/红头通知-正文.txtmarkdown1.5 KB
evals/files/红头通知-版式信息.jsonconfig284 B
evals/files/纪要-正文.txtmarkdown910 B
evals/files/纪要-版式信息.jsonconfig119 B
evals/files/请示-缺落款-正文.txtmarkdown339 B
evals/files/高校-单位画像.mdmarkdown509 B
evals/files/高校-请示-正文.txtmarkdown603 B
evals/trigger.jsonconfig1.9 KB
manifest.jsonconfig976 B
references/_shared/README.mdmarkdown110 B
references/_shared/guardrails.mdmarkdown12.6 KB
references/_shared/profiles/roles.mdmarkdown16.1 KB
references/_shared/profiles/units/dangzheng.mdmarkdown7.9 KB
references/_shared/profiles/units/gaoxiao.mdmarkdown11.2 KB
references/_shared/profiles/units/guoqi.mdmarkdown12.7 KB
references/_shared/profiles/units/jiceng.mdmarkdown9.3 KB
references/_shared/profiles/units/shequ.mdmarkdown8.8 KB
references/_shared/profiles/units/yiyuan.mdmarkdown13.2 KB
references/_shared/profiles/units/zhongxiaoxue.mdmarkdown10.6 KB
references/_shared/rules/doc-types.mdmarkdown28.1 KB
references/_shared/rules/gbt15834.mdmarkdown13.3 KB
references/_shared/rules/gbt15835.mdmarkdown10.6 KB
references/_shared/rules/gbt9704.mdmarkdown17.2 KB
references/_shared/rules/jianfu.mdmarkdown12.5 KB
references/_shared/rules/tiaoli.mdmarkdown15.3 KB
references/_shared/style/ai-tone.mdmarkdown10.2 KB
references/_shared/style/defensive.mdmarkdown8.1 KB
references/_shared/style/output-format.mdmarkdown9.0 KB
references/check-items.mdmarkdown16.1 KB
references/layouts.mdmarkdown20.8 KB
references/manual-setup.mdmarkdown13.9 KB
references/meta-fields.mdmarkdown11.6 KB
scripts/annotate_docx.pyscript9.7 KB
scripts/build_docx.pyscript76.1 KB
scripts/check_docx.pyscript74.7 KB
scripts/extract_docx.pyscript16.2 KB
scripts/fix_docx.pyscript28.3 KB
scripts/gw_docx.pyscript50.0 KB
scripts/gw_fonts.pyscript24.2 KB
scripts/gw_format.pyscript15.9 KB
scripts/gw_layout.pyscript56.6 KB
scripts/gw_verify.pyscript6.1 KB
scripts/preview_docx.pyscript11.1 KB
scripts/secret_check.pyscript8.9 KB
# gongwen-format 国标排版

把写好的公文排成符合 GB/T 9704-2012《党政机关公文格式》的 Word 文档,也能检查、修复已经做好的 Word 文档,把核稿意见写成批注。

成熟度为 Stable(v1.0.0),详见文末“成熟度”。

## 能做什么

| 功能 | 说明 |
|---|---|
| 生成 | 纯文本或 Markdown 正文排成 docx。版式有红头文件、信函、纪要、命令(令)、白头、普通材料(总结、讲话稿等)、简报七种。正文中的简单表格转成 Word 表格(全框线、表头加粗) |
| v1.1 版式 | 命令(令,10.2):红色标志、令号、签名章位置和成文日期;附件另面编排(7.3.7):附件另起一页,第一行“附件1”三号黑体顶格,第三行居中标题,页码连续;联合行文版头与署名(7.2.4、7.3.5.1):多个机关名称并列,“文件”置于右侧上下居中,盖章时署名各占一格;预印红头纸套打:不输出红色标志和红线,按预印纸留白。上行文红头的发文字号居左空一字(7.2.5)。参数和用法见 `references/layouts.md` |
| 简报版式 | 简报无国家标准格式,以下为常见做法,各单位以往期样式为准:报头为简报名称(红色居中)、期号行(可加总期号)、编印单位与日期同一行、红色分隔线;一期可排多篇稿件,标题、正文同材料版式;报尾为分隔线加报、送、发或抄送、(共印X份),有就排、没有就不排。期号等缺的不写 |
| 检查 | 查纸张、页边距、字体字号、行距、首行缩进、层次标题字体、页码、发文字号、成文日期、纪要出席名单前空行、表格宽度等,按 P0、P1、P2 分级 |
| 修复 | 统一已有 docx 的页面、字体、行距、缩进、页码,另存新文件并给出修复报告;加 `--keep-text` 时一个字都不改(段首空格、标点、文字写法问题只在报告中列出) |
| 批注 | 把 gongwen-review 的核稿意见写成 Word 批注,定位不到的单独列出 |
| 手动清单 | 没有 Python 时,告诉你在 WPS、Word 里一步一步怎么设 |

排版只动格式,不改文字。要改内容,请先用对应的起草或改稿 skill(如 gongwen-draft、gongwen-report、gongwen-polish、gongwen-review)。这些 skill 没有安装,或你在网页版使用时,会给出交接卡、网页提示词的用法和安装命令(见 `references/_shared/style/output-format.md` 第四部分)。

## 怎么说

1. “这份通知帮我套个红头,发文字号是某发〔2026〕9号,抄送市消防救援支队。”
2. “把这篇年终总结转成 Word,按公文格式排。”
3. “领导说这个文档格式不对,你帮我改一下。”(附 docx)
4. “核稿意见出来了,帮我批注到文档里,我好对着改。”
5. “我们这儿电脑装不了 Python,你告诉我 WPS 里页码怎么设成‘— 1 —’,单页在右双页在左。”
6. “这份通知里有张统计表,排成 Word 时表格也弄规整。”
7. “把这期工作简报排成 Word,第8期,两篇稿件,报:区委办公室。”

## 输入和输出

输入:
- 正文用 .txt 或 .md,一段一行。正文后有【起草说明】的,排版时自动忽略其后内容。表格用 Markdown 管道表格(表头行、“|---|”分隔行、数据行),不支持合并单元格。
- 版式信息(可选):版式信息.json,写版式、发文机关标志、发文字号、签发人、抄送、印发机关等;简报版式写简报名称、期号、总期号、编印单位、印发日期、报、送、发、印数(正文里已写报头报尾的可不写)。字段见 `references/meta-fields.md`。不写时自动识别标题、主送机关、附件说明、署名和日期。
- 单位画像(可选):`.gongwen/单位画像.md` 中的发文机关标志、发文字号格式、红头或白头。
- 修复和批注需要已有的 .docx,批注还要核稿意见.json。批注加在由送审稿排出的 docx 上(核稿意见是对着送审稿写的),改好的终稿不加批注。

输出:
- 排版默认文件名:正文.txt 输出 `成稿.docx`,正文-××.txt 输出 `成稿-××.docx`,其他输入输出“<输入文件名>.docx”(如送审稿.txt 输出 `送审稿.docx`);修复、批注输出“原名-修复.docx”“原名-批注.docx”。同名文件存在时加 -v2、-v3,不覆盖。
- 报告写明识别结果、缺失要素(或待补事项)、文字核对、字体提示、检查结论;修复和批注另存 Markdown 报告。

命令行(在 skill 目录下运行,需要 Python 3.9+ 和 `pip install -U python-docx`,版本 1.2.0 以上):

```text
python scripts/build_docx.py 正文.txt --meta 版式信息.json -o 成稿.docx
python scripts/check_docx.py 成稿.docx --strict
python scripts/check_docx.py 成稿.docx --strict --allow DOCX-050    # 本单位制度规定文号用方括号时
python scripts/fix_docx.py 旧稿.docx
python scripts/fix_docx.py 旧稿.docx --keep-text    # 用户要求“内容别动”“一个字都别改”时:只调格式,不改文字
python scripts/build_docx.py 正文.txt --keep-text    # 同上,排版时不补冒号、不加括号、不去段首空格
python scripts/build_docx.py 正文.txt --meta 版式信息.json --layout 命令    # 命令(令)
python scripts/build_docx.py 正文.txt --meta 版式信息.json --overprint      # 预印红头纸套打
python scripts/check_docx.py 成稿.docx --overprint
python scripts/build_docx.py 正文.txt --unit-fonts "仿宋=方正仿宋_GBK,小标宋=方正小标宋_GBK"    # 本单位制度规定了字体时(build、fix、check、preview、gw_fonts 都支持)
python scripts/build_docx.py 送审稿.txt --meta 版式信息.json    # 输出 送审稿.docx,供批注用
python scripts/annotate_docx.py 送审稿.docx 核稿意见.json
python scripts/preview_docx.py 成稿.docx    # 本机装有 LibreOffice 且标准字体齐全时,转成逐页图片目检;缺字体时拒绝渲染
python scripts/gw_fonts.py    # 检查本机是否装齐标准字体,缺哪款、怎么装
```

## 注意事项

1. 字体(严格模式):不附带任何字体文件,也不提供下载。文件中一律写入仿宋_GB2312、楷体_GB2312、黑体、方正小标宋简体、宋体,打开文档的电脑上必须装有这些字体。本机缺字体时,脚本不会改用其他字体顶替,而是在报告开头明确指出缺哪些字体,说明在缺字体的电脑上看到的不是正式效果、不能据此核对版式或打印,并给出每款字体的获取途径和安装方法,请自行下载安装;缺字体时 `preview_docx.py` 拒绝渲染。随时可运行 `python scripts/gw_fonts.py` 检查。方正小标宋简体是商业字体,需要单位自行取得授权。
2. 不编造、不补内容:发文字号、成文日期、签发人、印发日期只用你提供的,缺了就不写(不补版记,不插【待补】),报告里列出“缺失要素”由你决定;确实要留位置的,明确说“缺的要素帮我留出位置”,才写【待补】占位。“内容别动”时用 `--keep-text`,脚本保存前把输入全文与文档全文双向、按顺序比对,多字、少字、乱序、重复都会中止。
3. 保密:涉密材料请勿输入联网 AI;材料带密级或“内部资料”等标注时会停止处理,有个人敏感信息等敏感信号时才提示一句。脚本本身只在本机运行,不联网。
4. 位置要打印核对:红头标志、红线、页码、版记的位置是近似实现,正式印发前打印一页量一下(清单见 `references/manual-setup.md` 第十三部分)。
5. 不做的事:不生成印章、签名章和院徽、校徽;附件另面编排只排“【附件N】标题”分界行引出的内容;简报版式是常见做法的默认样式,要与本单位往期简报一致的,核对后在 Word 中微调;表格不支持合并单元格,修复时不调整已有的正文表格;批注不写修订。
6. 单位规定与国标不同的(例如企业规定年份用方括号),按单位规定排,检查时加 `--allow DOCX-050`,相应问题降为提示并注明“按本单位制度保留”。
7. 单位规定字体:本单位制度明文规定了字体(例如正文用方正仿宋_GBK)的,用 `--unit-fonts "角色=字体名,…"` 指定(角色限仿宋、楷体、黑体、小标宋、宋体;build_docx.py 的版式信息也可写 `unit_fonts`,命令行优先)。该角色写入单位指定的字体名,严格模式不变:本机没装就同样报“字体缺失”并引导安装(向单位信息中心或办公室索取),不回退国标字体或其他字体;检查时单位字体合规、国标字体报 DOCX-016。只是没装国标字体想换个字体的,不属于单位规定,不能用该参数。

## 成熟度

Stable。v1.0 真实模型评测(Sonnet 5.5,17 条用例)中,A 组(装 skill)期望通过率 100.0%(94/94),编造 0 次,触发评测正例 10/10、反例 10/10,详见 `evals/results/v1.0-benchmark.md`。红头、信函、纪要、白头、材料、简报六种版式都有自动测试,样稿在 LibreOffice 中做过位置测量或目检;Word 和 WPS 下的红头位置、版记位置仍需打印核对。评测用例见 `evals/`。已知局限:

- 简报没有国家标准格式,简报版式是机关常见做法的默认样式(报头、多篇稿件、报尾),各单位以往期样式为准,需对照后在 Word 中微调;篇目标题按“不带句末标点的短行”识别,须核对识别结果;
- 红头标志、红线、页码、版记的位置是近似实现,正式印发前打印核对;版记、简报报尾用浮动表格固定在最后一页底部,WPS 部分版本可能不按底端定位;
- 不生成印章、签名章和院徽、校徽;命令(令)的签名章占位宽、联署印章直径、套打留白高度是实践值,不是标准原文,v1.1 新增版式须打印核对;正文表格不支持合并单元格;
- 不打包字体,方正小标宋简体等商业字体需单位自行取得授权。
canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall