doc-format
- Repo stars 342
- Author updated Live
- Author repo Word-Formatter-Pro
- Domain
- Documentation
- Compatible agents
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- Trust score
- 88 / 100 · community maintained
- Author / version / license
- @cwyalpha · no license declared
- Token usage
- Lean
- Setup complexity
- Plug-and-play
- External API key
- Not required
- Operating systems
- macOS · Linux · Windows
- Runtime requirements
- Python
- Permissions
-
- Read-only
- Write / modify
- Network behavior
- Local-only
- Install commands
- 26 variants
Profile is derived at build time from SKILL.md and install vectors. Subject to drift from author intent.
Heads up: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: doc-format
description: 使用 scripts/wfp_cli.py 将文档按公文排版规则格式化为标准 .docx。原始文件不原地修改,Word/WPS 类文档会先复制或转换到临时副本,再执行排版。 python sc…
category: documentation
runtime: Python
---
# doc-format output preview
## PART A: Task fit
- Use case: 使用 scripts/wfp_cli.py 将文档按公文排版规则格式化为标准 .docx。原始文件不原地修改,Word/WPS 类文档会先复制或转换到临时副本,再执行排版。 python scripts/wfp_cli.py format -i report.docx python scripts/wfpcli.py format -i report.docx -o reportfinal.docx runs entirely locally; runs on Python. Works with Claude Code, Cursor, Cline and 23 more..
- Inputs: target material, constraints, expected output, and acceptance criteria.
- Evidence boundary: follow “核心能力 / 使用前检查 / 常用命令” and do not present inference as author intent.
## PART B: Execution result
- **01** The card summarizes the use case; runtime output centers on “使用 scripts/wfp_cli.py 将文档按公文排版规则格式化为标准 .docx。原始文件不原地修改,Word/WPS 类文档会先复制或转换到临时副本,再执行排版。 python scripts/wfp_cli.py format -i report.docx python scripts/wfpcli.py format -i report.docx -o reportfinal.docx runs entirely locally; runs on Python. Works with Claude Code, Cursor, Cline and 23 more.”.
- **02** When the source has headings, the agent prioritizes “核心能力 / 使用前检查 / 常用命令” so the result follows the author’s structure.
- **03** Typical output includes task judgment, concrete steps, required commands or file edits, validation, and follow-up options.
- **04** Risk context follows the fingerprint: read files, write/modify files; mostly runs locally; usually needs no extra API key.
## Running Rules
- read files, write/modify files; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding scope.
- Return the result, validation criteria, and next iteration options. The source mentions slash commands such as `/applications`; use them first when your agent supports command triggers.
Name target files or source material, expected output, forbidden changes, and whether network or shell access is allowed. Permission fingerprint: read files, write/modify files.
Start with a small task and check whether the result follows “核心能力 / 使用前检查 / 常用命令”. Inspect diffs, logs, previews, or tests before expanding scope.
Confirm the final output includes a concrete result, evidence, and next action. If it stays generic, tighten inputs, boundaries, and acceptance criteria.
---
name: doc-format
description: 使用 scripts/wfp_cli.py 将文档按公文排版规则格式化为标准 .docx。原始文件不原地修改,Word/WPS 类文档会先复制或转换到临时副本,再执行排版。 python sc…
category: documentation
source: cwyalpha/Word-Formatter-Pro
---
# doc-format
## When to use
- 使用 scripts/wfp_cli.py 将文档按公文排版规则格式化为标准 .docx。原始文件不原地修改,Word/WPS 类文档会先复制或转换到临时副本,再执行排版。 python scripts/wfp_cli.py forma…
- Use it when the task has clear inputs, repeatable steps, and validation criteria.
## What to provide
- Target material, scope, expected result, and forbidden changes.
- Whether network, commands, file writes, or external services are allowed.
## Execution rules
- Organize steps around “核心能力 / 使用前检查 / 常用命令” and keep inference separate from source facts.
- read files, write/modify files; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding the task.
## Output requirements
- Return the deliverable, key evidence, validation method, and next action.
- Mark missing information as unknown; do not invent commands, platforms, or dependencies. The author source anchors workflow facts; repository files anchor sources and commands; Fluxly only adds fit, limitations, and quality judgment.
skill "doc-format" {
input -> user goal + target files + boundaries + acceptance criteria
context -> 核心能力 / 使用前检查 / 常用命令
rules -> SKILL.md triggers / order / output contract
runtime -> Python | read files, write/modify files | mostly runs locally
guardrails -> usually needs no extra API key + small-sample validation + diff/log review
output -> copyable result + checklist + next iteration
} doc-format — 公文格式排版工具
使用 scripts/wfp_cli.py 将文档按公文排版规则格式化为标准 .docx。原始文件不原地修改,Word/WPS 类文档会先复制或转换到临时副本,再执行排版。
核心能力
- 支持
.docx、.doc、.wps、.txt、.md。 - 支持单文件、多文件、重复
-i、位置参数输入,以及一个或多个目录;目录输入默认递归扫描,输出目录保留原结构。 - 自动识别题目、副标题、四级标题、二级标题段内正文、图/表标题、附件标识。
- 可选表格内容自动调整、数字和字母单独字体、符号标准化。
- TXT/MD 支持三种空行模式:不改动任何空行;删除单个空行,多个空行保留至 1 个空行;保留单个空行,多个空行保留至 1 个空行。
- TXT/MD 中手写数字编号(如
1.、1.2.3)按源文档保留,不自动递增重排。 - 支持自动读取当前目录
wfp_config.json、指定 JSON 配置文件、内联 JSON、--set key=value和便利开关覆盖配置。
使用前检查
- 确认脚本路径:脚本位于本 Skill 目录下的
scripts/wfp_cli.py。如果当前工作目录不是 Skill 目录,使用SKILL.md所在目录推导脚本绝对路径,或先cd到 Skill 目录。 - 检查输入:如果用户没有给出文件或目录,请先要求提供输入路径;告知支持
.docx/.doc/.wps/.txt/.md,目录默认递归处理。 - 检查配置:CLI 会自动读取当前工作目录的
wfp_config.json。如果用户指定--config或明确给出配置文件,使用用户指定配置;否则说明将使用当前目录配置或内置默认配置。 - 检查转换条件:Windows 处理
.doc/.wps时优先使用 WPS/Word 和 pywin32;macOS/Kylin/Linux 或 COM 不可用时,CLI 会尝试调用 LibreOfficesoffice转为.docx。如果未安装 LibreOffice,旧格式文件会记录为跳过,继续处理.docx/.txt/.md;如用户必须处理旧格式,再提示安装 LibreOffice、用--soffice指定路径,或先另存为.docx。
常用命令
# 单文件
python scripts/wfp_cli.py format -i report.docx
# 指定输出文件
python scripts/wfp_cli.py format -i report.docx -o report_final.docx
# 目录批量处理,默认递归并保留目录结构
python scripts/wfp_cli.py format -i ./documents -o ./documents_formatted
# 多文件
python scripts/wfp_cli.py format -i a.docx -i b.txt c.md -o ./formatted_output
# 目录批量处理,只处理当前目录
python scripts/wfp_cli.py format -i ./documents -o ./documents_formatted --no-recursive
# 使用自定义配置
python scripts/wfp_cli.py format -i input.docx --config ./wfp_config.json
# macOS/Kylin/Linux 或 COM 不可用时,可指定 soffice 处理 .doc/.wps 转换
python scripts/wfp_cli.py format -i old.doc --soffice /Applications/LibreOffice.app/Contents/MacOS/soffice
# 临时覆盖配置
python scripts/wfp_cli.py format -i input.docx --set body_size=12 --enable-table-formatting
# 内联 JSON 覆盖配置
python scripts/wfp_cli.py format -i input.docx --config-json "{\"force_a4\": true, \"line_spacing\": 30}"
# TXT/MD 文件转换
python scripts/wfp_cli.py format -i draft.md
# 查看默认配置
python scripts/wfp_cli.py show-config
# 保存默认配置模板
python scripts/wfp_cli.py save-config
# 显示 LibreOffice 安装提示
python scripts/wfp_cli.py install-help
# 运行内置单元测试
python scripts/wfp_cli.py test
配置处理流程
当用户要求调整字体、字号、边距、行距、表格、符号等配置时:
- 运行
show-config了解当前配置来源和值。 - 将用户自然语言需求映射到配置字段。
- 用
save-config --set ...或便利开关保存到当前目录wfp_config.json,或保存到用户指定路径。 - 再运行
format处理文档。
用户只要求一次性临时调整时,可用 --config-json 或 --set 直接运行 format。
输出行为
- 成功生成的
.docx绝对路径写入 stdout。 - 详细日志仅在使用
-v/--verbose时写入 stderr。 - 退出码
0表示没有失败;macOS/Kylin/Linux 未安装 LibreOffice 导致的.doc/.wps跳过会写入 stderr,但不会阻止其他文件处理。非0表示没有找到可处理文件或至少一个文件失败。 - 目录处理中单个文件失败不会阻止后续文件继续处理。
- 处理失败时,最终回复应说明失败文件和错误原因。
完成后必读
每次完成格式化后,都要提醒用户打开输出文件抽查题目、副标题、标题层级、附件、图/表标题、页码和表格。
如果处理过 .doc/.wps 或 Word/WPS 类文档,尤其要检查自动编号。自动编号未能确认转换成功时,编号文本、段落缩进、字体字号可能没有正常格式化;如果编号无法单独选中,说明可能仍是 Word/WPS 自动编号,必要时请将其转为手写文本编号后重新运行工具。
表格内容自动调整、符号标准化属于更容易影响版面的增强项,重要文件建议在副本上检查效果。
Reference Files
- 需要完整命令格式、参数说明、更多命令示例时,读取
references/cli-reference.md。 - 需要把用户配置需求映射到字段、查看字号对照时,读取
references/config-reference.md。 - 需要说明默认排版规则、标题识别、页面段落、TXT/MD、表格和附件规则时,读取
references/formatting-rules.md。
Agent 使用准则
- 没有输入时不要直接运行
format。 - 用户询问配置时运行
show-config,不要凭记忆列配置。 - 用户提出配置修改时,优先保存配置,再用该配置处理文档。
- 用户只要求一次性临时调整时,可用
--config-json或--set直接运行format。 - 目录输入默认递归;只有用户明确要求“只处理当前目录”时才加
--no-recursive。 - macOS/Kylin/Linux 或 COM 不可用环境下,可以处理
.doc/.wps的前提是 LibreOfficesoffice可用;LibreOffice 不可用时旧格式会跳过,不要承诺可转换自动编号。 - 处理结束后必须提示用户检查自动编号所在标题和段落的转换效果,并提醒用户如启用了表格内容自动调整、数字和字母单独字体、符号标准化,应重点抽查版面。
Decide Fit First
Design Intent
How To Use It
Boundaries And Review