Create, import, edit, redline, comment, and verify .docx, Word, and Google Docs-targeted artifacts using the office-kit DocumentModel and OfficeKit codec. Includes a render workflow for page-level visual QA before delivery.
Ships in Documents. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Use this skill when you need to create or modify .docx, Word, or a
Google-Docs-ready document and verify it visually. Read the shared
../office-kit/references/workspace.md contract before choosing paths, and
follow ../office-kit/references/review.md after the final DOCX is reopened.
For a multi-step document task, start officekit repl and read
../office-kit/references/repl.md. Import the public API with
await ctx.import("office-kit"), keep the inspected DocumentModel or
bounded helper in ctx.state, and follow inspect → edit → export → reimport →
render/verify before ctx.publish. Use ctx.recordEvidence for page renders
and return the final absolute path, SHA-256, and visualReview status. A
failed mutation is uncertain until the target is reread; do not replay a
checkpointed cell automatically.
officekit run; do not assume a host-specific dependency
loader or global package.@oai/artifact-tool. It is a different host-bundled
runtime, not an OfficeKit alias or fallback, and its output must never be
attributed to OfficeKit.SEQ/REF/PAGEREF field runs plus bounded SEQ/REF cache materialization, bounded source-free header/footer literal/simple-field sequences, canonical native TOC placeholders with explicit field-refresh intent, and export, MUST use the public office-kit DocumentModel/DocumentFile surface and its bundled OfficeKit codec. Read artifact_tool/API_QUICK_START.md, then use tasks/create_edit.md for the task workflow.document.auditAccessibility() and resolve every machine issue. Review every returned manual check; heading intent, table purpose, link purpose, and opaque package content still require author or native-host judgment. For an immutable existing-file report, use examples/officekit-accessibility-audit-workflow.mjs and artifact_tool/ACCESSIBILITY_AUDIT.md. Never present machineCheckPassed: true as Word Accessibility Checker or WCAG conformance.For a net-new Google Docs request, create and visually verify a local .docx
with this skill first. OfficeKit produces and verifies the local file; the
user or another host may import it into Google Docs. OfficeKit does not upload
files or control a cloud drive.
After OfficeKit export and before rendering or importing any Google Docs-targeted DOCX, run the deterministic title sanitizer as an explicit compatibility patch:
python scripts/google_docs_title_sanitize.py input.docx --out sanitized.docx
python scripts/google_docs_title_sanitize.py sanitized.docx --check
Use the sanitized DOCX for render QA and any later import. This is not a style
preference or prose reminder: the sanitizer removes Word Title paragraph-style
border residue, direct title-paragraph borders, and leading title-block
paragraph borders from the OOXML so Word's built-in blue title rule cannot
survive into the imported Google Doc.
Do not create a blank cloud document or claim a native Google Docs link. If a
host offers a separate import flow, it may consume the verified local .docx
after this Skill completes.
When an attached or retained DOCX is meant to control a new document, read
template-distill.md and then template-create.md. Keep the reference file and
the task-local taskRoot/artifact.md together throughout authoring. In this
mode, the retained reference is the design authority: do not apply a generic
design preset, page baseline, or header pattern unless the user explicitly asks
to depart from the template. Classify multiple references by deliverable and do
not mix formatting from a manual, form, source listing, or other document role.
Do not start the builder until artifact.md records exact page geometry, font
family, font size, color, paragraph spacing, line spacing, and margins, with any
unknown value marked unresolved; stop while a controlling value remains
unresolved. The render gate and Google Docs import contract still apply. For a
Google Docs-targeted result, record any change made by the required title
sanitizer as an intentional fidelity deviation.
DOCX text extraction or OOXML inspection alone misses layout defects such as clipping, overlap, missing glyphs, broken tables, spacing drift, and misplaced headers or footers. Always render the final document. When the Agent can understand images, inspect every page image; otherwise run the full structured layout checks and report the visual limitation. Request the AnyDoc reading view only when it can close an identified text or table content-coverage gap.
Shipping gate: before delivering any DOCX, you must:
render_docx.py to produce page-<N>.png images (optionally also a PDF with --emit_pdf)visualReview as "requires-human"
when layout or aesthetics are material, otherwise "unavailable".The packaged renderer uses only the Python standard library plus the existing
soffice, pdfinfo, and pdftoppm executables. It never asks the Agent to
install a Python package or silently substitutes another renderer.
If rendering fails because LibreOffice/soffice is missing, it is acceptable to return the requested DOCX without rendered PNG QA. In that fallback case, use the relevant Markdown task docs in this skill package as the authoritative guidance for building and checking the document structurally, state clearly in the final response that rendering/visual QA could not be completed, and do not imply that the document passed the render gate.
If rendering fails for any other reason, fix rendering first (LibreOffice profile/HOME, conversion errors, or renderer setup) rather than guessing.
Deliverable discipline: Rendered artifacts (PNGs and optional PDFs) are for internal QA only. Unless the user explicitly asks for intermediates, return only the requested final deliverable (e.g., when the task asks for a DOCX, deliver the DOCX — not page images or PDFs).
Outside template-following mode, a design preset is mandatory for new DOCX creation and major rewrites unless the user explicitly asks for a different visual system. For existing-document edit tasks, preserve the original document and apply the minimal local edits described later in this skill.
Picking a preset is not enough. You must resolve the preset into exact numeric tokens and apply those numbers in the DOCX implementation. Do not rely on Word defaults, built-in list styles, theme defaults, inherited paragraph spacing, or renderer-dependent behavior for any preset-controlled value.
Before writing content, read references/design_presets.md and choose exactly one preset:
google_docs_default for any net-new document whose destination is a native Google Doc, unless the user explicitly asks for a special, branded, or highly polished visual treatment.standard_business_brief for formal memos, RFI responses, decision memos, and board-style briefs.compact_reference_guide for launch guides, negotiation briefs, checklists, and dense operator references.narrative_proposal for grants, proposals, and persuasive documents with longer prose.rfi_response, decision_memo, launch_messaging_guide, contract_negotiation_brief, neighborhood_business_proposal, or grant_proposal.If the destination is Google Docs, choose google_docs_default. Google Docs-targeted documents should feel native: Arial-based typography, black hierarchy, simple title treatment.
For Google Docs-targeted documents, never assign the built-in Word Title paragraph style. Create a named DocumentModel paragraph style and apply the selected token values directly: font family, size, color, weight, spacing, and border/rule settings. For google_docs_default, that means Arial 26 pt, black, normal weight, 0 pt before, 3 pt after, and no underline, bottom border, horizontal rule, or other Word-template residue. This instruction is not the enforcement layer; scripts/google_docs_title_sanitize.py is the explicit deterministic post-export patch and must still run before render/import.
If creating a new first-page header, cover, or title block for a non-Google-docs document, also read references/header_templates.md and choose one header pattern before drafting. For google_docs_default, keep the opening block simple unless the user explicitly requests richer first-page furniture.
Then resolve the preset into a token map and apply the tokens consistently:
google_docs_default, that means explicitly carrying the simple Google Docs defaults instead of inheriting the more polished Word-oriented defaults above.Baseline geometry for all presets: US Letter portrait, 1 inch margins, 9360 DXA usable width, real Word styles for Normal/Title/Subtitle/Heading 1/Heading 2/Heading 3, real Word numbering for lists, and DXA table widths only.
Tables must use explicit Word geometry. Compute exact DXA widths, then pass matching widthDxa, indentDxa, columnWidthsDxa, and cellMarginsDxa values to DocumentModel.addTable(...). Use horizontalAlignment: "left" for explicit native table placement with a paragraph-aligned indent; use "center" or "right" only with indentDxa: 0, because Word exposes w:jc and w:tblInd as separate placement mechanisms. Use verticalAlignment: "center" or "bottom" only when the same alignment should apply to every physical cell; omit it for Word's ordinary top alignment. For deliberate extra row space, pass one physical-row value per minimumRowHeightsDxa: 0 omits the leaf and a positive DXA value writes native w:trHeight hRule="atLeast", so wrapped text may grow. Do not use exact/fixed row heights that can clip content. Imported tables permit these semantic changes only after OfficeKit recognizes the complete fixed-layout and row-property profiles. Set table indent to the start cell margin token (120 DXA by default) so the visible outer border aligns with surrounding paragraph text. scripts/table_geometry.py is an audit or explicit package-patch tool for an existing DOCX, not the ordinary authoring path. Do not rely on autofit, percentage widths, centered default tables, or tables as layout/divider hacks.
Lists must use real numbering definitions. Never create fake bullets with Unicode bullet text, hyphen-prefixed paragraphs, manual numbers, or newline-separated list items inside one paragraph. Wrapped list lines must align under the item text, not under the marker. For a bounded picture-bulleted list, use pictureBullet with an embedded PNG/JPEG/GIF data URL or an absolute HTTP(S) URI. Treat the marker as numbering-level data: every item with the same numberingId and level must have the same marker. When editing an imported picture-bullet group, update every matching item together and keep its embedded-versus-external source kind; never flatten a rejected or irregular VML graph into ordinary bullets. External marker URIs are retained as references and are not fetched, so final native rendering remains a required review step.
Before final render review, run a preset audit: page geometry, styles, heading spacing/colors, list indents, table widths/table indents/cell margins, callout fills, headers/footers, and direct-formatting exceptions must match the selected token map. Also check for fake headings, fake bullets, missing table geometry, clipped/pinned table text, inconsistent page furniture, and unexplained direct formatting drift. For google_docs_default, fail the audit if the title style or title paragraph contains w:pBdr, a bottom border, an underline, a horizontal rule, or any rendered decorative line under the title.
For new DOCX creation and major rewrites, choose content form factors deliberately before drafting. Start from the information type, then calibrate the structure to the document archetype. Use the lightest readable structure that helps the reader understand, compare, act on, or fill in the information with the least friction.
First map each major content unit to a form factor:
Use a table only when the content is truly row/column data: repeated items, shared fields, and useful comparison or lookup.
Do not use tables to package normal prose. If cells become mini-paragraphs, switch to prose sections, bullets, steps, checklists, callouts, or appendix material.
Before finalizing, run a table-overuse audit:
During render review, check content diversity and archetype fit. If multiple adjacent components use the same visual form, decide whether one should become prose, bullets, steps, a callout, or an appendix. The goal is not variety for its own sake; it is to match form to reading task and document purpose.
For generating new documents or major rewrite/repackages, follow the design standards below unless the user explicitly requests otherwise. The user's instructions always take precedence; otherwise, adhere to these standards.
When creating the document design, do not compromise on the content and make factual/technical errors. Do not produce something that looks polished but not actually what the user requested.
It is very important that the document is professional and aesthetically pleasing. As such, you should follow this general workflow to make your final delivered document:
Before you make the DOCX, please first think about the high-level design of the DOCX:
Once you have a working DOCX, continue iterating until the entire document is polished and correct. After every change or edit, render the DOCX and review it carefully to evaluate the result. If LibreOffice/soffice is missing, continue using the relevant Markdown task docs in this skill package for structural QA and document-design guidance, and disclose that visual render QA was skipped. The plan from (1) should guide you, but it is only a flexible draft; you should update your decisions as needed throughout the revision process. Important: each time you render and reflect, you should check for both:
While making and revising the DOCX, please adhere to and check against these quality reminders, to ensure the deliverable is visually high quality:
When the user asks to edit an existing document, preserve the original and make minimal, local changes:
textEditable and textPatchable evidence before mutation. Use text assignment only when textEditable is true; use resolve(.../text).replace(old, next) for one unique literal match when only textPatchable is true. A literal may occupy one ordinary w:t or adjacent non-empty ordinary runs with byte-identical w:rPr; mixed formatting, empty-run gaps, paragraph boundaries, fields, controls, revisions, and other graphs fail closed instead of being rebuilt.# 0) Run the shipped public-API/OfficeKit create-import-edit-export example
officekit run examples/officekit-end-to-end.mjs output.docx
# 1) Apply one source-bound literal edit to block 0. This permits a match split
# across adjacent native runs only when their formatting is byte-identical.
officekit run examples/officekit-source-text-patch-workflow.mjs \
input.docx edited.docx edited.audit.json paragraph 0 "Quarterly" "Annual"
# For table cell row 1, column 2 in block 4:
officekit run examples/officekit-source-text-patch-workflow.mjs \
input.docx edited.docx edited.audit.json tableCell 4 "Pending" "Approved" 1 2
# 2) Apply one bounded imported classic-comment text edit with full reimport/audit evidence
officekit run examples/officekit-classic-comment-edit-workflow.mjs input.docx reviewed.docx audit.json \
"Decision: proceed with controlled rollout." \
"Please confirm the final retention wording." \
"Approved after legal review."
# 3) Apply the mixed-comment board-review surgical transaction
officekit run examples/officekit-board-review-surgical-edit-workflow.mjs \
board-review.docx board-review-updated.docx audit.json
# 4) Edit one ordinary imported header paragraph. It rejects PAGE/simple fields,
# shared/inherited parts, rich text, topology changes, and every second edit to
# the same HeaderPart; only one word/headerN.xml part may change.
officekit run examples/officekit-header-text-edit-workflow.mjs input.docx reviewed.docx audit.json \
"Northwind | Internal" "Northwind | Reviewed" 0 default
# 5) Edit one ordinary imported footer paragraph. It uses the same narrow
# source-bound transaction, but accepts only one word/footerN.xml part.
officekit run examples/officekit-footer-text-edit-workflow.mjs input.docx reviewed.docx audit.json \
"Northwind | Internal" "Northwind | Reviewed" 0 default
# 6) Update one recognized imported inline/floating image's reviewed alt text.
# It binds the block index plus exact source description; visible pixels should
# remain unchanged, but native render QA and author-intent review remain required.
officekit run examples/officekit-image-alt-text-edit-workflow.mjs input.docx reviewed.docx audit.json \
1 "Existing architecture overview" "Architecture overview showing the API gateway and three service lanes"
# 6) Edit one bounded modern root + direct reply and mark the root resolved
officekit run examples/officekit-modern-comment-thread-workflow.mjs input.docx reviewed.docx audit.json \
"Decision: proceed with controlled rollout." \
"Please confirm the release evidence." "Release evidence approved." \
"The evidence is attached." "Evidence retained with the approval." resolved
# 7) Add one source-bound native single-format in-paragraph tracked replacement.
# request.json contains either paragraph-only targetBlockIndex or a structured
# paragraph/tableCell target, plus expectedText, search, replacement, author,
# and optional date.
officekit run examples/officekit-tracked-replacement-workflow.mjs \
input.docx reviewed.docx reviewed.audit.json request.json
# 7) Sanitize Google Docs-targeted title blocks after OfficeKit export
python scripts/google_docs_title_sanitize.py input.docx --out sanitized.docx
python scripts/google_docs_title_sanitize.py sanitized.docx --check
# 6) Render any DOCX to PNGs (visual QA)
python render_docx.py input.docx --output_dir out
# 7) Remove reviewer comments (explicit package-level finalization)
python scripts/comments_strip.py input.docx --out no_comments.docx
# 8) Finalize bounded whole-paragraph revisions or a canonical tracked replacement through OfficeKit
officekit run examples/officekit-revision-finalization-workflow.mjs input.docx accepted.docx audit.json accept
# Reject instead, while preserving an existing trackRevisions setting:
officekit run examples/officekit-revision-finalization-workflow.mjs input.docx rejected.docx audit.json reject --keep-tracking
# 9) Accessibility audit (+ optional explicit package fixes)
officekit run examples/officekit-accessibility-audit-workflow.mjs input.docx a11y_report.json
# Optional explicit package helper when a separately reviewed quick-fix policy is required:
python scripts/a11y_audit.py input.docx --fix_image_alt from_filename --out a11y_fixed.docx
# 10) Redact sensitive text (explicit package patch; layout-preserving by default)
python scripts/redact_docx.py input.docx redacted.docx --emails --phones
This skill is organized for progressive discovery: start here, then jump into task- or OOXML-specific docs.
DOCS SKILL PACKAGE
Root:
Artifact tool:
DocumentModel/DocumentFile and OfficeKit workflowReferences:
Tasks:
OOXML:
Troubleshooting:
Scripts:
Explicit package-patch building blocks (importable helpers):
scripts/docx_ooxml_patch.py — low-level OOXML patch helper (tracked changes, comments, hyperlinks, relationships). Other scripts reuse this; ordinary authoring does not.scripts/fields_materialize.py — explicit arbitrary-package fallback for materializing SEQ/REF field display text; canonical modeled fields use document.materializeFields().scripts/table_geometry.py — apply/audit exact Word table geometry in an existing package (tblW, tblInd, tblGrid, and every tcW match).High-leverage utilities (also importable, but commonly invoked as CLIs):
render_docx.py — canonical DOCX → PNG renderer (optional PDF via --emit_pdf; do not deliver intermediates unless asked).scripts/render_and_diff.py — render + per-page image diff between two DOCXs.scripts/google_docs_title_sanitize.py — deterministic OOXML sanitizer/audit for Google Docs-targeted DOCX title blocks; removes Word Title-style bottom borders/rules before render/import.scripts/content_controls.py — explicit package route to list / wrap / fill controls in existing templates or parts outside the bounded public model. Use paragraph.addTextContentControl(...), paragraph.addCheckboxContentControl(...), paragraph.addDropdownContentControl(...), paragraph.addComboBoxContentControl(...), paragraph.addDateContentControl(...), the matching table.getCell(row, column).addTextContentControl(...), addCheckboxContentControl(...), addDropdownContentControl(...), addComboBoxContentControl(...), and addDateContentControl(...) cell primitives, plus document.addBlockTextContentControl(...), document.contentControls, document.fillContentControls(...), document.setCheckboxContentControls(...), document.setDropdownContentControls(...), document.setComboBoxContentControls(...), and document.setDateContentControls(...) for the bounded inline/table-cell five-type profiles and body-block plain text.scripts/captions_and_crossrefs.py — insert Caption paragraphs for tables/figures + optional bookmarks around caption numbers.scripts/insert_ref_fields.py — replace [[REF:bookmark]] markers with real REF fields (cross-references).scripts/internal_nav.py — add internal navigation links (static TOC + Top/Bottom + figN/tblN jump links).scripts/style_lint.py — report common formatting/style inconsistencies.scripts/style_normalize.py — conservative cleanup (clear run-level overrides; optional paragraph overrides).scripts/redact_docx.py — layout-preserving redaction/anonymization.scripts/privacy_scrub.py — remove personal metadata + rsid* attributes.scripts/set_protection.py — restrict editing (read-only / comments / forms).scripts/comments_extract.py — extract comments to JSON (text, author/date, resolved flag, anchored snippets).scripts/comments_strip.py — remove all comments (final-delivery mode).Audits / conversions / niche helpers:
scripts/fields_report.py, scripts/heading_audit.py, scripts/section_audit.py, scripts/images_audit.py, scripts/footnotes_report.py, scripts/watermark_audit_remove.pyscripts/xlsx_to_docx_table.py, scripts/docx_table_to_csv.pyscripts/insert_toc.py, scripts/insert_note.py, scripts/apply_template_styles.py, scripts/accept_tracked_changes.py, scripts/make_fixtures.pyv7 additions (stress-test helpers):
scripts/watermark_add.py — add a detectable VML watermark object into an existing header.scripts/comments_add.py — add multiple comments (by paragraph substring match) and wire up comments.xml plumbing if needed.scripts/comments_apply_patch.py — append/replace comment text and mark/clear resolved state (w:done=1).scripts/add_tracked_replacements.py — generate tracked-change replacements (<w:del> + <w:ins>) in-place.scripts/a11y_audit.py — audit a11y issues; can also apply simple fixes via --fix_table_headers / --fix_image_alt.scripts/flatten_ref_fields.py — replace REF/PAGEREF field blocks with their cached visible text for deterministic rendering.
scripts/xlsx_to_docx_table.pyalso marks header rows as repeating headers (w:tblHeader) to improve a11y and multi-page tables.
Examples:
examples/officekit-accessibility-audit-workflow.mjs — read-only imported-DOCX audit with source SHA-256/immutability, no-overwrite JSON publication, no silent fallback, document.verify() evidence, and explicit non-conformance boundariesexamples/officekit-end-to-end.mjs — runnable public-API create → export → import → typed text/checkbox/drop-down/combo-box/date-control edit → export → import vertical sliceexamples/officekit-source-text-patch-workflow.mjs — source-bound paragraph/table-cell literal replacement with same-format run-fragment support, immutable input, exact changed-part audit, no-replace publication, second import, verification, and model render evidenceexamples/officekit-classic-comment-edit-workflow.mjs — imported classic-comment text-only edit with a unique text anchor, fixed comment topology, second import, model render, byte-bound audit, and atomic outputexamples/officekit-board-review-surgical-edit-workflow.mjs — source-bound board-review paragraph/table/classic-comment edit that preserves mixed modern comment replies, fields, notes, sections, page furniture, and complex-table parts; it uses DocumentFile.patchDocx only after typed import/precondition checks and proves an exact two-part rewriteexamples/officekit-header-text-edit-workflow.mjs — one ordinary source-bound HeaderPart paragraph edit with immutable input, exact one-part and header-residual proof, no-replace publication, second import, verification, and byte-bound audit; PAGE/simple fields and all broader page furniture fail closedexamples/officekit-footer-text-edit-workflow.mjs — the symmetric ordinary source-bound FooterPart transaction with the same immutable input, exact one-part/footer-residual proof, no-replace publication, second import, verification, and byte-bound audit; it never treats PAGE/simple fields or rich/shared page furniture as textexamples/officekit-note-text-edit-workflow.mjs — one fixed imported footnote/endnote physical-paragraph text edit bound to the semantic note ID, native ID, anchor ID, index, and exact source text; it permits only the matching note part, proves the raw residual outside that text leaf, reimports, verifies, model-renders, and publishes without overwriteexamples/officekit-heading-level-edit-workflow.mjs — one imported direct-body heading-level repair bound to block index, exact text/style/direct outline state, and the complete audited level jump; it changes only one canonical direct w:outlineLvl, rejects new accessibility issues, proves an unchanged semantic/visual projection, and publishes without overwriteexamples/officekit-hyperlink-text-edit-workflow.mjs — one canonical imported whole-paragraph hyperlink label edit bound to block index, complete old text, and exact http(s)/bookmark destination; it permits only the target w:t/xml:space state in word/document.xml, preserves relationship/formatting semantics, reimports, audits accessibility, renders, and publishes without overwriteexamples/officekit-image-alt-text-edit-workflow.mjs — one canonical imported inline or bounded floating image alternative-text edit with source block/old-text binding, paired native-description residual proof, immutable input, exact word/document.xml scope, reimport, model/native-render QA, and byte-bound auditexamples/officekit-table-header-rows-edit-workflow.mjs — one canonical imported flat-table repeat-header correction with source block/count binding, native w:tblHeader-prefix residual proof, immutable input, exact word/document.xml scope, reimport, model/native-render QA, and byte-bound auditexamples/officekit-table-row-break-policy-edit-workflow.mjs — one canonical imported flat-table physical-row pagination correction with source block/row/boolean binding, native w:cantSplit residual proof, immutable input, exact word/document.xml scope, reimport, model/native-render QA, and byte-bound auditexamples/officekit-table-accessibility-edit-workflow.mjs — one canonical imported table alternative-text transaction with source block/full-metadata binding, w:tblCaption/w:tblDescription residual proof, immutable input, exact word/document.xml scope, reimport, model/native-render QA, and byte-bound auditexamples/officekit-table-formatting-edit-workflow.mjs — one fixed-layout direct-formatting transaction with optional canonical table-level w:jc placement and a paired minimumRowHeightsDxa non-clipping row-minimum profile, raw residual proof, second import, model/native-render QA, and byte-bound auditexamples/officekit-modern-comment-thread-workflow.mjs — imported bounded root/direct-reply text and resolved-state edit with fixed identities/topology, second import, model/native render, byte-bound audit, and atomic outputexamples/officekit-watermark-workflow.mjs — unique recognized canonical VML text-watermark edit/removal with immutable input, exact one-header-part scope, second import, model render, and byte-bound auditexamples/end_to_end_smoke_test.md — optional reference-compatible checklist for the explicit Python render/package-patch helpers; keep the public OfficeKit workflow above as the defaultNote:
manifest.txtis machine-readable and is used by download tooling. It must contain only relative file paths (one per line).
This is a quick index so you can jump from a helper script to the right task guide.
style_lint.py, style_normalize.py → tasks/style_lint_normalize.mdapply_template_styles.py → tasks/templates_style_packs.mdsection_audit.py → tasks/sections_layout.mdheading_audit.py → tasks/headings_numbering.mdimages_audit.py, a11y_audit.py → tasks/images_figures.md, tasks/accessibility_a11y.mdcaptions_and_crossrefs.py → tasks/captions_crossrefs.mddocument.addImage({ ..., placement }) for the bounded public floating profile; keep inline placement as the default and treat native rendering as authoritative.alt must change, use examples/officekit-image-alt-text-edit-workflow.mjs; it never guesses a description or alters the asset/geometry.table_geometry.py → root Design Preset Contract table geometry rulesxlsx_to_docx_table.py → tasks/tables_spreadsheets.mddocx_table_to_csv.py → tasks/tables_spreadsheets.mdfields_report.py, fields_materialize.py → tasks/fields_update.mdinsert_ref_fields.py, flatten_ref_fields.py → tasks/fields_update.md, tasks/captions_crossrefs.mdinsert_toc.py → tasks/toc_workflow.mddocument.addInsertion(...) / document.addDeletion(...) authors standalone whole-paragraph revisions, while DocumentFile.addTrackedReplacement(...) plus examples/officekit-tracked-replacement-workflow.mjs adds one exact source-bound native in-paragraph deletion/insertion pair in either a direct body paragraph or one bounded direct table-cell paragraph. document.setSettings({ trackRevisions: true }) independently enables future-change tracking. DocumentFile.finalizeRevisions(...) accepts/rejects both bounded profiles; the shipped revision-finalization workflow adds richer whole-block projection checks. add_tracked_replacements.py and accept_tracked_changes.py remain explicit helpers only for broader graphs → ooxml/tracked_changes.md, tasks/clean_tracked_changes.mdexamples/officekit-classic-comment-edit-workflow.mjs is the preferred public route for one uniquely located imported classic comment when only its text may changeexamples/officekit-board-review-surgical-edit-workflow.mjs is the bounded route for a known board-review packet whose classic and modern comment families coexist. The modern root/direct/nested graph is source-bound; only the uniquely anchored classic comment text, one recommendation run, and one risk-table status cell may change. If comment identity, table ownership, or source values are ambiguous, refuse before writing. Its audit savePolicy.strategy is exactly rewrite; atomic no-overwrite publication is an output-safety mechanism, not a second save policy, so do not post-process or rename the workflow audit strategy.examples/officekit-modern-comment-thread-workflow.mjs handles one recognized root plus one direct reply: text and root resolved state may change, while imported identity, people/durable metadata, anchors, and topology stay source-bound; nested or irregular graphs fail closedcomments_add.py, comments_extract.py, comments_apply_patch.py, comments_strip.py → tasks/comments_manage.mdprivacy_scrub.py → tasks/privacy_scrub_metadata.mdredact_docx.py → tasks/redaction_anonymization.mdwatermark_add.py, watermark_audit_remove.py → tasks/watermarks_background.mdinternal_nav.py → tasks/navigation_internal_links.mdmerge_docx_append.py → tasks/multi_doc_merge.mdparagraph.addTextContentControl(...), paragraph.addCheckboxContentControl(...), paragraph.addDropdownContentControl(...), paragraph.addComboBoxContentControl(...), paragraph.addDateContentControl(...), the matching table.getCell(row, column) five-type content-control primitives, document.addBlockTextContentControl(...), document.contentControls, document.fillContentControls(...), and the four typed setters handle source-free and recognized imported canonical inline/table-cell profiles; content_controls.py handles explicit existing-template/package routes → tasks/forms_content_controls.mddocument.setSettings({ documentProtection: ... }) authors, imports, changes, or removes the bounded passwordless Word editing-restriction modes; set_protection.py remains an explicit reference-compatible package helper and never a silent fallback → tasks/protection_restrict_editing.mddocument.setSettings({ mirrorMargins: true }) authors, imports, changes, or removes the canonical facing-page inside/outside-margin flag. It does not swap margin values itself; irregular imported w:mirrorMargins markup remains source-owned and fails closed on replacement → artifact_tool/API_QUICK_START.mddocument.setSettings({ gutterAtTop: true }) plus document.addSection({ margins: { gutter: 720, ... } }) authors a top-edge binding allowance; omit/disable gutterAtTop for the binding-side gutter. Imported canonical settings and w:pgMar/@w:gutter are editable, while irregular page-margin mode markup makes section geometry read-only and fails closed → artifact_tool/API_QUICK_START.mddocument.addSection({ columns: { count: 2, spacing: 720, separator: true } }) authors canonical equal-width native w:cols; use columns: { definitions: [{ width: 3000, spacing: 720 }, { width: 5640, spacing: 0 }], separator: true } for explicit widths. Each profile is bounded to 1–45 columns and must fit the page content width; ambiguous, extension-bearing, or otherwise irregular graphs remain source-owned/read-only → tasks/sections_layout.md, artifact_tool/API_QUICK_START.mddocument.addSection({ lineNumbering: { countBy: 5, start: 0, distance: 360, restart: "newPage" } }) authors canonical w:lnNumType before each text column. countBy defaults to 1; native start is zero-based; distance uses twentieths of a point; restart may be newPage, newSection, or continuous. Use paragraphFormat: { suppressLineNumbers: true } on a paragraph or named paragraph style to exclude its lines from display/calculation; explicit false overrides inherited style suppression and omission inherits. Use paragraphFormat: { shadingFill: "#FEF3C7" } for one canonical solid paragraph background. It is neither a pattern/theme API nor a generic style writer; a recognized ordinary direct paragraph can add, change, or clear its canonical fill inside the modeled direct-formatting profile. keepNext, boolean keepLinesTogether, boolean widowControl, and pageBreakBefore are separate native paragraph pagination directives; they do not calculate pages. Canonical imported direct leaves are editable only within their fixed profile; irregular suppression/shading/section/pagination leaves and imported style-catalog changes remain source-owned and fail closed → tasks/sections_layout.md, artifact_tool/API_QUICK_START.mddocument.addParagraph("Decision", { paragraphFormat: { borders: { bottom: { color: "#315A83", size: 8, space: 2 } } } }) authors one bounded direct w:pBdr profile. Use only top, left, bottom, right, between, or bar; every edge requires #RRGGBB plus a 2..96 eighth-point size, and optional 0..31-point space. The writer fixes w:val="single"; a recognized ordinary direct paragraph can add, replace, or clear the complete profile. Source-free paragraph styles may author the same profile, but imported style catalogs, themes/patterns/frame/shadow, other styles, duplicate edges, or irregular markup stay source-owned and fail closed → tasks/sections_layout.md, artifact_tool/API_QUICK_START.mddocument.addSection({ pageNumbering: { start: 1, format: "lowerRoman" } }) authors canonical w:pgNumType; start is optional (omission continues the prior sequence), and format may be decimal, upper/lower Roman, or upper/lower letter. This controls PAGE-field presentation but does not insert or refresh a field. Chapter-numbered, duplicate, extension-bearing, or otherwise irregular graphs remain source-owned/read-only → tasks/sections_layout.md, artifact_tool/API_QUICK_START.mdexamples/officekit-section-page-numbering-edit-workflow.mjs performs a no-replace transaction. It permits only word/document.xml, reimports, compares a namespace-tolerant raw OPC residual outside the target w:pgNumType, and binds source/output bytes in its audit. It never adds PAGE fields or refreshes cached field text → tasks/sections_layout.mdmargins object are known, examples/officekit-section-margin-edit-workflow.mjs performs a no-replace margin transaction. It permits only word/document.xml, changes only the target canonical w:pgMar body-margin attributes, keeps native header/footer distances as raw canaries, reimports the complete section projection, and binds source/output bytes in its audit → tasks/sections_layout.mdorientation plus two-dimension pageSize object are known, examples/officekit-section-page-geometry-edit-workflow.mjs performs a no-replace page-geometry transaction. It treats w:pgSz as one atomic leaf, permits only word/document.xml, reimports the complete section projection, and binds source/output bytes in its audit; it never silently rescales content → tasks/sections_layout.mdlineNumbering object are known, examples/officekit-section-line-numbering-edit-workflow.mjs performs a no-replace transaction. It permits only word/document.xml, compares a raw OPC residual outside the one w:lnNumType leaf, reimports the complete section projection, and binds source/output bytes in its audit; it never infers displayed line numbers or edits paragraph suppression → tasks/sections_layout.mdcolumns profile are known, examples/officekit-section-columns-edit-workflow.mjs performs a no-replace transaction. It permits only word/document.xml, retains the source width-profile shape, compares a raw OPC residual outside the one w:cols element, reimports the complete section projection, and binds source/output bytes in its audit; it never adds/removes columns or claims to calculate column flow → tasks/sections_layout.mdbreakType are known, examples/officekit-section-break-edit-workflow.mjs performs a no-replace transaction. It permits only word/document.xml, compares a raw OPC residual outside the one w:type leaf, reimports the complete section projection, and binds source/output bytes in its audit; it never moves a boundary or claims to calculate pagination → tasks/sections_layout.mdcolumnWidthsDxa are known, examples/officekit-table-column-widths-edit-workflow.mjs redistributes widths without changing the total table width. It permits only word/document.xml, keeps every grid/cell topology, text, style, and direct-formatting value bound, compares a raw OPC residual outside matching w:tblGrid/w:gridCol and w:tcW widths, reimports the full table projection, and binds source/output bytes in its audit; it never guesses ideal widths, changes a merge, or claims to calculate resulting wrapping → tasks/tables_spreadsheets.mdexamples/officekit-table-formatting-edit-workflow.mjs changes only table indentation, one optional canonical table-level w:jc leaf, four cell margins, six uniform borders, the uniformly shaded first-row fill, and one optional uniform physical-cell w:vAlign value. center/right w:jc requires zero indentation, keeping placement semantics unambiguous. An optional minimumRowHeightsDxa must appear in both source and replacement profiles, contain one value per physical row, and maps only to canonical non-clipping w:trHeight hRule="atLeast" leaves; it can add, change, or clear those row minima but never writes exact heights. Mixed, missing, duplicate, exact, or irregular alignment/row-property leaves fail closed. It retains the table width, grid/cell widths, text, style, and topology; permits only word/document.xml; compares a raw OPC residual outside those bound leaves; reimports the full table projection; and writes a no-overwrite byte-bound audit. It is not a generic table-style editor and never infers wrapping or page flow → tasks/tables_spreadsheets.mdexamples/officekit-table-header-rows-edit-workflow.mjs changes only the contiguous leading w:tblHeader prefix. It keeps text, headerFill, widths, style, row/cell topology, and all non-document parts bound; permits only word/document.xml; proves a raw residual outside those marker leaves; reimports the full table projection; and writes a no-overwrite byte-bound audit. It does not infer header semantics from bold or fill, calculate pagination, or accept irregular row properties → tasks/accessibility_a11y.mdkeepTogether source state are known, examples/officekit-table-row-break-policy-edit-workflow.mjs changes only that native w:cantSplit leaf. It keeps repeat-header state, text, headerFill, widths, style, row/cell topology, and all non-document parts bound; permits only word/document.xml; proves a raw residual outside that leaf; reimports the full table projection; and writes a no-overwrite byte-bound audit. It does not group rows or calculate pagination, and it rejects irregular row-property graphs → tasks/tables_spreadsheets.mdaccessibility metadata are known, examples/officekit-table-accessibility-edit-workflow.mjs changes only native w:tblCaption/@w:val and w:tblDescription/@w:val leaves. The replacement object can add, replace, or clear either value; it does not create a visible caption or edit geometry, cells, style, or layout. It permits only word/document.xml, proves a raw residual outside those leaves, reimports the full table projection, and writes a no-overwrite byte-bound audit. Duplicate, empty, child-bearing, extension-bearing, nested, stale, and opaque alternative-text markup fails closed → tasks/accessibility_a11y.mdexamples/officekit-note-text-edit-workflow.mjs performs a no-replace transaction. It permits only word/footnotes.xml or word/endnotes.xml, reimports, compares a raw OPC residual outside the requested w:t, and binds source/output bytes in its audit. It never moves a reference, changes note count, or rebuilds a rich note graph → tasks/footnotes_endnotes.mdrender_and_diff.py, render_docx.py → tasks/compare_diff.md, tasks/verify_render.mdmake_fixtures.py → tasks/fixtures_edge_cases.mddocx_ooxml_patch.py → used across guides for targeted patchestasks/ — task playbooks (what to do step-by-step)references/ — compact reference material loaded only when needed, including design presetsooxml/ — advanced OOXML patches (tracked changes, comments, hyperlinks, fields)scripts/ — reusable helper scriptsexamples/ — small runnable examplestemplate-distill.md — distill a retained DOCX into a task-local artifact.mdtemplate-create.md — create from the retained DOCX and its artifact.mdRule of thumb: every meaningful edit batch ends with a render and review; only direct pixel understanding counts as visual review. "80/20" here means: follow the simplest workflow that covers most DOCX tasks reliably.
Golden path (don’t mix-and-match unless debugging):
DocumentModel and DocumentFile from office-kit.verify()/inspect() assertions for the requested content.Use the packaged renderer (dedicated LibreOffice profile + writable HOME):
python render_docx.py /mnt/data/input.docx --output_dir /mnt/data/out
# If debugging LibreOffice:
python render_docx.py /mnt/data/input.docx --output_dir /mnt/data/out --verbose
# Optional: also write <input_stem>.pdf to --output_dir (for debugging/archival):
python render_docx.py /mnt/data/input.docx --output_dir /mnt/data/out --emit_pdf
Then inspect the generated page-<N>.png files when visual input is available.
Without it, use the shared post-edit review contract. Request the text reading
view (contentView: "anydoc") only for an identified coverage gap in headings,
paragraphs, or tables. AnyDoc does not validate pagination, typography, images,
or layout.
Success criteria (render + visual QA):
Note: LibreOffice sometimes prints scary-looking stderr (e.g., error : Unknown IO error) even when output is correct. Treat the render as successful if the PNGs exist and look right (and if you used --emit_pdf, the PDF exists and is non-empty).
tasks/read_review.mdtasks/create_edit.mdtasks/accessibility_a11y.mdtasks/comments_manage.mdtasks/protection_restrict_editing.mdtasks/privacy_scrub_metadata.mdtasks/multi_doc_merge.mdtasks/style_lint_normalize.mdtasks/forms_content_controls.md for explicit placement, typed updates, strict tag matching, advanced package routes, and fail-closed boundariesdocument.addBibliographySource(...), document.addCitation(...), and once per source-free document document.addBibliography(...); it emits a canonical BIBLIOGRAPHY field plus the update-on-open hint, but a compatible Word host—not JavaScript—must calculate the formatted entries. Imported canonical output fields allow cached-display edits only; source order/tags, citation tags, and the field instruction stay fixeddocument.addTableOfContents(...), preserve the resulting settings.updateFields refresh hint, then follow tasks/toc_workflow.md for host refresh and page-level verificationparagraph.addField(...), including bookmarkName on a SEQ field when REF/PAGEREF must target only the caption number; use document.materializeFields() for transactional SEQ/REF caches, then follow tasks/captions_crossrefs.md; use the explicit package helper for bulk/arbitrary-package insertion and a real pagination host for PAGEREFtasks/redaction_anonymization.mdtasks/verify_render.mdtasks/fields_update.mdtasks/toc_workflow.mdtasks/navigation_internal_links.mdtasks/headings_numbering.mdtasks/sections_layout.mdexamples/officekit-{header,footer}-text-edit-workflow.mjs, then follow tasks/headers_footers.md; each proves exactly one target word/headerN.xml or word/footerN.xml part and its residual before no-replace publication. PAGE/simple fields, rich, shared, inherited, or irregular page furniture stays read-onlyalt, then use examples/officekit-image-alt-text-edit-workflow.mjs; it changes only the paired native description leaves and requires native render plus human author-intent review. For missing/irregular descriptions or asset/placement work, follow tasks/images_figures.mdexamples/officekit-heading-level-edit-workflow.mjs; it changes one canonical direct w:outlineLvl override without renaming the style or changing visible content. A newly introduced hierarchy issue, irregular paragraph properties, stale facts, or package drift fails closed; native render and editorial hierarchy review remain requiredexamples/officekit-hyperlink-text-edit-workflow.mjs; it changes one canonical native text leaf and requires native render plus author-purpose review. Rich, multi-run, nested, table/textbox, or irregular links stay source-bounddocument.addImage({ ..., placement }) profile and follow tasks/images_figures.md; never infer support for an imported anchor from its visible appearance alonetasks/tables_spreadsheets.mddocument.addInsertion(...) / document.addDeletion(...) for whole blocks, or examples/officekit-tracked-replacement-workflow.mjs for one exact source-bound literal inside a direct body paragraph or bounded single-paragraph table cell; use document.setSettings({ trackRevisions: true }) for future edits, then route broader graphs through ooxml/tracked_changes.mdooxml/comments.mdooxml/hyperlinks_and_fields.mdtroubleshooting/libreoffice_headless.mdexamples/officekit-revision-finalization-workflow.mjs, then follow tasks/clean_tracked_changes.md for capability boundaries and native render QAtasks/compare_diff.mdtasks/templates_style_packs.mdreferences/header_templates.mddocument.addWatermark(...) or the shipped source-bound edit/removal workflow, then follow tasks/watermarks_background.md; image, DrawingML, shared-header, multiple, and irregular VML backgrounds stay opaque or require an explicit reviewed package routedocument.addFootnote(...) / document.addEndnote(...) for the bounded 1-through-16 physical-paragraph plain-text profile. For one existing canonical physical paragraph, use examples/officekit-note-text-edit-workflow.mjs with its inspected note/anchor/native IDs and exact source text; otherwise follow tasks/footnotes_endnotes.md for import, audit, advanced graphs, and render QAtasks/fixtures_edge_cases.mdReturn the final DOCX as an absolute path, its SHA-256, and kind: "document".
Include page locators and inspect/render/verify evidence paths when they are
available. Report visualReview: "complete" only after the required page PNGs
were understood; otherwise use "unavailable" or "requires-human". Do not
emit a host-specific citation directive. The shared contract in
../office-kit/references/workspace.md defines the result envelope.
LICENSE.txt (opens in a new tab)agents/agent.yaml (opens in a new tab)agents/openai.yaml (opens in a new tab)artifact_tool/ACCESSIBILITY_AUDIT.md (opens in a new tab)artifact_tool/API_QUICK_START.md (opens in a new tab)artifact_tool/_source_bound_docx.mjs (opens in a new tab)artifact_tool/_source_bound_sections.mjs (opens in a new tab)assets/file-document.png (opens in a new tab)examples/end_to_end_smoke_test.md (opens in a new tab)examples/officekit-accessibility-audit-workflow.mjs (opens in a new tab)examples/officekit-board-review-surgical-edit-workflow.mjs (opens in a new tab)examples/officekit-classic-comment-edit-workflow.mjs (opens in a new tab)examples/officekit-end-to-end.mjs (opens in a new tab)examples/officekit-footer-text-edit-workflow.mjs (opens in a new tab)examples/officekit-header-text-edit-workflow.mjs (opens in a new tab)examples/officekit-heading-level-edit-workflow.mjs (opens in a new tab)examples/officekit-hyperlink-text-edit-workflow.mjs (opens in a new tab)examples/officekit-image-alt-text-edit-workflow.mjs (opens in a new tab)examples/officekit-modern-comment-thread-workflow.mjs (opens in a new tab)examples/officekit-note-text-edit-workflow.mjs (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
docx, word, google-docs, office-kit, document-creation, visual-qa
/documents:documentsfrom Documents
npx claudepluginhub w31r4/officekit --plugin documentsOther plugins' skills for the same job