跳到主要内容

minimax-docx 标准

Professional DOCX document creation, editing, and formatting using OpenXML SDK (.NET). Three pipelines: (A) create new documents from scratch, (B) fill/edit content in existing documents, (C) apply template formatting with XSD validation gate-check. MUST use this skill whenever the user wants to produce, modify, or format a Word document — including when they say "write a report", "draft a proposal", "make a contract", "fill in this form", "reformat to match this template", or any task whose final output is a .docx file. Even if the user doesn't mention "docx" explicitly, if the task implies a printable/formal document, use this skill.

在 GitHub 打开

安装方式

cp -r skills/minimax-docx ~/.claude/skills/minimax-docx

把该 skill 目录放进客户端 skills 目录。不同客户端的目录可能不同,Claude Code 默认是 ~/.claude/skills/

整仓一次性获取:git clone --depth 1 https://github.com/pengfeiqiao/kunpeng.git

依赖与权限

  • 无需 API Key
  • 无需联网
  • 依赖外部命令:make convert
  • 以上为按正文与 frontmatter 自动推断的信号,仅供参考;安装前建议先阅读原文。
触发场景
Worddocxdocument文档Word文档报告合同公文

SKILL.md 正文

来源 pengfeiqiao/kunpeng@bf8a8ac · 许可 MIT · 内容未修改

minimax-docx

Create, edit, and format DOCX documents via CLI tools or direct C# scripts built on OpenXML SDK (.NET).

Setup

First time: bash scripts/setup.sh (or powershell scripts/setup.ps1 on Windows, --minimal to skip optional deps).

First operation in session: scripts/env_check.sh — do not proceed if NOT READY. (Skip on subsequent operations within the same session.)

Quick Start: Direct C# Path

When the task requires structural document manipulation (custom styles, complex tables, multi-section layouts, headers/footers, TOC, images), write C# directly instead of wrestling with CLI limitations. Use this scaffold:

// File: scripts/dotnet/task.csx  (or a new .cs in a Console project)
// dotnet run --project scripts/dotnet/MiniMaxAIDocx.Cli -- run-script task.csx
#r "nuget: DocumentFormat.OpenXml, 3.2.0"

using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;

using var doc = WordprocessingDocument.Create("output.docx", WordprocessingDocumentType.Document);
var mainPart = doc.AddMainDocumentPart();
mainPart.Document = new Document(new Body());

// --- Your logic here ---
// Read the relevant Samples/*.cs file FIRST for tested patterns.
// See Samples/ table in References section below.

**Before writing any C#, read the relevant Samples/.cs file* — they contain compilable, SDK-version-verified patterns. The Samples table in the References section below maps topics to files.

CLI shorthand

All CLI commands below use $CLI as shorthand for:

dotnet run --project scripts/dotnet/MiniMaxAIDocx.Cli --

Pipeline routing

Route by checking: does the user have an input .docx file?

User task
├─ No input file → Pipeline A: CREATE
│   signals: "write", "create", "draft", "generate", "new", "make a report/proposal/memo"
│   → Read references/scenario_a_create.md
│
└─ Has input .docx
    ├─ Replace/fill/modify content → Pipeline B: FILL-EDIT
    │   signals: "fill in", "replace", "update", "change text", "add section", "edit"
    │   → Read references/scenario_b_edit_content.md
    │
    └─ Reformat/apply style/template → Pipeline C: FORMAT-APPLY
        signals: "reformat", "apply template", "restyle", "match this format", "套模板", "排版"
        ├─ Template is pure style (no content) → C-1: OVERLAY (apply styles to source)
        └─ Template has structure (cover/TOC/example sections) → C-2: BASE-REPLACE
            (use template as base, replace example content with user content)
        → Read references/scenario_c_apply_template.md

If the request spans multiple pipelines, run them sequentially (e.g., Create then Format-Apply).

Pre-processing

Convert .doc → .docx if needed: scripts/doc_to_docx.sh input.doc output_dir/

Preview before editing (avoids reading raw XML): scripts/docx_preview.sh document.docx

Analyze structure for editing scenarios: $CLI analyze --input document.docx

Scenario A: Create

Read references/scenario_a_create.md, references/typography_guide.md, and references/design_principles.md first. Pick an aesthetic recipe from Samples/AestheticRecipeSamples.cs that matches the document type — do not invent formatting values. For CJK, also read references/cjk_typography.md.

Choose your path:

  • Simple (plain text, minimal formatting): use CLI — $CLI create --type report --output out.docx --config content.json
  • Structural (custom styles, multi-section, TOC, images, complex tables): write C# directly. Read the relevant Samples/*.cs first.

CLI options: --type (report|letter|memo|academic), --title, --author, --page-size (letter|a4|legal|a3), --margins (standard|narrow|wide), --header, --footer, --page-numbers, --toc, --content-json.

Then run the validation pipeline (below).

Scenario B: Edit / Fill

Read references/scenario_b_edit_content.md first. Preview → analyze → edit → validate.

Choose your path:

  • Simple (text replacement, placeholder fill): use CLI subcommands.
  • Structural (add/reorganize sections, modify styles, manipulate tables, insert images): write C# directly. Read references/openxml_element_order.md and the relevant Samples/*.cs.

Available CLI edit subcommands:

  • replace-text --find "X" --replace "Y"
  • fill-placeholders --data '{"key":"value"}'
  • fill-table --data table.json
  • insert-section, remove-section, update-header-footer
$CLI edit replace-text --input in.docx --output out.docx --find "OLD" --replace "NEW"
$CLI edit fill-placeholders --input in.docx --output out.docx --data '{"name":"John"}'

Then run the validation pipeline. Also run diff to verify minimal changes:

$CLI diff --before in.docx --after out.docx

Scenario C: Apply Template

Read references/scenario_c_apply_template.md first. Preview and analyze both source and template.

$CLI apply-template --input source.docx --template template.docx --output out.docx

For complex template operations (multi-template merge, per-section headers/footers, style merging), write C# directly — see Critical Rules below for required patterns.

Run the validation pipeline, then the hard gate-check:

$CLI validate --input out.docx --gate-check assets/xsd/business-rules.xsd

Gate-check is a hard requirement. Do NOT deliver until it passes. If it fails: diagnose, fix, re-run.

Also diff to verify content preservation: $CLI diff --before source.docx --after out.docx

Validation pipeline

Run after every write operation. For Scenario C the full pipeline is mandatory; for A/B it is recommended (skip only if the operation was trivially simple).

$CLI merge-runs --input doc.docx                                    # 1. consolidate runs
$CLI validate --input doc.docx --xsd assets/xsd/wml-subset.xsd     # 2. XSD structure
$CLI validate --input doc.docx --business                           # 3. business rules

If XSD fails, auto-repair and retry:

$CLI fix-order --input doc.docx
$CLI validate --input doc.docx --xsd assets/xsd/wml-subset.xsd

If XSD still fails, fall back to business rules + preview:

$CLI validate --input doc.docx --business
scripts/docx_preview.sh doc.docx
# Verify: font contamination=0, table count correct, drawing count correct, sectPr count correct

Final preview: scripts/docx_preview.sh doc.docx

Critical rules

These prevent file corruption — OpenXML is strict about element ordering.

Element order (properties always first):

ParentOrder
w:ppPr → runs
w:rrPr → t/br/tab
w:tbltblPr → tblGrid → tr
w:trtrPr → tc
w:tctcPr → p (min 1 <w:p/>)
w:bodyblock content → sectPr (LAST child)

Direct format contamination: When copying content from a source document, inline rPr (fonts, color) and pPr (borders, shading, spacing) override template styles. Always strip direct formatting — keep only pStyle reference and t text. Clean tables too (including pPr/rPr inside cells).

Track changes: <w:del> uses <w:delText>, never <w:t>. <w:ins> uses <w:t>, never <w:delText>.

Font size: w:sz = points × 2 (12pt → sz="24"). Margins/spacing in DXA (1 inch = 1440, 1cm ≈ 567).

Heading styles MUST have OutlineLevel: When defining heading styles (Heading1, ThesisH1, etc.), always include new OutlineLevel { Val = N } in StyleParagraphProperties (H1→0, H2→1, H3→2). Without this, Word sees them as plain styled text — TOC and navigation pane won't work.

Multi-template merge: When given multiple template files (font, heading, breaks), read references/scenario_c_apply_template.md section "Multi-Template Merge" FIRST. Key rules:

  • Merge styles from all templates into one styles.xml. Structure (sections/breaks) comes from the breaks template.
  • Each content paragraph must appear exactly ONCE — never duplicate when inserting section breaks.
  • NEVER insert empty/blank paragraphs as padding or section separators. Output paragraph count must equal input. Use section break properties (w:sectPr inside w:pPr) and style spacing (w:spacing before/after) for visual separation.
  • Insert oddPage section breaks before EVERY chapter heading, not just the first. Even if a chapter has dual-column content, it MUST start with oddPage; use a second continuous break after the heading for column switching.
  • Dual-column chapters need THREE section breaks: (1) oddPage in preceding para's pPr, (2) continuous+cols=2 in the chapter HEADING's pPr, (3) continuous+cols=1 in the last body para's pPr to revert.
  • Copy titlePg settings from the breaks template for EACH section. Abstract and TOC sections typically need titlePg=true.

Multi-section headers/footers: Templates with 10+ sections (e.g., Chinese thesis) have DIFFERENT headers/footers per section (Roman vs Arabic page numbers, different header text per zone). Rules:

  • Use C-2 Base-Replace: copy the TEMPLATE as output base, then replace body content. This preserves all sections, headers, footers, and titlePg settings automatically.
  • NEVER recreate headers/footers from scratch — copy template header/footer XML byte-for-byte.
  • NEVER add formatting (borders, alignment, font size) not present in the template header XML.
  • Non-cover sections MUST have header/footer XML files (at least empty header + page number footer).
  • See references/scenario_c_apply_template.md section "Multi-Section Header/Footer Transfer".

References

Load as needed — don't load all at once. Pick the most relevant files for the task.

The C# samples and design references below are the project's knowledge base ("encyclopedia"). When writing OpenXML code, ALWAYS read the relevant sample file first — it contains compilable, SDK-version-verified patterns that prevent common errors. When making aesthetic decisions, read the design principles and recipe files — they encode tested, harmonious parameter sets from authoritative sources (IEEE, ACM, APA, Nature, etc.), not guesses.

Scenario guides (read first for each pipeline)

FileWhen
references/scenario_a_create.mdPipeline A: creating from scratch
references/scenario_b_edit_content.mdPipeline B: editing existing content
references/scenario_c_apply_template.mdPipeline C: applying template formatting

C# code samples (compilable, heavily commented — read when writing code)

FileTopic
Samples/DocumentCreationSamples.csDocument lifecycle: create, open, save, streams, doc defaults, settings, properties, page setup, multi-section
Samples/StyleSystemSamples.csStyles: Normal/Heading chain, character/table/list styles, DocDefaults, latentStyles, CJK 公文, APA 7th, import, resolve inheritance
Samples/CharacterFormattingSamples.csRunProperties: fonts, size, bold/italic, all underlines, color, highlight, strike, sub/super, caps, spacing, shading, border, emphasis marks
Samples/ParagraphFormattingSamples.csParagraphProperties: justification, indentation, line/paragraph spacing, keep/widow, outline level, borders, tabs, numbering, bidi, frame
Samples/TableSamples.csTables: borders, grid, cell props, margins, row height, header repeat, merge (H+V), nested, floating, three-line 三线表, zebra striping
Samples/HeaderFooterSamples.csHeaders/footers: page numbers, "Page X of Y", first/even/odd, logo image, table layout, 公文 "-X-", per-section
Samples/ImageSamples.csImages: inline, floating, text wrapping, border, alt text, in header/table, replace, SVG fallback, dimension calc
Samples/ListAndNumberingSamples.csNumbering: bullets, multi-level decimal, custom symbols, outline→headings, legal, Chinese 一/(一)/1./(1), restart/continue
Samples/FieldAndTocSamples.csFields: TOC, SimpleField vs complex field, DATE/PAGE/REF/SEQ/MERGEFIELD/IF/STYLEREF, TOC styles
Samples/FootnoteAndCommentSamples.csFootnotes, endnotes, comments (4-file system), bookmarks, hyperlinks (internal + external)
Samples/TrackChangesSamples.csRevisions: insertions (w:t), deletions (w:delText!), formatting changes, accept/reject all, move tracking
Samples/AestheticRecipeSamples.cs13 aesthetic recipes from authoritative sources: ModernCorporate, AcademicThesis, ExecutiveBrief, ChineseGovernment (GB/T 9704), MinimalModern, IEEE Conference, ACM sigconf, APA 7th, MLA 9th, Chicago/Turabian, Springer LNCS, Nature, HBR — each with exact values from official style guides

Note: Samples/ path is relative to scripts/dotnet/MiniMaxAIDocx.Core/.

Markdown references (read when you need specifications or design rules)

FileWhen
references/openxml_element_order.mdXML element ordering rules (prevents corruption)
references/openxml_units.mdUnit conversion: DXA, EMU, half-points, eighth-points
references/openxml_encyclopedia_part1.mdDetailed C# encyclopedia: document creation, styles, character & paragraph formatting
references/openxml_encyclopedia_part2.mdDetailed C# encyclopedia: page setup, tables, headers/footers, sections, doc properties
references/openxml_encyclopedia_part3.mdDetailed C# encyclopedia: TOC, footnotes, fields, track changes, comments, images, math, numbering, protection
references/typography_guide.mdFont pairing, sizes, spacing, page layout, table design, color schemes
references/cjk_typography.mdCJK fonts, 字号 sizes, RunFonts mapping, GB/T 9704 公文 standard
references/cjk_university_template_guide.mdChinese university thesis templates: numeric styleIds (1/2/3 vs Heading1), document zone structure (cover→abstract→TOC→body→references), font expectations, common mistakes
references/design_principles.mdAesthetic foundations: 6 design principles (white space, contrast/scale, proximity, alignment, repetition, hierarchy) — teaches WHY, not just WHAT
references/design_good_bad_examples.mdGood vs Bad comparisons: 10 categories of typography mistakes with OpenXML values, ASCII mockups, and fixes
references/track_changes_guide.mdRevision marks deep dive
references/troubleshooting.mdSymptom-driven fixes: 13 common problems indexed by what you SEE (headings wrong, images missing, TOC broken, etc.) — search by symptom, find the fix

质量与来源

所属仓库
pengfeiqiao/kunpeng
仓库星标
99
最近更新
2 天前
采集时间
今天
commit
bf8a8ac8c6d3
内容指纹
sha256:45c169630f30b8f
文件路径
skills/minimax-docx/SKILL.md

同仓库其它 Skill

查看全部 49 个
anchor-frame-production
建立参考分工、锚定图变体、局部核验与版本记录,用于普通对话、画布和工坊的连续镜头创作。
pengfeiqiao/kunpeng 99 原文
Codex CLIMCP 客户端
blender-clay-previz
用户提到白模/白膜/运镜预演/previs 时使用。调用本机 Blender 无界面渲染极简白模场景与运镜视频,用于验证构图遮挡、空间调度与动作时机,也可作为 AI 视频生成的全能参考。
pengfeiqiao/kunpeng 99 原文
Codex CLIMCP 客户端
blender-modeling
在 Blender 中新建或修改可编辑模型、材质、灯光及场景工程。适用于产品建模、场景搭建、已有 blend 修改与渲染;纯白模运镜使用 blender-clay-previz。
pengfeiqiao/kunpeng 99 原文
Codex CLIMCP 客户端
canvas-project-manager
画布能力由 canvas 工具契约提供,本文件仅保留操作顺序和数据安全约束。
pengfeiqiao/kunpeng 99 原文
Codex CLIMCP 客户端
car-commercial-storyboard
汽车TVC、品牌片、汽车文案剧本、车辆资产与图片/视频提示词、分镜及Blender白模运镜。按人物叙事、生活观察、产品演示、造型光影等意图选择方法,维护车型身份与驾驶安全带连续性;不处理购车行情或维修问答。
pengfeiqiao/kunpeng 99 原文
Codex CLIMCP 客户端
car-model-generation
专业的汽车3D模型图片生成技能,使用Gemini API生成高质量汽车展示图片,并通过豆包AI进行质量分析和优化。 使用场景:汽车品牌宣传片、车型展示、汽车广告素材生成。 关键词:汽车模型、车型图、汽车展示图、AI生图、Gemini
pengfeiqiao/kunpeng 99 原文
Codex CLIMCP 客户端

相似 Skill

更多「办公」
opencli-adapter-author
Use when writing an OpenCLI adapter for a new site or adding a new command to an existing site. Guides end-to-end from first recon through field decoding, adapter coding, and verify. Replaces opencli-oneshot / opencli-explorer. For ad-hoc browser driving (no adapter), see opencli-browser instead; for a top-level orientation to opencli, see opencli-usage.
精选 jackwener/OpenCLI 3.0 万 原文
Gemini CLI
opencli-autofix
Automatically fix broken OpenCLI adapters when commands fail. Load this skill when an opencli command fails — it guides you through collecting a trace artifact, patching the adapter, retrying, and filing an upstream GitHub issue after a verified fix. Works with any AI agent.
精选 jackwener/OpenCLI 3.0 万 原文
Gemini CLI
opencli-browser
Use when an agent needs to drive a real Chrome window via opencli — inspect a page, fill forms, click through logged-in flows, or extract data ad-hoc. Covers the selector-first target contract, compound form fields, stale-ref handling, network capture, and the agent-native envelopes the CLI returns. Not for writing adapters — see opencli-adapter-author for that.
精选 jackwener/OpenCLI 3.0 万 原文
Gemini CLI
opencli-usage
Use at the start of any OpenCLI session — this is the top-level map of what `opencli` can do, how to discover adapters, what flags and output formats are universal, and which specialized skill to load next. Point here when an agent asks "what can opencli do?" or "how do I find the right command?".
精选 jackwener/OpenCLI 3.0 万 原文
Gemini CLI
smart-search
基于 opencli 命令的智能搜索路由器。当用户想要使用 OpenCLI、CLI 或 API 搜索、查询、查找或研究信息时,尤其是涉及指定网站、社交媒体、技术资料、新闻、购物、旅游、求职、金融或中文内容时,务必使用此 skill
精选 jackwener/OpenCLI 3.0 万 原文
Gemini CLI
deeptutor-cli
终身个性化辅导系统:根据学习者情况持续调整教学方式。
精选 HKUDS/DeepTutor 4.1 万 仓库简介
Codex CLIMCP 客户端