π« 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)
Engineering Prompt:
**Role:** Python Tool Developer
**Task:** Create a "Document Diff Tool".
**Requirements:**
1. **GUI:**
* Select two documents.
* Diff mode: Line-by-line, Word-by-word.
* Side-by-side preview.
* Export: HTML, PDF.
2. **Logic:**
* Extract text preserving paragraphs.
* Use difflib for comparison.
* Generate HTML with CSS highlighting.
3. **Deliverables:**
* `doc_diff.py`
* `run.bat`, `run.sh`
* `requirements.txt`
π§ Prompt Decoding
- difflib: Pythonβs built-in library for comparing sequences.
π οΈ Instructions
- Install:
pip install python-docx - Copy Prompt β Run.