Create, read, edit, review, comment on, sanitize, render, and validate Microsoft Word DOCX documents. Use whenever a DOCX or Word document is a primary input or
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-documents-2a5cdddc37fc ,按照其中的说明把「documents」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Use python-docx for ordinary creation and editing. Use direct OOXML inspection or small targeted patches only for features that python-docx cannot represent safely. Preserve the source unless the user explicitly requests an in-place edit.
python-docx, validate the OOXML package, and render every page when LibreOffice and a PDF renderer are available.Use the bundled inspector before unfamiliar edits:
python <this-skill-directory>/scripts/inspect_docx.py input.docx
For a quick text-only read, astrbot_file_read_tool is sufficient. Text extraction does not prove layout, comments, fields, tracked changes, or images are correct.
DOCX files normally record font names rather than embedding the actual fonts. Choose common fonts and expect the opening application to substitute when a font is unavailable.
Set all relevant Word font mappings for each styled run or style:
from docx.oxml.ns import qn
run.font.name = "Noto Sans CJK SC"
fonts = run._element.get_or_add_rPr().get_or_add_rFonts()
fonts.set(qn("w:ascii"), "Noto Sans CJK SC")
fonts.set(qn("w:hAnsi"), "Noto Sans CJK SC")
fonts.set(qn("w:eastAsia"), "Noto Sans CJK SC")
Prefer the user's template fonts. For a new cross-platform Chinese document, choose a readable system CJK font, verify that it exists in the actual render environment (fc-match "Font Name" when Fontconfig is available), and inspect the rendered output. Do not claim font consistency across devices unless the required font is installed or intentionally embedded with a licensed workflow.
Read advanced-ooxml.md before changing tracked revisions, fields, content controls, protection, footnotes, endnotes, macros, digital signatures, or document relationships.
python-docx can create and read ordinary comments in current versions, but comments still require structural validation because headless renderers may omit them.Review author, last editor, creation/modification time, comments, tracked-change authors, custom properties, hidden text, document variables, external links, and embedded files before publishing sensitive documents.
Use the bundled scrubber only when the user requests metadata removal:
python <this-skill-directory>/scripts/privacy_scrub.py input.docx sanitized.docx
Scrubbing metadata is not content redaction. Search visible text, headers, footers, comments, tracked changes, fields, hyperlinks, images, and embedded objects separately when removing sensitive information.
Run structural validation after every create or edit operation:
python <this-skill-directory>/scripts/validate_docx.py output.docx
When LibreOffice and a PDF renderer are available, render the document:
python <this-skill-directory>/scripts/render_docx.py output.docx rendered
Inspect every rendered page at normal zoom. Rendering is strong evidence for layout, fonts, spacing, tables, images, headers, footers, and page breaks. It is not sufficient proof for comments, field instructions, content controls, accessibility metadata, or tracked-change structure.
If rendering is unavailable, perform structural validation and disclose that visual QA was skipped. Do not imply that the document passed a render gate.
Deliver only the requested DOCX unless the user asks for rendered pages, PDF, or other intermediates. Report the output path, representative changes, structural checks, visual QA status, and any limitation involving fonts, fields, macros, signatures, comments, revisions, or unsupported OOXML features.