AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Docx Batch

skill-ni1o1-claude-skill-docx-batch-claude-skill-docx-batch · by ni1o1

高效的 Word 文档批量编辑工具,基于 python-docx 封装。适用于:(1) 批量格式化(字体、对齐、缩进、行距)(2) 段落/表格/图片的增删改 (3) 全局文本替换 (4) 清理自动编号。当需要快速统一文档格式、批量修改样式时使用此 skill,而非逐个操作 XML。

No reviews yet
0 installs
36 views
0.0% view→install

Install

$ agentstack add skill-ni1o1-claude-skill-docx-batch-claude-skill-docx-batch

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-ni1o1-claude-skill-docx-batch-claude-skill-docx-batch)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
7mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Docx Batch? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

DocxEditor - Word 文档批量编辑工具

使用此 skill 前,确保已安装依赖:pip install python-docx

核心概念

三轨制索引

文档由三个独立列表组成,索引互不干扰:

| 轨道 | 索引参数 | 说明 | |------|----------|------| | 段落 | index | 包含标题和正文 | | 表格 | table_index | 独立于段落 | | 图片 | image_index | 独立于段落 |

工作流程

  1. 查询 → 获取最新索引和内容
  2. 构建操作列表 → 组装 batch_update 参数
  3. 执行batch_update 自动倒序执行,无需手动计算索引漂移
  4. 保存save() 写入文件

快速开始

import sys
sys.path.insert(0, 'SKILL_DIR/scripts')  # 替换为实际路径
from docx_editor import DocxEditor

editor = DocxEditor('input.docx')
outline = editor.get_outline()
print(f"共 {outline['total']} 段落")

editor.batch_update([
    {'op': 'update_style', 'index': 0, 'font': {'name': '宋体'}, 'alignment': 'left'},
])
editor.save('output.docx')

查询接口

| 方法 | 用途 | |------|------| | get_outline() | 获取文档大纲(标题层级和索引) | | read_content(indices) | 读取指定段落详情 | | get_tables_outline() | 获取表格概览 | | read_table(table_index) | 读取表格内容 | | get_images_outline() | 获取图片概览 |

修改操作

所有修改通过 batch_update(operations) 执行,常用操作:

段落

{'op': 'delete', 'index': 50}                    # 删除(自动保护含图片的段落)
{'op': 'delete', 'index': 50, 'force': True}     # 强制删除
{'op': 'insert', 'index': 10, 'position': 'after', 'text': '新内容'}
{'op': 'update_style', 'index': 20,
 'font': {'name': '宋体', 'size': 12, 'bold': False},
 'alignment': 'left',  # left/center/right/justify
 'indent': {'first_line': 0.74, 'left': 0},  # 厘米
 'spacing': {'before': 0, 'after': 0, 'line': 1.5}}  # line 是倍数
{'op': 'replace_text', 'index': 30, 'pattern': r'^(\d)\s*', 'replacement': '', 'regex': True}
{'op': 'replace_text_global', 'pattern': '旧文本', 'replacement': '新文本'}
{'op': 'clean_xml', 'index': 15, 'remove': ['numPr']}  # 清理自动编号
{'op': 'set_text', 'index': 25, 'text': '新的段落内容'}

表格

{'op': 'update_table_cell', 'table_index': 0, 'row': 1, 'col': 2, 'text': '新内容'}
{'op': 'update_table_row', 'table_index': 0, 'row': 1, 'texts': ['列1', '列2', '列3']}
{'op': 'update_table_col', 'table_index': 0, 'col': 1, 'texts': ['行1', '行2', '行3']}

图片

{'op': 'delete_image', 'image_index': 0}
{'op': 'resize_image', 'image_index': 0, 'width': 10.0}  # 宽度cm,高度自动
{'op': 'insert_image', 'index': 10, 'path': '/path/to/img.png', 'width': 6.0}

系统

{'op': 'update_fields_on_open'}  # 让Word打开时刷新目录/页码

重要:删除操作的安全保护

Word 段落可能包含隐藏内容(图片、OLE对象),text 属性为空但实际有内容。

read_content 返回的关键字段:

| 字段 | 含义 | |------|------| | is_empty | 文本为空(可能包含图片) | | is_truly_empty | 真正为空,可安全删除 | | has_embedded | 是否包含图片/OLE等 |

安全清理空段落:

content = editor.read_content(range(100))
ops = [{'op': 'delete', 'index': p['index']} for p in content if p['is_truly_empty']]
editor.batch_update(ops)

限制

  • 不支持 tracked changes(需要请用官方 docx skill)
  • 不支持读取图片内容,只能操作尺寸或删除
  • 目录/页码需用 update_fields_on_open,让 Word 自己计算

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.