$npx -y skills add nguyenphp/antigravity-marketing --skill minimax-docxProfessional 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 t
| 1 | # minimax-docx |
| 2 | |
| 3 | Create, edit, and format DOCX documents via CLI tools or direct C# scripts built on OpenXML SDK (.NET). |
| 4 | |
| 5 | ## Setup |
| 6 | |
| 7 | **First time:** `bash scripts/setup.sh` (or `powershell scripts/setup.ps1` on Windows, `--minimal` to skip optional deps). |
| 8 | |
| 9 | **First operation in session:** `scripts/env_check.sh` — do not proceed if `NOT READY`. (Skip on subsequent operations within the same session.) |
| 10 | |
| 11 | ## Quick Start: Direct C# Path |
| 12 | |
| 13 | 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: |
| 14 | |
| 15 | ```csharp |
| 16 | // File: scripts/dotnet/task.csx (or a new .cs in a Console project) |
| 17 | // dotnet run --project scripts/dotnet/MiniMaxAIDocx.Cli -- run-script task.csx |
| 18 | #r "nuget: DocumentFormat.OpenXml, 3.2.0" |
| 19 | |
| 20 | using DocumentFormat.OpenXml; |
| 21 | using DocumentFormat.OpenXml.Packaging; |
| 22 | using DocumentFormat.OpenXml.Wordprocessing; |
| 23 | |
| 24 | using var doc = WordprocessingDocument.Create("output.docx", WordprocessingDocumentType.Document); |
| 25 | var mainPart = doc.AddMainDocumentPart(); |
| 26 | mainPart.Document = new Document(new Body()); |
| 27 | |
| 28 | // --- Your logic here --- |
| 29 | // Read the relevant Samples/*.cs file FIRST for tested patterns. |
| 30 | // See Samples/ table in References section below. |
| 31 | ``` |
| 32 | |
| 33 | **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. |
| 34 | |
| 35 | ## CLI shorthand |
| 36 | |
| 37 | All CLI commands below use `$CLI` as shorthand for: |
| 38 | ```bash |
| 39 | dotnet run --project scripts/dotnet/MiniMaxAIDocx.Cli -- |
| 40 | ``` |
| 41 | |
| 42 | ## Pipeline routing |
| 43 | |
| 44 | Route by checking: does the user have an input .docx file? |
| 45 | |
| 46 | ``` |
| 47 | User task |
| 48 | ├─ No input file → Pipeline A: CREATE |
| 49 | │ signals: "write", "create", "draft", "generate", "new", "make a report/proposal/memo" |
| 50 | │ → Read references/scenario_a_create.md |
| 51 | │ |
| 52 | └─ Has input .docx |
| 53 | ├─ Replace/fill/modify content → Pipeline B: FILL-EDIT |
| 54 | │ signals: "fill in", "replace", "update", "change text", "add section", "edit" |
| 55 | │ → Read references/scenario_b_edit_content.md |
| 56 | │ |
| 57 | └─ Reformat/apply style/template → Pipeline C: FORMAT-APPLY |
| 58 | signals: "reformat", "apply template", "restyle", "match this format", "套模板", "排版" |
| 59 | ├─ Template is pure style (no content) → C-1: OVERLAY (apply styles to source) |
| 60 | └─ Template has structure (cover/TOC/example sections) → C-2: BASE-REPLACE |
| 61 | (use template as base, replace example content with user content) |
| 62 | → Read references/scenario_c_apply_template.md |
| 63 | ``` |
| 64 | |
| 65 | If the request spans multiple pipelines, run them sequentially (e.g., Create then Format-Apply). |
| 66 | |
| 67 | ## Pre-processing |
| 68 | |
| 69 | Convert `.doc` → `.docx` if needed: `scripts/doc_to_docx.sh input.doc output_dir/` |
| 70 | |
| 71 | Preview before editing (avoids reading raw XML): `scripts/docx_preview.sh document.docx` |
| 72 | |
| 73 | Analyze structure for editing scenarios: `$CLI analyze --input document.docx` |
| 74 | |
| 75 | ## Scenario A: Create |
| 76 | |
| 77 | 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`. |
| 78 | |
| 79 | **Choose your path:** |
| 80 | - **Simple** (plain text, minimal formatting): use CLI — `$CLI create --type report --output out.docx --config content.json` |
| 81 | - **Structural** (custom styles, multi-section, TOC, images, complex tables): write C# directly. Read the relevant `Samples/*.cs` first. |
| 82 | |
| 83 | 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`. |
| 84 | |
| 85 | Then run the **validation pipeline** (below). |
| 86 | |
| 87 | ## Scenario B: Edit |