Communitygithub.com

bg-szy/TOP-SKILLS

创建、阅读、编辑和操作 Word 文档 (.docx) 和 Word 模板 (.dotx) 文件。支持目录、标题、页码、页眉、图片插入、查找替换、修订、批注以及内容提取和重新组织。

TOP-SKILLS 是什么?

该技能专门用于处理 Word 文档 (.docx) 和 Word 模板 (.dotx) 文件。它涵盖了文档的创建(使用 npm 的 docx 库)、编辑(通过解压 XML 并编辑)、内容读取(使用 pandoc),以及图片插入、查找替换、修订和批注管理等高级功能。技能详细说明了处理 docx 文件时的常见陷阱,例如页面尺寸、表格宽度、列表格式和分页符的正确用法。支持从现有文档中提取和重新组织内容。它还对编辑已有文档的工作流提供了完整指导,包括处理旧版 .doc 文件、合并零散的 XML 运行节点、验证输出文档以及处理修订痕迹(接受或检查)和批注。该技能适用于 Claude Code、Cursor、Codex 等 AI 代理平台,可显著提升 Word 文档自动化处理的效率和准确性。它通过脚本和命令行工具(如 pandoc、LibreOffice、pdftoppm)实现与文档文件的交互,并强调输出验证以确保质量。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/bg-szy/TOP-SKILLS/tree/HEAD/skills/skills/docx

在你喜欢的 AI 中提问

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

文档

DOCX 的创建、编辑和分析

.docx 文件是 XML 文件的 ZIP 压缩包。根据任务选择合适的处理方式:

任务处理方式
创建新文档编写 docx (npm) 脚本 —— 请参见下文注意事项
编辑现有文档unzip → 编辑 word/document.xml → zip (docx-js 无法打开现有文件)
读取内容pandoc -t markdown file.docx

以下脚本路径均相对于此技能所在目录。

使用 docx-js 创建文档 —— 注意事项

docx 已预安装 —— 请勿先运行 npm install;直接编写脚本并使用 require('docx')。仅当 require 失败时:npm install docx。模型已了解该 API;以下是一些易错点:

  • 页面大小默认为 A4。 如需美国信纸尺寸,请设置 page: { size: { width: 12240, height: 15840 } } (DXA;1440 = 1 英寸)。
  • 横向: 传递纵向尺寸并设置 orientation: PageOrientation.LANDSCAPE —— docx-js 会在内部自动交换宽度/高度。
  • 表格需要双重宽度: 在表格上设置 columnWidths,同时在每个单元格上设置 width,两者均使用 WidthType.DXA 单位(PERCENTAGE 会在 Google Docs 中出错)。各列宽度之和必须等于表格宽度。
  • 表格阴影: 使用 ShadingType.CLEAR,切勿使用 SOLID(会导致渲染为黑色)。
  • 列表: 绝不要直接插入 • 字符;应使用带有 LevelFormat.BULLET 的 numbering 配置。
  • ImageRun 必须指定 type : ("png", "jpg", …)。
  • PageBreak 必须包含在 Paragraph 内部。
  • 绝不要使用 \n —— 应使用独立的 Paragraph 元素。
  • 目录: 标题必须使用内置的 HeadingLevel.*;自定义标题样式需要设置 outlineLevel,否则不会出现在目录中。
  • 不要使用表格作为水平线 —— 应改用段落的底部边框。
  • 点前导符 / 同一行右对齐: 使用 PositionalTab(alignment: PositionalTabAlignment.RIGHT,leader: PositionalTabLeader.DOT)包含在 TextRun 内部,不要使用文字 . 或空格填充。

验证输出

写入 .docx 文件后,渲染并查看它:

python scripts/office/soffice.py --headless --convert-to pdf output.docx
pdftoppm -jpeg -r 100 output.pdf page
ls page-*.jpg   # 然后查看这些图片

pdftoppm 会用页数的位数对页码进行补零(如 page-01.jpg … page-12.jpg)。

编辑现有文档

旧版 .doc 文件必须首先转换:python scripts/office/soffice.py --headless --convert-to docx file.doc。

unzip -q doc.docx -d unpacked/
find unpacked -type l -delete   # 删除符号链接条目 —— 来自外部的 docx 文件不可信
python scripts/merge_runs.py unpacked/   # 合并零散的运行节点,使文本可查找
# 在原地编辑 unpacked/word/document.xml —— 不要重新格式化或美化
(cd unpacked && rm -f ../out.docx && zip -Xr ../out.docx .)
python scripts/office/validate.py out.docx --original doc.docx   # XSD 检查;--auto-repair 修复常见问题
# 需要修订痕迹?添加 --author "<您做修订时使用的名称>" 来检查每次编辑是否都被追踪

Word 会将文本分割到多个 <w:r> 运行节点中(由于修订 ID、拼写检查标记等),因此您在文档中看到的短语在 XML 中通常不是一个连续的字符串。merge_runs.py 脚本可以在不改变内容或渲染的前提下,将 word/document.xml 中相邻且格式相同的运行节点合并;它也可以直接处理 .docx 文件(python scripts/merge_runs.py doc.docx -o merged.docx)。

修订痕迹: 进行修订时,使用 --author "<您做修订时使用的名称>"(需要 --original 参数)进行验证 —— 它会报告您修改了但周围没有 <w:ins>/<w:del> 标记的文本。这种情况容易意外发生,且在“接受”视图中不可见。将运行节点包裹在带有 w:id、w:author、w:date 属性的 <w:ins>/<w:del> 标签内。在 <w:del> 内部,文本元素不是 <w:t>,而是 <w:delText>。一个被删除的段落标记(<w:pPr><w:rPr><w:del w:id=".." w:author=".." w:date=".."/></w:rPr></w:pPr>)意味着“将此段落合并到下一个段落”——因此直接删除一个段落就是这样做,再加上在每个运行节点周围包裹 <w:del>。<w:del/> 必须出现在 rPr 的其他子元素之前;它们的顺序由模式强制规定。

要生成一个接受所有修订痕迹的干净副本:python scripts/accept_changes.py in.docx out.docx。

接受一个被删除的段落标记应该将该段落与它下面的段落合并,因此所有运行节点都被删除的段落就会消失。Word 会这样做;而 accept_changes.py 和 pandoc --track-changes=accept 并不总是能做到。两者同样失败 —— 它们会删掉被删除的文本,但会留下空段落,当它是自动编号的段时,就会显示为一个多余的空白项目符号:

  • pandoc --track-changes=accept 从不合并段落。
  • accept_changes.py (LibreOffice) 可以正确合并它们,除非删除的段落后面跟着一个空的间隔段落。

在任一视图中的空白项目符号都是该视图的产物,并非文档的缺陷。请在 XML 中检查段落删除。

批注

批注需要六个相互关联的文件。使用辅助脚本 —— 当您也要编辑 document.xml 时使用目录模式(可节省解压/重新压缩的周期),否则使用 .docx 直接模式:

# 针对已解压的目录(当也需要放置标记时推荐使用)
python scripts/comment.py unpacked/ "费用与支出上限太低"
python scripts/comment.py unpacked/ "同意" --parent 0

# 直接针对 .docx 文件
python scripts/comment.py contract.docx "此上限太低" -o annotated.docx

该脚本会写入 comments.xml、commentsExtended.xml、commentsIds.xml、commentsExtensible.xml、关系文件以及内容类型覆盖文件。批注 ID 会自动分配。然后它会打印要添加到 word/document.xml 的 <w:commentRangeStart>/<w:commentRangeEnd>/<w:commentReference> 代码片段,以便将批注锚定到特定文本 —— 在放置这些标记之前,批注存在但不可见。

依赖项

docx (npm,已预装 —— 仅当 require('docx') 失败时安装) · pandoc · LibreOffice (soffice) · pdftoppm (Poppler)

Individual skills in this repo

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

bg-szy/TOP-SKILLS

Brand-first landing page designer — runs a brand-identity interview (colors, typography, shape language), then generates and iterates on a polished landing page via Stitch with deployment-ready HTML. Use when the user asks to create, design, or build a landing page, homepage, or marketing page and has no established visual direction. Skip when they have a design mockup, need a dashboard or app UI, are working at component level, building a multi-page app, or restyling with known design tokens — use frontend-design instead.

bg-szy/TOP-SKILLS

Fill out Microsoft Azure Landing Zone (ALZ) Accelerator checklists by interviewing the user, mapping their Azure subscriptions, integrating IP addressing documentation, and applying Microsoft Cloud Adoption Framework best practices. Produces a completed Excel checklist (.xlsx) ready for ALZ deployment. Use this skill whenever the user mentions Azure Landing Zone, ALZ checklist, landing zone accelerator, platform landing zone configuration, ALZ bootstrap, hub-and-spoke setup, Azure network topology planning, or wants to fill out any ALZ-related checklist or configuration file. Also trigger when the user uploads an Excel file that contains tabs like "Accelerator - Bootstrap", "Accelerator - Bicep", or "Accelerator - Terraform".

bg-szy/TOP-SKILLS

Compose a premium, animated landing page section by section in Next.js + Tailwind + Motion (Framer Motion) — built on a real design system, with editorial copy and motion that feels human-crafted, not template-generated. Use when building or rebuilding a landing page, marketing site, or hero/feature/pricing/CTA sections that need to look production-ready and bespoke from day one.

bg-szy/TOP-SKILLS

Write high-converting landing page copy using proven frameworks like PAS (Problem-Agitate-Solution), AIDA, and StoryBrand. Creates headlines, value propositions, CTAs, and full page sections optimized for conversion. Use when users need landing page copy, sales page content, or marketing website text.

bg-szy/TOP-SKILLS

Optimize landing pages for conversions, performance, and SEO. Use when improving landing pages, increasing conversions, or optimizing page performance.

bg-szy/TOP-SKILLS

Review investment portfolios for risk, diversification, fees. Asset allocation recommendations, tax-loss harvesting, rebalancing.

bg-szy/TOP-SKILLS

Beads Viewer - Graph-aware triage engine for Beads projects. Computes PageRank, betweenness, critical path, and cycles. Use --robot-* flags for AI agents.

bg-szy/TOP-SKILLS

CI red? Call us. Pipeline fire brigade deploys. Use when user mentions CI failures, build errors, test failures, or pipeline issues. Do NOT load for: local builds, standard implementation work, reviews, or setup.

bg-szy/TOP-SKILLS

CASS Memory System - procedural memory for AI coding agents. Three-layer cognitive architecture with confidence decay, anti-pattern learning, cross-agent knowledge transfer, trauma guard safety system. Bun/TypeScript CLI.

bg-szy/TOP-SKILLS

Mandatory entry point: read this first for any request to make, create, edit, animate, or render a video, animation, or motion graphic, including a promo, explainer, captioned clip, title card, overlay, slideshow or interactive deck, Remotion port, or any HyperFrames HTML composition. Also use it to inspect, diagnose, validate, preview, publish, or batch-render an existing HyperFrames project. Inputs may be a website URL, GitHub PR, Figma design or URL, text or brief, existing footage, or music. It resumes project state, captures intent when applicable, selects and installs the owning workflow, and routes domain capabilities. HyperFrames is the default output framework unless the user explicitly chooses another framework for the deliverable or asks only to record a browser session.

bg-szy/TOP-SKILLS

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.

bg-szy/TOP-SKILLS

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. 落地页体验预检/广告落地页一致性检查

bg-szy/TOP-SKILLS

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.

bg-szy/TOP-SKILLS

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.

bg-szy/TOP-SKILLS

Landing page conversion optimization with layout rules, hero section design, and CTA psychology. Covers above-the-fold formula, social proof placement, mobile design, and F-pattern reading. Use for: startup landing pages, product pages, SaaS marketing, conversion optimization. Triggers: landing page, hero section, above the fold, conversion optimization, landing page design, cta button, hero image, landing page layout, saas landing page, product page design, conversion rate, landing page best practices

bg-szy/TOP-SKILLS

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.

bg-szy/TOP-SKILLS

Landing page conversion optimization with layout rules, hero section design, and CTA psychology. Covers above-the-fold formula, social proof placement, mobile design, and F-pattern reading. Use for: startup landing pages, product pages, SaaS marketing, conversion optimization. Triggers: landing page, hero section, above the fold, conversion optimization, landing page design, cta button, hero image, landing page layout, saas landing page, product page design, conversion rate, landing page best practices

bg-szy/TOP-SKILLS

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", "我的风险", "持仓风险", "风险敞口", "資產", "資產配置", "風險分析", "績效歸因", "撤單

bg-szy/TOP-SKILLS

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.

bg-szy/TOP-SKILLS

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.

相关技能