πŸ“„

Document Diff

Compare two documents and highlight differences (like Git diff for Word files).

Document ⭐⭐ Intermediate ⏱️ 5 minutes

😫 The Pain Point

You have two versions of a contract. What changed between Draft 1 and Draft 2? Reading line by line is tedious and error-prone.

πŸš€ Agentic Solution

A Document Diff Tool that highlights insertions, deletions, and modifications.

Key Features:

  • Side-by-Side View: Compare documents visually.
  • Highlight Changes: Color-coded additions/removals.
  • Export Report: Save diff as HTML or PDF.

βš”οΈ Phase 1: Commander (Quick Fix)

For quick comparison.

Prompt:

β€œI have two Word documents: contract_v1.docx and contract_v2.docx. Write a Python script using python-docx and difflib to:

  1. Extract: Text from both documents.
  2. Compare: Generate unified diff.
  3. Output: Save as diff_report.html with color-coded changes.

Show summary: X additions, Y deletions, Z modifications.”

Result: Clear visualization of all changes.

πŸ—οΈ Phase 2: Architect (Permanent Tool)

For Legal Teams.

Engineering Prompt:

**Role:** Python GUI Developer (PyQt6 Specialist)
**Task:** Create "Document Comparison Pro" Desktop App

**Objective:** A professional tool to compare Word documents and visualize changes side-by-side.

**Tech Stack:**
* Language: Python 3.10+
* GUI Library: PyQt6 (Cross-platform)
* Document Engine: python-docx, difflib, pygments
* Packaging: PyInstaller

**Functional Requirements:**
1.  **UI Layout (PyQt6):**
    *   **Inputs:** File Selectors for "Original Doc" and "Revised Doc".
    *   **View:** Split-pane HTML viewer showing diffs (Green=Added, Red=Removed).
    *   **Stats:** Counts for Insertions/Deletions.
    *   **Action:** "Export Report" (HTML/PDF).

2.  **Core Logic:**
    *   Extract text from DOCX while preserving paragraph structure.
    *   Compute unified diff using `difflib`.
    *   Generate styled HTML for the visualizer.
    *   **Threading:** Comparison processed in background thread.

3.  **Deliverables:**
    *   `main.py`: Complete source code.
    *   `requirements.txt`: Dependencies.
    *   **Build Instructions:**
        *   Windows: `pyinstaller --onefile --noconsole main.py`
        *   macOS: `pyinstaller --windowed --noconsole main.py`

🧠 Prompt Decoding

  • difflib: Python’s built-in library for comparing sequences.

πŸ› οΈ Instructions

  1. Install: pip install python-docx
  2. Copy Prompt β†’ Run.

Related Workflows

Explore other categories

πŸ“¬

Get Started with Agentic Working

Subscribe to receive updates from AgenticWorking.io

πŸ“– Free eBook Guide πŸ“¦ 7 Ready-to-use Scripts πŸ”” Weekly Tips

No spam, unsubscribe anytime. Join 1,000+ subscribers.