Official Document Format Conversion: One-Click Formatting of Multi-Format Manuscripts into Standard DOCX within Agent

Introduction

For government agencies, enterprises, and institutions, the layout of daily documents often takes more time than the content itself: centering titles and subtitles, distinguishing heading levels with “一、” (1), “(一)” (2), “1.” (3), “(1)” (4), unifying body font (FangSong), line spacing, and margins, and handling attachments and figure/table captions separately. Manually adjusting these item by item in Word or WPS is repetitive labor, especially for batches of files.

Below is an introduction to the SkillHub community Skill “公文格式转换” (Official Document Format Conversion, coordinate @user_60300dde/doc-format). After installation, the Agent calls the local script wfp_cli.py according to the Skill manual to format existing doc/docx/wps/txt/md files based on official document layout conventions. It outputs standard .docx files without overwriting the original files. Unlike “asking the model to directly rewrite a Word document,” this approach uses rule recognition and OOXML layout, making it suitable for scenarios where existing drafts need unified formatting.

What is this

“公文格式转换” is a community Skill designed for office efficiency (Category office-efficiency, current version 1.0.5, publisher user_60300dde). The tag indicates requires_api_key=false, meaning no additional API Key is required.

In one sentence: It automatically formats doc / docx / wps / txt / md files according to official document layout conventions and outputs standard docx; it supports heading level recognition, titles and subtitles, attachments, figure/table captions, page margins, page numbers, line spacing, fonts and sizes, TXT/MD blank line strategies, custom configuration, and batch directory processing.

SkillHub Page: https://www.skillhub.cn/skills/user_60300dde/doc-format
Installation Instructions: https://skillhub.cn/install/skillhub.md
API Coordinate Page: https://api.skillhub.cn/user_60300dde/doc-format

Core Features

The following capabilities are derived from the SKILL.md and reference documents within the Skill package, version 1.0.5.

Input and Output

  • Supports .docx, .doc, .wps, .txt, .md.
  • Supports single files, multiple files (via repeating -i or positional arguments), and directory input; directories are scanned recursively by default, and the output preserves the relative directory structure.
  • Original files are not modified in place; Word/WPS documents are copied or converted to temporary copies before formatting.

Structure and Layout Recognition

  • Automatically recognizes titles, subtitles, four levels of heading hierarchy (一、 / (一) / 1. / (1)), body text within secondary heading segments, figure/table captions, and attachment identifiers.
  • Default rules for margins, line spacing, page numbers (aligned to odd/even pages), fonts, and sizes are defined in the package’s references/formatting-rules.md (e.g., default body font FangSong_GB2312 16pt, line spacing 28pt, etc.).

Enhancements (Optional)

  • Automatic table content adjustment, separate English fonts for numbers and letters, and symbol standardization. These are disabled by default and can be enabled via configuration or CLI switches.
  • TXT/MD supports three blank line modes; handwritten numbering is preserved as-is from the source document and is not automatically incremented or rearranged.

Configuration

  • Automatically reads wfp_config.json from the current working directory, or uses --config, --config-json, --set key=value, and convenience switches for temporary overrides.
  • show-config / save-config can be used to view and export configuration templates.

Installation and Activation

1. Install SkillHub CLI (if not already installed)

command -v skillhub && skillhub --version

If not installed, run (CLI only):

curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash -s -- --cli-only

2. Install the Skill to the current Agent’s skills directory

During installation, you must use --dir to point to the skills directory actually recognized by the Agent; otherwise, the default installation to ./skills/ might not be loaded. Common paths (from SkillHub installation docs):

  • Cursor: ~/.cursor/skills/
  • Claude Code: ~/.claude/skills/
  • Codex: ~/.codex/skills/ or .agents/skills/ in the project

Installation command (recommended method from search results):

skillhub install doc-format --namespace user_60300dde --dir ~/.cursor/skills

Equivalent coordinate: @user_60300dde/doc-format. You can also send the official page prompt to the Agent and ask it to install the Skill according to https://skillhub.cn/install/skillhub.md.

3. Python Dependencies

The requirements.txt in the Skill directory lists:

python-docx
tkinterdnd2
pywin32; platform_system == "Windows"

Install dependencies in the Skill’s root directory before running scripts/wfp_cli.py. On Windows, pywin32 and local Word/WPS COM can be used to handle .doc/.wps files.

After installing or enabling the Skill, you generally need to restart or reload the Agent to read the new SKILL.md.

Typical Usage

The script is located at scripts/wfp_cli.py in the Skill directory. If the current working directory is not the Skill root, you should first cd to the directory containing SKILL.md or call it using the absolute path.

Single File and Specified Output

python scripts/wfp_cli.py format -i report.docx
python scripts/wfp_cli.py format -i report.docx -o report_final.docx

If no -o is specified for a single file, it defaults to generating *_formatted.docx in the same directory; on success, stdout prints the absolute path of the output file.

Directory Batch Processing

python scripts/wfp_cli.py format -i ./documents -o ./documents_formatted
python scripts/wfp_cli.py format -i ./documents -o ./documents_formatted --no-recursive

TXT / MD and Blank Line Modes

python scripts/wfp_cli.py format -i draft.md
python scripts/wfp_cli.py format -i draft.md --blank-line-mode "不改动任何空行"

Custom Configuration

python scripts/wfp_cli.py show-config
python scripts/wfp_cli.py save-config --set body_font=宋体 --set body_size=12
python scripts/wfp_cli.py format -i input.docx --config ./wfp_config.json
python scripts/wfp_cli.py format -i input.docx --set body_size=12 --enable-table-formatting

Handing over to the Agent in Conversation

Users can directly state their needs, e.g., “Format /path/to/请示稿.docx according to official document format, body font size Xiao Si, line spacing 30pt, and output to the same directory.” The Agent should confirm the input path according to Skill guidelines, use save-config if necessary, then run format, and prompt for a spot check of the layout upon completion.

Applicable Scenarios and Notes

Who it is for

  • Administrative staff, secretaries, project assistants: Those who have existing Word/WPS/plain text/Markdown drafts and need to unify them into printable docx files.
  • Those who need to batch process multiple materials in the same directory while preserving the subdirectory structure.
  • Those who want fonts, line spacing, margins, etc., to be configurable and reusable (wfp_config.json) rather than describing them verbally every time.

Limitations and Pitfalls

  • Legacy Format Conversion: On Windows, .doc/.wps prefers WPS/Word COM; on macOS/Linux or when COM is unavailable, it relies on LibreOffice soffice. If it fails, you need to install LibreOffice, specify the path with --soffice, or save as .docx first. Use python scripts/wfp_cli.py install-help to view installation tips.
  • Automatic Numbering: When not on Windows or when COM is unavailable, automatic numbering conversion to text will be skipped. If numbering cannot be selected individually, it may still be Word auto-numbering, requiring conversion to handwritten numbering before rerunning. Always spot-check heading levels, attachments, page numbers, and tables after completion.
  • Enhancements: Automatic table adjustment, English fonts, and symbol standardization may alter the layout. It is recommended to test important files on a copy first.
  • Compliance Statement: The Skill describes “Official Document Layout Habits” and configurable rules. Whether it meets the mandatory requirements of your unit or GB/T 9704-2012 still requires manual final inspection.

Conclusion

“公文格式转换” consolidates multi-format input, hierarchy recognition, layout parameters, and batch directory processing into a reusable Agent Skill. It is suitable for transforming “formatting” from a vague description in conversation into a repeatable CLI workflow. For installation or documentation, please refer to the official SkillHub page: https://www.skillhub.cn/skills/user_60300dde/doc-format

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye