πŸ“„

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)

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

  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.