Communitygithub.com

文档创建、编辑与分析

全面的文档创建、编辑与分析工具,支持修订、评论、格式保留和文本提取。适用于处理专业 .docx 文件的各种任务。

文档创建、编辑与分析 是什么?

此技能为 AI 代理提供了处理 Word 文档 (.docx) 的完整工作流,包括创建新文档、编辑现有文档及分析内容。它支持修订、评论、格式保留及文本提取等高级功能。对于文本提取,推荐使用 pandoc 转换文档;对于深入分析,则需处理底层 XML。创建新文档依赖 docx-js 库,编辑现有文档则使用 Document 库。特别地,技能强调“修订工作流”,要求以批量方式(每批 3-10 个更改)实现精确的最小化修订,避免修改未变化的文本。此外,还支持将文档转换为图像进行视觉验证。该技能适用于 Claude Code、Cursor 等支持 CLI 和环境自定义的命令行 AI 代理平台。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/aiskillstore/marketplace/tree/HEAD/skills/docx

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

DOCX 创建、编辑与分析

概述

用户可能会要求你创建、编辑或分析 .docx 文件的内容。.docx 文件本质上是一个 ZIP 存档,包含 XML 文件和其他资源,你可以读取或编辑这些资源。你拥有针对不同任务的不同工具和工作流。

工作流决策树

读取/分析内容

使用下面的“文本提取”或“原始 XML 访问”部分

创建新文档

使用“创建新的 Word 文档”工作流

编辑现有文档

  • 你自己的文档 + 简单的更改 使用“基础 OOXML 编辑”工作流

  • 他人的文档 使用**“修订工作流”**(推荐默认)

  • 法律、学术、商业或政府文档 使用**“修订工作流”**(必需)

读取和分析内容

文本提取

如果你只需要读取文档的文本内容,应使用 pandoc 将文档转换为 Markdown。Pandoc 在保留文档结构方面表现出色,并且可以显示修订:

# 将文档转换为 Markdown,保留修订
pandoc --track-changes=all path-to-file.docx -o output.md
# 选项:--track-changes=accept/reject/all

原始 XML 访问

对于评论、复杂格式、文档结构、嵌入媒体和元数据,你需要原始 XML 访问权限。对于这些功能,你需要解压文档并读取其原始 XML 内容。

解压文件

python ooxml/scripts/unpack.py <office_file> <output_directory>

关键文件结构

  • word/document.xml - 主要文档内容
  • word/comments.xml - document.xml 中引用的评论
  • word/media/ - 嵌入的图像和媒体文件
  • 修订使用 <w:ins>(插入)和 <w:del>(删除)标签

创建新的 Word 文档

从头开始创建新的 Word 文档时,请使用 docx-js,它允许你使用 JavaScript/TypeScript 创建 Word 文档。

工作流

  1. 必须 - 读取整个文件:从头到尾完整阅读 docx-js.md(约 500 行)。阅读此文件时,切勿设置任何范围限制。 在创建文档之前,阅读完整文件内容以了解详细语法、关键格式规则和最佳实践。
  2. 使用 Document、Paragraph、TextRun 组件创建 JavaScript/TypeScript 文件(你可以假设所有依赖项都已安装,但如果没有,请参考下面的依赖项部分)
  3. 使用 Packer.toBuffer() 导出为 .docx

编辑现有的 Word 文档

编辑现有的 Word 文档时,请使用 Document Library(一个用于 OOXML 操作的 Python 库)。该库会自动处理基础设施设置,并提供文档操作方法。对于复杂场景,你可以通过该库直接访问底层 DOM。

工作流

  1. 必须 - 读取整个文件:从头到尾完整阅读 ooxml.md(约 600 行)。阅读此文件时,切勿设置任何范围限制。 阅读完整文件内容以了解 Document 库 API 和用于直接编辑文档文件的 XML 模式。
  2. 解压文档:python ooxml/scripts/unpack.py <office_file> <output_directory>
  3. 使用 Document 库创建并运行 Python 脚本(有关详细信息,请参阅 ooxml.md 中的“Document 库”部分)
  4. 打包最终文档:python ooxml/scripts/pack.py <input_directory> <office_file>

Document 库既提供用于常见操作的高级方法,也提供用于复杂场景的直接 DOM 访问。

用于文档审阅的修订工作流

此工作流允许你在实施ожений之前,使用 Markdown 规划全面的修订。关键:对于完整的修订,你必须系统地实施所有更改。

分批策略:将相关更改分组为批次,每批 3-10 个更改。这使调试易于管理,同时保持效率。在进入下一批次之前测试每个批次。

原则:最小化、精确的编辑 实施修订时,只标记实际更改的文本。重复未更改的文本会使编辑难以审阅,并且显得不专业。将替换分解为:[未更改文本] + [删除] + [插入] + [未更改文本]。通过提取原始 <w:r> 元素并重用它,保留未更改文本的原始运行 RSID。

示例 - 将句子中的“30 天”更改为“60 天”:

# 错误 - 替换了整个句子
'<w:del><w:r><w:delText>期限为 30 天。</w:delText></w:r></w:del><w:ins><w:r><w:t>期限为 60 天。</w:t></w:r></w:ins>'

# 正确 - 仅标记更改的内容,保留未更改文本的原始 <w:r>
'<w:r w:rsidR="00AB12CD"><w:t>期限为 </w:t></w:r><w:del><w:r><w:delText>30</w:delText></w:r></w:del><w:ins><w:r><w:t>60</w:t></w:r></w:ins><w:r w:rsidR="00AB12CD"><w:t> 天。</w:t></w:r>'

修订工作流

  1. 获取 Markdown 表示:将文档转换为 Markdown,并保留修订:

    pandoc --track-changes=all path-to-file.docx -o current.md
    
  2. 识别并分组更改:审阅文档,识别所有必要的更改,并将它们组织成逻辑批次:

    定位方法(用于在 XML 中查找更改):

    • 章节/标题编号(例如,“第 3.2 节”、“第四条款”)
    • 如果已编号,则为段落标识符
    • 使用唯一周围文本的 Grep 模式
    • 文档结构(例如,“第一段”、“签名栏”)
    • 请勿使用 Markdown 行号 - 它们不映射到 XML 结构

    批次组织(每批分组 3-10 个相关更改):

    • 按章节:“批次 1:第 2 节修订案”、“批次 2:第 5 节更新”
    • 按类型:“批次 1:日期更正”、“批次 2:当事人姓名更改”
    • 按复杂性:从简单的文本替换开始,然后处理复杂的结构更改
    • 按顺序:“批次 1:第 1-3 页”、“批次 2:第 4-6 页”
  3. 阅读文档并解压:

    • 必须 - 读取整个文件:从头到尾完整阅读 ooxml.md(约 600 行)。阅读此文件时,切勿设置任何范围限制。 特别注意“Document 库”和“修订模式”部分。
    • 解压文档:python ooxml/scripts/unpack.py <file.docx> <dir>
    • 记下建议的 RSID:解压脚本将建议一个用于修订的 RSID。复制此 RSID 以在步骤 4b 中使用。
  4. 分批实施更改:按逻辑分组更改(按章节、按类型或按邻近性),并在单个脚本中共同实施。此方法:

    • 使调试更容易(较小的批次 = 更容易隔离错误)
    • 允许渐进式进步
    • 保持效率(每批 3-10 个更改效果很好)

    建议的批次分组:

    • 按文档章节(例如,“第 3 节更改”、“定义”、“终止条款”)
    • 按更改类型(例如,“日期更改”、“当事人姓名更新”、“法律术语替换”)
    • 按邻近性(例如,“第 1-3 页的更改”、“文档前半部分的更改”)

    对于每批相关更改:

    a. 将文本映射到 XML:在 word/document.xml 中 grep 文本以验证文本如何跨 <w:r> 元素拆分。

    b. 创建并运行脚本:使用 get_node 查找节点,实施更改,然后 doc.save()。有关模式,请参见 ooxml.md 中的**“Document 库”**部分。

    注意:在编写脚本之前,始终立即 grep word/document.xml 以获得当前行号并验证文本内容。每次脚本运行后行号都会更改。

  5. 打包文档:所有批次完成后,将解压目录转换回 .docx:

    python ooxml/scripts/pack.py unpacked reviewed-document.docx
    
  6. 最终验证:对完整文档进行综合检查:

    • 将最终文档转换为 Markdown:
      pandoc --track-changes=all reviewed-document.docx -o verification.md
      
    • 验证所有更改均已正确应用:
      grep "原始短语" verification.md  # 不应找到它
      grep "替换短语" verification.md  # 应找到它
      
    • 检查是否引入了意外更改

将文档转换为图像

要以可视方式分析 Word 文档,请使用两步过程将它们转换为图像:

  1. 将 DOCX 转换为 PDF:

    soffice --headless --convert-to pdf document.docx
    
  2. 将 PDF 页面转换为 JPEG 图像:

    pdftoppm -jpeg -r 150 document.pdf page
    

    这将创建文件,如 page-1.jpg、page-2.jpg 等。

选项:

  • -r 150:将分辨率设置为 150 DPI(根据需要调整质量/大小平衡)
  • -jpeg:输出 JPEG 格式(如果需要,使用 -png 输出 PNG)
  • -f N:要转换的第一页(例如,-f 2 从第 2 页开始)
  • -l N:要转换的最后一页(例如,-l 5 在第 5 页停止)
  • page:输出文件的前缀

特定范围示例:

pdftoppm -jpeg -r 150 -f 2 -l 5 document.pdf page  # 仅转换第 2-5 页

代码风格指南

重要:生成 DOCX 操作代码时:

  • 编写简洁的代码
  • 避免冗长的变量名称和冗余操作
  • 避免不必要的 print 语句

依赖项

必需的依赖项(如果不可用,请安装):

  • pandoc:sudo apt-get install pandoc(用于文本提取)
  • docx:npm install -g docx(用于创建新文档)
  • LibreOffice:sudo apt-get install libreoffice(用于 PDF 转换)
  • Poppler:sudo apt-get install poppler-utils(用于 pdftoppm 将 PDF 转换为图像)
  • defusedxml:pip install defusedxml(用于安全的 XML 解析)

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

aiskillstore/marketplace

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

aiskillstore/marketplace

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

aiskillstore/marketplace

Use when the user asks to "pre-launch check the landing page", "run a Quality-Score preflight", or "verify ad-to-page message match before launch"; produces an ad↔page continuity report — message-match gaps, above-the-fold check, page-speed read, form-friction count, mobile-render flags — as a pass/fix punch list. Not for redesigning or rewriting the page — use landing-optimizer; not for scoring the account or the RQS — use ad-account-auditor. 落地页体验预检/广告落地页一致性检查

aiskillstore/marketplace

Use when the user asks to "optimize our landing page for influencer traffic", "fix our promo-code landing page", or "improve conversion from a creator campaign"; produces a message-match audit, page-structure and social-proof recommendations, a promo-code/CTA conversion plan, and an A/B test roadmap. Not for measuring campaign results after launch — use performance-analyzer.

aiskillstore/marketplace

Audit a landing page, sales page or checkout page for conversion leaks and return a fix list ordered by expected revenue impact. Use when asked to review, critique or improve a landing page, sales page, opt-in page, product page or checkout flow, when conversion rate is low, when paid traffic is not converting, or when someone asks "why isn't this page converting" or wants a CRO / landing page review.

aiskillstore/marketplace

This skill helps users extract GitHub repository project details and contributor contact information using keywords, stars, and update dates. Agent should proactively apply this skill when users express needs like search for GitHub projects by keywords, find top open-source contributors in specific domains, extract developer contacts from GitHub repositories, discover trending repositories with high stars, gather contributor profiles and social links for tech recruiting, retrieve GitHub project descriptions and metrics, build developer communities by finding active contributors, search for repositories updated recently, collect personal website and Twitter links of developers, generate targeted leads for developer tools, or track active open-source contributors for collaboration.

aiskillstore/marketplace

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.

aiskillstore/marketplace

Using the Wonda CLI to generate images, videos, music, and audio from the terminal — plus LinkedIn, Reddit, and X/Twitter research and automation

aiskillstore/marketplace

Generates creative domain name ideas for your project and checks availability across multiple TLDs (.com, .io, .dev, .ai, etc.). Saves hours of brainstorming and manual checking.

aiskillstore/marketplace

Process video files with audio extraction, format conversion (mp4, webm), and Whisper transcription. Use when user mentions video conversion, audio extraction, transcription, mp4, webm, ffmpeg, or whisper transcription.

aiskillstore/marketplace

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output should be a bitmap asset rather than repo-native code or vector. Do not use when the task is better handled by editing existing SVG/vector/code-native assets, extending an established icon or logo system, or building the visual directly in HTML/CSS/canvas.

aiskillstore/marketplace

A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).

aiskillstore/marketplace

Router skill for LLMQuant portfolio workflows. Use when the user needs company profiles, thesis tracking, theme research, watchlist monitoring, or alert management.

aiskillstore/marketplace

Account assets, equity and fund positions, P&L, cash flow records, account statements, margin ratios, buy-power estimates, order management, and DCA recurring investments via Longbridge (most require Trade permission). Frameworks: portfolio diagnosis, rebalancing, asset allocation, risk analysis (VaR/CVaR), performance attribution, and tax-loss harvesting. Triggers: "持仓", "账户", "盈亏", "资产", "对账单", "下单", "买入", "卖出", "撤单", "定投", "组合诊断", "再平衡", "资产配置", "风险分析", "绩效归因", "税损收割", "持倉", "賬戶", "盈虧", "對賬單", "下單", "買入", "賣出", "組合診斷", "再平衡", "稅損收割", "positions", "portfolio", "P&L", "order", "buy", "sell", "DCA", "statement", "risk analysis", "rebalancing", "tax harvesting", "我的风险", "持仓风险", "风险敞口", "資產", "資產配置", "風險分析", "績效歸因", "撤單

aiskillstore/marketplace

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

aiskillstore/marketplace

Use for Codex models/pricing, scheduled tasks, skills, settings, setup, troubleshooting, customization, automations, and self-knowledge—including 'you,' 'your,' 'this app,' or 'this coding agent' when they refer to Codex—and for OpenAI APIs/products and ChatGPT Work. Also use for model choice/migration, prompting, SDKs, Responses, Realtime, agents, evals, and Chat/Work/Codex comparisons. Do not use for generic app/software tasks that merely mention Codex.

aiskillstore/marketplace

Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.

aiskillstore/marketplace

Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks

aiskillstore/marketplace

Perform a read-only, defect-first review of a specified code change and return every actionable finding. Use when another agent delegates review of uncommitted changes, a base-branch diff, a commit, or custom review instructions.

aiskillstore/marketplace

Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities.

相关技能