Office word diff

From LegalQuants/lq-skills · View interactive version

Office word diff is an AI agent skill from the GitHub repository LegalQuants/lq-skills. Use when you need to apply word-level tracked changes to Microsoft Word documents programmatically, preserve formatting through diffs, or integrate with Office.js for document transformation.

How to use this skill

Skill file

office-word-diff

When to Use

How It Works

Core Problem

Most diff tools operate at the line or paragraph level. Word documents have structural complexity — nested lists, tables, headers, formatting runs — that line-based diffs destroy. office-word-diff solves the kernel-level problem: applying word-level tracked changes to DOCX while preserving formatting.

Architecture

  1. Parse — Read DOCX via Office.js API, extract text runs with formatting metadata
  2. Diff — Compute word-level differences between old and new text
  3. Transform — Insert Word-compatible tracked changes (insertions/deletions) preserving formatting
  4. Output — Return valid DOCX with native Word tracked changes

Usage

import { diffWords } from 'office-word-diff';

const result = await diffWords(oldDoc, newDoc, {
  trackChanges: true,
  author: 'LQClaw'
});

Key Features

Audience and Work Shape

Audience: lawyers and developers building Word add-ins or document-transformation tools that emit native tracked changes. Output is consumed by Microsoft Word and ultimately signed off by a lawyer.

Work shape: Bounded Transactional. The skill applies a defined set of word-level edits to a DOCX and emits revised DOCX. It does not decide which edits to apply.

Scope and Legal Use

This skill provides legal support, not legal advice. The output is a DOCX with tracked changes — not a redlined version that is approved, signed off, or fit to send to counterparties or file with a court.

Privilege and confidentiality. Runs client-side via Office.js. No network calls. The skill does not transmit document content anywhere. Privilege exposure depends entirely on what the calling application does with the input and output — the lawyer must control the data flow.

Accountability. A qualified lawyer must review every tracked change in the output before accepting, sending, filing, or storing the revised document. The author field (author: 'LQClaw' in the usage example) makes the AI origin visible in Word's revision metadata — keep that visible rather than masking it as a human author.

Confidence Bands

The diff itself is deterministic, but the upstream generation of newDoc (from an AI agent) is not. Tag tracked changes with confidence from the upstream agent where possible:

Out of Scope

Escalation

Stop and route to the responsible lawyer when:

Limitations

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.