officecli-docx

Create, edit, and validate Word .docx documents via the officecli command-line tool.

Updated Aug 19, 2026
One-click install
npx skills add https://github.com/Dhanuzh/DCode-Core --skill officecli-docx-dhanuzh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: officecli-docx
Source: https://github.com/Dhanuzh/DCode-Core/tree/main/crates/dcode-app/assets/builtin-skills/officecli-docx
Command: npx skills add https://github.com/Dhanuzh/DCode-Core --skill officecli-docx-dhanuzh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Working with .docx files programmatically is error-prone: raw XML manipulation, broken field codes, missing page numbers, and placeholder tokens leaking into finished documents. This Skill provides a disciplined, help-first workflow for building, reading, and editing Word documents through the officecli CLI, with built-in QA gates that catch formatting and content problems before delivery. ## Core Features & Use Cases - Document creation and editing: Build reports, letters, memos, and proposals with proper heading hierarchy, styles, tables, lists, images, charts, hyperlinks, and tab stops using semantic paths like /body/p[1]. - Reading and analysis: Inspect existing documents with outline, text, HTML, and stats views, plus CSS-like queries to find empty paragraphs, missing alt text, or specific styles. - Fields, TOC, headers and footers: Insert live PAGE, NUMPAGES, MERGEFIELD, and TOC fields, with explicit guidance on recalculation and a static TOC fallback for viewers that do not refresh fields. - Use Case: Generate a quarterly business review with a cover page, table of contents, styled financial tables with zebra striping, and a Page X of Y footer, then validate the result and verify the rendered HTML before handing it off. ## Quick Start Ask the AI to create a Word document named review.docx with a heading, body paragraphs, and a centered page-number footer using the officecli docx skill.

Frequently Asked Questions about officecli-docx

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Word document from the command line?

Use officecli create to make the file, open it in resident mode, then add paragraphs, headings, tables, and footers with officecli add and set commands using semantic paths like /body/p[1]. Finish with officecli close and officecli validate to confirm the document has no errors.

How do I add page numbers to a docx footer?

Add a footer with the field property: officecli add "$FILE" / --type footer --prop type=default --prop text="Page " --prop field=page. The CLI injects the live PAGE field automatically; verify with get /footer[1] --depth 3 that fldChar elements exist rather than literal text.

Does officecli work on Windows?

Yes, the officecli tool itself is cross-platform and installs on Windows via irm https://d.officecli.ai/install.ps1 | iex. However, the skill's shell snippets are written for bash/zsh, so on Windows you must translate them to PowerShell equivalents before running.

Why does my table of contents show placeholder text in the docx?

A live TOC field renders the literal 'Update field to see table of contents' until a viewer recalculates it. Either set updateFields=true so Word recomputes on open, or replace the field with a hand-written static TOC using dot-leader lines for recipients who will not recalculate.

How do I extract or search text in an existing docx file?

Start with officecli view outline to see the heading structure, then use view text for content or query with CSS-like selectors such as 'p:contains("quarterly")' to find matching paragraphs. Use get with a semantic path to inspect any single element in detail.

What are the limitations of officecli for docx generation?

officecli has no pagination engine, so PAGE, PAGEREF, NUMPAGES, and TOC page numbers cannot be pre-computed and must be deferred to Word via updateFields or recalculated manually with F9. Complex layouts should be verified with view html before delivery.