Communitygithub.com

DOCX作成・編集・分析スキル

このスキルは、Word文書(.docx)やWordテンプレート(.dotx)ファイルの作成、読み取り、編集、操作が必要なときに使用します。目次、見出し、ページ番号、レターヘッドなどの書式設定や、画像の挿入・置換、検索置換、変更履歴、コメントの操作など、あらゆるWord文書関連タスクに対応します。

DOCX作成・編集・分析スキル とは?

このスキルは、.docxファイルや.dotxファイルに関するあらゆる操作—新規作成、編集、読み取り、変更履歴の管理、コメントの追加、画像の挿入・置換、検索置換—を専門的に扱います。.docxファイルはZIPアーカイブであり、その内部のXMLを直接操作することで、複雑な書式設定(表・リスト・ページレイアウト・表紙・透かしなど)を正確に実現します。新規作成時は、プリインストールされたnpmパッケージ`docx`(docx-js)を使用してスクリプトを記述します。既存文書の編集は、`unzip`で展開後`word/document.xml`を編集し、再ZIPする方法を推奨します。読み取りには`pandoc`を利用してMarkdown形式に変換します。さらに、変更履歴の検証や、コメントの追加を補助するPythonスクリプトが用意されており、出力確認のためのPDF変換と画像レンダリングも行えます。適切なページサイズ設定(A4/US Letter)、表の列幅、箇条書き、画像の埋め込み、改ページ、目次(TOC)に関する注意点もドキュメント化されており、堅牢な文書生成を支援します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/LiChangZheng10086/doyin_ai_video/tree/HEAD/.agents/skills/docx

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

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です。US Letterの場合はpage: { size: { width: 12240, height: 15840 } }を設定します(DXA単位、1440 = 1インチ)。
  • 横向き(Landscape): 縦向きの寸法と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要素を使用します。
  • 目次(TOC): 見出しは組み込みのHeadingLevel.*を使用する必要があります。カスタムの見出しスタイルの場合、outlineLevelが設定されていないと目次に表示されません。
  • 表を水平線の代わりに使用しないでください — 代わりに段落の下線境界線を使用します。
  • ドットリーダー/同一直線上の右揃え: TextRun内でPositionalTab(alignment: PositionalTabAlignment.RIGHT, leader: PositionalTabLeader.DOT)を使用します。リテラルの.やスペースでのパディングは使用しないでください。

出力の確認

.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 をインプレース編集 — reformatやpretty-printはしない
(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)。

変更履歴(Tracked changes): 変更履歴を記録する場合、--author "<変更履歴を記録した名前>"(--originalが必要)を指定して検証します — これにより、うっかり<w:ins>/<w:del>で囲み忘れたテキスト変更を報告します。このようなミスは承認済みビューで見えなくなるため、見逃しやすいです。ランを<w:ins>/<w:del>で囲み、w:id、w:author、w:date属性を付与します。<w:del>内のテキスト要素は<w:delText>であり、<w:t>ではありません。削除された段落記号(<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で確認してください。

コメント

コメントには6つの相互参照ファイルが必要です。ヘルパースクリプトを使用します。document.xmlも編集する場合はディレクトリモード(unzip/rezipのサイクルを節約)、それ以外は.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は自動割り当てされます。次に、<w:commentRangeStart>/<w:commentRangeEnd>/<w:commentReference>のスニペットをword/document.xmlに追加して、コメントを特定のテキストにアンカーする方法が表示されます — これらのマーカーを配置するまでは、コメントは存在しますが表示されません。

依存関係

docx(npm、プリインストール — require('docx')が失敗した場合のみインストール) · pandoc · LibreOffice(soffice) · pdftoppm(Poppler)

Individual skills in this repo

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

LiChangZheng10086/doyin_ai_video

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction.

LiChangZheng10086/doyin_ai_video

Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIR...

LiChangZheng10086/doyin_ai_video

Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.

LiChangZheng10086/doyin_ai_video

Grill me about specs for the workflows I want to build, within this workspace.

LiChangZheng10086/doyin_ai_video

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

LiChangZheng10086/doyin_ai_video

智能 PPT 生成器。支持 7 种视觉风格(乐高/波普/黏土/黑白/商务/学术/科技),具备根据内容自动推荐风格、生成大纲、绘制配图并组装成片的全自动能力。

LiChangZheng10086/doyin_ai_video

Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions \"deck,\" \"slides,\" \"presentation,\" or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.

LiChangZheng10086/doyin_ai_video

Diagnose and fix React codebase health issues. Use when reviewing React code, fixing performance problems, auditing security, or improving code quality.

LiChangZheng10086/doyin_ai_video

Sentry error monitoring and performance tracing patterns for Next.js applications.

LiChangZheng10086/doyin_ai_video

Simplify and refine recently modified code for clarity and consistency. Use after writing code to improve readability without changing functionality.

LiChangZheng10086/doyin_ai_video

✅ "你知道今天所有大模型能读懂你的话,全靠一个叫Transformer的架构吗?"

LiChangZheng10086/doyin_ai_video

Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like \"the xlsx in my downloads\") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.

関連スキル