docx template preserver

    by juntheworld

    1

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

    $15

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    docx template preserver

    Example session with this skill installed

    Replace the placeholder image in 'report_template.docx' with 'q3_chart.png' while keeping the original frame and caption. Verify that the footer and page numbers are unchanged.

    • Read your context and instructions
    • Compiled the docx template preserver

    DOCX Template Preserver

    docx-template-preserver is a reusable Codex skill for editing an existing Word document while treating its current design as the source of truth.

    Use it when text, images, tables, captions, or sections must change without replacing the document's fonts, styles, page geometry, headers, footers, numbering, relationships, or recurring layout.

    What the skill enforces

    • The source DOCX is never edited in place.
    • The output starts as a copy of the source, not as a blank document.
    • Edits use the least invasive representation available.
    • Untouched OOXML package parts remain byte-for-byte identical whenever practical.
    • Structural checks and a full DOCX-to-PNG review are required before delivery.
    • The final answer returns only the requested document, not QA artifacts.

    Install

    Copy or symlink the skill folder into the Codex skills directory:

    cp -R docx-template-preserver ~/.codex/skills/
    

    Then invoke it explicitly or let Codex select it automatically:

    Use $docx-template-preserver to move this content into the supplied DOCX while preserving its design.
    

    Repository layout

    docx-template-preserver/
    ├── SKILL.md
    ├── agents/openai.yaml
    ├── references/
    │   ├── editing-strategies.md
    │   ├── media-and-tables.md
    │   ├── template-migration.md
    │   ├── verification.md
    │   └── case-study-code-captions.md
    ├── scripts/
    │   ├── inspect_docx.py
    │   ├── replace_media_part.py
    │   ├── replace_text_preserve_format.py
    │   └── verify_docx_preservation.py
    └── tests/smoke_test.py
    

    The scripts are helpers, not substitutes for visual review. A DOCX can be structurally valid and still have clipped text, broken pagination, or shifted figures.

    Dependencies

    The inspection, media replacement, and verification helpers use only the Python standard library. replace_text_preserve_format.py additionally requires lxml so it can patch selected WordprocessingML text nodes without rebuilding unrelated package parts.

    In Codex, prefer the runtime and renderer supplied by the installed documents skill. Outside that environment, provide Python 3, lxml, LibreOffice, and Poppler for the same edit-and-render workflow.

    Connects securely to your tools. The creator never sees your data.

    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.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 12 days ago

    Software
    Python

    Permissions

    Terminal / Shell
    Read Files
    Write Files
    Listed12 days ago

    What's inside

    Frequently Asked Questions

    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.

    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.

    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.

    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.

    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.

    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.

    New in APIs & Backend

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.