[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73BMBRFEH4XCA063TK9F0FE":3,"skill-same:01M73BMBRFEH4XCA063TK9F0FE":43},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":6,"ownerHtmlUrl":27,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":28,"install":29,"resources":42},"01M73BMBRFEH4XCA063TK9F0FE","officecli-docx",null,"Use this skill any time a .docx file is involved -- as input, output, or both. This includes: creating Word documents, reports, letters, memos, or proposals; reading, parsing, or extracting text from any .docx file; editing, modifying, or updating existing documents; working with templates, tracked changes, comments, headers\u002Ffooters, or tables of contents. Trigger whenever the user mentions 'Word doc', 'document', 'report', 'letter', 'memo', or references a .docx filename.","ngdletrung\u002FJKAI-Zenith","ngdletrung","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F88302940?v=4","01M73BJVV5QJ87R3MC4BXJMWDN","01M73BJVWAAM03TM18QHKRDAMH",0,"MIT","https:\u002F\u002Fgithub.com\u002Fngdletrung\u002FJKAI-Zenith\u002Fblob\u002Fmain\u002Ffiles\u002FOfficeCLI-main\u002Fskills\u002Fofficecli-docx\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: officecli-docx\ndescription: \"Use this skill any time a .docx file is involved -- as input, output, or both. This includes: creating Word documents, reports, letters, memos, or proposals; reading, parsing, or extracting text from any .docx file; editing, modifying, or updating existing documents; working with templates, tracked changes, comments, headers\u002Ffooters, or tables of contents. Trigger whenever the user mentions 'Word doc', 'document', 'report', 'letter', 'memo', or references a .docx filename.\"\n---\n\n# OfficeCLI DOCX Skill\n\n## Setup\n\nIf `officecli` is missing:\n\n- **macOS \u002F Linux**: `curl -fsSL https:\u002F\u002Fd.officecli.ai\u002Finstall.sh | bash`\n- **Windows (PowerShell)**: `irm https:\u002F\u002Fd.officecli.ai\u002Finstall.ps1 | iex`\n\nVerify with `officecli --version` (open a new terminal if PATH hasn't picked up). If install fails, download a binary from https:\u002F\u002Fgithub.com\u002FiOfficeAI\u002FOfficeCLI\u002Freleases.\n\n## ⚠️ Help-First Rule\n\n**This skill teaches what good docx looks like, not every command flag. When a property name, enum value, or alias is uncertain, consult help BEFORE guessing.**\n\n```bash\nofficecli help docx                         # List all docx elements\nofficecli help docx \u003Celement>               # Full element schema (e.g. paragraph, field, numbering, watermark, toc)\nofficecli help docx \u003Cverb> \u003Celement>        # Verb-scoped (e.g. add field, set section)\nofficecli help docx \u003Celement> --json        # Machine-readable schema\n```\n\nHelp is pinned to the installed CLI version. When this skill and help disagree, **help is authoritative**.\n\n## Mental Model\n\nA `.docx` is a ZIP of XML parts (`document.xml`, `styles.xml`, `numbering.xml`, `header*.xml`, `footer*.xml`, `comments.xml`, …). Everything the user sees — headings, tables, page numbers, TOC, tracked changes — is XML inside that ZIP. `officecli` gives you a semantic-path API (`\u002Fbody\u002Fp[1]\u002Fr[2]`) over it, so you almost never touch raw XML; when you must, use `raw-set` (see the XML appendix).\n\n## Shell & Execution Discipline\n\ndocx paths contain `[]`; some prop values contain `$`. Both are shell metacharacters. Escaping happens at three layers — keep them separate.\n\n1. **Shell.** ALWAYS quote element paths: `\"\u002Fbody\u002Fp[1]\"`, not `\u002Fbody\u002Fp[1]` (zsh\u002Fbash glob `[N]`). Single-quote any value containing `$`: `--prop text='$50M'` — at any length, the whole value inside one pair of single quotes. Unquoted `$50M` is stripped to `M`; mixing `'…$var…'` and `\"…$50…\"` on one long string is where the `$50` silently vanishes.\n2. **CLI (`text=`).** The two-char escapes `\\n` and `\\t` ARE interpreted in `--prop text=` — `\\n` becomes a `\u003Cw:br\u002F>` soft line break, `\\t` a `\u003Cw:tab\u002F>` — consistently across docx \u002F pptx \u002F xlsx. Double them (`\\\\n`) for a literal backslash-n (rarely wanted). This applies to row-level table `c1…cN` shortcuts too (`\\n` → `\u003Cw:br\u002F>` within the cell).\n3. **JSON (batch).** A real newline can also be passed as `\"\\n\"` in the JSON string of a `batch` heredoc; same result.\n\nIf in doubt, `view text` after writing and compare character-for-character.\n\n**Incremental execution.** `officecli` mutates the file on every call. Run commands one at a time and check each exit code — a 50-command script that fails at command 3 cascades silently. After any structural op (new style, table, TOC, section break) run `get` on it before stacking more.\n\n**Open\u002Fsave lifecycle:** `officecli open \u003Cfile>` at the start, `officecli save \u003Cfile>` at the end to flush to disk — `save` only writes and leaves the resident warm for follow-up edits; reach for `officecli close \u003Cfile>` only to release the resident on a one-shot handoff. Both are always safe (never error or lose work). For many paragraphs of one style, use `batch` (one pass for the whole array). **Flush only at the non-officecli boundary:** officecli's own reads always see your edits; run `save`\u002F`close` only before a non-officecli program reads the file (python-docx, Word, a renderer, delivery).\n\n**`$FILE` convention.** All commands use `\"$FILE\"` — set it once (`FILE=\"your-doc.docx\"`). Never copy a literal `doc.docx` \u002F `review.docx` into output — always substitute your actual target.\n\n## Requirements for Outputs\n\nDeliverable standards every document MUST meet — know these before reaching for a command.\n\n**Clear hierarchy.** Every non-trivial document has Title → Heading 1 → Heading 2 → body, not a wall of unstyled `Normal` paragraphs. If `view outline` shows one flat list, the hierarchy is missing.\n\n**Explicit heading sizes** (Word default style sizes drift between templates): **H1 ≥ 18pt** (20pt for long reports), H2 = 14pt bold, H3 = 12pt bold, body = 11–12pt, line spacing 1.15–1.5x. Prefer `style=Heading1` over inline sizes so a retheme touches the definition once — but set explicit sizes when you can't trust the template's styles.\n\n**One body font, one accent.** One readable body font (Calibri, Cambria, Georgia, Times New Roman); accent color for heading emphasis or table headers, not rainbow formatting.\n\n**Spacing through properties.** Use `spaceBefore` \u002F `spaceAfter` on paragraphs. Rows of empty paragraphs break pagination and are flagged by `view issues`.\n\n**Typographic quality.** New content uses curly quotes (`'` `'` `\"` `\"`), not ASCII — Unicode directly or XML entities (`&#x2018;`\u002F`&#x2019;`\u002F`&#x201C;`\u002F`&#x201D;`) inside `raw-set`. En-dash `–` for ranges (`2024–2026`), em-dash `—` for parenthetical breaks.\n\n**Headers, footers, page numbers on any document > 1 page.** Page numbers go through a live `PAGE` field (`--prop field=page`), never the literal text \"Page 1\" — the CLI injects `\u003Cw:fldChar>` for you (see Headers & Footers).\n\n**Preserve existing templates.** When editing a file that already has a look, match it — existing conventions override these guidelines.\n\n### Visual delivery floor (applies to EVERY document)\n\nBefore declaring done, run `officecli view \"$FILE\" html` and Read the returned HTML path to confirm ALL of these:\n\n- **No placeholder tokens rendered as data.** `$xxx$`, `{var}`, `{{name}}`, `\u003CTODO>`, `lorem`, `xxxx` must never appear in a heading, body, cover, TOC, caption, header, or footer. A literal `{name}` meant for a human to fill belongs inside a visible instruction paragraph (\"Replace `{name}` before sending\"), never as finished content.\n- **No truncated titles or overflowing cells.** Widen the column or set `wrapText` rather than trimming content.\n- **TOC present when the document has 3+ headings** (`--type toc`).\n- **Cover page ≥ 60% filled, last page ≥ 40% filled.** Pad a thin cover with subtitle \u002F author \u002F date \u002F scope \u002F key highlights; pad a \"Thank you\" last page with conclusion \u002F next steps \u002F contact \u002F legal.\n- **No `\\$`, `\\t`, `\\n` literals in document text.** If `view text` shows these, a shell-escape layer leaked — delete the paragraph and re-enter it.\n\nIf any fails, STOP and fix before declaring done.\n\n## Common Workflow\n\nSix steps. Every non-trivial build follows this shape.\n\n1. **Open the file.** `officecli open \"$FILE\"` (resident default). New file: `officecli create \"$FILE\"` first.\n2. **Orient.** Existing file: `officecli view \"$FILE\" outline` — heading tree, section count, whether a TOC \u002F watermark \u002F tracked changes already exist. Never edit blind.\n3. **Build incrementally.** Structural first, content next, formatting last: styles & numbering defs → sections \u002F page setup → headings & body → tables \u002F images \u002F fields \u002F TOC → headers \u002F footers → comments. After each structural op, `get` it back before stacking on top.\n4. **Format to spec.** Explicit heading sizes, spacing, widths, alignment, tabs, list indents — formatting is part of the deliverable, not optional polish.\n5. **Save, then trust structure over cached text.** `officecli save \"$FILE\"` writes the XML. TOC \u002F PAGE \u002F NUMPAGES \u002F SEQ \u002F PAGEREF fields carry **cached values** that may be stale or empty until a human recalculates (F9 in Word). Confirm fields *exist* (`get --depth 3` finds `\u003Cw:fldChar>`) rather than trusting the visible text.\n6. **QA — assume there are problems.** You are done after one fix-and-verify cycle finds zero new issues, not when your last command exited 0. See QA.\n\n## Quick Start\n\nMinimal viable docx: a heading, a body paragraph, a subheading, and a footer with a live page-number field. Adapt, don't copy-paste — your file, your content.\n\n```bash\nFILE=\"review.docx\"\nofficecli create \"$FILE\"\nofficecli open \"$FILE\"\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Q4 2026 Review\" --prop style=Heading1 --prop size=20pt --prop bold=true --prop spaceAfter=12pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Revenue grew 18% year-over-year, ahead of plan.\" --prop size=11pt --prop spaceAfter=8pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Key Drivers\" --prop style=Heading2 --prop size=14pt --prop bold=true --prop spaceBefore=12pt --prop spaceAfter=6pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Enterprise renewals, upsell, and a new EMEA region.\" --prop size=11pt\nofficecli add \"$FILE\" \u002F --type footer --prop type=default --prop size=9pt --prop text=\"Page \" --prop field=page\nofficecli set \"$FILE\" \"\u002Ffooter[1]\u002Fp[1]\" --prop align=center\nofficecli save \"$FILE\"\nofficecli validate \"$FILE\"\n```\n\nVerified: `validate` returns `no errors found`; `get \u002Ffooter[1] --depth 3` shows the 5-run PAGE field chain (begin \u002F instrText \u002F separate \u002F cached value \u002F end).\n\n## Reading & Analysis\n\nStart wide, then narrow. `outline` tells you what's already there; jump into `view text` \u002F `get` \u002F `query` once you know where to look.\n\n```bash\nofficecli view \"$FILE\" outline            # heading tree, section count, table\u002Fimage counts, watermark, tracked-changes presence — orient here first\nofficecli view \"$FILE\" html               # Read the returned HTML path: first visual check after a batch of edits (hierarchy, empty-para spacing, missing TOC)\nofficecli view \"$FILE\" text --start 1 --end 80   # text for content QA; paths shown as [\u002Fbody\u002Fp[N]] so you can jump back with get\nofficecli view \"$FILE\" annotated          # values + style\u002Ffont\u002Fsize + warnings per run\nofficecli view \"$FILE\" stats              # paragraph counts, font usage, style distribution\nofficecli view \"$FILE\" issues             # empty paras, missing alt text, spacing anomalies\n```\n\n`officecli watch \"$FILE\"` keeps a live preview running for the human user to open at their discretion — agent self-check uses `view html`. Final visual verification is the user opening the `.docx` in Word \u002F WPS \u002F Pages.\n\n**Inspect one element.** XPath-style semantic paths (1-based). Always quote — shells glob `[N]`. Use `[last()]` (with parens) for the last element; `[last]` errors. Add `--json` for machine output.\n\n```bash\nofficecli get \"$FILE\" \u002F                          # document root: metadata, page setup\nofficecli get \"$FILE\" \"\u002Fbody\u002Fp[1]\"                # one paragraph\nofficecli get \"$FILE\" \"\u002Fbody\u002Fp[1]\u002Fr[1]\"           # one run (character-level formatting)\nofficecli get \"$FILE\" \"\u002Fbody\u002Ftbl[1]\" --depth 3    # table with rows and cells\nofficecli get \"$FILE\" \"\u002Ffooter[1]\" --depth 3      # footer — check for fldChar\nofficecli get \"$FILE\" \"\u002Fstyles\u002FHeading1\"          # style definition\nofficecli get \"$FILE\" \u002Fnumbering --depth 2        # numbering abstractNum + num bindings\n```\n\n**Query across the document.** CSS-like selectors, for systematic checks rather than hand-walking. Operators: `=`, `!=`, `~=` (contains), `>=`, `\u003C=`, `[attr]` (exists). Full reference: `officecli query --help`.\n\n```bash\nofficecli query \"$FILE\" 'paragraph[style=Heading1]'       # all H1s\nofficecli query \"$FILE\" 'p:contains(\"quarterly\")'         # text match\nofficecli query \"$FILE\" 'p:empty'                         # empty paragraphs (clutter)\nofficecli query \"$FILE\" 'image:no-alt'                    # accessibility gaps\nofficecli query \"$FILE\" 'paragraph[size>=24pt]'           # numeric comparison\nofficecli query \"$FILE\" 'field[fieldType!=page]'          # fields other than PAGE\n```\n\n`query --json` wraps results in `.data.results[]` — `jq '.data.results | length'` to count.\n\n**Large documents.** Navigate by heading with `view outline` and jump with `query`; don't dump the whole body into context.\n\n## Creating & Editing\n\nVerbs: `add` (new element), `set` (change a prop), `remove`, `move`, `swap`, `batch`, `raw-set` (last-resort XML). Ninety percent of a build is paragraphs, runs, tables, a couple of images, a TOC, and a footer.\n\n### Paragraphs, runs, styles\n\nA paragraph (`p`) is a block; a run (`r`) is a span of consistent character formatting inside it. Set paragraph-level props (style, alignment, spacing, indent) on the `p`; set font \u002F size \u002F color \u002F bold on the `r`.\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Executive Summary\" --prop style=Heading1 --prop size=18pt --prop bold=true --prop spaceAfter=12pt\nofficecli set \"$FILE\" \"\u002Fbody\u002Fp[1]\u002Fr[1]\" --prop color=1F4E79\n```\n\nUse `spaceBefore` \u002F `spaceAfter` for vertical spacing — never chains of empty paragraphs. For left indent use `--prop indent=720` (twips), `firstLineIndent=360` for first line, `hangingIndent=720` for hanging; leading spaces fire `view issues`.\n\n### Tables\n\nTables are `\u002Fbody\u002Ftbl[N]` with rows `tr[N]` and cells `tc[N]`. Add with row\u002Fcolumn counts, then fill.\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type table --prop rows=4 --prop cols=3 --prop width=100%\nofficecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\" --prop header=true --prop c1=Quarter --prop c2=\"Revenue\" --prop c3=\"Growth\"\nofficecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\u002Ftc[1]\u002Fp[1]\u002Fr[1]\" --prop bold=true\n```\n\nRow-level `set` supports `height`, `header`, and `c1 \u002F c2 \u002F … \u002F cN` text shortcuts (`cN` generalises to any column count). Cell formatting (bold, fill, color) goes on the cell's paragraph \u002F run — **not** row-level. For per-cell borders, set cell-level `border.*` on the `tc` (`--prop border.bottom=\"single;6;000000;0\"`), or paragraph-level `pbdr.*` on the inner paragraph.\n\n**Horizontal rule = a paragraph bottom border, never a 1-row table.** A table-as-divider renders as an empty min-height box (worst in headers\u002Ffooters). Use `pbdr.bottom` (`STYLE;SIZE;COLOR`) on the paragraph instead:\n\n```bash\nofficecli set \"$FILE\" \"\u002Fbody\u002Fp[3]\" --prop pbdr.bottom=\"single;6;2E75B6\"\n```\n\n### Lists (bullets, numbered, multi-level)\n\nFor single-level bullets\u002Fnumbers, set `listStyle` on the paragraph (`listStyle` is a paragraph prop, NOT a run prop — common mistake):\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"First item\" --prop listStyle=bullet\n```\n\nFor multi-level (legal-style 1 \u002F 1.1 \u002F 1.1.1), add an `abstractNum`, then a `num`, then reference the `numId` per paragraph:\n\n```bash\nofficecli add \"$FILE\" \u002Fnumbering --type abstractnum --prop format=decimal     # → abstractNum id=0\nofficecli add \"$FILE\" \u002Fnumbering --type num --prop abstractNumId=0             # → num id=1\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Section one\" --prop numId=1 --prop ilvl=0\n```\n\nIDs are 0-based: the first `abstractNum` is id=0; the `num` references it via `abstractNumId=0` and is itself assigned id=1. A non-existent `abstractNumId` errors, so check ids after creating. Verify with `officecli query \"$FILE\" 'paragraph[numId>0]'`. See `help docx abstractnum` \u002F `help docx num` for level and format options.\n\n### Tab stops (signature lines, leader rows)\n\nTab stops are a first-class `tab` child of the paragraph; `pos` accepts `6in`\u002F`6cm`\u002Ftwips, `val` ∈ `left`\u002F`center`\u002F`right`, `leader` ∈ `none`\u002F`dot`\u002F`hyphen`\u002F`underscore`. See `help docx tab`.\n\n```bash\nofficecli add \"$FILE\" \"\u002Fbody\u002Fp[1]\" --type tab --prop pos=6in --prop val=right --prop leader=dot\n```\n\n**Leader caveat.** `leader=dot` alone emits no dots — the leader renders only when a real `\u003Cw:tab\u002F>` character sits in a run between the text and the tab stop. Put one there with `\\t` in the text: define the stop (`add tab --prop pos=6in --prop val=right --prop leader=dot`), then `--prop text=\"Chapter 1\\t12\"` — the `\\t` becomes the `\u003Cw:tab\u002F>` and dots fill to the right-aligned page number. (Literal `text=\"Chapter 1 ......... 12\"` also ships, but a real tab stop aligns cleanly.)\n\n### Fields (PAGE \u002F NUMPAGES \u002F DATE \u002F MERGEFIELD \u002F REF)\n\nFields are live values computed at render time. `fieldType` picks the field; `name` supplies the target (merge name or `ref` bookmark); `format` \u002F `instr` add switches.\n\n| Field | Use | Example |\n|---|---|---|\n| `page` | current page number | `--prop field=page` on footer, or `--prop fieldType=page` inline |\n| `numpages` | total pages | `--prop field=numpages` \u002F `--prop fieldType=numpages` |\n| `date` | today | `--prop fieldType=date --prop format='yyyy-MM-dd'` |\n| `mergefield` | template merge token | `--prop fieldType=mergefield --prop name=CustomerName` |\n| `ref` | cross-reference to a bookmark | `--prop fieldType=ref --prop name=bookmarkName` |\n\nFull `fieldType` enum (30+ values incl. `pageref`, `seq`, `styleref`, `docproperty`, `createdate`, …) is in `help docx field`. **There is NO `fieldInstr` fieldType** — use the `instruction` prop for raw field instruction text when typed shortcuts fall short. Picture switches (`MERGEFIELD Amount \\# \"#,##0.00\"`, `DATE \\@ \"yyyy年MM月\"`) go via `--prop instruction='…'` (mergefield's `format` prop is ignored with a warning — use `instruction`).\n\n```bash\nofficecli add \"$FILE\" \"\u002Fbody\u002Fp[3]\" --type field --prop fieldType=mergefield --prop name=customer_name\n# Renders «customer_name» — visible placeholder, replaced in Word at mail-merge time.\n```\n\n**MERGEFIELD templates: never render placeholder literals.** A `{{customer_name}}` or `$NAME$` shown as body text is a failed template the recipient sees — insert a real MERGEFIELD (above), or confine literal tokens to an obvious instruction paragraph. Confirm with `query 'field[fieldType=mergefield]'`.\n\n**SEQ \u002F PAGEREF \u002F TOC field values.** officecli doesn't store rendered field values at write time. Recompute by what each path needs:\n\n- **SEQ numbering** (`Figure 1\u002F2\u002F3`): `officecli set \"$FILE\" \u002F --prop recalcFields=seq` counts SEQ fields in body document order and writes the cached values (`evaluated` flips true; switches\u002Fformats in `help docx document`). Heading-relative `\\s` and SEQ in headers\u002Ffooters defer to Word.\n- **PAGE \u002F PAGEREF \u002F NUMPAGES \u002F TOC page numbers** need pagination, which officecli has no engine for — `officecli set \"$FILE\" \u002Fsettings --prop updateFields=true` defers them to Word on open.\n\nUse both on a multi-figure document. Academic papers: see the `officecli-academic-paper` skill.\n\n### Headers & Footers (page numbering)\n\nSingle-command pattern — the CLI injects `\u003Cw:fldChar>`, so you never compose the field by hand:\n\n```bash\n# Empty first-page footer — auto-enables differentFirstPage so the cover has no page number\nofficecli add \"$FILE\" \u002F --type footer --prop type=first --prop text=\"\"\n# Default footer with live page number\nofficecli add \"$FILE\" \u002F --type footer --prop type=default --prop align=center --prop size=9pt --prop text=\"Page \" --prop field=page\n```\n\nWhen both exist, the default footer is `\u002Ffooter[2]`; alone it is `\u002Ffooter[1]`. **Verify**: `get --depth 3` must show `fldChar` children, not just a run with literal `\"Page\"` (`view outline` prints \"Footer: Page\" for both live fields AND static text — don't rely on it). Do NOT `set --prop differentFirstPage=true` — that prop is unsupported (rejected with exit 2, not silently); adding a first-type footer flips the bit. For composite **Page X of Y**, see recipe (b).\n\n### Table of Contents\n\nFor any document with 3+ headings, first verify that the requested range has real sources. A TOC source must use a built-in Heading style or a custom paragraph style with `outlineLvl`; bold or large Normal text is not a source. If no eligible source exists, stop and fix the heading structure instead of inserting a TOC that renders \"Error! No table of contents entries found.\"\n\n```bash\n# Built-in Heading styles are TOC sources.\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Introduction\" --prop style=Heading1\n# Custom paragraph styles need an outline level (0 = Heading 1).\nofficecli add \"$FILE\" \u002Fstyles --type style --prop id=ThesisH1 --prop type=paragraph --prop outlineLvl=0\n# Add the TOC only after its sources exist.\nofficecli add \"$FILE\" \u002Fbody --type toc --prop levels=\"1-3\" --prop title=\"Table of Contents\" --prop hyperlinks=true --index 0\n```\n\nPage numbers need pagination; OfficeCLI cannot calculate TOC page numbers itself. Set `updateFields=true` so Word recomputes the TOC (and all fields) on open. Without a Word-compatible field engine, report the TOC as dynamic and uncomputed; do not claim ready page numbers or guess a static TOC.\n\n```bash\nofficecli set \"$FILE\" \u002Fsettings --prop updateFields=true\n```\n\nAddress the TOC directly with `\u002Ftoc[1]` or `\u002Ftableofcontents` for `get`\u002F`set`\u002F`remove`.\n\n### Images\n\nPictures go inside a run. Alt text is mandatory for accessibility — pass `alt` directly at create time:\n\n```bash\nofficecli add \"$FILE\" \"\u002Fbody\u002Fp[5]\" --type picture --prop src=logo.png --prop width=1.5in --prop alt=\"Acme logo\"\n```\n\nConfirm `officecli query \"$FILE\" 'image:no-alt'` is empty before delivery.\n\n### Charts\n\nFor data, add a **native chart** — editable, themeable, accessible, re-renders in Word — never a flat PNG screenshot of a chart. `data=\"Label:v1,v2,…\"` per series; one `data=` per series (or `series1=`\u002F`series2=`).\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type chart --prop chartType=bar --prop title=\"Revenue by Region\" --prop categories=\"EMEA,APAC,Americas\" --prop data=\"2026:120,150,180\"\n```\n\n`chartType` ∈ bar \u002F column \u002F line \u002F pie \u002F area \u002F scatter (`help docx chart` for axis\u002Flegend\u002Fseries styling). A PNG via `--type picture` is only a fallback for an exotic chart officecli can't build.\n\n### Hyperlinks and bookmarks\n\nExternal links go via `hyperlink`:\n\n```bash\nofficecli add \"$FILE\" \"\u002Fbody\u002Fp[2]\" --type hyperlink --prop url=\"https:\u002F\u002Fexample.com\" --prop text=\"our site\"\n```\n\n**Internal links** (to a bookmark) use `--prop anchor=bookmarkName` — not a `#fragment` in `url`:\n\n```bash\nofficecli add \"$FILE\" \"\u002Fbody\u002Fp[2]\" --type hyperlink --prop anchor=chapter1 --prop text=\"See Chapter 1\"\n```\n\nPairing a `PAGEREF` field with visible text is the alternative. See `help docx hyperlink` \u002F `help docx bookmark`.\n\n### Sections and page setup\n\nDocument root `\u002F` carries page setup (`pageWidth`, `pageHeight`, margins, in twips). Multi-section documents (landscape insert, columns) add a `section` break — see `help docx section`. Both camelCase (`pageWidth`, canonical) and lowercase alias (`pagewidth`) are accepted; prefer camelCase.\n\n```bash\nofficecli set \"$FILE\" \u002F --prop pageWidth=12240 --prop pageHeight=15840 --prop marginTop=1440 --prop marginLeft=1440\n# Newspaper-style multi-column flow (columnSpace in twips; 720 = 0.5in):\nofficecli set \"$FILE\" \u002F --prop columns=2 --prop columnSpace=720\n```\n\n### Forcing page breaks\n\nUse exactly one page-break mechanism per logical boundary. The default is `pageBreakBefore=true` on the target heading. Alternatively, insert one explicit `pagebreak` before the heading. Never combine both mechanisms for the same boundary: the resulting double break can create a blank page. Never set `pageBreakBefore` on `p[last()]` immediately after adding a `pagebreak`.\n\n```bash\n# Default: apply the break directly to the heading.\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Introduction\" --prop style=Heading1 --prop pageBreakBefore=true\n```\n\n`--prop break=newPage` is an alias for `pageBreakBefore=true`. Preview with `view html` and check for blank pages.\n\n### Report-level recipes\n\nPatterns that come up on every long-form report. Each has been executed and `validate`-passed.\n\n**(a) Rich cover page — hit the ≥ 60% filled floor.** Stack a confidentiality banner, title, subtitle, client\u002Fproject\u002Fdate block, and a key-themes strip, then force the next section onto a new page:\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"CONFIDENTIAL — CLIENT USE ONLY\" --prop align=center --prop size=9pt --prop color=C00000 --prop spaceAfter=24pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Strategic Growth Review\" --prop style=Title --prop size=32pt --prop bold=true --prop align=center --prop font=Cambria --prop spaceAfter=8pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"FY26 Outlook and Scenario Planning\" --prop italic=true --prop size=16pt --prop align=center --prop spaceAfter=36pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text='Prepared for: Acme Corp. Leadership Team' --prop align=center --prop size=11pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text='Engagement: 2026-04 — 2026-06' --prop align=center --prop size=11pt --prop spaceAfter=36pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Key themes: 1) margin resilience, 2) EMEA expansion, 3) capital allocation.\" --prop align=center --prop italic=true --prop size=10pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Executive Summary\" --prop style=Heading1 --prop pageBreakBefore=true\n```\n\n**(b) Page X of Y footer — composite PAGE + NUMPAGES.** Add the footer paragraph, then three child ops build `Page \u003CX> of \u003CY>` live. The official `help docx footer` recipe.\n\n```bash\nofficecli add \"$FILE\" \u002F --type footer --prop type=default --prop text=\"Page \" --prop align=center --prop size=9pt\nofficecli add \"$FILE\" \"\u002Ffooter[1]\u002Fp[1]\" --type field --prop fieldType=page\nofficecli add \"$FILE\" \"\u002Ffooter[1]\u002Fp[1]\" --type run --prop text=\" of \"\nofficecli add \"$FILE\" \"\u002Ffooter[1]\u002Fp[1]\" --type field --prop fieldType=numpages\nofficecli get \"$FILE\" \"\u002Ffooter[1]\u002Fp[1]\" --depth 1 | grep -o fldChar | wc -l   # expect ≥ 4; use grep -o ... | wc -l, NOT grep -c (single-line XML returns 1)\n```\n\n**(c) Header row with fill and white bold text.** Order matters — populate header cell text FIRST (runs don't exist in empty cells; a `set …\u002Ftc[N]\u002Fp[1]\u002Fr[1]` on an empty cell errors \"No r found\"), THEN cell fill, THEN run formatting:\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type table --prop rows=5 --prop cols=4 --prop width=100%\nofficecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\" --prop header=true --prop c1=Quarter --prop c2=Revenue --prop c3=Growth --prop c4=Status\nfor col in 1 2 3 4; do\n  officecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\u002Ftc[$col]\" --prop fill=1F4E79\n  officecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\u002Ftc[$col]\u002Fp[1]\u002Fr[1]\" --prop bold=true --prop color=FFFFFF\ndone\nfor row in 3 5; do for col in 1 2 3 4; do\n  officecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[$row]\u002Ftc[$col]\" --prop fill=D9E2F3      # zebra stripe\ndone; done\n```\n\n**(d) Financial table — right-align numbers, bold totals, bottom border on total row.**\n\n```bash\nfor row in 2 3 4 5; do for col in 2 3 4; do\n  officecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[$row]\u002Ftc[$col]\u002Fp[1]\" --prop align=right\ndone; done\nfor col in 1 2 3 4; do\n  officecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[5]\u002Ftc[$col]\u002Fp[1]\u002Fr[1]\" --prop bold=true\n  officecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[4]\u002Ftc[$col]\u002Fp[1]\" --prop pbdr.bottom=\"single;6;000000;0\"\ndone\n```\n\n**(e) Cell with multiple bullets (SWOT \u002F risk matrix).** `c1=\"a\\nb\"` gives a `\u003Cw:br\u002F>` line break within **one** paragraph — fine for plain multi-line text, but bullets need separate paragraphs. Seed the first via `set c1=`, then `add paragraph` (with `listStyle=bullet`) under the cell per subsequent bullet:\n\n```bash\nofficecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\" --prop c1=\"Installed base of 18k enterprise seats\"\nofficecli add \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\u002Ftc[1]\" --type paragraph --prop text=\"Margin structure above peer median\" --prop listStyle=bullet\nofficecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\u002Ftc[1]\u002Fp[1]\" --prop listStyle=bullet\n```\n\nIf the seeded line lands at the bottom, re-order: `officecli move \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\u002Ftc[1]\u002Fp[N]\" --index 0`.\n\n**(f) TOC without a field engine.** A CLI-only pipeline cannot calculate reliable page numbers. Keep the live TOC, set `updateFields=true`, and tell the recipient to open the document in Word or another compatible field engine. Do not replace it with guessed static page numbers.\n\n### Template delivery — separating Template Notes from end-user content\n\nHR \u002F legal \u002F vendor templates carry internal-only guidance (\"replace `{{CompanyName}}`\") that must NOT ship. Two working patterns:\n\n- **Trailing \"Template Notes\" section** under a clear `Heading 1` (\"Template Notes for HR Users\") with all instructions below it; before distribution, `remove` from the heading downward (locate with `query 'paragraph[style=Heading1]:contains(\"Template Notes\")'`).\n- **Bookmark-bounded internal section** between `__template_notes_start` \u002F `_end` bookmarks; at delivery `raw-set` removes everything between the anchors.\n\nDelivery gate for templates: after removal, `query 'p:contains(\"Template Notes\")'` AND `query 'p:contains(\"{{\")'` both return empty. If a notes paragraph survives, a downstream employee reads internal language.\n\n### Advanced \u002F specialty topics (skip if you are writing a report)\n\nReports, memos, letters, proposals, and HR templates don't need this. Keep reading only if your document is academic (equations, footnotes, bibliography), reviewed (comments, tracked changes), or marked (watermark).\n\n**Equations and footnotes.** `--type equation` takes LaTeX — `\\frac`, `\\sum`, Greek, `\\mathit`, `\\mathcal` all render. By default it creates a standalone `\u002Fbody\u002FoMathPara[N]` display block; pass `--prop mode=inline` with a paragraph parent path (`add \"\u002Fbody\u002Fp[N]\" --type equation --prop formula=… --prop mode=inline`) to drop an inline `\u003Cm:oMath>` into running text. Footnotes auto-number by paragraph index. Bibliography hanging indent: `firstLineIndent=-720 indent=720` per entry.\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type equation --prop formula=\"\\\\frac{a}{b} + \\\\sum_{i=1}^{n} x_i\"\nofficecli add \"$FILE\" \"\u002Fbody\u002Fp[3]\" --type footnote --prop text=\"See Appendix A for methodology.\"\n```\n\n**Comments and tracked changes.** Bulk accept\u002Freject: `set \"$FILE\" \u002Frevision --prop revision.action=accept` (or `--prop revision.action=reject`); narrow with a selector like `\u002Frevision[@author=Alice]` or `\u002Frevision[@type=ins]`. Locate individual changes with `query ins` and `query del` (`trackedchange` is not a selector). Create tracked changes on a run with `--prop revision.type=ins|del --prop revision.author=…` (`help docx run` for the full `revision.*` set — `format`\u002F`moveFrom`\u002F`moveTo` too). Add a comment: `add \"\u002Fbody\u002Fp[4]\" --type comment --prop author=… --prop text=…`; reply-thread it with `--prop parentId=N` and mark it resolved with `set \"\u002Fcomments\u002Fcomment[N]\" --prop done=true` (resolve rather than delete to keep the audit trail — `query 'comment[done=false]'` then lists what's still open). Prop schema: `help docx comment` \u002F `help docx run`.\n\n**Watermark.** `add \u002F --type watermark --prop text=\"DRAFT\" --prop color=BFBFBF --prop opacity=0.8` in one command (default opacity 0.5); `set \u002Fwatermark --prop opacity=…` adjusts it later.\n\n**When to switch skills.** Stay in docx for chapter drafts, ≤ 3 footnotes, ≤ 2 equations, no bibliography\u002Fcross-refs. Switch to **`academic-paper`** for citation styles (APA \u002F Chicago \u002F IEEE \u002F GB 7714), in-text↔reference auto-linking, numbered equations with `\\ref`, \"List of Figures\", or auto-updating cross-refs. Switch to **`officecli-word-form`** when the document's purpose is **data capture** — fillable forms, contracts with user-fill slots, questionnaires, mail-merge templates (`\u003Cw:sdt>` content controls, `\u003Cw:ffData>`, `documentProtection=forms`).\n\n### Raw-set escape hatch (L1 \u002F L2 \u002F L3)\n\nThree tiers of precision; use the lowest that does the job.\n\n- **L1 — high-level props** (`--prop text=…`, `--prop style=Heading1`): your default. Covers 80%.\n- **L2 — dotted-attr fallback** (`pbdr.top=`, `ind.left=`, `shd.fill=`, `padding.top=`, `font.size=`): when L1 lacks the knob. Example: `--prop pbdr.bottom=\"single;6;1F4E79;0\"`. Emits schema-valid XML.\n- **L3 — `raw-set` with XML**: last resort, no schema protection. Use for internal hyperlinks, composite fields, and other shapes the typed verbs can't express (see XML appendix).\n\nBorders use the format `style;size;color;space`: `single;4;FF0000;1`. Hex colors never start with `#`: `FF0000`. Scheme color names (`accent1..6`, `dark1`\u002F`dark2`, `light1`\u002F`light2`, `hyperlink`) are accepted anywhere a hex color is — prefer hex for stable colors across themes.\n\n## QA (Required)\n\n**Assume there are problems — QA is a bug hunt, not a confirmation step.** Your first document is almost never correct; zero issues on first inspection means you weren't looking hard enough. Headings look fine until `view outline` shows an H3 directly under an H1; the footer shows \"Page 1\" until `get --depth 3` reveals a static run, not a field.\n\n### Minimum cycle before \"done\"\n\n1. `officecli view \"$FILE\" issues` — empty paras, missing alt text, formatting anomalies.\n2. `officecli view \"$FILE\" outline` — heading hierarchy (no H1 → H3 skips), TOC presence, section count.\n3. `officecli view \"$FILE\" text --max-lines 400` — typos, stray `\\$`\u002F`\\t`\u002F`\\n` literals, placeholder tokens.\n4. `officecli validate \"$FILE\"` — schema check (the Delivery Gate re-runs this on the closed, on-disk file).\n5. **Visual pass — whole document as a contact sheet** (vision-capable agents only — if you cannot interpret images, skip this step: steps 1–4 are your ceiling, and flag the document \"not visually verified\" at handoff). `officecli view \"$FILE\" screenshot --grid auto -o \u002Ftmp\u002Fsheet.png`, then Read it. `--grid auto` tiles **every page** into one image (auto column count; `--grid 4` to force) — you *see* pagination, blank pages, heading rhythm, lopsided margins, and TOC\u002Fcover placement, not just the DOM. Windows+Word renders each page through real Word; elsewhere HTML. If the screenshot fails, fall back to `view html` and flag cross-page breaks \u002F alignment \u002F rhythm as \"not visually verified\". Thumbnails only **locate**: confirm any fine call (column alignment, line spacing, indents, dark-on-dark, caption placement) on the suspect page at full resolution with `screenshot --page N` (no `--grid`; real Word on Windows). \"validate pass\" is not delivery; \"looks like a real document\" is.\n6. If anything failed, fix, then **rerun the full cycle** — one fix commonly creates another problem.\n\n### Delivery Gate (run before handing off — any failure = REJECT, do NOT deliver)\n\nCopy-paste, set `FILE`, and refuse to declare done until every gate prints OK.\n\n```bash\nFILE=\"your-file.docx\"\n\n# Gate 1 — schema.\nofficecli close \"$FILE\" 2>\u002Fdev\u002Fnull\nofficecli validate \"$FILE\" | grep -q \"no errors found\" || { echo \"REJECT Gate 1: validate failed\"; exit 1; }\necho \"Gate 1 OK\"\n\n# Gate 2 — token leak (shell-escape \u002F template tokens \u002F literal \\$ \\t \\n). grep -c never false-PASSes.\nLEAK=$(officecli view \"$FILE\" text | grep -cE '(\\$[A-Za-z_]+\\$|\\{\\{[^}]+\\}\\}|\u003CTODO>|xxxx|lorem|\\\\[\\$tn])')\n[ \"$LEAK\" -eq 0 ] && echo \"Gate 2 OK\" || { echo \"REJECT Gate 2: $LEAK leak line(s)\"; officecli view \"$FILE\" text | grep -nE '(\\$[A-Za-z_]+\\$|\\{\\{[^}]+\\}\\}|\u003CTODO>|xxxx|lorem|\\\\[\\$tn])'; exit 1; }\n# A TOC placeholder is valid before a Word-compatible field engine updates it; confirm the TOC field and updateFields setting structurally instead.\n\n# Gate 3 — live PAGE field exists when a footer is expected.\nFLD=$(officecli query \"$FILE\" 'field[fieldType=page]' --json | jq '.data.results | length')\n[ \"$FLD\" -ge 1 ] && echo \"Gate 3 OK\" || { echo \"REJECT Gate 3: no live PAGE field\"; exit 1; }\necho \"Delivery Gate PASS\"\n```\n\n### Field \u002F cached-value spot-check\n\nFields carry cached values that may be stale or empty at write time — confirm existence by **structure, not text**.\n\n- **Footer PAGE:** `get \u002Ffooter[N] --depth 3` lists the begin \u002F instrText \u002F separate \u002F cached \u002F end run chain — ≥ 5 runs for one PAGE, ≥ 11 for composite \"Page X of Y\". A single run with text `\"Page\"` = field missing; re-add with `--prop field=page`.\n- **TOC:** `get \u002Ftoc[1] --depth 2` shows field structure. Page numbers may read `1 1 1 1` or `Update field to see…` until recalculated (see §Table of Contents — set `updateFields=true`).\n- **MERGEFIELD:** `query 'field[fieldType=mergefield]'` — one per slot, no literal `{{name}}` elsewhere.\n\n### Honest limit\n\n`validate` catches schema errors, not design errors — a document can pass it with wrong heading hierarchy, fake-Heading-1 sizes, placeholder tokens as body text, or an empty first-page footer on a coverless document. The contact-sheet visual pass (`screenshot --grid`) and the field-structure check are how you catch what validation can't.\n\n### QA display notes (don't chase these)\n\n- `view text` shows `\"1.\"` for every numbered list item regardless of rendered number — actual output increments correctly.\n- `view issues` flags \"body paragraph missing first-line indent\" on cover paragraphs, centered headings, list items, bibliography entries — first-line indent is only required for APA\u002Facademic body text; on block-style professional documents these are expected.\n\n## Known Issues & Pitfalls\n\nWhen something \"looks broken\", attribute it before chasing: **[AGENT-ERROR]** the document is wrong (fix it) · **[RENDERER-BUG]** the document is correct, a viewer renders it differently (don't chase) · **[SKILL gap]** the skill didn't teach the rule (file an issue).\n\n### Renderer quirks (cross-viewer, [RENDERER-BUG] — don't chase)\n\nBefore calling a color\u002Ffield\u002Fchart broken, open the file in the user's target viewer; if it looks correct there it's a viewer quirk.\n\n- **PAGE field may render literal \"Page\"** (no number) until recalculated — judge by `fldChar` presence, not the digit.\n- **TOC cached page numbers may read \"1 1 1 1\"** until F9.\n- **Pie \u002F doughnut fill may collapse to one color** in some viewers (column\u002Fbar render fine).\n- **Form-control checkboxes may render double-boxed**; **OMML equation baselines** may shift across viewers (XML identical).\n\n### Common pitfalls\n\n| Pitfall | Correct approach |\n|---|---|\n| `--index` vs `[N]` | `--index` is 0-based; `[N]` paths are 1-based |\n| Multiple `add --index N` with the same N | Each insert shifts later content down; reusing N puts later items BEFORE earlier ones — insert in reverse order, or `move --after\u002F--before` anchored on `paraId` |\n| Unquoted `[N]` in zsh\u002Fbash | Quote every path: `\"\u002Fbody\u002Fp[1]\"` |\n| `[last]` as predicate | Must be `[last()]` with parens |\n| Raw twips in spacing | Use unit-qualified values: `12pt`, `0.5cm`, `1.5x` |\n| Empty paragraphs for spacing | Use `spaceBefore` \u002F `spaceAfter` |\n| Row-level `set` for cell formatting | Row `set` only supports `height`, `header`, `c1..cN` text; format goes on the cell paragraph \u002F run |\n| `listStyle` on a run | It's a paragraph property |\n| Indent via leading spaces | `indent=720` \u002F `firstLineIndent=360` \u002F `hangingIndent=720` (dotted `ind.left` \u002F `ind.firstLine` also work) |\n| Cover page-number suppression via `set differentFirstPage=true` | UNSUPPORTED — add a first-type footer: `--type footer --prop type=first --prop text=\"\"` |\n| Need a fresh chapter page | Use `pageBreakBefore=true` on the heading; use an explicit `pagebreak` only as an alternative, never both |\n| Multiple bullet paragraphs in one cell | `c1=\"a\\nb\"` makes a `\u003Cw:br\u002F>` line break (one paragraph); for separate bullet paragraphs use recipe (e) |\n| `raw-set` when dotted-attr would work | Prefer L2 dotted-attr over L3 raw-set |\n| Next paragraph inherits the previous Heading style | Set explicit `--prop style=Normal` on the following paragraph |\n| Modifying a file open in Word | Close it in Word first |\n| Echo into batch breaks on `$`\u002F`'` | Heredoc with single-quoted delimiter: `cat \u003C\u003C'EOF' \\| officecli batch …` |\n\n## Raw-set XML appendix (L3 patterns)\n\n`raw-set` injects literal OOXML — no schema protection. Element order in `\u003Cw:pPr>`: `pStyle`, `numPr`, `spacing`, `ind`, `jc`, `rPr` (last). Smart quotes as entities (`&#x2018;`\u002F`&#x2019;`\u002F`&#x201C;`\u002F`&#x201D;`). Add `xml:space=\"preserve\"` to any `\u003Cw:t>` with leading\u002Ftrailing spaces. RSIDs are 8-digit hex. Use \"Claude\" as the author for tracked changes\u002Fcomments unless the user names another.\n\n**Tracked-change insertion \u002F deletion** — prefer the high-level `--prop revision.type=ins|del` on a run; raw-set only for what the typed path can't express (rejecting\u002Frestoring another author's change, below). Replace the whole `\u003Cw:r>…\u003C\u002Fw:r>`, never inject tags inside a run; copy the original `\u003Cw:rPr>` into both to preserve formatting. Inside `\u003Cw:del>` use `\u003Cw:delText>` (and `\u003Cw:delInstrText>` for instructions):\n\n```xml\n\u003Cw:r>\u003Cw:t>The term is \u003C\u002Fw:t>\u003C\u002Fw:r>\n\u003Cw:del w:id=\"1\" w:author=\"Claude\" w:date=\"2026-01-01T00:00:00Z\">\u003Cw:r>\u003Cw:delText>30\u003C\u002Fw:delText>\u003C\u002Fw:r>\u003C\u002Fw:del>\n\u003Cw:ins w:id=\"2\" w:author=\"Claude\" w:date=\"2026-01-01T00:00:00Z\">\u003Cw:r>\u003Cw:t>60\u003C\u002Fw:t>\u003C\u002Fw:r>\u003C\u002Fw:ins>\n\u003Cw:r>\u003Cw:t> days.\u003C\u002Fw:t>\u003C\u002Fw:r>\n```\n\nWhen deleting ALL content of a paragraph\u002Flist item, also mark the paragraph mark deleted (`\u003Cw:del\u002F>` inside `\u003Cw:pPr>\u003Cw:rPr>`) — otherwise accepting changes leaves an empty paragraph. To **reject another author's insertion**, nest your `\u003Cw:del>` inside their `\u003Cw:ins>`; to **restore their deletion**, add a `\u003Cw:ins>` after it (don't modify theirs).\n\n**Internal hyperlink to a bookmark** (prefer the high-level `--prop anchor=` path; raw-set only for custom run styling the command can't express):\n\n```xml\n\u003Cw:hyperlink w:anchor=\"chapter1\">\u003Cw:r>\u003Cw:rPr>\u003Cw:rStyle w:val=\"Hyperlink\"\u002F>\u003C\u002Fw:rPr>\u003Cw:t>See Chapter 1\u003C\u002Fw:t>\u003C\u002Fw:r>\u003C\u002Fw:hyperlink>\n```\n\n**Composite field in one run** (e.g. two fields the single-command path can't compose) — the `fldChar begin \u002F instrText \u002F separate \u002F value \u002F end` chain:\n\n```xml\n\u003Cw:r>\u003Cw:fldChar w:fldCharType=\"begin\"\u002F>\u003C\u002Fw:r>\n\u003Cw:r>\u003Cw:instrText xml:space=\"preserve\"> PAGE \u003C\u002Fw:instrText>\u003C\u002Fw:r>\n\u003Cw:r>\u003Cw:fldChar w:fldCharType=\"separate\"\u002F>\u003C\u002Fw:r>\n\u003Cw:r>\u003Cw:t>1\u003C\u002Fw:t>\u003C\u002Fw:r>\n\u003Cw:r>\u003Cw:fldChar w:fldCharType=\"end\"\u002F>\u003C\u002Fw:r>\n```\n\n**Comment markers** are siblings of `\u003Cw:r>`, NEVER inside one (reply threading and resolved-state are high-level — `--prop parentId=`\u002F`done=`, see Comments above):\n\n```xml\n\u003Cw:commentRangeStart w:id=\"0\"\u002F>\u003Cw:r>\u003Cw:t>annotated text\u003C\u002Fw:t>\u003C\u002Fw:r>\u003Cw:commentRangeEnd w:id=\"0\"\u002F>\n\u003Cw:r>\u003Cw:rPr>\u003Cw:rStyle w:val=\"CommentReference\"\u002F>\u003C\u002Fw:rPr>\u003Cw:commentReference w:id=\"0\"\u002F>\u003C\u002Fw:r>\n```\n\nForce field recalc on open with `officecli set \"$FILE\" \u002Fsettings --prop updateFields=true` (writes `\u003Cw:updateFields w:val=\"true\"\u002F>`; covers the layout-dependent fields PAGE \u002F PAGEREF \u002F NUMPAGES \u002F TOC page numbers — no raw-set needed). For SEQ numbering, prefer `set \u002F --prop recalcFields=seq`, which writes correct cached values now without waiting on Word.\n\n### Help pointer\n\nWhen in doubt: `officecli help docx`, `officecli help docx \u003Celement>`, `officecli help docx \u003Cverb> \u003Celement>`, `--json` for agents. Help is the authoritative schema; this skill is the decision guide.\n","# OfficeCLI DOCX Skill\n\n## Setup\n\nIf `officecli` is missing:\n\n- **macOS \u002F Linux**: `curl -fsSL https:\u002F\u002Fd.officecli.ai\u002Finstall.sh | bash`\n- **Windows (PowerShell)**: `irm https:\u002F\u002Fd.officecli.ai\u002Finstall.ps1 | iex`\n\nVerify with `officecli --version` (open a new terminal if PATH hasn't picked up). If install fails, download a binary from https:\u002F\u002Fgithub.com\u002FiOfficeAI\u002FOfficeCLI\u002Freleases.\n\n## ⚠️ Help-First Rule\n\n**This skill teaches what good docx looks like, not every command flag. When a property name, enum value, or alias is uncertain, consult help BEFORE guessing.**\n\n```bash\nofficecli help docx                         # List all docx elements\nofficecli help docx \u003Celement>               # Full element schema (e.g. paragraph, field, numbering, watermark, toc)\nofficecli help docx \u003Cverb> \u003Celement>        # Verb-scoped (e.g. add field, set section)\nofficecli help docx \u003Celement> --json        # Machine-readable schema\n```\n\nHelp is pinned to the installed CLI version. When this skill and help disagree, **help is authoritative**.\n\n## Mental Model\n\nA `.docx` is a ZIP of XML parts (`document.xml`, `styles.xml`, `numbering.xml`, `header*.xml`, `footer*.xml`, `comments.xml`, …). Everything the user sees — headings, tables, page numbers, TOC, tracked changes — is XML inside that ZIP. `officecli` gives you a semantic-path API (`\u002Fbody\u002Fp[1]\u002Fr[2]`) over it, so you almost never touch raw XML; when you must, use `raw-set` (see the XML appendix).\n\n## Shell & Execution Discipline\n\ndocx paths contain `[]`; some prop values contain `$`. Both are shell metacharacters. Escaping happens at three layers — keep them separate.\n\n1. **Shell.** ALWAYS quote element paths: `\"\u002Fbody\u002Fp[1]\"`, not `\u002Fbody\u002Fp[1]` (zsh\u002Fbash glob `[N]`). Single-quote any value containing `$`: `--prop text='$50M'` — at any length, the whole value inside one pair of single quotes. Unquoted `$50M` is stripped to `M`; mixing `'…$var…'` and `\"…$50…\"` on one long string is where the `$50` silently vanishes.\n2. **CLI (`text=`).** The two-char escapes `\\n` and `\\t` ARE interpreted in `--prop text=` — `\\n` becomes a `\u003Cw:br\u002F>` soft line break, `\\t` a `\u003Cw:tab\u002F>` — consistently across docx \u002F pptx \u002F xlsx. Double them (`\\\\n`) for a literal backslash-n (rarely wanted). This applies to row-level table `c1…cN` shortcuts too (`\\n` → `\u003Cw:br\u002F>` within the cell).\n3. **JSON (batch).** A real newline can also be passed as `\"\\n\"` in the JSON string of a `batch` heredoc; same result.\n\nIf in doubt, `view text` after writing and compare character-for-character.\n\n**Incremental execution.** `officecli` mutates the file on every call. Run commands one at a time and check each exit code — a 50-command script that fails at command 3 cascades silently. After any structural op (new style, table, TOC, section break) run `get` on it before stacking more.\n\n**Open\u002Fsave lifecycle:** `officecli open \u003Cfile>` at the start, `officecli save \u003Cfile>` at the end to flush to disk — `save` only writes and leaves the resident warm for follow-up edits; reach for `officecli close \u003Cfile>` only to release the resident on a one-shot handoff. Both are always safe (never error or lose work). For many paragraphs of one style, use `batch` (one pass for the whole array). **Flush only at the non-officecli boundary:** officecli's own reads always see your edits; run `save`\u002F`close` only before a non-officecli program reads the file (python-docx, Word, a renderer, delivery).\n\n**`$FILE` convention.** All commands use `\"$FILE\"` — set it once (`FILE=\"your-doc.docx\"`). Never copy a literal `doc.docx` \u002F `review.docx` into output — always substitute your actual target.\n\n## Requirements for Outputs\n\nDeliverable standards every document MUST meet — know these before reaching for a command.\n\n**Clear hierarchy.** Every non-trivial document has Title → Heading 1 → Heading 2 → body, not a wall of unstyled `Normal` paragraphs. If `view outline` shows one flat list, the hierarchy is missing.\n\n**Explicit heading sizes** (Word default style sizes drift between templates): **H1 ≥ 18pt** (20pt for long reports), H2 = 14pt bold, H3 = 12pt bold, body = 11–12pt, line spacing 1.15–1.5x. Prefer `style=Heading1` over inline sizes so a retheme touches the definition once — but set explicit sizes when you can't trust the template's styles.\n\n**One body font, one accent.** One readable body font (Calibri, Cambria, Georgia, Times New Roman); accent color for heading emphasis or table headers, not rainbow formatting.\n\n**Spacing through properties.** Use `spaceBefore` \u002F `spaceAfter` on paragraphs. Rows of empty paragraphs break pagination and are flagged by `view issues`.\n\n**Typographic quality.** New content uses curly quotes (`'` `'` `\"` `\"`), not ASCII — Unicode directly or XML entities (`&#x2018;`\u002F`&#x2019;`\u002F`&#x201C;`\u002F`&#x201D;`) inside `raw-set`. En-dash `–` for ranges (`2024–2026`), em-dash `—` for parenthetical breaks.\n\n**Headers, footers, page numbers on any document > 1 page.** Page numbers go through a live `PAGE` field (`--prop field=page`), never the literal text \"Page 1\" — the CLI injects `\u003Cw:fldChar>` for you (see Headers & Footers).\n\n**Preserve existing templates.** When editing a file that already has a look, match it — existing conventions override these guidelines.\n\n### Visual delivery floor (applies to EVERY document)\n\nBefore declaring done, run `officecli view \"$FILE\" html` and Read the returned HTML path to confirm ALL of these:\n\n- **No placeholder tokens rendered as data.** `$xxx$`, `{var}`, `{{name}}`, `\u003CTODO>`, `lorem`, `xxxx` must never appear in a heading, body, cover, TOC, caption, header, or footer. A literal `{name}` meant for a human to fill belongs inside a visible instruction paragraph (\"Replace `{name}` before sending\"), never as finished content.\n- **No truncated titles or overflowing cells.** Widen the column or set `wrapText` rather than trimming content.\n- **TOC present when the document has 3+ headings** (`--type toc`).\n- **Cover page ≥ 60% filled, last page ≥ 40% filled.** Pad a thin cover with subtitle \u002F author \u002F date \u002F scope \u002F key highlights; pad a \"Thank you\" last page with conclusion \u002F next steps \u002F contact \u002F legal.\n- **No `\\$`, `\\t`, `\\n` literals in document text.** If `view text` shows these, a shell-escape layer leaked — delete the paragraph and re-enter it.\n\nIf any fails, STOP and fix before declaring done.\n\n## Common Workflow\n\nSix steps. Every non-trivial build follows this shape.\n\n1. **Open the file.** `officecli open \"$FILE\"` (resident default). New file: `officecli create \"$FILE\"` first.\n2. **Orient.** Existing file: `officecli view \"$FILE\" outline` — heading tree, section count, whether a TOC \u002F watermark \u002F tracked changes already exist. Never edit blind.\n3. **Build incrementally.** Structural first, content next, formatting last: styles & numbering defs → sections \u002F page setup → headings & body → tables \u002F images \u002F fields \u002F TOC → headers \u002F footers → comments. After each structural op, `get` it back before stacking on top.\n4. **Format to spec.** Explicit heading sizes, spacing, widths, alignment, tabs, list indents — formatting is part of the deliverable, not optional polish.\n5. **Save, then trust structure over cached text.** `officecli save \"$FILE\"` writes the XML. TOC \u002F PAGE \u002F NUMPAGES \u002F SEQ \u002F PAGEREF fields carry **cached values** that may be stale or empty until a human recalculates (F9 in Word). Confirm fields *exist* (`get --depth 3` finds `\u003Cw:fldChar>`) rather than trusting the visible text.\n6. **QA — assume there are problems.** You are done after one fix-and-verify cycle finds zero new issues, not when your last command exited 0. See QA.\n\n## Quick Start\n\nMinimal viable docx: a heading, a body paragraph, a subheading, and a footer with a live page-number field. Adapt, don't copy-paste — your file, your content.\n\n```bash\nFILE=\"review.docx\"\nofficecli create \"$FILE\"\nofficecli open \"$FILE\"\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Q4 2026 Review\" --prop style=Heading1 --prop size=20pt --prop bold=true --prop spaceAfter=12pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Revenue grew 18% year-over-year, ahead of plan.\" --prop size=11pt --prop spaceAfter=8pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Key Drivers\" --prop style=Heading2 --prop size=14pt --prop bold=true --prop spaceBefore=12pt --prop spaceAfter=6pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Enterprise renewals, upsell, and a new EMEA region.\" --prop size=11pt\nofficecli add \"$FILE\" \u002F --type footer --prop type=default --prop size=9pt --prop text=\"Page \" --prop field=page\nofficecli set \"$FILE\" \"\u002Ffooter[1]\u002Fp[1]\" --prop align=center\nofficecli save \"$FILE\"\nofficecli validate \"$FILE\"\n```\n\nVerified: `validate` returns `no errors found`; `get \u002Ffooter[1] --depth 3` shows the 5-run PAGE field chain (begin \u002F instrText \u002F separate \u002F cached value \u002F end).\n\n## Reading & Analysis\n\nStart wide, then narrow. `outline` tells you what's already there; jump into `view text` \u002F `get` \u002F `query` once you know where to look.\n\n```bash\nofficecli view \"$FILE\" outline            # heading tree, section count, table\u002Fimage counts, watermark, tracked-changes presence — orient here first\nofficecli view \"$FILE\" html               # Read the returned HTML path: first visual check after a batch of edits (hierarchy, empty-para spacing, missing TOC)\nofficecli view \"$FILE\" text --start 1 --end 80   # text for content QA; paths shown as [\u002Fbody\u002Fp[N]] so you can jump back with get\nofficecli view \"$FILE\" annotated          # values + style\u002Ffont\u002Fsize + warnings per run\nofficecli view \"$FILE\" stats              # paragraph counts, font usage, style distribution\nofficecli view \"$FILE\" issues             # empty paras, missing alt text, spacing anomalies\n```\n\n`officecli watch \"$FILE\"` keeps a live preview running for the human user to open at their discretion — agent self-check uses `view html`. Final visual verification is the user opening the `.docx` in Word \u002F WPS \u002F Pages.\n\n**Inspect one element.** XPath-style semantic paths (1-based). Always quote — shells glob `[N]`. Use `[last()]` (with parens) for the last element; `[last]` errors. Add `--json` for machine output.\n\n```bash\nofficecli get \"$FILE\" \u002F                          # document root: metadata, page setup\nofficecli get \"$FILE\" \"\u002Fbody\u002Fp[1]\"                # one paragraph\nofficecli get \"$FILE\" \"\u002Fbody\u002Fp[1]\u002Fr[1]\"           # one run (character-level formatting)\nofficecli get \"$FILE\" \"\u002Fbody\u002Ftbl[1]\" --depth 3    # table with rows and cells\nofficecli get \"$FILE\" \"\u002Ffooter[1]\" --depth 3      # footer — check for fldChar\nofficecli get \"$FILE\" \"\u002Fstyles\u002FHeading1\"          # style definition\nofficecli get \"$FILE\" \u002Fnumbering --depth 2        # numbering abstractNum + num bindings\n```\n\n**Query across the document.** CSS-like selectors, for systematic checks rather than hand-walking. Operators: `=`, `!=`, `~=` (contains), `>=`, `\u003C=`, `[attr]` (exists). Full reference: `officecli query --help`.\n\n```bash\nofficecli query \"$FILE\" 'paragraph[style=Heading1]'       # all H1s\nofficecli query \"$FILE\" 'p:contains(\"quarterly\")'         # text match\nofficecli query \"$FILE\" 'p:empty'                         # empty paragraphs (clutter)\nofficecli query \"$FILE\" 'image:no-alt'                    # accessibility gaps\nofficecli query \"$FILE\" 'paragraph[size>=24pt]'           # numeric comparison\nofficecli query \"$FILE\" 'field[fieldType!=page]'          # fields other than PAGE\n```\n\n`query --json` wraps results in `.data.results[]` — `jq '.data.results | length'` to count.\n\n**Large documents.** Navigate by heading with `view outline` and jump with `query`; don't dump the whole body into context.\n\n## Creating & Editing\n\nVerbs: `add` (new element), `set` (change a prop), `remove`, `move`, `swap`, `batch`, `raw-set` (last-resort XML). Ninety percent of a build is paragraphs, runs, tables, a couple of images, a TOC, and a footer.\n\n### Paragraphs, runs, styles\n\nA paragraph (`p`) is a block; a run (`r`) is a span of consistent character formatting inside it. Set paragraph-level props (style, alignment, spacing, indent) on the `p`; set font \u002F size \u002F color \u002F bold on the `r`.\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Executive Summary\" --prop style=Heading1 --prop size=18pt --prop bold=true --prop spaceAfter=12pt\nofficecli set \"$FILE\" \"\u002Fbody\u002Fp[1]\u002Fr[1]\" --prop color=1F4E79\n```\n\nUse `spaceBefore` \u002F `spaceAfter` for vertical spacing — never chains of empty paragraphs. For left indent use `--prop indent=720` (twips), `firstLineIndent=360` for first line, `hangingIndent=720` for hanging; leading spaces fire `view issues`.\n\n### Tables\n\nTables are `\u002Fbody\u002Ftbl[N]` with rows `tr[N]` and cells `tc[N]`. Add with row\u002Fcolumn counts, then fill.\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type table --prop rows=4 --prop cols=3 --prop width=100%\nofficecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\" --prop header=true --prop c1=Quarter --prop c2=\"Revenue\" --prop c3=\"Growth\"\nofficecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\u002Ftc[1]\u002Fp[1]\u002Fr[1]\" --prop bold=true\n```\n\nRow-level `set` supports `height`, `header`, and `c1 \u002F c2 \u002F … \u002F cN` text shortcuts (`cN` generalises to any column count). Cell formatting (bold, fill, color) goes on the cell's paragraph \u002F run — **not** row-level. For per-cell borders, set cell-level `border.*` on the `tc` (`--prop border.bottom=\"single;6;000000;0\"`), or paragraph-level `pbdr.*` on the inner paragraph.\n\n**Horizontal rule = a paragraph bottom border, never a 1-row table.** A table-as-divider renders as an empty min-height box (worst in headers\u002Ffooters). Use `pbdr.bottom` (`STYLE;SIZE;COLOR`) on the paragraph instead:\n\n```bash\nofficecli set \"$FILE\" \"\u002Fbody\u002Fp[3]\" --prop pbdr.bottom=\"single;6;2E75B6\"\n```\n\n### Lists (bullets, numbered, multi-level)\n\nFor single-level bullets\u002Fnumbers, set `listStyle` on the paragraph (`listStyle` is a paragraph prop, NOT a run prop — common mistake):\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"First item\" --prop listStyle=bullet\n```\n\nFor multi-level (legal-style 1 \u002F 1.1 \u002F 1.1.1), add an `abstractNum`, then a `num`, then reference the `numId` per paragraph:\n\n```bash\nofficecli add \"$FILE\" \u002Fnumbering --type abstractnum --prop format=decimal     # → abstractNum id=0\nofficecli add \"$FILE\" \u002Fnumbering --type num --prop abstractNumId=0             # → num id=1\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Section one\" --prop numId=1 --prop ilvl=0\n```\n\nIDs are 0-based: the first `abstractNum` is id=0; the `num` references it via `abstractNumId=0` and is itself assigned id=1. A non-existent `abstractNumId` errors, so check ids after creating. Verify with `officecli query \"$FILE\" 'paragraph[numId>0]'`. See `help docx abstractnum` \u002F `help docx num` for level and format options.\n\n### Tab stops (signature lines, leader rows)\n\nTab stops are a first-class `tab` child of the paragraph; `pos` accepts `6in`\u002F`6cm`\u002Ftwips, `val` ∈ `left`\u002F`center`\u002F`right`, `leader` ∈ `none`\u002F`dot`\u002F`hyphen`\u002F`underscore`. See `help docx tab`.\n\n```bash\nofficecli add \"$FILE\" \"\u002Fbody\u002Fp[1]\" --type tab --prop pos=6in --prop val=right --prop leader=dot\n```\n\n**Leader caveat.** `leader=dot` alone emits no dots — the leader renders only when a real `\u003Cw:tab\u002F>` character sits in a run between the text and the tab stop. Put one there with `\\t` in the text: define the stop (`add tab --prop pos=6in --prop val=right --prop leader=dot`), then `--prop text=\"Chapter 1\\t12\"` — the `\\t` becomes the `\u003Cw:tab\u002F>` and dots fill to the right-aligned page number. (Literal `text=\"Chapter 1 ......... 12\"` also ships, but a real tab stop aligns cleanly.)\n\n### Fields (PAGE \u002F NUMPAGES \u002F DATE \u002F MERGEFIELD \u002F REF)\n\nFields are live values computed at render time. `fieldType` picks the field; `name` supplies the target (merge name or `ref` bookmark); `format` \u002F `instr` add switches.\n\n| Field | Use | Example |\n|---|---|---|\n| `page` | current page number | `--prop field=page` on footer, or `--prop fieldType=page` inline |\n| `numpages` | total pages | `--prop field=numpages` \u002F `--prop fieldType=numpages` |\n| `date` | today | `--prop fieldType=date --prop format='yyyy-MM-dd'` |\n| `mergefield` | template merge token | `--prop fieldType=mergefield --prop name=CustomerName` |\n| `ref` | cross-reference to a bookmark | `--prop fieldType=ref --prop name=bookmarkName` |\n\nFull `fieldType` enum (30+ values incl. `pageref`, `seq`, `styleref`, `docproperty`, `createdate`, …) is in `help docx field`. **There is NO `fieldInstr` fieldType** — use the `instruction` prop for raw field instruction text when typed shortcuts fall short. Picture switches (`MERGEFIELD Amount \\# \"#,##0.00\"`, `DATE \\@ \"yyyy年MM月\"`) go via `--prop instruction='…'` (mergefield's `format` prop is ignored with a warning — use `instruction`).\n\n```bash\nofficecli add \"$FILE\" \"\u002Fbody\u002Fp[3]\" --type field --prop fieldType=mergefield --prop name=customer_name\n# Renders «customer_name» — visible placeholder, replaced in Word at mail-merge time.\n```\n\n**MERGEFIELD templates: never render placeholder literals.** A `{{customer_name}}` or `$NAME$` shown as body text is a failed template the recipient sees — insert a real MERGEFIELD (above), or confine literal tokens to an obvious instruction paragraph. Confirm with `query 'field[fieldType=mergefield]'`.\n\n**SEQ \u002F PAGEREF \u002F TOC field values.** officecli doesn't store rendered field values at write time. Recompute by what each path needs:\n\n- **SEQ numbering** (`Figure 1\u002F2\u002F3`): `officecli set \"$FILE\" \u002F --prop recalcFields=seq` counts SEQ fields in body document order and writes the cached values (`evaluated` flips true; switches\u002Fformats in `help docx document`). Heading-relative `\\s` and SEQ in headers\u002Ffooters defer to Word.\n- **PAGE \u002F PAGEREF \u002F NUMPAGES \u002F TOC page numbers** need pagination, which officecli has no engine for — `officecli set \"$FILE\" \u002Fsettings --prop updateFields=true` defers them to Word on open.\n\nUse both on a multi-figure document. Academic papers: see the `officecli-academic-paper` skill.\n\n### Headers & Footers (page numbering)\n\nSingle-command pattern — the CLI injects `\u003Cw:fldChar>`, so you never compose the field by hand:\n\n```bash\n# Empty first-page footer — auto-enables differentFirstPage so the cover has no page number\nofficecli add \"$FILE\" \u002F --type footer --prop type=first --prop text=\"\"\n# Default footer with live page number\nofficecli add \"$FILE\" \u002F --type footer --prop type=default --prop align=center --prop size=9pt --prop text=\"Page \" --prop field=page\n```\n\nWhen both exist, the default footer is `\u002Ffooter[2]`; alone it is `\u002Ffooter[1]`. **Verify**: `get --depth 3` must show `fldChar` children, not just a run with literal `\"Page\"` (`view outline` prints \"Footer: Page\" for both live fields AND static text — don't rely on it). Do NOT `set --prop differentFirstPage=true` — that prop is unsupported (rejected with exit 2, not silently); adding a first-type footer flips the bit. For composite **Page X of Y**, see recipe (b).\n\n### Table of Contents\n\nFor any document with 3+ headings, first verify that the requested range has real sources. A TOC source must use a built-in Heading style or a custom paragraph style with `outlineLvl`; bold or large Normal text is not a source. If no eligible source exists, stop and fix the heading structure instead of inserting a TOC that renders \"Error! No table of contents entries found.\"\n\n```bash\n# Built-in Heading styles are TOC sources.\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Introduction\" --prop style=Heading1\n# Custom paragraph styles need an outline level (0 = Heading 1).\nofficecli add \"$FILE\" \u002Fstyles --type style --prop id=ThesisH1 --prop type=paragraph --prop outlineLvl=0\n# Add the TOC only after its sources exist.\nofficecli add \"$FILE\" \u002Fbody --type toc --prop levels=\"1-3\" --prop title=\"Table of Contents\" --prop hyperlinks=true --index 0\n```\n\nPage numbers need pagination; OfficeCLI cannot calculate TOC page numbers itself. Set `updateFields=true` so Word recomputes the TOC (and all fields) on open. Without a Word-compatible field engine, report the TOC as dynamic and uncomputed; do not claim ready page numbers or guess a static TOC.\n\n```bash\nofficecli set \"$FILE\" \u002Fsettings --prop updateFields=true\n```\n\nAddress the TOC directly with `\u002Ftoc[1]` or `\u002Ftableofcontents` for `get`\u002F`set`\u002F`remove`.\n\n### Images\n\nPictures go inside a run. Alt text is mandatory for accessibility — pass `alt` directly at create time:\n\n```bash\nofficecli add \"$FILE\" \"\u002Fbody\u002Fp[5]\" --type picture --prop src=logo.png --prop width=1.5in --prop alt=\"Acme logo\"\n```\n\nConfirm `officecli query \"$FILE\" 'image:no-alt'` is empty before delivery.\n\n### Charts\n\nFor data, add a **native chart** — editable, themeable, accessible, re-renders in Word — never a flat PNG screenshot of a chart. `data=\"Label:v1,v2,…\"` per series; one `data=` per series (or `series1=`\u002F`series2=`).\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type chart --prop chartType=bar --prop title=\"Revenue by Region\" --prop categories=\"EMEA,APAC,Americas\" --prop data=\"2026:120,150,180\"\n```\n\n`chartType` ∈ bar \u002F column \u002F line \u002F pie \u002F area \u002F scatter (`help docx chart` for axis\u002Flegend\u002Fseries styling). A PNG via `--type picture` is only a fallback for an exotic chart officecli can't build.\n\n### Hyperlinks and bookmarks\n\nExternal links go via `hyperlink`:\n\n```bash\nofficecli add \"$FILE\" \"\u002Fbody\u002Fp[2]\" --type hyperlink --prop url=\"https:\u002F\u002Fexample.com\" --prop text=\"our site\"\n```\n\n**Internal links** (to a bookmark) use `--prop anchor=bookmarkName` — not a `#fragment` in `url`:\n\n```bash\nofficecli add \"$FILE\" \"\u002Fbody\u002Fp[2]\" --type hyperlink --prop anchor=chapter1 --prop text=\"See Chapter 1\"\n```\n\nPairing a `PAGEREF` field with visible text is the alternative. See `help docx hyperlink` \u002F `help docx bookmark`.\n\n### Sections and page setup\n\nDocument root `\u002F` carries page setup (`pageWidth`, `pageHeight`, margins, in twips). Multi-section documents (landscape insert, columns) add a `section` break — see `help docx section`. Both camelCase (`pageWidth`, canonical) and lowercase alias (`pagewidth`) are accepted; prefer camelCase.\n\n```bash\nofficecli set \"$FILE\" \u002F --prop pageWidth=12240 --prop pageHeight=15840 --prop marginTop=1440 --prop marginLeft=1440\n# Newspaper-style multi-column flow (columnSpace in twips; 720 = 0.5in):\nofficecli set \"$FILE\" \u002F --prop columns=2 --prop columnSpace=720\n```\n\n### Forcing page breaks\n\nUse exactly one page-break mechanism per logical boundary. The default is `pageBreakBefore=true` on the target heading. Alternatively, insert one explicit `pagebreak` before the heading. Never combine both mechanisms for the same boundary: the resulting double break can create a blank page. Never set `pageBreakBefore` on `p[last()]` immediately after adding a `pagebreak`.\n\n```bash\n# Default: apply the break directly to the heading.\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Introduction\" --prop style=Heading1 --prop pageBreakBefore=true\n```\n\n`--prop break=newPage` is an alias for `pageBreakBefore=true`. Preview with `view html` and check for blank pages.\n\n### Report-level recipes\n\nPatterns that come up on every long-form report. Each has been executed and `validate`-passed.\n\n**(a) Rich cover page — hit the ≥ 60% filled floor.** Stack a confidentiality banner, title, subtitle, client\u002Fproject\u002Fdate block, and a key-themes strip, then force the next section onto a new page:\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"CONFIDENTIAL — CLIENT USE ONLY\" --prop align=center --prop size=9pt --prop color=C00000 --prop spaceAfter=24pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Strategic Growth Review\" --prop style=Title --prop size=32pt --prop bold=true --prop align=center --prop font=Cambria --prop spaceAfter=8pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"FY26 Outlook and Scenario Planning\" --prop italic=true --prop size=16pt --prop align=center --prop spaceAfter=36pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text='Prepared for: Acme Corp. Leadership Team' --prop align=center --prop size=11pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text='Engagement: 2026-04 — 2026-06' --prop align=center --prop size=11pt --prop spaceAfter=36pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Key themes: 1) margin resilience, 2) EMEA expansion, 3) capital allocation.\" --prop align=center --prop italic=true --prop size=10pt\nofficecli add \"$FILE\" \u002Fbody --type paragraph --prop text=\"Executive Summary\" --prop style=Heading1 --prop pageBreakBefore=true\n```\n\n**(b) Page X of Y footer — composite PAGE + NUMPAGES.** Add the footer paragraph, then three child ops build `Page \u003CX> of \u003CY>` live. The official `help docx footer` recipe.\n\n```bash\nofficecli add \"$FILE\" \u002F --type footer --prop type=default --prop text=\"Page \" --prop align=center --prop size=9pt\nofficecli add \"$FILE\" \"\u002Ffooter[1]\u002Fp[1]\" --type field --prop fieldType=page\nofficecli add \"$FILE\" \"\u002Ffooter[1]\u002Fp[1]\" --type run --prop text=\" of \"\nofficecli add \"$FILE\" \"\u002Ffooter[1]\u002Fp[1]\" --type field --prop fieldType=numpages\nofficecli get \"$FILE\" \"\u002Ffooter[1]\u002Fp[1]\" --depth 1 | grep -o fldChar | wc -l   # expect ≥ 4; use grep -o ... | wc -l, NOT grep -c (single-line XML returns 1)\n```\n\n**(c) Header row with fill and white bold text.** Order matters — populate header cell text FIRST (runs don't exist in empty cells; a `set …\u002Ftc[N]\u002Fp[1]\u002Fr[1]` on an empty cell errors \"No r found\"), THEN cell fill, THEN run formatting:\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type table --prop rows=5 --prop cols=4 --prop width=100%\nofficecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\" --prop header=true --prop c1=Quarter --prop c2=Revenue --prop c3=Growth --prop c4=Status\nfor col in 1 2 3 4; do\n  officecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\u002Ftc[$col]\" --prop fill=1F4E79\n  officecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\u002Ftc[$col]\u002Fp[1]\u002Fr[1]\" --prop bold=true --prop color=FFFFFF\ndone\nfor row in 3 5; do for col in 1 2 3 4; do\n  officecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[$row]\u002Ftc[$col]\" --prop fill=D9E2F3      # zebra stripe\ndone; done\n```\n\n**(d) Financial table — right-align numbers, bold totals, bottom border on total row.**\n\n```bash\nfor row in 2 3 4 5; do for col in 2 3 4; do\n  officecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[$row]\u002Ftc[$col]\u002Fp[1]\" --prop align=right\ndone; done\nfor col in 1 2 3 4; do\n  officecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[5]\u002Ftc[$col]\u002Fp[1]\u002Fr[1]\" --prop bold=true\n  officecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[4]\u002Ftc[$col]\u002Fp[1]\" --prop pbdr.bottom=\"single;6;000000;0\"\ndone\n```\n\n**(e) Cell with multiple bullets (SWOT \u002F risk matrix).** `c1=\"a\\nb\"` gives a `\u003Cw:br\u002F>` line break within **one** paragraph — fine for plain multi-line text, but bullets need separate paragraphs. Seed the first via `set c1=`, then `add paragraph` (with `listStyle=bullet`) under the cell per subsequent bullet:\n\n```bash\nofficecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\" --prop c1=\"Installed base of 18k enterprise seats\"\nofficecli add \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\u002Ftc[1]\" --type paragraph --prop text=\"Margin structure above peer median\" --prop listStyle=bullet\nofficecli set \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\u002Ftc[1]\u002Fp[1]\" --prop listStyle=bullet\n```\n\nIf the seeded line lands at the bottom, re-order: `officecli move \"$FILE\" \"\u002Fbody\u002Ftbl[1]\u002Ftr[1]\u002Ftc[1]\u002Fp[N]\" --index 0`.\n\n**(f) TOC without a field engine.** A CLI-only pipeline cannot calculate reliable page numbers. Keep the live TOC, set `updateFields=true`, and tell the recipient to open the document in Word or another compatible field engine. Do not replace it with guessed static page numbers.\n\n### Template delivery — separating Template Notes from end-user content\n\nHR \u002F legal \u002F vendor templates carry internal-only guidance (\"replace `{{CompanyName}}`\") that must NOT ship. Two working patterns:\n\n- **Trailing \"Template Notes\" section** under a clear `Heading 1` (\"Template Notes for HR Users\") with all instructions below it; before distribution, `remove` from the heading downward (locate with `query 'paragraph[style=Heading1]:contains(\"Template Notes\")'`).\n- **Bookmark-bounded internal section** between `__template_notes_start` \u002F `_end` bookmarks; at delivery `raw-set` removes everything between the anchors.\n\nDelivery gate for templates: after removal, `query 'p:contains(\"Template Notes\")'` AND `query 'p:contains(\"{{\")'` both return empty. If a notes paragraph survives, a downstream employee reads internal language.\n\n### Advanced \u002F specialty topics (skip if you are writing a report)\n\nReports, memos, letters, proposals, and HR templates don't need this. Keep reading only if your document is academic (equations, footnotes, bibliography), reviewed (comments, tracked changes), or marked (watermark).\n\n**Equations and footnotes.** `--type equation` takes LaTeX — `\\frac`, `\\sum`, Greek, `\\mathit`, `\\mathcal` all render. By default it creates a standalone `\u002Fbody\u002FoMathPara[N]` display block; pass `--prop mode=inline` with a paragraph parent path (`add \"\u002Fbody\u002Fp[N]\" --type equation --prop formula=… --prop mode=inline`) to drop an inline `\u003Cm:oMath>` into running text. Footnotes auto-number by paragraph index. Bibliography hanging indent: `firstLineIndent=-720 indent=720` per entry.\n\n```bash\nofficecli add \"$FILE\" \u002Fbody --type equation --prop formula=\"\\\\frac{a}{b} + \\\\sum_{i=1}^{n} x_i\"\nofficecli add \"$FILE\" \"\u002Fbody\u002Fp[3]\" --type footnote --prop text=\"See Appendix A for methodology.\"\n```\n\n**Comments and tracked changes.** Bulk accept\u002Freject: `set \"$FILE\" \u002Frevision --prop revision.action=accept` (or `--prop revision.action=reject`); narrow with a selector like `\u002Frevision[@author=Alice]` or `\u002Frevision[@type=ins]`. Locate individual changes with `query ins` and `query del` (`trackedchange` is not a selector). Create tracked changes on a run with `--prop revision.type=ins|del --prop revision.author=…` (`help docx run` for the full `revision.*` set — `format`\u002F`moveFrom`\u002F`moveTo` too). Add a comment: `add \"\u002Fbody\u002Fp[4]\" --type comment --prop author=… --prop text=…`; reply-thread it with `--prop parentId=N` and mark it resolved with `set \"\u002Fcomments\u002Fcomment[N]\" --prop done=true` (resolve rather than delete to keep the audit trail — `query 'comment[done=false]'` then lists what's still open). Prop schema: `help docx comment` \u002F `help docx run`.\n\n**Watermark.** `add \u002F --type watermark --prop text=\"DRAFT\" --prop color=BFBFBF --prop opacity=0.8` in one command (default opacity 0.5); `set \u002Fwatermark --prop opacity=…` adjusts it later.\n\n**When to switch skills.** Stay in docx for chapter drafts, ≤ 3 footnotes, ≤ 2 equations, no bibliography\u002Fcross-refs. Switch to **`academic-paper`** for citation styles (APA \u002F Chicago \u002F IEEE \u002F GB 7714), in-text↔reference auto-linking, numbered equations with `\\ref`, \"List of Figures\", or auto-updating cross-refs. Switch to **`officecli-word-form`** when the document's purpose is **data capture** — fillable forms, contracts with user-fill slots, questionnaires, mail-merge templates (`\u003Cw:sdt>` content controls, `\u003Cw:ffData>`, `documentProtection=forms`).\n\n### Raw-set escape hatch (L1 \u002F L2 \u002F L3)\n\nThree tiers of precision; use the lowest that does the job.\n\n- **L1 — high-level props** (`--prop text=…`, `--prop style=Heading1`): your default. Covers 80%.\n- **L2 — dotted-attr fallback** (`pbdr.top=`, `ind.left=`, `shd.fill=`, `padding.top=`, `font.size=`): when L1 lacks the knob. Example: `--prop pbdr.bottom=\"single;6;1F4E79;0\"`. Emits schema-valid XML.\n- **L3 — `raw-set` with XML**: last resort, no schema protection. Use for internal hyperlinks, composite fields, and other shapes the typed verbs can't express (see XML appendix).\n\nBorders use the format `style;size;color;space`: `single;4;FF0000;1`. Hex colors never start with `#`: `FF0000`. Scheme color names (`accent1..6`, `dark1`\u002F`dark2`, `light1`\u002F`light2`, `hyperlink`) are accepted anywhere a hex color is — prefer hex for stable colors across themes.\n\n## QA (Required)\n\n**Assume there are problems — QA is a bug hunt, not a confirmation step.** Your first document is almost never correct; zero issues on first inspection means you weren't looking hard enough. Headings look fine until `view outline` shows an H3 directly under an H1; the footer shows \"Page 1\" until `get --depth 3` reveals a static run, not a field.\n\n### Minimum cycle before \"done\"\n\n1. `officecli view \"$FILE\" issues` — empty paras, missing alt text, formatting anomalies.\n2. `officecli view \"$FILE\" outline` — heading hierarchy (no H1 → H3 skips), TOC presence, section count.\n3. `officecli view \"$FILE\" text --max-lines 400` — typos, stray `\\$`\u002F`\\t`\u002F`\\n` literals, placeholder tokens.\n4. `officecli validate \"$FILE\"` — schema check (the Delivery Gate re-runs this on the closed, on-disk file).\n5. **Visual pass — whole document as a contact sheet** (vision-capable agents only — if you cannot interpret images, skip this step: steps 1–4 are your ceiling, and flag the document \"not visually verified\" at handoff). `officecli view \"$FILE\" screenshot --grid auto -o \u002Ftmp\u002Fsheet.png`, then Read it. `--grid auto` tiles **every page** into one image (auto column count; `--grid 4` to force) — you *see* pagination, blank pages, heading rhythm, lopsided margins, and TOC\u002Fcover placement, not just the DOM. Windows+Word renders each page through real Word; elsewhere HTML. If the screenshot fails, fall back to `view html` and flag cross-page breaks \u002F alignment \u002F rhythm as \"not visually verified\". Thumbnails only **locate**: confirm any fine call (column alignment, line spacing, indents, dark-on-dark, caption placement) on the suspect page at full resolution with `screenshot --page N` (no `--grid`; real Word on Windows). \"validate pass\" is not delivery; \"looks like a real document\" is.\n6. If anything failed, fix, then **rerun the full cycle** — one fix commonly creates another problem.\n\n### Delivery Gate (run before handing off — any failure = REJECT, do NOT deliver)\n\nCopy-paste, set `FILE`, and refuse to declare done until every gate prints OK.\n\n```bash\nFILE=\"your-file.docx\"\n\n# Gate 1 — schema.\nofficecli close \"$FILE\" 2>\u002Fdev\u002Fnull\nofficecli validate \"$FILE\" | grep -q \"no errors found\" || { echo \"REJECT Gate 1: validate failed\"; exit 1; }\necho \"Gate 1 OK\"\n\n# Gate 2 — token leak (shell-escape \u002F template tokens \u002F literal \\$ \\t \\n). grep -c never false-PASSes.\nLEAK=$(officecli view \"$FILE\" text | grep -cE '(\\$[A-Za-z_]+\\$|\\{\\{[^}]+\\}\\}|\u003CTODO>|xxxx|lorem|\\\\[\\$tn])')\n[ \"$LEAK\" -eq 0 ] && echo \"Gate 2 OK\" || { echo \"REJECT Gate 2: $LEAK leak line(s)\"; officecli view \"$FILE\" text | grep -nE '(\\$[A-Za-z_]+\\$|\\{\\{[^}]+\\}\\}|\u003CTODO>|xxxx|lorem|\\\\[\\$tn])'; exit 1; }\n# A TOC placeholder is valid before a Word-compatible field engine updates it; confirm the TOC field and updateFields setting structurally instead.\n\n# Gate 3 — live PAGE field exists when a footer is expected.\nFLD=$(officecli query \"$FILE\" 'field[fieldType=page]' --json | jq '.data.results | length')\n[ \"$FLD\" -ge 1 ] && echo \"Gate 3 OK\" || { echo \"REJECT Gate 3: no live PAGE field\"; exit 1; }\necho \"Delivery Gate PASS\"\n```\n\n### Field \u002F cached-value spot-check\n\nFields carry cached values that may be stale or empty at write time — confirm existence by **structure, not text**.\n\n- **Footer PAGE:** `get \u002Ffooter[N] --depth 3` lists the begin \u002F instrText \u002F separate \u002F cached \u002F end run chain — ≥ 5 runs for one PAGE, ≥ 11 for composite \"Page X of Y\". A single run with text `\"Page\"` = field missing; re-add with `--prop field=page`.\n- **TOC:** `get \u002Ftoc[1] --depth 2` shows field structure. Page numbers may read `1 1 1 1` or `Update field to see…` until recalculated (see §Table of Contents — set `updateFields=true`).\n- **MERGEFIELD:** `query 'field[fieldType=mergefield]'` — one per slot, no literal `{{name}}` elsewhere.\n\n### Honest limit\n\n`validate` catches schema errors, not design errors — a document can pass it with wrong heading hierarchy, fake-Heading-1 sizes, placeholder tokens as body text, or an empty first-page footer on a coverless document. The contact-sheet visual pass (`screenshot --grid`) and the field-structure check are how you catch what validation can't.\n\n### QA display notes (don't chase these)\n\n- `view text` shows `\"1.\"` for every numbered list item regardless of rendered number — actual output increments correctly.\n- `view issues` flags \"body paragraph missing first-line indent\" on cover paragraphs, centered headings, list items, bibliography entries — first-line indent is only required for APA\u002Facademic body text; on block-style professional documents these are expected.\n\n## Known Issues & Pitfalls\n\nWhen something \"looks broken\", attribute it before chasing: **[AGENT-ERROR]** the document is wrong (fix it) · **[RENDERER-BUG]** the document is correct, a viewer renders it differently (don't chase) · **[SKILL gap]** the skill didn't teach the rule (file an issue).\n\n### Renderer quirks (cross-viewer, [RENDERER-BUG] — don't chase)\n\nBefore calling a color\u002Ffield\u002Fchart broken, open the file in the user's target viewer; if it looks correct there it's a viewer quirk.\n\n- **PAGE field may render literal \"Page\"** (no number) until recalculated — judge by `fldChar` presence, not the digit.\n- **TOC cached page numbers may read \"1 1 1 1\"** until F9.\n- **Pie \u002F doughnut fill may collapse to one color** in some viewers (column\u002Fbar render fine).\n- **Form-control checkboxes may render double-boxed**; **OMML equation baselines** may shift across viewers (XML identical).\n\n### Common pitfalls\n\n| Pitfall | Correct approach |\n|---|---|\n| `--index` vs `[N]` | `--index` is 0-based; `[N]` paths are 1-based |\n| Multiple `add --index N` with the same N | Each insert shifts later content down; reusing N puts later items BEFORE earlier ones — insert in reverse order, or `move --after\u002F--before` anchored on `paraId` |\n| Unquoted `[N]` in zsh\u002Fbash | Quote every path: `\"\u002Fbody\u002Fp[1]\"` |\n| `[last]` as predicate | Must be `[last()]` with parens |\n| Raw twips in spacing | Use unit-qualified values: `12pt`, `0.5cm`, `1.5x` |\n| Empty paragraphs for spacing | Use `spaceBefore` \u002F `spaceAfter` |\n| Row-level `set` for cell formatting | Row `set` only supports `height`, `header`, `c1..cN` text; format goes on the cell paragraph \u002F run |\n| `listStyle` on a run | It's a paragraph property |\n| Indent via leading spaces | `indent=720` \u002F `firstLineIndent=360` \u002F `hangingIndent=720` (dotted `ind.left` \u002F `ind.firstLine` also work) |\n| Cover page-number suppression via `set differentFirstPage=true` | UNSUPPORTED — add a first-type footer: `--type footer --prop type=first --prop text=\"\"` |\n| Need a fresh chapter page | Use `pageBreakBefore=true` on the heading; use an explicit `pagebreak` only as an alternative, never both |\n| Multiple bullet paragraphs in one cell | `c1=\"a\\nb\"` makes a `\u003Cw:br\u002F>` line break (one paragraph); for separate bullet paragraphs use recipe (e) |\n| `raw-set` when dotted-attr would work | Prefer L2 dotted-attr over L3 raw-set |\n| Next paragraph inherits the previous Heading style | Set explicit `--prop style=Normal` on the following paragraph |\n| Modifying a file open in Word | Close it in Word first |\n| Echo into batch breaks on `$`\u002F`'` | Heredoc with single-quoted delimiter: `cat \u003C\u003C'EOF' \\| officecli batch …` |\n\n## Raw-set XML appendix (L3 patterns)\n\n`raw-set` injects literal OOXML — no schema protection. Element order in `\u003Cw:pPr>`: `pStyle`, `numPr`, `spacing`, `ind`, `jc`, `rPr` (last). Smart quotes as entities (`&#x2018;`\u002F`&#x2019;`\u002F`&#x201C;`\u002F`&#x201D;`). Add `xml:space=\"preserve\"` to any `\u003Cw:t>` with leading\u002Ftrailing spaces. RSIDs are 8-digit hex. Use \"Claude\" as the author for tracked changes\u002Fcomments unless the user names another.\n\n**Tracked-change insertion \u002F deletion** — prefer the high-level `--prop revision.type=ins|del` on a run; raw-set only for what the typed path can't express (rejecting\u002Frestoring another author's change, below). Replace the whole `\u003Cw:r>…\u003C\u002Fw:r>`, never inject tags inside a run; copy the original `\u003Cw:rPr>` into both to preserve formatting. Inside `\u003Cw:del>` use `\u003Cw:delText>` (and `\u003Cw:delInstrText>` for instructions):\n\n```xml\n\u003Cw:r>\u003Cw:t>The term is \u003C\u002Fw:t>\u003C\u002Fw:r>\n\u003Cw:del w:id=\"1\" w:author=\"Claude\" w:date=\"2026-01-01T00:00:00Z\">\u003Cw:r>\u003Cw:delText>30\u003C\u002Fw:delText>\u003C\u002Fw:r>\u003C\u002Fw:del>\n\u003Cw:ins w:id=\"2\" w:author=\"Claude\" w:date=\"2026-01-01T00:00:00Z\">\u003Cw:r>\u003Cw:t>60\u003C\u002Fw:t>\u003C\u002Fw:r>\u003C\u002Fw:ins>\n\u003Cw:r>\u003Cw:t> days.\u003C\u002Fw:t>\u003C\u002Fw:r>\n```\n\nWhen deleting ALL content of a paragraph\u002Flist item, also mark the paragraph mark deleted (`\u003Cw:del\u002F>` inside `\u003Cw:pPr>\u003Cw:rPr>`) — otherwise accepting changes leaves an empty paragraph. To **reject another author's insertion**, nest your `\u003Cw:del>` inside their `\u003Cw:ins>`; to **restore their deletion**, add a `\u003Cw:ins>` after it (don't modify theirs).\n\n**Internal hyperlink to a bookmark** (prefer the high-level `--prop anchor=` path; raw-set only for custom run styling the command can't express):\n\n```xml\n\u003Cw:hyperlink w:anchor=\"chapter1\">\u003Cw:r>\u003Cw:rPr>\u003Cw:rStyle w:val=\"Hyperlink\"\u002F>\u003C\u002Fw:rPr>\u003Cw:t>See Chapter 1\u003C\u002Fw:t>\u003C\u002Fw:r>\u003C\u002Fw:hyperlink>\n```\n\n**Composite field in one run** (e.g. two fields the single-command path can't compose) — the `fldChar begin \u002F instrText \u002F separate \u002F value \u002F end` chain:\n\n```xml\n\u003Cw:r>\u003Cw:fldChar w:fldCharType=\"begin\"\u002F>\u003C\u002Fw:r>\n\u003Cw:r>\u003Cw:instrText xml:space=\"preserve\"> PAGE \u003C\u002Fw:instrText>\u003C\u002Fw:r>\n\u003Cw:r>\u003Cw:fldChar w:fldCharType=\"separate\"\u002F>\u003C\u002Fw:r>\n\u003Cw:r>\u003Cw:t>1\u003C\u002Fw:t>\u003C\u002Fw:r>\n\u003Cw:r>\u003Cw:fldChar w:fldCharType=\"end\"\u002F>\u003C\u002Fw:r>\n```\n\n**Comment markers** are siblings of `\u003Cw:r>`, NEVER inside one (reply threading and resolved-state are high-level — `--prop parentId=`\u002F`done=`, see Comments above):\n\n```xml\n\u003Cw:commentRangeStart w:id=\"0\"\u002F>\u003Cw:r>\u003Cw:t>annotated text\u003C\u002Fw:t>\u003C\u002Fw:r>\u003Cw:commentRangeEnd w:id=\"0\"\u002F>\n\u003Cw:r>\u003Cw:rPr>\u003Cw:rStyle w:val=\"CommentReference\"\u002F>\u003C\u002Fw:rPr>\u003Cw:commentReference w:id=\"0\"\u002F>\u003C\u002Fw:r>\n```\n\nForce field recalc on open with `officecli set \"$FILE\" \u002Fsettings --prop updateFields=true` (writes `\u003Cw:updateFields w:val=\"true\"\u002F>`; covers the layout-dependent fields PAGE \u002F PAGEREF \u002F NUMPAGES \u002F TOC page numbers — no raw-set needed). For SEQ numbering, prefer `set \u002F --prop recalcFields=seq`, which writes correct cached values now without waiting on Word.\n\n### Help pointer\n\nWhen in doubt: `officecli help docx`, `officecli help docx \u003Celement>`, `officecli help docx \u003Cverb> \u003Celement>`, `--json` for agents. Help is the authoritative schema; this skill is the decision guide.\n",{"name":5,"description":7},"main","571327a911ec45873180fd5628525b6d4504ed79","files\u002FOfficeCLI-main\u002Fskills\u002Fofficecli-docx","https:\u002F\u002Fgithub.com\u002Fngdletrung\u002FJKAI-Zenith","https:\u002F\u002Fgithub.com\u002Fngdletrung","2026-11-08 11:23:33",{"source":8,"skillName":5,"commands":30,"prompt":40,"zipAvailable":41},[31,34,37],{"tool":32,"command":33},"npx","npx skills add ngdletrung\u002FJKAI-Zenith --skill officecli-docx",{"tool":35,"command":36},"bunx","bunx skills add ngdletrung\u002FJKAI-Zenith --skill officecli-docx",{"tool":38,"command":39},"pnpm","pnpm dlx skills add ngdletrung\u002FJKAI-Zenith --skill officecli-docx","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fngdletrung\u002FJKAI-Zenith\u002Fblob\u002Fmain\u002Ffiles\u002FOfficeCLI-main\u002Fskills\u002Fofficecli-docx\u002FSKILL.md",true,[],[44,51,57,64,70,76],{"skillNo":45,"name":46,"nameZh":6,"description":47,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":48,"categories":49,"keywords":50,"publishedAt":18},"01M73C2NC1W5P3A0V3GQAJ0SJB","standard_plugin","Hướng dẫn kích hoạt và vận hành cho kỹ năng standard_plugin.","https:\u002F\u002Fgithub.com\u002Fngdletrung\u002FJKAI-Zenith\u002Fblob\u002Fmain\u002Fintelligence\u002Fskills\u002Ftemplates\u002Fstandard_plugin\u002FSKILL.md",[],[],{"skillNo":52,"name":53,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":18},"01M73C2KAN3Q7D5XEBKB3KZW1B","_STANDARD","https:\u002F\u002Fgithub.com\u002Fngdletrung\u002FJKAI-Zenith\u002Fblob\u002Fmain\u002Fintelligence\u002Fskills\u002F_STANDARD\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":18},"01M73C2HV7KDJQTA6ACCR10HZB","test_dynamic_audit","Thao tác kiểm toán động","https:\u002F\u002Fgithub.com\u002Fngdletrung\u002FJKAI-Zenith\u002Fblob\u002Fmain\u002Fintelligence\u002Fskills\u002FTEST\u002Ftest_dynamic_audit\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":18},"01M73C2FRG0JHZ6W155V1KCHRP","security-audit","https:\u002F\u002Fgithub.com\u002Fngdletrung\u002FJKAI-Zenith\u002Fblob\u002Fmain\u002Fintelligence\u002Fskills\u002FSECURITY\u002Fsecurity-audit\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":18},"01M73C2EMWYHFTAR9RSZ41TBGP","security-and-hardening","https:\u002F\u002Fgithub.com\u002Fngdletrung\u002FJKAI-Zenith\u002Fblob\u002Fmain\u002Fintelligence\u002Fskills\u002FSECURITY\u002Fsecurity-and-hardening\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M73C2CV0BQ59NAEWXKBQ370Z","performance-optimization","https:\u002F\u002Fgithub.com\u002Fngdletrung\u002FJKAI-Zenith\u002Fblob\u002Fmain\u002Fintelligence\u002Fskills\u002FSECURITY\u002Fperformance-optimization\u002FSKILL.md",[],[]]