SuperAPI AI Directory

official-doc-writer

General & other

View repository

Updated 10-15 23:59

About this skill

Party and Government Organ Official Document Generation Skill

Overview

This skill is used to generate official document files that comply with the Regulations on the Handling of Official Documents of Party and Government Organs and the national standard GB/T 9704-2012 Format for Official Documents of Party and Government Organs. It supports multiple types of official documents and can export Word documents in standard format.

Quick Start

Using the Executable Script

This skill provides a complete Python script that can directly generate standard-compliant Word documents:

python scripts/generate_official_doc.py

Script location:scripts/generate_official_doc.py

Basic Usage Process

  1. Collect official document elements: Extract key information such as document type, issuing authority, principal recipient authority, title, and body text from user input
  2. Call the generation script: Usescripts/generate_official_doc.pyGenerate Word document
  3. Save the document: Save the generated document to the location specified by the user

Font Installation

Overview

According to the national standard GB/T 9704-2012 Format for Official Documents of Party and Government Organs, official document generation requires the following special fonts. This skill provides a complete font installation solution.

List of Required Fonts

Font Name Purpose File Name Required
FZXiaoBiaoSong_GBK Issuing authority mark, title FZXBSJW.TTF Yes
FangSong_GB2312 Body text, document number SIMFANG.TTF Yes
SimHei Level-1 headings, secrecy level SIMHEI.TTF Yes
KaiTi_GB2312 Level-2 headings, signatory name SIMKAI.TTF Yes
SimSun Page numbers SIMSUN.TTF Yes

Automatic Installation (Recommended)

Use the automatic installation script provided by the skill:

# 进入skill目录
cd .trae/skills/official-doc-writer

# 运行安装脚本
python scripts/install_fonts.py

Note:

  • Windows systems require running as administrator
  • macOS/Linux systems may require entering a password

Manual Installation

Windows Systems

  1. Copy from the system font directory:

    复制字体文件到:C:\Windows\Fonts
    
  2. Or install from the fonts directory:

    • Right-click the font file
    • Select "Install for all users"

macOS Systems

  1. Copy the font files:

    复制字体文件到:~/Library/Fonts
    
  2. Verify installation:

    • Open the "Font Book" app
    • Check whether the fonts are installed

Linux Systems

  1. Create a font directory:

    mkdir -p ~/.fonts
    
  2. Copy the font files:

    cp fonts/*.ttf ~/.fonts/
    
  3. Update the font cache:

    fc-cache -fv
    

Font Download

If the system lacks the required fonts, they can be obtained from the following channels:

Method 1: Copy from the Windows system font directory (recommended)

Windows 10/11 systems already include all required fonts (except FZXiaoBiaoSong):

C:\Windows\Fonts

Copy the following files to the skill's fonts directory:

  • SIMFANG.TTF(FangSong_GB2312)
  • SIMHEI.TTF(SimHei)
  • SIMKAI.TTF(KaiTi_GB2312)
  • SIMSUN.TTF(SimSun)

Method 2: Download from official channels

FZXiaoBiaoSong_GBK:

Windows system fonts:

  • Microsoft official website download page
  • Or copy from the Windows system font directory

Method 3: Use open-source font alternatives

  • Source Han Serif(alternative to SimSun)
  • Source Han Sans(alternative to SimHei)

Verify font installation

Running the font installation script will automatically check the fonts already installed on the system and display the check results.

Detailed instructions

For complete font download and installation instructions, please refer to:

  • Font download instructions:fonts/README.md
  • Font installation script:scripts/install_fonts.py

Conversational interaction mode

Overview

This skill supportsintelligent conversational interaction mode, collecting official document elements through step-by-step guidance, providing a more user-friendly experience.

List of conversational elements

Core elements (interaction required)

Element Interaction method Example dialogue
Document type Selection-based dialogue "What type of official document do you need to generate?\n1. Notice\n2. Report\n3. Request for instructions\n4. Letter\n..."
Issuing authority Open-ended dialogue "Please tell me the full name of the issuing authority (e.g., XXX Company)"
Principal recipient Open-ended dialogue "Please tell me the principal recipient (receiving organization)"
Document title Guided dialogue "Please briefly describe the subject matter of the document, and I will help you generate a standardized title"
Date of issuance Confirmation-based dialogue "Is the date of issuance today (March 13, 2026)?"
Body content Multi-line input "Please describe the main content points of the official document"

Optional elements (intelligent interaction)

Element Trigger condition Interaction method
Document number User needs Open-ended dialogue
Security classification User mentions confidentiality Selection-based dialogue
Urgency level User mentions urgency Selection-based dialogue
Signatory Upward document (request for instructions, report) Open-ended dialogue
Attachment User mentions attachment Confirmation-based dialogue
Copy recipient User mentions copy Open-ended dialogue
Issuing organization Default value confirmation Confirmation-based dialogue
Issuance date Default value confirmation Confirmation-based dialogue

Intelligent prompt system

Opening phrase suggestions

Automatically recommend appropriate opening phrases based on the type of official document:

  • Notice: For..., it is hereby... as follows:
  • Report: The ... is hereby reported as follows:
  • Request for instructions: Request for instructions concerning...
  • Letter: Letter concerning...

Closing phrase suggestions

Automatically recommend appropriate closing phrases based on the type of official document:

  • Notice: This is hereby notified.
  • Report: This is hereby reported.
  • Request for instructions: Whether appropriate or not, please issue instructions.
  • Letter: Please consider and reply by letter.

Technical implementation

Dialogue manager

Usescripts/dialog_manager.pyManage dialogue state:

from scripts.dialog_manager import create_dialog_manager

# 创建对话管理器
dialog = create_dialog_manager()

# 获取下一个提示
prompt = dialog.get_next_prompt()

# 处理用户输入
dialog.process_user_input(user_input)

# 获取公文内容
content = dialog.get_document_content()

Intelligent suggestion system

Usescripts/smart_prompts.pyGet intelligent suggestions:

from scripts.smart_prompts import create_smart_prompt_system

# 创建智能提示系统
prompts = create_smart_prompt_system()

# 获取开头语建议
opening_prompts = prompts.get_opening_prompt("通知")

# 获取结尾语建议
ending_prompts = prompts.get_ending_prompt("通知")

# 获取结构建议
structure_hints = prompts.get_structure_hint("通知")

Advantages of dialogue mode

  1. User-friendly: Step-by-step guidance lowers the threshold for use
  2. Intelligent suggestions: Provide professional official document language suggestions
  3. Highly flexible: Supports modification and adjustment at any time
  4. Quality assurance: Ensure all necessary elements are complete
  5. Learning value: Help users understand official document standards

Usage examples

Example 1: Generate a notice

AI: 您好!我将帮您生成一份公文。请问您需要生成什么类型的公文?
    1. 通知
    2. 报告
    3. 请示
    4. 函
    ...

用户: 通知

AI: 好的,生成通知。请告诉我发文机关的全称:
用户: XXX公司

AI: 收到。请问主送机关(接收单位)是?
用户: 各部门

AI: 请简要描述通知的事由,我将帮您生成规范标题:
用户: 开展2026年度安全检查工作

AI: 我为您生成的标题是:"关于开展2026年度安全检查工作的通知",是否满意?
用户: 满意

AI: 请提供发文字号(格式:机关代字〔年份〕序号号):
用户: 沈数据〔2026〕1号

AI: 成文日期是今天(2026年3月13日)吗?
用户: 是的

AI: 这份公文需要标注密级吗?
用户: 不需要

AI: 这份公文的紧急程度是?
用户: 不需要

AI: 请描述通知的主要内容要点:
用户: 检查时间、检查范围、检查要求

AI: 这份公文有附件吗?
用户: 没有

AI: 是否需要抄送给其他单位?
用户: 需要抄送给沈阳市应急管理局

AI: 印发机关是发文机关办公室吗?
用户: 是的

AI: 印发日期与成文日期相同吗?
用户: 是的

AI: 现在生成公文预览,请确认...
[预览内容]

AI: 请确认公文内容是否正确?
用户: 确认无误,生成文档

AI: 公文已生成完成!

Technical implementation

Dialogue manager

Usescripts/dialog_manager.pyManage dialogue state:

from scripts.dialog_manager import create_dialog_manager

# 创建对话管理器
dialog = create_dialog_manager()

# 获取下一个提示
prompt = dialog.get_next_prompt()

# 处理用户输入
dialog.process_user_input(user_input)

# 获取公文内容
content = dialog.get_document_content()

Intelligent suggestion system

Usescripts/smart_prompts.pyGet intelligent suggestions:

from scripts.smart_prompts import create_smart_prompt_system

# 创建智能提示系统
prompts = create_smart_prompt_system()

# 获取开头语建议
opening_prompts = prompts.get_opening_prompt("通知")

# 获取结尾语建议
ending_prompts = prompts.get_ending_prompt("通知")

# 获取结构建议
structure_hints = prompts.get_structure_hint("通知")

Advantages of dialogue mode

  1. User-friendly: Step-by-step guidance lowers the threshold for use
  2. Intelligent suggestions: Provide professional official document language suggestions
  3. Highly flexible: Supports modification and adjustment at any time
  4. Quality assurance: Ensure all necessary elements are complete
  5. Learning value: Help users understand official document standards

Supported official document types

Type Applicable scenarios Document type characteristics Closing phrase
Notice Issuing and communicating matters that subordinate agencies are required to execute and that relevant units should be informed of or execute Directive, informational This is hereby notified.
Communiqué Commending the advanced, criticizing mistakes, conveying important spirit, and informing of important situations Typical, educational This is hereby communicated.
Report Reporting work to a higher-level agency, reflecting situations, and replying to inquiries from a higher-level agency Declarative, reporting This is hereby reported.
Request for instructions Requesting instructions and approval from a higher-level agency Requesting, expecting reply Whether appropriate or not, please issue instructions.
Letter Negotiating work, inquiring and replying to questions, requesting approval, and replying to approval matters between agencies not subordinate to each other Negotiating, flexible Please study and reply by letter.
Minutes Record the main circumstances of a meeting and the matters decided Documentary, summary in nature -
Decision Make decisions and arrangements on important matters, reward and punish relevant units and personnel, and alter or revoke inappropriate decisions of subordinate bodies Decision-making, authoritative -
Opinion Put forward views and handling measures on important issues Guiding, advisory -
Reply Reply to matters requested for instructions by subordinate organs Targeted, responsive -
Order (command) Promulgate administrative regulations and rules, announce the implementation of major compulsory measures, approve the conferral and promotion of ranks, and commend relevant units and personnel Compulsory, solemn -

Official document format specification (GB/T 9704-2012)

I. Paper and layout requirements

1.1 Paper specifications

  • Paper type: A4 paper
  • Finished format size: 210mm × 297mm

1.2 Margins and type area

Parameter Size
Head margin (top white margin) 37mm ± 1mm
Binding edge (left white margin) 28mm ± 1mm
Type area size 156mm × 225mm

1.3 Font and font size specifications

Element Font Font size Color
Issuing organ mark Small standard Song typeface - Red
Title Small standard Song typeface Size 2 Black
Main text Imitation Song typeface Size 3 Black
Level-1 heading Heiti Size 3 Black
Level-2 heading Kaiti Size 3 Black
Level-3/Level-4 heading Imitation Song typeface Size 3 Black
Document number Imitation Song typeface Size 3 Black
Signatory Imitation Song typeface (label) / Kaiti (name) Size 3 Black
Security classification/Urgency level Heiti Size 3 Black
Copy recipient organ Imitation Song typeface Size 4 Black
Printing and issuing organ/date Imitation Song typeface Size 4 Black
Page number Song typeface Size 4 half-width Black

1.4 Number of lines and number of characters

  • Lines per page: 22 lines
  • Characters per line: 28 characters
  • Fill the type area: Yes

II. Rules for arranging official document elements

2.1 Header (the part above the red separator line on the first page of an official document)

Issuing Agency Mark

  • Content: Full name or standardized abbreviation of the issuing agency + the word "Document"
  • Position: Centered, with the top edge 35mm from the top edge of the type area
  • Font: Red Xiaobiaosong typeface

Document Number

  • Format:〔年份〕序号号
  • Position: Two lines below the issuing agency mark, centered
  • Rule: Year in hexagonal brackets〔〕, serial number without padding zeros

Header Separator Line

  • Position: 4mm below the document number
  • Specification: Red, same width as the type area

2.2 Body (from below the red separator line to before the record section)

Title

  • Font: No. 2 Xiaobiaosong typeface
  • Position: Two lines below the red separator line, centered
  • Format: Issuing agency name + subject matter + document type
  • Line-wrapping rule: Complete word meaning, arranged in a trapezoid or diamond shape

Principal Recipient

  • Position: One line below the title, flush left
  • Format: Full-width colon after the agency name

Main Text

  • Font: No. 3 FangSong typeface
  • Position: The line below the principal recipient name
  • Indentation: Each natural paragraph indented two characters on the left, with wrapped lines flush left
  • Structural hierarchy numbering:
    • First level:一、(Hei typeface)
    • Second level:(一)(Kai typeface)
    • Third level:1.(FangSong typeface)
    • Fourth level:(1)(FangSong typeface)

Attachment Note

  • Position: One line below the main text, indented two characters on the left
  • Format:附件:附件名称
  • When there are multiple attachments, use Arabic numerals to indicate the sequence number

Issuing Agency Signature

  • Position: Above the date of issuance, centered
  • When jointly issued, arranged in the order of the issuing agencies

Date of Issuance

  • Format: Arabic numerals, with year, month, and day fully indicated
  • Position: Centered
  • Rule: Month and day without padding zeros (1 is not written as 01)

2.3 Record Section (the part below the separator line on the last page of an official document)

Separator Lines

  • First and last lines: Thick line (0.35mm)
  • Middle: Thin line (0.25mm)
  • Width: Same width as the type area

Copy Recipient

  • Font: No. 4 FangSong typeface
  • Position: The line above the printing agency and printing date
  • Format:抄送:机关名称。

Printing Agency and Printing Date

  • Font: No. 4 FangSong typeface
  • Position: Above the last separator line
  • Format: Printing agency indented one character on the left, printing date indented one character on the right

Workflow

Step 1: Requirements Collection

Extract the following information from user input:

  1. Document Type: Notice/Report/Request for Instructions/Letter/Circular/Minutes, etc.
  2. Issuing Agency: Full name of the organization
  3. Principal Recipient: Receiving organization
  4. Document Number: e.g., "Shen Data [2026] No. 1"
  5. Title: Official document title
  6. Body content: Key points of the core content
  7. Date of issuance: e.g., "March 13, 2026"
  8. Attachments: Whether there are attachments (optional)
  9. Copy recipients: Copy recipient units (optional)

Step 2: Generate the document

Usescripts/generate_official_doc.pyscript to generate a Word document:

from scripts.generate_official_doc import create_official_document

content = {
    'issuer': '发文机关名称',
    'doc_number': '发文字号',
    'title': '公文标题',
    'recipient': '主送机关',
    'body': ['正文段落1', '正文段落2'],
    'signer': '发文机关署名',
    'date': '成文日期',
    'attachment': '附件说明(可选)',
    'copy_to': '抄送机关(可选)'
}

doc = create_official_document('公文类型', content)
doc.save('输出文件路径.docx')

Step 3: Format verification

Check the following elements:

  • Title format is correct
  • Document number format is standardized
  • Body hierarchy is clear
  • Language expression is accurate
  • Elements are complete and comprehensive

Official document language standards

Common opening phrases

  • Notice:为……,现……如下:、根据……,决定……
  • Report:现将……报告如下:、关于……情况报告如下:
  • Request for instructions:关于……的请示、现就……请示如下:
  • Letter:关于……的函、现就……函告如下:

Common closing phrases

  • Notice:特此通知。、请认真贯彻执行。
  • Report:特此报告。、以上报告,请审阅。
  • Request for instructions:妥否,请批示。、以上请示,请予批复。
  • Letter:请予研究函复。、特此函告。

Structural hierarchy ordinal numbers

  • First level:一、、二、、三、
  • Second level:(一)、(二)、(三)
  • Third level:1.、2.、3.
  • Fourth level:(1)、(2)、(3)

Number usage standards

  • Date of issuance: Use Arabic numerals, e.g.,2024年1月15日
  • Document number sequence: Do not pad with zeros, e.g.,1号rather than01号
  • Statistical data: Use Arabic numerals
  • Approximate numbers: Use Chinese characters, e.g.,三五天、七八十人

Usage examples

Example 1: Generate a report-type official document

User input:

请帮我生成一份关于XXX公司情况的报告
公文类型:报告
发文机关:XXX公司
主送机关:XX市人民政府国有资产监督管理委员会、XX投资集团
发文字号:XX〔2026〕1号
成文日期:2026年3月13日
抄送机关:XX市数字经济发展局、XX区人民政府
附件:XXX公司核心成果及重点项目清单
正文:[正文内容...]

Processing steps:

  1. Extract official document elements
  2. Callscripts/generate_official_doc.py
  3. Generate a Word document and save it

Example 2: Generate a notice-type official document

User input:

帮我写一个通知,发文机关是XX公司,主送机关是各部门,内容是关于开展安全检查的通知

Processing steps:

  1. Identify the official document type as "Notice"
  2. Extract the issuing authority, principal recipient, and subject matter
  3. Generate a standardized official document title: "Notice on Conducting Safety Inspections"
  4. Write body text that conforms to official document language standards
  5. Call the script to generate a Word document

Notes

  1. Element completeness: Ensure that all required elements of the official document are complete and not omitted
  2. Format standardization: Strictly format according to the GB/T 9704-2012 standard
  3. Language accuracy: Use standardized official document language and avoid colloquial expressions
  4. Clarity of hierarchy: The body structure should be well-organized and logically clear
  5. Content authenticity: The content of the official document must be truthful, accurate, and complete
  6. Timeliness: Pay attention to the timeliness of official documents, and handle and reply promptly

Reference documents

National standard documents

This skill includes the complete GB/T 9704-2012 national standard document, located in thereferences/directory:

📖 GB/T 9704-2012 Format for Official Documents of Party and Government Organs

This is the authoritative standard for official document formatting, including:

  • Paper and layout requirements
  • Rules for arranging official document elements
  • Font and font size standards
  • Line count and character count requirements
  • Printing and binding requirements
  • Specific official document formats (letters, orders, minutes, etc.)
  • Complete sample illustrations

How to use the reference documents

When generating official documents, you should proactively consult national standard documents to ensure format accuracy:

  1. When the format is uncertain: Use the Read tool to readreferences/GBT_9704-2012_党政机关公文格式.md
  2. Special format requirements: Consult the "Specific Formats of Official Documents" chapter in the standard
  3. Element arrangement rules: Consult the "Arrangement Rules for Each Element of Official Document Format" chapter in the standard
  4. Font and font size specifications: Consult the "Fonts and Font Sizes" chapter in the standard

Example invocation method:

当需要确认公文格式的具体要求时,请查阅:
- 版心尺寸:查阅标准第5.2.1节
- 字体字号:查阅标准第5.2.2节
- 发文机关标志:查阅标准第7.2.4节
- 标题编排:查阅标准第7.3.1节
- 正文格式:查阅标准第7.3.3节

Other reference standards

  • "Regulations on the Handling of Official Documents by Party and Government Organs" (Zhong Ban Fa [2012] No. 14)
  • GB/T 15834 "Usage of Punctuation Marks"
  • GB/T 15835 "Usage of Numbers in Publications"