docx-win
Skill27 starsChanged 3 months agoMITView on GitHub
native microsoft word automation for windows .docx workflows. use when chatgpt or codex is running on windows with microsoft word installed and needs to create, edit, review, convert, or verify word documents through word com automation. trigger for .docx or .doc requests, professional word deliverables, no-template document polish, tracked changes, comments, find and replace, table of contents, headers and footers, page numbering, layout-sensitive edits, or exporting a word document to pdf for review. prefer this skill over libreoffice-based document workflows when word is available.
In this repository16 other files it gives its agents.
- adversarial-plan-review-codexSkill
- canvas-design-codexSkill
- code-intelligenceSkill
- code-mapper-skillSkill
- deep-planning-codexSkill
- document-handoffSkill
- frontend-design-codexSkill
- grill-me-codexSkill
- grill-with-docs-codexSkill
- handoff-codexSkill
- pptx-winSkill
- repo-map-codexSkill
- ultraplan-codexSkill
- verification-plan-codexSkill
- web-artifacts-builder-codexSkill
- xlsx-winSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
36 rules. About 0 are common, 19 are distinctive, and 17 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈19
Distinctive · estimate
This author's own choices. Worth a look.
17
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
Use docx-win to teach Codex how to turn an untemplated brief into a Word document that is structured, reviewable, and render-verified.
- Very specific: line 32
Read references/document-quality-map.md when a task asks for a polished document, executive memo, report, proposal, or other no-template …
- Very specific: line 34
Use Microsoft Word COM automation on Windows as the default engine for .docx work.
- Distinctive: line 35
Do not use LibreOffice when Word is installed.
- Distinctive: line 36
Do not edit OOXML directly unless Word automation fails and the task truly requires low-level repair.
- Distinctive: line 44
Update fields, pagination, and table of contents before final save.
- Distinctive: line 52
Before any Word COM step, run the shared Office preflight from a regular PowerShell window opened as the signed-in desktop user:
- Very specific: line 66
If preflight reports can_use_com = false, do not create Word.Application from the Codex sandbox.
- Distinctive: line 81
If the smoke test fails, stop and fix the local Word/Office environment before attempting production edits.
- Very specific: line 85
Prefer PowerShell scripts in scripts/ over ad hoc GUI interaction.
- Very specific: line 86
Keep Word.Application.Visible = $false unless visual debugging is required.
- Distinctive: line 93
Before final delivery, update all fields and tables of contents, then save again.
- Very specific: line 94
Always close the document and quit Word in finally blocks.
- Very specific: line 95
Always release COM objects.
- Very specific: line 96
Never call New-Object -ComObject Word.Application directly from the Codex sandbox.
- Very specific: line 134
Use Word COM to build the document directly when the user needs a polished Word deliverable.
- Very specific: line 135
Prefer built-in styles such as Title, Heading 1, Heading 2, and Normal instead of manual font-only formatting.
- Distinctive: line 136
Use tables, headers, footers, page numbers, and images through COM objects rather than raw XML.
- Distinctive: line 140
update tables of contents if present,
- Very specific: line 145
Use references/word-com-recipes.md for common construction patterns.
- Very specific: line 146
Use references/document-quality-map.md to decide the document structure, page system, visual evidence, and verification loop when no …
- Distinctive: line 155
When the user wants a clean deliverable:
- Distinctive: line 157
remove comments only if the user asked for them removed,
- Distinctive: line 158
update fields and TOC before final save.
- Distinctive: line 160
When the user wants review markup preserved:
- Very specific: line 161
leave TrackRevisions enabled before making edits,
- Distinctive: line 162
add comments through Word comments,
- Distinctive: line 167
Use Word-native review features through COM.
- Very specific: line 170
Add comments through $doc.Comments.Add(...).
- Distinctive: line 172
Update fields after accepting revisions because pagination and references may change.
- Distinctive: line 176
Use this verification loop whenever formatting or pagination matters:
- Distinctive: line 187
update tables of contents,
- Distinctive: line 227
If Word cannot be automated:
- Very specific: line 231
check for blocked dialogs, protected view, or orphaned WINWORD.EXE processes,
- Very specific: line 234
If Word COM throws 0x80070520, treat that as a wrong-session problem, not as a document problem.
- Distinctive: line 236
Only fall back to lower-level ZIP/XML repair when Word COM is unavailable or the file is structurally damaged in a way Word cannot fix.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
DOCX Win
Notes
Provenance
- Upstream repo:
https://github.com/anthropics/skills - Source folder:
skills/docx - Source branch:
main
Porting Notes
- This is a Windows COM adaptation of Anthropic's
docxskill for Codex. - The upstream skill centers on OOXML unpack/edit flows plus LibreOffice-backed conversion and accept-changes helpers.
- This port changes the default execution path to PowerShell wrappers around Microsoft Word COM so Word handles create, edit, review, comments, revisions, fields, pagination, and PDF export directly.
- It remains Windows-only because reliable execution depends on a local Microsoft Word desktop installation and COM automation.
Design Upskill Contribution
Use docx-win to teach Codex how to turn an untemplated brief into a Word document that is structured, reviewable, and render-verified. The skill contributes:
- Word-native style and section discipline instead of manual font-only formatting,
- layout fidelity through Word pagination, field refresh, and PDF evidence,
- review-state handling through comments and tracked changes,
- a clear non-COM versus COM split so Codex can prepare content safely and hand true rendering to Word when required.
Read references/document-quality-map.md when a task asks for a polished document, executive memo, report, proposal, or other no-template Word deliverable.
Use Microsoft Word COM automation on Windows as the default engine for .docx work.
Do not use LibreOffice when Word is installed.
Do not edit OOXML directly unless Word automation fails and the task truly requires low-level repair.
Workflow
- Preflight the machine.
- Choose create vs edit vs review.
- Save a working copy before risky changes.
- Make changes through Word COM.
- Update fields, pagination, and table of contents before final save.
- Export to PDF when layout matters.
- Close Word cleanly and release COM objects.
For no-template document creation or major restyling, use references/document-quality-map.md before writing automation so the structure, styles, page system, tables, review state, and PDF proof are planned together.
Preflight
Before any Word COM step, run the shared Office preflight from a regular PowerShell window opened as the signed-in desktop user:
& "$env:USERPROFILE\.codex\skills\.shared\office-com\scripts\office_com_preflight.ps1" -Apps WordThat path assumes a Codex-style install. If this skill is loaded through a Claude Code plugin instead, resolve the same script from the plugin cache first:
$preflight = (Get-ChildItem "$env:USERPROFILE\.claude\plugins\cache" -Recurse -Filter "office_com_preflight.ps1" -ErrorAction SilentlyContinue | Select-Object -First 1).FullName
if (-not $preflight) { $preflight = "$env:USERPROFILE\.codex\skills\.shared\office-com\scripts\office_com_preflight.ps1" }
& $preflight -Apps WordIf preflight reports can_use_com = false, do not create Word.Application from the Codex sandbox. Prepare non-COM inputs in Codex and run the Word COM step from that desktop-user PowerShell window through scripts/invoke-docx-win.ps1 or a task-specific script.
For a new machine or after an Office repair/update, run:
& "$env:USERPROFILE\.codex\skills\docx-win\scripts\invoke-docx-win.ps1" -Action smoke-testThe smoke test proves that:
- Word COM automation can start.
- A document can be created and saved.
- Tracked changes and comments work.
- A PDF export works.
- Page statistics can be computed.
If the smoke test fails, stop and fix the local Word/Office environment before attempting production edits.
Default operating rules
- Prefer PowerShell scripts in
scripts/over ad hoc GUI interaction. - Keep
Word.Application.Visible = $falseunless visual debugging is required. - Set
DisplayAlerts = 0to avoid blocking prompts. - Work on a copy unless the user clearly wants in-place edits.
- Save output as
.docxunless the user explicitly requests another format. - For legacy
.doc, convert to.docxfirst. - For layout-sensitive work, export a PDF after meaningful changes and inspect that PDF.
- For no-template deliverables, use Word styles, sections, fields, tables, and inline shapes as design structures rather than only changing visible text formatting.
- Before final delivery, update all fields and tables of contents, then save again.
- Always close the document and quit Word in
finallyblocks. - Always release COM objects. Orphaned
WINWORD.EXEprocesses are a reliability bug. - Never call
New-Object -ComObject Word.Applicationdirectly from the Codex sandbox. Use the shared preflight and then run COM work from the signed-in desktop user session throughscripts/invoke-docx-win.ps1or a task-specific script.
Common commands
Convert legacy .doc to .docx
& "$env:USERPROFILE\.codex\skills\docx-win\scripts\invoke-docx-win.ps1" -Action convert-doc-to-docx -InputPath .\input.doc -OutputPath .\input.docxExport .docx to PDF for review
& "$env:USERPROFILE\.codex\skills\docx-win\scripts\invoke-docx-win.ps1" -Action export-pdf -InputPath .\report.docx -OutputPath .\report.pdfAccept all tracked changes
& "$env:USERPROFILE\.codex\skills\docx-win\scripts\invoke-docx-win.ps1" -Action accept-revisions -InputPath .\draft.docx -OutputPath .\clean.docxFind and replace across the document
& "$env:USERPROFILE\.codex\skills\docx-win\scripts\invoke-docx-win.ps1" -Action find-replace -InputPath .\draft.docx -FindText "Old Name" -ReplaceText "New Name" -OutputPath .\draft-updated.docxAdd a comment to a specific range
& "$env:USERPROFILE\.codex\skills\docx-win\scripts\invoke-docx-win.ps1" -Action add-comment -InputPath .\draft.docx -Start 1 -End 25 -CommentText "verify this figure" -Author "Codex" -Initials "CX" -OutputPath .\draft-commented.docxDecide the path
Creating a new document
Use Word COM to build the document directly when the user needs a polished Word deliverable.
Prefer built-in styles such as Title, Heading 1, Heading 2, and Normal instead of manual font-only formatting.
Use tables, headers, footers, page numbers, and images through COM objects rather than raw XML.
After creating content:
- update fields,
- update tables of contents if present,
- compute page statistics,
- save the
.docx, - export a PDF when layout matters.
Use references/word-com-recipes.md for common construction patterns.
Use references/document-quality-map.md to decide the document structure, page system, visual evidence, and verification loop when no template exists.
Editing an existing document
Open the document in Word COM and preserve its native Word behavior.
For text edits, prefer direct Range operations or the Find/Replace engine.
For style-aware edits, target paragraphs, tables, sections, headers, and footers explicitly.
For layout-sensitive work, export a PDF after each meaningful stage.
When the user wants a clean deliverable:
- accept revisions only if the user asked for a clean copy,
- remove comments only if the user asked for them removed,
- update fields and TOC before final save.
When the user wants review markup preserved:
- leave
TrackRevisionsenabled before making edits, - add comments through Word comments,
- save a reviewed copy separately from any clean copy.
Reviewing and redlining
Use Word-native review features through COM.
- Turn on tracked changes with
$doc.TrackRevisions = $truebefore making edits. - Add comments through
$doc.Comments.Add(...). - Accept all revisions through
$doc.Revisions.AcceptAll()when a clean copy is required. - Update fields after accepting revisions because pagination and references may change.
Verification standard
Use this verification loop whenever formatting or pagination matters:
- save the
.docx, - export a PDF with
scripts/export-pdf.ps1, - inspect the PDF or page count,
- fix issues,
- export again.
For final delivery:
- update fields,
- update tables of contents,
- force repagination by computing page statistics,
- save the document,
- export a PDF companion when useful.
For no-template deliverables, also verify the relevant dimensions in references/document-quality-map.md: style hierarchy, page system, tables, figures, review artifacts, field behavior, and PDF evidence.
Word COM patterns and references
Load references/word-com-recipes.md when you need examples for:
- headings and styles,
- tables,
- headers and footers,
- page numbers,
- images,
- find and replace,
- comments and tracked changes,
- field and TOC refresh,
- PDF export,
- COM cleanup.
Load references/document-quality-map.md when the task requires:
- no-template document design,
- executive-report or proposal polish,
- style hierarchy decisions,
- table and figure layout checks,
- a clear non-COM versus Word COM verification split.
Bundled scripts
scripts/word-common.ps1: shared helpers for Word COM startup, cleanup, save, field refresh, PDF export, and path handling.scripts/convert-doc-to-docx.ps1: convert legacy.docto.docx.scripts/export-pdf.ps1: export a.docxto PDF.scripts/accept-revisions.ps1: open a document and write a clean copy with all revisions accepted.scripts/find-replace.ps1: run Word's native find/replace engine and save output.scripts/add-comment.ps1: add a Word comment to a range and save output.scripts/smoke-test.ps1: end-to-end validation for the local Windows + Word automation environment.
Failure handling
If Word cannot be automated:
- confirm the machine is Windows,
- confirm Microsoft Word launches manually,
- rerun
scripts/invoke-docx-win.ps1 -Action smoke-test, - check for blocked dialogs, protected view, or orphaned
WINWORD.EXEprocesses, - retry with a fresh working copy.
If Word COM throws 0x80070520, treat that as a wrong-session problem, not as a document problem. Move the COM step to the signed-in desktop user session and rerun it there.
Only fall back to lower-level ZIP/XML repair when Word COM is unavailable or the file is structurally damaged in a way Word cannot fix.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

