Help us improve
Share bugs, ideas, or general feedback.
From docx-master
Standardize, edit, or audit a Word (.docx) document via direct OOXML mutation. Two CLIs: `apply` (the unified writer — install styles + numbering + theme + template, restyle by pattern / fingerprint, insert content via edits, all in one config), `audit` (read-only conformance check, no file written). Common config shapes inside `apply`: standardize (role-based whole-doc reshape — paragraph classification, named styles, multi-level auto-numbering, template import), edit (location-based surgical changes — replace/insert/delete paragraphs, table cells, image embedding, optional tracked changes). Use whenever the user wants to format / restyle / normalize / edit / audit a Word document. Do NOT use for: PDFs, spreadsheets, or plain-text / Markdown source files (unless the task is specifically to *output* a docx).
npx claudepluginhub hawa130/docx-master --plugin docx-masterHow this skill is triggered — by the user, by Claude, or both
Slash command
/docx-master:docx-masterThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Mutates Word (.docx) OOXML directly: produce well-formed documents from messy templates, install styles + numbering, convert hand-typed prefixes to auto-numbering, insert content, audit conformance. Output is a new docx; the original is never touched.
references/audit.mdreferences/captions.mdreferences/chinese-font-sizes.mdreferences/config-schema.mdreferences/cross-references.mdreferences/edit.mdreferences/equations.mdreferences/header-footer.mdreferences/numbering-formats.mdreferences/standardize.mdreferences/tables.mdscripts/_assets/blank.docxscripts/_shared/blockers.jsscripts/_shared/document-parser.jsscripts/_shared/docx-validate.jsscripts/_shared/field-parse.jsscripts/_shared/fingerprint.jsscripts/_shared/format.jsscripts/_shared/load.jsscripts/_shared/locator.jsMandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
Mutates Word (.docx) OOXML directly: produce well-formed documents from messy templates, install styles + numbering, convert hand-typed prefixes to auto-numbering, insert content, audit conformance. Output is a new docx; the original is never touched.
User prompt overrides everything below.
Otherwise, treat a document as two kinds of paragraphs:
pPr / rPr). Engine's selective-strip keeps direct format as long as the new style doesn't override the same attribute.pStyle, strip typed structural prefixes via pattern_rules, install matching numbering). Chapter / heading / list / caption markers are structure, not typography — they belong to auto-numbering or SEQ fields. Existing typed prefixes are the input to retagging, not output to preserve.replace, never quoted into an inserted paragraph's text. Content insertion lands in the empty placeholder slot beside the chrome (set-run on inline blanks; replace against the empty slot for separate-paragraph forms).BodyText / ListNumber / Heading1..N), installing the style in styles[] if no existing one fits. Normal is fallback, not a body style.For styles[]: one style per semantic role. If the role has any paragraph already playing it in the source, the entry MUST use fromParagraph: N — the engine extracts typography from that paragraph automatically; add only outlineLevel / basedOn and user-spec overrides via overrides: { ... }. Top-level size / bold / alignment / spaceBefore / lineSpacing on a represented-role entry silently overrides the template — the dominant over-declaration failure. Reserve top-level explicit fields for empty-slot roles or fresh styles the user explicitly speced. Full design phase: standardize.md §1.
Tools surface visible facts; classification and judgment are yours.
A well-formed Word document expresses structure through styles + numbering + sections + SEQ fields, not typed text mimicking structure. When designing the reshape:
text.captions config + CaptionBlock / EquationBlock — SEQ + STYLEREF fields, not pattern_rules. Placement: figure / equation captions go below; table captions go above. See references/captions.md.InlineRef nodes in edits[], never typed counters. Literal counters silently desync when a target moves; REF fields stay correct. Page-number cites out of scope. See references/cross-references.md.ListNumber / ListBullet, figure / table / equation to their *Block types with captionId. Per-block schemas in references/edit.md.firstLineIndent: "2char"). No typed spaces at CJK ↔ Latin / digit boundaries; Word's autoSpace handles them. Chinese font sizes: references/chinese-font-sizes.md.| Command | When | Reference |
|---|---|---|
apply | The unified writer. Install styles + numbering + theme + template, restyle by pattern / fingerprint, insert content via edits — single config, single call. | standardize.md + edit.md |
audit | Read-only conformance check workflow. No CLI; uses the inspect tools to produce a violation report. | audit.md |
apply pipeline order:
install styles + numbering + theme + template
→ run edits (referencing just-installed styleIds)
→ re-fingerprint
→ run rules (pattern_rules / bulk_rules / assignments / exclude —
match BOTH pre-existing chrome AND agent-inserted content uniformly)
→ validate, write
Sparse by design — only declared blocks apply; untouched styles / numbering / paragraphs / theme stay as they are. Declare only what's wrong, missing, or what the user explicitly asks to change.
Creating from scratch. Omit source to scaffold from the bundled blank template (one empty Normal paragraph, A4 portrait, no other styles or numbering). Declare what you need in the usual blocks (styles / numbering / pageSetup / headerFooter / edits); styles[] must use Mode B (direct fields) since the blank has no representative paragraphs to extract from. The empty paragraph at index 1 is a replace or insert-after target (insert-before creates a stray leading empty paragraph; delete would empty the body). Incompatible with template (transplanting from a template into a blank is conceptually inconsistent — start with a host source if you need template-import).
overview first. From the output, note:
pPr / rPr content paragraphs carry. This IS the document's typographic convention; preserve it by not redeclaring those attributes on the re-tagging styles.第N章, 一、, 1.1, (一)) feed pattern_rules; caption shapes (图 2.1) and in-prose counters (如图 3.2) feed caption / cross-ref migration via edits[] (different mechanism).label + whitespace gap or label + ____ underscore placeholder. The blank is usually a separate run with <w:u/>. Note indices for Step 2.styles / numbering / pattern_rules / bulk_rules / assignments / exclude / edits) detailed in standardize.md §1–§3 and edit.md. Reactive additions accrete debt.apply --dry-run first. The change report's signals (Style Resolution / Sample Affected / Implicit-keep failure / unmatched stripPrefix) — see standardize.md §5.Default first. Don't ask unless one of the cases below applies:
Normal cascade vs per-role styles[] — see standardize.md "Font scope layers")Surface to the user when blocked by: layout-table restructuring, TOC body content, footnotes / comments, page-number cites. Paragraphs inside layout-table cells ARE indexed and fully editable; only the table holding them is off-limits.
Page setup (paper size, orientation, margins, columns, page-number format) and headers / footers ARE supported, including per-section overrides — see config-schema.md and references/header-footer.md.
All tools invoked via node <script> <args>, output to stdout.
| Tool | Invocation | When to Use |
|---|---|---|
overview | node scripts/overview.js <file> [--paras=A..B|none] [--include-unused] | First call on any task. Metadata, page setup, theme, style defs, numbering schemes (with used by N paragraphs count — 0 flags orphans), visual style statistics with direct-format per fingerprint (drives "don't redeclare" rule), document skeleton. --paras slices or drops the skeleton; --include-unused shows usage=0 styles. |
inspect_range | node scripts/inspect_range.js <file> <from> <to> | Full text and computed styles for a paragraph range. |
inspect_runs | node scripts/inspect_runs.js <file> <para> | Per-run rPr dump. Use for paragraphs with mixed run-level formatting OR form-fill segments (label + underscore-blank pattern). |
inspect_neighbors | node scripts/inspect_neighbors.js <file> <para> [--radius N] | What surrounds a paragraph. First choice for figure-caption / table-caption / first-after-heading classification. |
inspect_style | node scripts/inspect_style.js <file> <fingerprint> | What role a fingerprint plays. <fingerprint> accepts letter label or 6-char hash. |
inspect_style_def | node scripts/inspect_style_def.js <file> <styleId> | Pre-defined styles in styles.xml and their basedOn chain. Use before reusing or overriding an existing styleId. |
inspect_section | node scripts/inspect_section.js <file> <index> | Page setup differences between sections. |
inspect_table | node scripts/inspect_table.js <file> | Top-level tables with [row,col] cell snippets and per-cell paragraph-index spans. Use before composing a cell locator or a range touching table content. |
inspect_blockers | node scripts/inspect_blockers.js <file> | Paragraphs apply's edit phase will refuse — tracked changes, complex fields, SDT controls. |
inspect_caption | node scripts/inspect_caption.js <file> [identifier] | SEQ-based captions in the document. See captions.md. |
migrate_captions | node scripts/migrate_captions.js <file> [--style <styleId>]... | Read-only detector for manually-numbered caption-shaped paragraphs (图 2.1 typed, no SEQ). Agent uses the output to write apply config converting them to CaptionBlock. |
find_paragraphs | node scripts/find_paragraphs.js <file> --regex <pat> [--flags <flags>] [--limit N] [--fingerprint X] | Cross-document paragraph regex. Validate pattern_rules coverage before applying. |
find_text | node scripts/find_text.js <file> <pattern> [--regex] [--paragraph N | --range A-B] [--limit N] [--context N] | Character-level locator. Returns paragraph index, run index, char offset, length, structural-region annotations. Pair with inspect_runs for rPr or with set-run to replace at runIndex. |
validate | node scripts/validate.js <file> | Schema-aware OOXML check. apply runs this automatically; standalone for spot-checking arbitrary .docx files. |
apply --dry-run | node scripts/apply.js --dry-run <config.json> | Iterate on a config without writing. Use between every config edit. |
apply | node scripts/apply.js <config.json> | Unified writer. Default for any write task. |
pageSetup. Details: config-schema.md.#NNN in skeleton. Layout-table paragraphs are indexed; data / form-table paragraphs aren't (reachable via cell locator on edit path).edits[] locators resolve against the pre-edits document state — #NNN from overview is what locators reference, regardless of intervening ops. Resolved Element refs survive subsequent mutations.STYLEREF / TOC / REF / DATE / …) preserved as-is; not editable inside. TOC content is not regenerated — user must right-click → "Update Field" in Word.inspect_blockers first.<w:name> collisions (including en/zh-CN locale aliases) and aborts with a fix hint; --dry-run lists collisions as warnings instead.Block-level config details: references/standardize.md, references/edit.md, references/config-schema.md.