Back to Blog

design-creative

docx-cli: Word document editing for AI agents

Introducing docx-cli, an agent-friendly skill for reading, editing, redlining, and creating .docx files with stable locators and exit codes.

OpenAgentSkillPublished:

Where this fits

You're building an agent that needs to redline a contract, fill out a Word template, or extract text from a .docx for analysis. Without a reliable tool, your agent either fumbles with OOXML or falls back to lossy conversions that destroy formatting. docx-cli gives you a command-line interface that edits the document in place, so your agent can handle Word files just as confidently as text files.

Why agents benefit

  • Stable locators: Every paragraph, table, and comment is addressed by a stable identifier, so your agent can target specific content without fragile string matching.
  • In-place editing: The tool modifies the underlying OOXML directly—no re-rendering from a lossy view—so formatting, tracked changes, and comments survive untouched.
  • Machine-readable success signals: Exit codes and one-line confirmations let even small or cheap models verify success without parsing verbose output.
  • Build docs from Markdown or code: Generate new .docx files with headings, tables, and images programmatically, perfect for automated report generation.
  • Comment and redline support: Add, resolve, and list comments, plus insert tracked changes—critical for contract review and collaborative editing workflows.

Practical scenarios

Contract redlining with tracked changes

Your agent reviews a contract, identifies problematic clauses, and inserts suggested edits as tracked changes. docx-cli lets you add redlines and comments, preserving the original text and enabling human reviewers to accept or reject each change.

Template filling for invoices and forms

You have a Word invoice template with placeholder fields. The agent reads the template, replaces placeholders like {{client_name}} with actual data, and saves a new .docx—all while keeping the original layout and styles intact.

Extracting content as Markdown for downstream processing

Need to feed a Word document into a summarization pipeline? docx-cli converts the .docx to Markdown or plain text, giving you clean, structured content that can be passed to other tools without worrying about hidden formatting quirks.

Add it to your agent workflow

Install the skill with:

npx skills add kklimuk/docx-cli --skill docx-cli

Then use it in your agent's toolset. For example, to replace a placeholder in a contract:

docx replace "{{party_name}}" "Acme Corp" --file contract.docx --output contract_final.docx

The command exits with 0 on success, making it easy to chain in a script or agent loop.

Compare before adopting

Before making docx-cli a permanent part of your stack, compare it with alternatives like python-docx (if you're Python-centric) or Pandoc for conversion. Check how well the stable locators fit your document types, whether the command-line interface aligns with your agent's execution model, and if the project's maintenance cadence matches your needs. Also consider whether you need advanced features like mail merge or complex table manipulation—docx-cli covers most common cases but may not replace a full Office automation suite.

Why it is worth tracking

docx-cli has 196 stars and is actively maintained, with a focus on agent reliability—its design choices (exit codes, stable locators, in-place editing) are exactly what you want when delegating document work to an LLM. The project's approach to preserving fidelity while enabling automation makes it a strong candidate for any agent that touches Word files. As the skill ecosystem grows, this is one to evaluate early—check the full details on OpenAgentSkill: https://www.openagentskill.com/skills/kklimuk-docx-cli

Featured Skill

docx-cli

Skill by kklimuk