π« The Pain Point
The client sent back Contract_v2.docx with changes. You need to know exactly what they changed compared to Contract_v1.docx.
Opening two windows side-by-side and scanning line-by-line is exhausting and prone to missing subtle edits.
π Agentic Solution
The βSpot the Differenceβ Tool: Reads the content of two files and generates a highlighted report (Deleted/Added).
Key Features:
- Line-by-Line: Compares text structure.
- HTML Report: Exports a web-based view (like GitHub Diff): Green for Added, Red for Deleted.
βοΈ Phase 1: Commander (Quick Fix)
For a quick text comparison.
Prompt:
βI have two large text files:
text1.txtandtext2.txt. Write a Python script usingdifflibto generate adiff.htmlfile showing the side-by-side comparison of these files.β
Result: An HTML report file you can open in Chrome.
ποΈ Phase 2: Architect (Permanent Tool)
For Legal/Admin teams.
Engineering Prompt:
**Role:** Python Tool Developer
**Task:** Create a "Document Comparison Tool" (Word/Text).
**Requirements:**
1. **GUI:**
* Select Original File (A).
* Select Modified File (B).
* "Compare" button.
2. **Logic:**
* Convert .docx to plain text (using `python-docx`).
* Use `difflib.HtmlDiff()` to generate a comparison report.
* Save report as `Report_[Timestamp].html` and auto-open it in the default browser.
3. **Deliverables:** `diff_tool.py`, `run.bat` (Windows), `run.sh` (Mac).
π§ Prompt Decoding
- Difflib: A powerful standard Python library. It has a built-in
HtmlDiffclass that does 90% of the hard work (generating the UI). You donβt need to code a complex GUI, just generate the HTML and open it.
π οΈ Instructions
- Copy Prompt -> Paste -> Run.
- Select 2 Files -> Compare -> View Report.