π« 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.docxandcontract_v2.docx. Write a Python script using python-docx and difflib to:
- Extract: Text from both documents.
- Compare: Generate unified diff.
- Output: Save as
diff_report.htmlwith 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
- Install:
pip install python-docx - Copy Prompt β Run.