← All skills

office

Work with non-PowerPoint Office/OOXML documents through the published unified office CLI: identify, inspect, query, validate, diagnose, preview, create, template, comment, batch-edit, dump/replay, or safely inspect raw parts in .docx and .xlsx files. Use this for Word and Excel tasks instead of python-docx, openpyxl, ExcelJS, pandoc, or LibreOffice. Use the legacy format-specific CLIs only for the few workflows the umbrella command does not provide: direct CSV import/export, formula calculation, fine-grained XLSX formula linting and live batch-capability discovery, fine-grained XLSX rendering controls, and DOCX Markdown/style-map/image-extraction conversion.

$ files
SKILL.md
SKILL.md

Office documents through one CLI

Use the unified office command for every DOCX/XLSX workflow unless the legacy-only table below names the exact missing capability.

Nothing to install beyond moonx. Run from any directory:

moonx bobzhang/office help all --json moonx bobzhang/office <command> <args...>

Arguments after bobzhang/office are passed directly to the command; do not insert a -- separator.

The WebAssembly target is the default and is the right choice for untrusted documents. It cannot spawn programs or open network connections, and the CLI also applies bounded package, XML, scan, output, and mutation limits. It can still read or write the paths supplied to it and consume CPU within those limits. For trusted files, moonx --target native bobzhang/office ... is a faster drop-in.

Pin a version when reproducibility matters: moonx bobzhang/office@0.2.0 .... @latest refreshes the registry index before resolving.

The CLI describes itself — prefer that over prose

This file will drift; the binary will not. Three introspection commands are normative:

moonx bobzhang/office help all --json # every format, command, field, limit moonx bobzhang/office help schemas --json # every consumed JSON contract moonx bobzhang/office help schema ID --json # one contract, e.g. xlsx.batch/2

help all carries a crc32: fingerprint over the capability registry. When this document and the fingerprinted registry disagree, the registry wins.

Default workflow

  1. Discover the surface with help all --json, and help schema ID before authoring any JSON input document.
  2. Run identify, then outline --json, before choosing paths or edits.
  3. Inspect only what you need with get, text, or query. Reuse the canonical paths the CLI returns; do not invent selectors.
  4. For mutations, prefer a separate --out, run --dry-run where supported, and read the transaction preservation report.
  5. Read the result back, then run validate and issues. For any XLSX containing formulas, also run the legacy xlsx lint fallback below and require finding_count == 0: newly authored formulas have no cached result, so issues and preview cannot evaluate them. Lint evaluates formula masters but not shared/array slave formulas — treat those slaves as an unresolved residual rather than claiming formula correctness.
  6. Generate a preview and visually inspect the HTML before delivery.

Every documented failure exits non-zero, but a successful diagnostic command can still report warnings or formula findings with exit code zero. Inspect the structured counts and records, not just the exit code.

Ordinary --json commands emit one office.output/1 success/failure envelope. dump --json is the deliberate exception: it emits the replayable office.dump/1 document directly.

Command map

Replace the office token below with the moonx bobzhang/office launcher.

GoalCommand
Discover formats, commands, fields, limitsoffice help [all\|FORMAT\|COMMAND\|FORMAT COMMAND] [--json\|--jsonl]
Discover consumed JSON contractsoffice help schemas [--json\|--jsonl]; office help schema ID [--json\|--jsonl]
Verify and identify a packageoffice identify FILE [--json]
Map document/workbook structureoffice outline FILE [--max-elements N] [--max-output-chars N] [--json]
Resolve one canonical selectoroffice get FILE SELECTOR [limits] [--json]
Extract path-tagged paragraphs/cellsoffice text FILE [--under SELECTOR] [--offset N] [--limit N] [limits] [--json]
Search bounded literal predicatesoffice query FILE [CELL_SELECTOR] [--under SELECTOR] [DOCX predicates] [pagination/limits] [--json]
Run the exact mutation validation gateoffice validate FILE [--json\|--jsonl]
Report validation plus bounded actionable warningsoffice issues FILE [--json\|--jsonl]
Publish deterministic offline HTMLoffice preview FILE --output OUT.html [--overwrite] [--json\|--jsonl]
Create a blank validated fileoffice create xlsx OUT.xlsx [--sheet NAME] [--dry-run] [--overwrite] [--json] or office create docx OUT.docx [--dry-run] [--overwrite] [--json]
Merge strict placeholders/row regionsoffice template FILE DATA.json --out OUT [--dry-run] [--overwrite] [--allow-missing] [--json\|--jsonl]
Add/reply/resolve DOCX commentsoffice annotate FILE SCRIPT.json --out OUT.docx [--dry-run] [--overwrite] [--json\|--jsonl]
Mutate an XLSX transactionallyoffice batch BOOK.xlsx SCRIPT.json [--out OUT.xlsx] [--dry-run] [--overwrite] [--json]
Author a fresh DOCX from opsoffice batch --format docx OUT.docx SCRIPT.json [--dry-run] [--overwrite] [--json]
Produce a replayable semantic dumpoffice dump FILE --json or streaming --jsonl
Reconstruct replayable dump contentoffice replay DUMP.json --output OUT [--overwrite] [--json\|--jsonl]
Inventory/read OOXML partsoffice raw list FILE [--json]; office raw read FILE PART [--json] [--base64\|--output FILE]
Replace one XML partoffice raw replace FILE PART (--xml XML \| --xml-file FILE) [--out FILE] [--dry-run] [--overwrite] [--json]
Edit inside one XML partoffice raw edit FILE PART --path PATH --action ACTION [action arguments] [--namespace PREFIX=URI]... [--all] [--out FILE] [--dry-run] [--overwrite] [--json]

[limits] abbreviates --max-elements N --max-output-chars N. DOCX query predicates are --kind, --text, --id, repeatable --property NAME=VALUE, and --ignore-case. XLSX query uses a quoted cell selector such as 'cell[type=number][value>0]'.

Canonical selectors

Selectors are format-rooted:

/docx/body/p[1] /docx/body/tbl[1]/tr[1]/tc[2]/p[1] /docx/comments/comment[id="7"] /xlsx/workbook /xlsx/sheet[name="Data"] /xlsx/sheet[name="Data"]/cell[A1] /xlsx/sheet[name="Data"]/range[A1:C12]

Ordinal paths are snapshot-relative. Re-run outline or text after a mutation before reusing them.

The XLSX payload shape follows the selector: a cell[A1] selector returns a single data.cell object, while a range[A1:C12] selector returns a data.cells array. Do not assume data.cells is always present.

Mutation contracts

  • create is create-new by default; --overwrite explicitly replaces an existing destination. --dry-run validates without publishing.
  • XLSX batch consumes xlsx.batch/2; the historical xlsx.batch/1 remains accepted with its exact v1 registry subset. With no --out it rewrites the input after all operations pass; prefer --out when preserving the source matters.
  • DOCX batch --format docx consumes docx.batch/2 (and accepts docx.batch/1) and only authors a fresh destination. It does not edit an existing DOCX and does not accept --out.
  • template never modifies its template. It substitutes non-executable {{key}} placeholders from flat scalar data and optional marked-row regions into a separate output.
  • annotate is the preservation-safe existing-DOCX mutation surface. It consumes docx.annotation-batch/1 with comment_add, comment_reply, comment_resolve, and comment_unresolve ops and publishes a separate output. Its ops carry their fields directly, not under a params object — unlike xlsx.batch and docx.batch. comment_add takes anchor: {"at": "/docx/body/p[1]"}, author, and body as an array of strings, plus an optional label that later ops reference via {"label": ...}. Passing params fails with office.annotate.invalid_script. Run office help schemadocx.annotation-batch/1 --json and read its examples before authoring.
  • raw replace and raw edit are expert fallbacks. Use --dry-run and a separate --out; semantic commands are safer whenever they can express the task.
  • A preservation report is authoritative. Do not infer preservation from the requested operations.
  • dump --json is the form accepted by replay. dump --jsonl is a streaming inspection form with a terminal digest, not replay input.
  • preview --overwrite and replay --overwrite remove the old destination before staging the replacement; a later write failure can leave it absent. Use a fresh destination, or make and verify a backup before explicit replacement. They do not share the atomic-overwrite guarantee of the transaction-backed mutation commands.

Run office help schema ID --json before authoring any consumed JSON document. It is normative for xlsx.batch/2, docx.batch/2, office.template.data/1, and docx.annotation-batch/1.

Legacy-only fallbacks

Do not start with these. Use them only when the named capability is required. Each is a separately published module, reachable the same way:

Missing from officeLegacy command
Direct CSV import to a new workbookmoonx bobzhang/mbtexcel/cmd/xlsx csv INPUT.csv OUT.xlsx --sheet Data
Evaluate one formula locallymoonx bobzhang/mbtexcel/cmd/xlsx calc BOOK.xlsx Sheet1 B4
Recompute and lint formula masters, including formulas with no cached result; shared/array slave formulas are not evaluatedmoonx bobzhang/mbtexcel/cmd/xlsx lint BOOK.xlsx [--sheet Sheet1]
Discover the exact XLSX batch operations, parameters, allowed values, and limits accepted by this buildmoonx bobzhang/mbtexcel/cmd/xlsx capabilities
Export one sheet as generic CSV (LF-delimited records)moonx bobzhang/mbtexcel/cmd/xlsx rows BOOK.xlsx --sheet Sheet1
Render a selected or bounded XLSX view, suppress images, or calculate uncached formulasmoonx bobzhang/mbtexcel/cmd/xlsx html BOOK.xlsx --out OUT.html [--sheet Sheet1] [--max-rows N] [--max-cols N] [--no-images] [--calc]
DOCX to Markdown, custom Mammoth style maps, or extracted-image directoriesmoonx bobzhang/docx2html/cmd/docx2html ...

The legacy writers do not share the unified transaction contract. CSV import truncates an existing output, and XLSX HTML rendering replaces its output. Use verified-new destination paths unless replacement is explicitly intended. DOCX conversion truncates output files and writes extracted images non-transactionally, so use a fresh output directory and publish it only after the command completes successfully.

The umbrella already covers general HTML preview, read/query, validation, creation, batch authoring, templating, comments, and raw OOXML access. Do not route those tasks through the legacy CLIs.

Skill
Author
Name
bobzhang/office
Version
0.2.0
Published
2 months ago
Download
Download ZIP

SHA-256

d2470ffaad1753a43610254e7983ca2e7adc496359cc694fd977d664d6cdfba0

Powered by MoonBit

Site sourceReport issueModulesSkillsBuild queueStatistics

© 2026 mooncakes.io