wps-docx-writer

wps-docx-writer is a skill for Claude Code from Bwkyd/wps-skills. It costs 69 tokens per session (2,906 once invoked), scanned A, original, MIT.

A Word document generator for creating .docx files with Python. It can add headings, text, tables, pictures, headers, and footers, and the files work with WPS Office and Microsoft Word.

In plain words
What is it for?
Use it for contracts, reports, resumes, plans, papers, letters, and form-like documents. It is for ordinary Word files, not government-format documents or plain text.
Why use it?
It removes the need to build and format Word documents by hand. It also supports repeated document creation and filling templates.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it for contracts, reports, resumes, plans, papers, letters, and form-like documents. It is for ordinary Word files, not government-format documents or plain text.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/bwkyd/wps-skills/wps-docx-writer
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Bwkyd/wps-skills --skill wps-docx-writer
Clone the repo
git clone --depth 1 https://github.com/Bwkyd/wps-skills

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for wps-docx-writer

README.md
[![agentmods](https://agentmods.dev/badge/skills/bwkyd/wps-skills/wps-docx-writer/github.svg)](https://agentmods.dev/skills/bwkyd/wps-skills/wps-docx-writer)
Your own site
<a href="https://agentmods.dev/skills/bwkyd/wps-skills/wps-docx-writer"><img src="https://agentmods.dev/badge/skills/bwkyd/wps-skills/wps-docx-writer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for wps-docx-writer

Your own site · 80×15
<a href="https://agentmods.dev/skills/bwkyd/wps-skills/wps-docx-writer"><img src="https://agentmods.dev/badge/skills/bwkyd/wps-skills/wps-docx-writer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 69 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,906 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00069 $0.02906
Opus 5 $0.00034 $0.01453
Sonnet 5 $0.00014 $0.00581
Haiku 4.5 $0.00007 $0.00291

Measured 12d ago against content hash 76536655d7f4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

wps-docx-writer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/wps-docx-writer/SKILL.md · 314 lines

How it starts

The opening of the file, as written. The whole thing — 314 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Word 文档生成器

使用 python-docx 生成各类规范的中文 .docx 文档,兼容 WPS Office 和 Microsoft Word。

When to Use

  • 用户需要生成 Word/docx 文档
  • 用户需要创建合同、报告、简历、论文、方案等
  • 用户需要批量生成文档或填充模板
  • 用户说"帮我写一份XX"且不是公文场景

When NOT to Use

  • 党政机关公文 → 使用 wps-gongwen
  • WPS宏脚本开发 → 使用 wps-jsa-macro
  • 纯文本/Markdown文档 → 直接编写

支持的文档类型

类型 典型场景 模板特征
合同/协议 劳动合同、租赁合同、保密协议、合作协议 甲乙方信息、条款编号、签章区
报告 工作报告、调研报告、分析报告、可行性报告 封面、目录、章节标题、图表
简历 中式求职简历 照片位、个人信息表、工作经历
方案/计划 项目方案、实施计划、营销方案 背景、目标、步骤、预算
论文 毕业论文、学术论文 封面、摘要、关键词、参考文献
信函 商业函件、邀请函、感谢信 抬头、正文、落款
表格文档 考勤表、登记表、审批表 多列表格、合并单元格

工作流程

Step 1: 需求确认

确认以下信息:

  • 文档类型:合同/报告/简历/方案/论文/信函/其他
  • 主要内容:核心内容描述
  • 特殊要求:页面方向、字体偏好、是否需要封面/目录等

Step 2: 内容撰写

根据文档类型撰写内容,遵循中文商务/学术写作规范。

Step 3: 生成 .docx 文件

先确保依赖已安装:

pip install python-docx 2>/dev/null || pip3 install python-docx 2>/dev/null

使用以下核心代码框架:

from docx import Document
from docx.shared import Pt, Mm, Cm, Inches, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_TABLE_ALIGNMENT
from docx.enum.section import WD_ORIENT
from docx.oxml.ns import qn, nsdecls
from docx.oxml import parse_xml
import os

class DocxWriter:
    """通用中文docx文档生成器"""

    # 预置样式
    STYLES = {
        'title':    {'font': '方正小标宋简体', 'size': 22, 'bold': True,  'align': 'CENTER'},
        'heading1': {'font': '黑体',           'size': 18, 'bold': True,  'align': 'LEFT'},
        'heading2': {'font': '黑体',           'size': 16, 'bold': True,  'align': 'LEFT'},
        'heading3': {'font': '黑体',           'size': 14, 'bold': True,  'align': 'LEFT'},
        'body':     {'font': '仿宋_GB2312',    'size': 12, 'bold': False, 'align': 'JUSTIFY'},
        'body_song':{'font': '宋体',           'size': 12, 'bold': False, 'align': 'JUSTIFY'},
        'small':    {'font': '宋体',           'size': 10.5,'bold': False, 'align': 'LEFT'},
        'footer':   {'font': '宋体',           'size': 9,  'bold': False, 'align': 'CENTER'},
    }

    def __init__(self, page='A4', orientation='portrait', margins=None):
        self.doc = Document()
        section = self.doc.sections[0]

        # 页面设置
        if orientation == 'landscape':
            section.orientation = WD_ORIENT.LANDSCAPE
            section.page_width = Mm(297)
            section.page_height = Mm(210)
        else:
            section.page_width = Mm(210)
            section.page_height = Mm(297)

        # 边距(默认普通边距)
        m = margins or {'top': 25.4, 'bottom': 25.4, 'left': 31.8, 'right': 31.8}
        section.top_margin = Mm(m['top'])
        section.bottom_margin = Mm(m['bottom'])
        section.left_margin = Mm(m['left'])
        section.right_margin = Mm(m['right'])

    def add_text(self, text, style='body', space_before=0, space_after=0,
                 first_indent=None, line_spacing=None, color=None):
        """添加格式化段落"""
        s = self.STYLES.get(style, self.STYLES['body'])
        p = self.doc.add_paragraph()
        p.alignment = getattr(WD_ALIGN_PARAGRAPH, s['align'])
        p.paragraph_format.space_before = Pt(space_before)
        p.paragraph_format.space_after = Pt(space_after)
        if line_spacing:
            p.paragraph_format.line_spacing = Pt(line_spacing)
        if first_indent is not None:
            p.paragraph_format.first_line_indent = Pt(first_indent)
        elif style == 'body' or style == 'body_song':
            p.paragraph_format.first_line_indent = Pt(s['size'] * 2)

        run = p.add_run(text)
        run.font.size = Pt(s['size'])
        run.font.name = s['font']
        run._element.rPr.rFonts.set(qn('w:eastAsia'), s['font'])
        run.bold = s['bold']
        if color:
            run.font.color.rgb = RGBColor(*color)
        return p

    def add_table(self, headers, rows, col_widths=None, style='Table Grid'):
        """添加表格"""
        table = self.doc.add_table(rows=1 + len(rows), cols=len(headers), style=style)
        table.alignment = WD_TABLE_ALIGNMENT.CENTER

        # 表头
        for i, header in enumerate(headers):
            cell = table.rows[0].cells[i]
            cell.text = header
            for paragraph in cell.paragraphs:
                paragraph.alignment = WD_ALIGN_PARAGRAPH.CENTER
                for run in paragraph.runs:
                    run.bold = True
                    run.font.size = Pt(10.5)
                    run.font.name = '黑体'
                    run._element.rPr.rFonts.set(qn('w:eastAsia'), '黑体')

        # 数据行
        for r_idx, row_data in enumerate(rows):
            for c_idx, cell_text in enumerate(row_data):
                cell = table.rows[r_idx + 1].cells[c_idx]
                cell.text = str(cell_text)
                for paragraph in cell.paragraphs:
                    paragraph.alignment = WD_ALIGN_PARAGRAPH.CENTER
                    for run in paragraph.runs:
                        run.font.size = Pt(10.5)
                        run.font.name = '宋体'
                        run._element.rPr.rFonts.set(qn('w:eastAsia'), '宋体')

        # 列宽
        if col_widths:
            for i, width in enumerate(col_widths):
                for row in table.rows:
                    row.cells[i].width = Mm(width)

        return table

    def add_page_break(self):
        """添加分页符"""
        self.doc.add_page_break()

    def add_cover(self, title, subtitle=None, org=None, date_str=None):
        """添加封面页"""
        # 上方留白
        for _ in range(6):
            self.doc.add_paragraph()

        self.add_text(title, 'title', space_after=20)
        if subtitle:
            self.add_text(subtitle, 'heading1', space_after=40)
        if org:
            self.add_text(org, 'heading2', space_after=10)
        if date_str:
            self.add_text(date_str, 'heading2')

        self.add_page_break()

    def add_toc_placeholder(self):
        """添加目录占位(需在WPS中更新域)"""
        p = self.doc.add_paragraph()
        p.alignment = WD_ALIGN_PARAGRAPH.CENTER
        run = p.add_run('目  录')
        run.font.size = Pt(22)
        run.font.name = '黑体'
        run._element.rPr.rFonts.set(qn('w:eastAsia'), '黑体')
        run.bold = True

        p2 = self.doc.add_paragraph()
        p2.alignment = WD_ALIGN_PARAGRAPH.CENTER
        run2 = p2.add_run('(请在WPS中右键此处 → 更新域 → 更新整个目录)')
        run2.font.size = Pt(10.5)
        run2.font.name = '宋体'
        run2._element.rPr.rFonts.set(qn('w:eastAsia'), '宋体')
        run2.font.color.rgb = RGBColor(0x99, 0x99, 0x99)

        self.add_page_break()

    def save(self, filename):
        """保存文档"""
        self.doc.save(filename)
        return os.path.abspath(filename)

Read the full file on GitHub · 314 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 314 lines · 69 tokens per session scan A 76536655d7f4

Subscribe to this mod's changes

wps-docx-writer is a skill published in the GitHub repository Bwkyd/wps-skills (7 stars, last pushed 4mo ago), licensed MIT. It adds 69 tokens to every session and 2,906 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

docx-template-translator

Adaptive conversion of LaTeX, PDF, or Markdown sources into a complete Word .docx that follows a user-supplied .docx template. Use when pandoc --reference-doc alone is not enough — for thesis, dissertation, report, or institutional Word formatting that needs cover pages, declarations, TOC, heading numbering, captions…

zouchenzhen/docx-template-translator-skill · 87 tokens

法律文件脱敏处理

A browser-based and Python tool for removing sensitive details from legal Word documents and restoring them later. It can replace information such as names, dates, prices, bank accounts and case numbers while preserving document formatting.

moyupeng0422/legal-doc-redactor · 128 tokens

note-organizer

Use this skill whenever the user wants to organize course materials, lecture notes, PPT/PDF/DOCX files, textbooks, personal notes, senior-student notes, historical exams, review questions, standards, manuals, or scattered study resources into a structured Markdown note library. Use it even when the user only says…

Renakoni/note-organizer · 228 tokens

exhibition-outline

A template for turning an exhibition plan into a three-page presentation outline. The pages cover the theme, its explanation and visitor story, and a detailed area-by-area display plan.

Amalia6767/curator-skills · 60 tokens

tender-analysis

A workflow for reviewing tender documents, which are formal project requests that describe requirements and bidding rules. It extracts project details, technical and business conditions, deadlines, scoring rules, risks, and questions for clarification.

Amalia6767/curator-skills · 85 tokens

docx

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when…

lingxling/awesome-skills-cn · 168 tokens