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', supports multiple official document types, 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 Workflow
- Collect official document elements: Extract key information such as document type, issuing organ, principal recipient organ, title, and body text from user input
- Call the generation script: Use
scripts/generate_official_doc.pyto generate a Word document - 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 organ mark, title | FZXBSJW.TTF | Yes |
| FangSong_GB2312 | Body text, document number | SIMFANG.TTF | Yes |
| SimHei | Level-1 headings, classification 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
-
Copy from the system font directory:
复制字体文件到:C:\Windows\Fonts -
or install from the fonts directory:
- Right-click the font file
- Select "Install for all users"
macOS Systems
-
Copy the font files:
复制字体文件到:~/Library/Fonts -
Verify installation:
- Open the "Font Book" app
- Check whether the fonts are installed
Linux Systems
-
Create a font directory:
mkdir -p ~/.fonts -
Copy the font files:
cp fonts/*.ttf ~/.fonts/ -
Update the font cache:
fc-cache -fv
Font Download
If the system lacks the required fonts, they can be obtained from the following sources:
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(Heiti)SIMKAI.TTF(Kaiti_GB2312)SIMSUN.TTF(Songti)
Method 2: Download from official channels
FangZheng XiaoBiaoSong_GBK:
- Official website:http://www.foundertype.com/
- Note: Commercial license required
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(replaces Songti)
- Source Han Sans(replaces Heiti)
Verify font installation
Running the font installation script will automatically check the fonts 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, which collects official document elements through step-by-step guidance, providing a more friendly user experience.
Conversational element list
Core elements (interaction required)
| Element | Interaction method | Example dialogue |
|---|---|---|
| Document type | Selection 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)" |
| Main recipient authority | Open-ended dialogue | "Please tell me the main recipient authority (receiving unit)" |
| Document title | Guided dialogue | "Please briefly describe the subject of the official document, and I will help you generate a standard title" |
| Date of issuance | Confirmation 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 it | Open-ended dialogue |
| Security classification | User mentions confidentiality | Selection dialogue |
| Urgency level | User mentions urgency | Selection dialogue |
| Signatory | Upward document (request for instructions, report) | Open-ended dialogue |
| Attachment | User mentions attachment | Confirmation dialogue |
| Copy recipient authority | User mentions copying | Open-ended dialogue |
| Issuing authority | Default value confirmation | Confirmation dialogue |
| Date of issue | Default value confirmation | Confirmation dialogue |
Intelligent prompt system
Opening phrase suggestions
Automatically recommend appropriate opening phrases based on the document type:
- Notice: To..., the following is hereby...:
- Report: The following ... is hereby reported:
- Request for Instructions: Request for instructions regarding...
- Letter: Letter regarding...
Closing phrase suggestions
Automatically recommend appropriate closing phrases based on the document type:
- Notice: This is hereby notified.
- Report: This is hereby reported.
- Request for Instructions: Whether this is appropriate, please instruct.
- Letter: Please study and reply by letter.
Technical implementation
Dialogue manager
Usagescripts/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
Usagescripts/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 the dialogue mode
- User-friendly: Step-by-step guidance lowers the usage threshold
- Intelligent suggestions: Provides professional official document language suggestions
- High flexibility: Supports modification and adjustment at any time
- Quality assurance: Ensures all necessary elements are complete
- Learning value: Helps 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
Usagescripts/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
Usagescripts/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 the dialogue mode
- User-friendly: Step-by-step guidance lowers the usage threshold
- Intelligent suggestions: Provides professional official document language suggestions
- High flexibility: Supports modification and adjustment at any time
- Quality assurance: Ensures all necessary elements are complete
- Learning value: Helps users understand official document standards
Supported official document types
| Type | Applicable scenario | Document characteristics | Closing phrase |
|---|---|---|---|
| Notice | Issuing and conveying matters that lower-level agencies are required to execute and that relevant units must be informed of or execute | Directive, informative | This is hereby notified. |
| Circular | Commending advanced deeds, criticizing mistakes, conveying important directives, and informing of important situations | Exemplary, educational | This is hereby circulated. |
| 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, awaiting reply | Whether this is appropriate, please instruct. |
| Letter | Consulting on work, inquiring and replying to questions, requesting approval, and replying to approval matters between agencies with no subordinate relationship | Consultative, flexible | Please study and reply by letter. |
| Minutes | Record the main circumstances of a meeting and the matters agreed upon | Record-based, summary in nature | - |
| Decision | Make decisions and arrangements on important matters, reward or punish the relevant units and personnel, and alter or rescind inappropriate decisions of subordinate bodies | Decision-making, authoritative | - |
| Opinion | Put forward views and handling methods on important issues | Guiding, advisory | - |
| Reply | Reply to matters requested by a subordinate body | Targeted, responsive | - |
| Order (Decree) | Promulgate administrative regulations and rules, announce the implementation of major compulsory measures, approve the conferral and promotion of ranks, and commend the relevant units and personnel | Compulsory, solemn | - |
Official Document Format Specification (GB/T 9704-2012)
I. Paper and Layout Requirements
1.1 Paper Specification
- Paper type: A4 paper
- Finished trim size: 210mm × 297mm
1.2 Margins and Type Area
| Parameter | Dimension |
|---|---|
| Head margin (top white edge) | 37mm ± 1mm |
| Binding edge (left white edge) | 28mm ± 1mm |
| Type area size | 156mm × 225mm |
1.3 Font and Type Size Specification
| Element | Font | Type size | Color |
|---|---|---|---|
| Issuing authority logo | Small standard Song typeface | - | Red |
| Title | Small standard Song typeface | Size 2 | Black |
| Main text | Imitation Song typeface | Size 3 | Black |
| Level-1 heading | Hei typeface | Size 3 | Black |
| Level-2 heading | Kai typeface | 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) / Kai typeface (name) | Size 3 | Black |
| Security classification/Urgency level | Hei typeface | Size 3 | Black |
| Copy recipient | Imitation Song typeface | Size 4 | Black |
| Issuing authority/Date | Imitation Song typeface | Size 4 | Black |
| Page number | Song typeface | Size 4 half-width | Black |
1.4 Number of Lines and 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 Authority Mark
- Content: full name or standardized abbreviation of the issuing authority + the word "Document"
- Position: centered, with the top edge 35mm from the top edge of the type area
- Font: red small standard Song typeface
Document Number
- Format:
〔年份〕序号号 - Position: two blank lines below the issuing authority mark, centered
- Rule: the year is enclosed in hexagonal brackets
〔〕, and the sequence number is not padded with leading zeros
Header Separator Line
- Position: 4mm below the document number
- Specification: red, the same width as the type area
2.2 Body (from below the red separator line to before the record section)
Title
- Font: No. 2 small standard Song typeface
- Position: two blank lines below the red separator line, centered
- Format: issuing authority name + subject matter + document type
- Line-wrapping rule: complete word meaning, arranged in a trapezoid or diamond shape
Principal Recipient
- Position: one blank line below the title, flush left
- Format: a full-width colon after the authority name
Main Text
- Font: No. 3 FangSong typeface
- Position: the line below the principal recipient name
- Indentation: each natural paragraph is indented two characters from the left, with wrapped lines flush left
- Structural level ordinals:
- First level:
一、(Hei typeface) - Second level:
(一)(Kai typeface) - Third level:
1.(FangSong typeface) - Fourth level:
(1)(FangSong typeface)
- First level:
Attachment Note
- Position: one blank line below the main text, indented two characters from the left
- Format:
附件:附件名称 - When there are multiple attachments, use Arabic numerals to mark the sequence numbers
Issuing Authority Signature
- Position: above the date of issuance, centered
- For joint documents, arrange in the order of the issuing authorities
Date of Issuance
- Format: Arabic numerals, with year, month, and day written in full
- Position: centered
- Rule: month and day are not padded with leading 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 lines (0.35mm)
- Middle: thin lines (0.25mm)
- Width: the same width as the type area
Copy Recipient
- Font: No. 4 FangSong typeface
- Position: the line above the issuing office and date of issuance
- Format:
抄送:机关名称。
Issuing Office and Date of Issuance
- Font: No. 4 FangSong typeface
- Position: above the last separator line
- Format: the issuing office is indented one character from the left, and the date of issuance is indented one character from the right
Workflow
Step 1: Requirements Collection
Extract the following information from the user input:
- Document Type: notice/report/request for instructions/letter/circular/minutes, etc.
- Issuing Authority: full name of the organization
- Principal Recipient: receiving organization
- Document Number: e.g., "Shen Data [2026] No. 1"
- Title: official document title
- Body content: Key points of the core content
- Date of issuance: e.g. "March 13, 2026"
- Attachments: Whether there are attachments (optional)
- 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 validation
Check the following elements:
- Title format is correct
- Document reference number format is compliant
- 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 ordinals
- 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 reference number serial number: do not pad with placeholder digits, 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:
- Extract official document elements
- Call
scripts/generate_official_doc.py - Generate a Word document and save it
Example 2: Generate a notice-type official document
User input:
帮我写一个通知,发文机关是XX公司,主送机关是各部门,内容是关于开展安全检查的通知
Processing steps:
- Identify the official document type as "notice"
- Extract the issuing authority, main recipient authority, and subject matter
- Generate a standardized official document title: "Notice on Conducting Safety Inspections"
- Write the body text in compliance with official document language standards
- Call the script to generate a Word document
Precautions
- Element completeness: Ensure all required elements of the official document are present and none are omitted
- Format compliance: Strictly follow the GB/T 9704-2012 standard for layout
- Language accuracy: Use standard official document language and avoid colloquial expressions
- Hierarchical clarity: The body structure should be well-organized with clear logic
- Content authenticity: The content of the official document must be truthful, accurate, and complete
- 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 formats for official documents (letters, orders, minutes, etc.)
- Complete sample illustrations
How to use the reference documents
When generating official documents, national standard documents should be proactively consulted to ensure format accuracy:
- When the format is uncertain: Use the Read tool to read
references/GBT_9704-2012_党政机关公文格式.md - Special format requirements: Consult the "Specific Formats of Official Documents" chapter in the standard
- Element arrangement rules: Consult the "Arrangement Rules for Each Element of Official Document Format" chapter in the standard
- 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" (Zhongbanfa [2012] No. 14)
- GB/T 15834 "Usage of Punctuation Marks"
- GB/T 15835 "Usage of Numerals in Publications"