# docx template preserver

> Edit and migrate DOCX content while strictly preserving styles, headers, and layouts via structural OOXML verification.

docx template preserver is a paid AI agent skill on Agensi by juntheworld, in APIs & Backend. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $15 (one-time purchase)
- Creator: [juntheworld](https://www.agensi.io/creators/juntheworld)
- Category: [APIs & Backend](https://www.agensi.io/skills/apis-backend)
- Version: 1.0
- Last updated: 2026-11-23
- Security: scan passed (2026-11-23); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/docx-template-preserver
- Tags: api, docx-automationooxml, python, documentation

## About this skill

Modifying a complex DOCX file usually breaks its fragile styling, headers, or section breaks. High-level libraries often rewrite the entire document structure, leading to font substitutions and layout shifts. This skill treats your source document as the design authority, using targeted OOXML patching and structural verification to ensure every pixel of your template remains intact while content is updated.

### What it does
- **Targeted Content Replacement** updates text, captions, or images while preserving paragraph and run-level formatting.
- **Media Swapping** replaces images inside their existing frames, maintaining anchors, crops, and wrapping.
- **Structural Preservation** ensures headers, footers, fields, and content controls survive the editing process.
- **Visual Verification** renders every page to images to catch clipping, overlaps, or pagination shifts before delivery.
- **Integrity Auditing** compares package parts and SHA-256 hashes to prove untouched sections remain byte-for-byte identical.

### How it works
1. **Establish Baseline** by running inspection scripts to map styles, tables, and section patterns.
2. **Execute Edit** using the least invasive method, such as targeted OOXML patching or cloning existing components.
3. **Verify Structure** with comparison scripts to flag any unexplained changes in document parts.
4. **Final Rendering** to inspect every page for layout drift or font issues at 100% zoom.

### Frameworks & tools
Uses Python for automation, OOXML (Office Open XML) for low-level document patching, and `scripts/inspect_docx.py`. Integrates with LibreOffice-based renderers for visual QA.

### Why this beats prompting it yourself
Standard LLMs struggle with the underlying XML complexity of Word documents and often suggest code that destroys headers or styles. This skill follows a non-negotiable contract to verify ZIP integrity and part-level equivalence, preventing the "save-as" damage typical of high-level libraries.

### Use cases
- **Legal Document Updates** replacing specific clauses without shifting signature lines or footer metadata.
- **Branded Report Automation** inserting data into tables while strictly adhering to corporate style guides.
- **High-Fidelity Migration** moving content from one template to another using a validated slot map.
- **Technical Document Maintenance** swapping screenshots in technical manuals while keeping captions and anchors locked.

### Known limitations
Requires a reference DOCX; not for net-new designs. Visual rendering requires a compatible environment with `render_docx.py` and its dependencies.

## Requires

- Python

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the docx template preserver skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### How does this differ from standard Python libraries like python-docx for editing templates?

Standard libraries often 'rewrite' the XML, causing font shifts and broken headers. This skill uses low-level OOXML patching and structural verification to ensure the document's design integrity remains byte-for-byte identical where content isn't changed.

### What technical environment or dependencies are required to run this skill?

The skill requires a Python environment and the included scripts, specifically `inspect_docx.py`. For visual verification features, a LibreOffice-based renderer is used to ensure the final layout matches the source document exactly.

### Can I replace images without breaking the text wrapping or layout anchors?

Yes, the 'Media Swapping' feature is specifically designed to replace images within their existing frames. It maintains the original anchors, wrapping styles, and cropping parameters so your layout doesn't shift when screenshots are updated.

### What assets are included in the purchase of the 'docx template preserver' skill?

You receive the full automation logic, the `inspect_docx.py` and `render_docx.py` utility scripts, and the integration workflows for OOXML patching. It also includes the structural auditing framework used to verify document integrity.

### Can I use this skill to generate a brand-new document design from a text prompt?

This skill is designed for high-fidelity modification of existing designs, not for creating documents from scratch. It treats your source DOCX as the 'design authority' and requires a template to establish a baseline for its structural verification.

### How does the skill guarantee that my headers and footers won't be corrupted?

The skill uses SHA-256 hash comparisons and part-level integrity auditing. This ensures that sections of the document you didn't intend to change remain completely untouched at the code level.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
