Understand that python-docx does not natively support inserting OOXML tracked-change revision marks (w:ins, w:del); to produce true redlines you must manipulate the underlying XML directly via python-docx's element access or use a library like docx2python or a DOCX manipulation API.
For deletions, wrap the run XML in a w:del element with w:id, w:author, and w:date attributes; the run content moves inside a w:delText element.
For insertions, wrap new run XML in a w:ins element with the same required attributes; this signals to Word and compatible viewers that the text is an addition.
Set the w:author attribute to a meaningful name (e.g., the AI reviewer or the user) and w:date to an ISO 8601 datetime so the change is attributed correctly in the revision pane.
Validate the output by opening the file in Microsoft Word or LibreOffice and confirming that Track Changes shows the expected insertions and deletions before delivering to end users.
Known gotchas
OOXML tracked changes require matching w:id values that are unique within the document; duplicate IDs cause Word to silently discard or merge revisions in unpredictable ways.
python-docx's high-level API does not preserve or manipulate tracked changes; any call to paragraph.add_run() or similar high-level methods on a paragraph containing revision marks can corrupt the XML structure.
Automated redlines produced by code are a drafting aid only; clause-level legal judgment about what changes are appropriate requires attorney review.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp