LegalContracts

Redlines

Use when you need to generate tracked changes in Word documents from diff output, apply redlines from AI agents to DOCX files, or convert text diffs into native Word revisions.

LLegalQuants·Legal·Apache-2.0

Library skill — the default version is maintained in GitHub; edits you make live in your own clone.

Use this skillDownload .zip
How does this work?
  • ChatGPT opens a new chat with the skill loaded. If it's too long for a link, it's copied to your clipboard — just paste.
  • Claude works the same way. To install it permanently, download the .zip and upload it under Claude → Settings → Capabilities → Skills (Pro/Team/Enterprise).
  • Copy prompt copies the skill so you can paste it into any assistant, including Grok.

redlines — Word Document Redlining Library

When to Use

How It Works

Takes diff output (from any source) and applies it to a DOCX as native Word tracked changes. Built by a practising Singapore counsel who needed deterministic document transformation.

Input

Output

DOCX with Word native tracked changes (insertions in blue, deletions in strikethrough)

Usage

import { applyRedlines } from '@houfu/redlines';

const result = applyRedlines({
  originalDoc: './contract.docx',
  modifiedText: 'modified contract text here',
  author: 'LQClaw'
});

result.toDocx('./contract-redlined.docx');

Key Design Decisions

Audience and Work Shape

Audience: legal engineers and counsel comfortable invoking a JavaScript library from a workflow. Not a self-service tool for a reviewing partner and not intended for non-technical users. The judgment as to which edits to apply sits upstream of this skill; this skill only carries them into the DOCX.

Work shape: Bounded Transactional primitive. Text-in (or diff-in) → DOCX-out. The transform is mechanical. It is not a redline reviewer, not a redline generator, and not a substantive review step.

Scope and Legal Use

This skill provides legal support, not legal advice. Producing a tracked-changes DOCX is mechanical document processing; the redlined output is a draft, not a vetted lawyer redline and not signed-off work product. A successful run means "the supplied edits were carried into the file as Word revisions" — not "these edits are correct" and not "this draft is fit to send."

Privilege and metadata exposure. Tracked changes carry author metadata into the document. The author field in the call (e.g., 'LQClaw') is written into the Word XML alongside revision timestamps and is preserved in the saved file. Anyone who opens the DOCX (counterparty, opposing counsel, recipient on production) can read it. Stance: AI authorship should be visible — do not mask AI-generated revisions behind a lawyer's name or firm identity. Treat the redlined DOCX as a draft document and assess data flow with the firm before routing draft files externally; redlines on privileged drafts can be discoverable and can affect privilege if circulated. Confirm a metadata-scrubbing step before any external delivery and confirm with the firm that the upstream diff and the source DOCX may be processed by the calling pipeline.

Accountability. Output is a mechanical transform of an upstream diff. A qualified, named lawyer must read the redlined DOCX page-by-page before any client or counterparty delivery. The skill does not stamp provenance, does not maintain an audit log, and does not designate an owner of the output — the calling workflow must do all three.

Confidence Bands

Out of Scope

Escalation

Stop and route to the responsible lawyer when: - the diff does not anchor cleanly to the source (return a structured error, do not write a partial redline); - the source DOCX already contains tracked changes or unresolved comments; - the source DOCX is password-protected, corrupt, or cannot be parsed; - the diff touches footnotes, cross-references, defined-term placement, or nested numbering; - the redlined DOCX is about to leave the firm and no metadata-scrubbing / provenance-stamping step has run; - a confidence band of Medium or Low is emitted and no named lawyer has been designated to review the output.

Limitations

QA Remediation (LegalQuants, 2026-05)

Original author: Hou Fu Ang. Technical content (When to Use, How It Works, Input, Output, Usage, Key Design Decisions, Limitations) preserved verbatim.

LegalQuants applied QA remediation against the Legal Skill Design Framework on 2026-05-11 in response to the QA report at /tmp/qa-results/redlines.md (verdict: MATERIAL CONCERNS — three legal failure modes unaddressed). Added: version, last_reviewed, last_reviewed_by in frontmatter; Audience and Work Shape; Scope and Legal Use covering the three mandatory legal failure modes (advice-vs-support, privilege/metadata, accountability), with specific treatment of Word XML author metadata persistence and the stance that AI authorship should be visible rather than masked; Confidence Bands tied to document shape; Out of Scope ("does NOT do"); Escalation triggers. No changes to the technical instructions or the @houfu/redlines API.