docx-trackdiff
Compare two versions of a .docx document and produce a single Word file in tracked-changes (revision / tracking) mode, as if a human had edited the old file into the new one with Track Changes turned on. Use whenever the user has two versions of a DOCX (e.g., successive drafts of a paper, report, or contract — often AI-generated or AI-assisted revisions) and wants to see the differences as native Word revisions (insertions/deletions) that can be accepted/rejected in Word. Triggers: "对比两个版本的 docx", "tracked changes", "tracking mode", "修订模式对比", "compare two Word documents", "diff two drafts", "生成修订对比文件". Do NOT use for: creating new documents from scratch (use docx skill), single-file editing with revisions (use docx WIR engine), or PDF-only comparisons.
Rank
62
Safety
84
Downloads
1.6k
Updated
Oct 10, 2026
Version
0.1.0
Source
CLAWHUB
About
What it does, and when to use it.
Capability contract not published. No trust telemetry is available yet. 1.6K downloads reported by the source. Last updated 10/10/2026.
Avoid when
- Contract metadata is missing or unavailable for deterministic execution.
Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing
Public facts
Every fact links back to the source it came from.
- Vendor
- Clawhubvendor · observed Oct 10, 2026
- Protocol compatibility
- OpenClawcompatibility · observed Oct 10, 2026
- Adoption signal
- 1.6K downloadsadoption · observed Oct 10, 2026
- Latest release
- 0.1.0release · observed Aug 15, 2026
- Handshake status
- UNKNOWNsecurity
Install and run
Setup complexity: low.
clawhub skill install s170nnpqv8ratxbb59qz0zxkp587h65b:docx-trackdiff- Install using `clawhub skill install s170nnpqv8ratxbb59qz0zxkp587h65b:docx-trackdiff` in an isolated environment before connecting it to live workloads.
- No published capability contract is available yet, so validate auth and request/response behavior manually.
- Review the upstream CLAWHUB listing at https://clawhub.ai/stephenlzc/docx-trackdiff before using production credentials.
Contract: missing
curl -s "https://www.xpersona.co/api/v1/agents/clawhub-stephenlzc-docx-trackdiff/snapshot"
Documentation
CLAWHUB
30,315 characters of source documentation, loaded on request.
Extracted files
5 files captured from the source.
SKILL.md
---
name: docx-trackdiff
description: >
Compare two versions of a .docx document and produce a single Word file in
tracked-changes (revision / tracking) mode, as if a human had edited the old
file into the new one with Track Changes turned on. Use whenever the user has
two versions of a DOCX (e.g., successive drafts of a paper, report, or
contract — often AI-generated or AI-assisted revisions) and wants to see the
differences as native Word revisions (insertions/deletions) that can be
accepted/rejected in Word. Triggers: "对比两个版本的 docx", "tracked changes",
"tracking mode", "修订模式对比", "compare two Word documents", "diff two
drafts", "生成修订对比文件". Do NOT use for: creating new documents from
scratch (use docx skill), single-file editing with revisions (use docx WIR
engine), or PDF-only comparisons.
---
# DOCX Tracked-Changes Comparison
Given an OLD and a NEW version of a `.docx`, produce ONE output `.docx` that
opens in Word with native revision marks (`<w:ins>` / `<w:del>`) showing every
change from OLD to NEW. The output uses the NEW file as the base package, so
all its styles, images, footnotes, tables, and section properties are
preserved; accepting all revisions yields exactly NEW, rejecting all yields
exactly OLD.
## Workflow
1. **Run the script** — do not reimplement the diff:
```bash
python3 scripts/compare_docx_tracked.py OLD.docx NEW.docx OUT.docx \
--author "Reviser Name" --date "2026-08-15T00:00:00Z"
```
- Ask the user for the revision **author name** and date if not provided
(default author "Editor", default date = today). The author is usually the
person who made the new draft, not the assistant.
- `--threshold` (default 0.45) controls when a paragraph pair is treated as
"modified" (word-level inline revisions) vs "deleted + inserted" (two whole
paragraphs). Lower it if too many lightly-edited paragraphs show as whole-
paragraph replace; raise it if heavily rewritten paragraphs produce noisy
inline diffs.
- The script prints stats (ins/del paragraphs, word-level modified, fallbacks).
Report these numbers to the user.
2. **Verify (mandatory)** — run the verifier; all checks must PASS:
```bash
python3 scripts/verify_tracked.py OUT.docx OLD.docx NEW.docx
```
It checks: unique revision ids, no stray `w:t` inside `w:del`, resolvable
relationship references, `w:trackChanges` present, accept-all == NEW text,
reject-all == OLD text, and that OLD-only content is fully covered by
`w:delText`.
3. **Render check** — convert with LibreOffice to confirm the package opens
cleanly and revisions render (strikethrough deletions, marked insertions):
```bash
soffice --headless --convert-to pdf --outdir <tmpdir> OUT.docx
```
If conversion fails or the verifier fails, consult
`references/ooxml-revision-rules.md` — it catalogs the exact OOXML rules and
known failure modes (stray `w:t` in `w:del`, missing paragraph-mark deletions,
dangling r:ids, missing `w:trackChanges`).
## Output conventions
- Name the oREADME.md
# 📝 docx-trackdiff  **Compare two Word documents (.docx) and get a native Track Changes redline — as if a human editor had revised the old draft into the new one with "Track Changes" switched on.** English | [简体中文](README.zh-CN.md)      `track-changes` `docx-diff` `word-compare` `redline` `document-comparison` `ooxml` `kimi-skill` `agent-swarm` --- ## 🤔 Why this exists In the age of AI-assisted writing, documents iterate *fast*. A paper, a report, a contract — every prompt produces a new version, and suddenly you have `v3-final-FINAL.docx` chaos. You want to know **exactly what changed** between two drafts, in the one format every collaborator understands: **Word's native revision mode**, where each edit can be individually accepted or rejected. Existing options fall short: - ☁️ Online comparison tools require uploading your unpublished manuscript — a privacy no-go for pre-publication research. - 📄 Word's built-in *Compare* works, but is manual, GUI-bound, and can't be scripted into an automated pipeline. - 🐍 `difflib` & friends give you text diffs, not a Word file with real `<w:ins>` / `<w:del>` revision marks. This tool fills the gap: **one command in, one tracked-changes `.docx` out** — open it in Microsoft Word, WPS, or LibreOffice and review every insertion and deletion in the familiar "All Markup" view. ## 📸 Demo Two synthetic demo documents (text + figure + table) are compared — no real data involved: | Page 1 — title, inline edits, deleted caption, replaced figure | Page 2 — table cell edit, new row, rewritten conclusion, new section | |---|---| |  |  | Notice the details: - 🔤 **Word-level inline revisions** — `12%` → ~~12~~`18%`, ~~sharply~~`moderately` - 🖼️ **Figure replacement tracked** — the old chart is marked deleted *with its original bytes preserved*, the new chart marked inserted - 📊 **Table edits** — a changed cell (`4.5` → `4.3`) and an inserted row (`Delta`) - ➕➖ **Whole-paragraph insertions & deletions** — the removed caption, the new "Next Steps" section Try it yourself with the files in [`examples/`](examples/): ```bash python3 scripts/compare_docx_tracked.py examples/demo_v1.docx examples/demo_v2.docx out.docx --author "You" ``` ## ✨ Features - ✅ **Native Word revisions** — real `<w:ins>` / `<w:del>` with unique IDs, author, and date; `w:trackChanges` enabled automatically - ✅ **Word-level granularity** — modified paragraphs get fine-grained inline diffs, not just whole-paragraph replace - ✅ **Structure-aware** — headings, styles, tables, footnotes, hyperlinks, equa
_meta.json
{
"ownerId": "kn77k0qnxvrb2gwbr1132zf7kh80qhny",
"slug": "docx-trackdiff",
"version": "0.1.0",
"publishedAt": 1786818488707
}references/ooxml-revision-rules.md
# OOXML 修订标记规则速查(失败模式手册)
生成 tracked-changes docx 时必须遵守的硬规则。脚本 `compare_docx_tracked.py` 已实现全部规则;仅当脚本需要修补或需要手工排查时阅读本文件。
## 目录
1. 修订元素语法
2. 段落级 vs 行内修订
3. 包级要求
4. 已知失败模式
## 1. 修订元素语法
```xml
<w:ins w:id="12" w:author="Name" w:date="2026-08-15T00:00:00Z">
<w:r><w:t>newly added text</w:t></w:r>
</w:ins>
<w:del w:id="13" w:author="Name" w:date="2026-08-15T00:00:00Z">
<w:r><w:delText xml:space="preserve">removed text</w:delText></w:r>
</w:del>
```
- `w:id` 必须全局唯一且递增。
- `<w:del>` 内的文本节点**必须**是 `<w:delText>`(不是 `<w:t>`),并保留 `xml:space="preserve"`。递归转换整棵子树。
- `<w:ins>`/`<w:del>` 包裹完整的 `<w:r>`,不得放在 `<w:r>` 内部。
- 不得出现 ins/del 互相嵌套。
## 2. 段落级 vs 行内修订
**整段插入/删除**:除包裹所有内容 run 外,还必须标记段落标记本身(否则 Word 里会留下空行或不显示为整段增删):
```xml
<w:p>
<w:pPr>
<w:rPr><w:del w:id="14" w:author="Name" w:date="..."/></w:rPr>
</w:pPr>
<w:del ...><w:r><w:delText xml:space="preserve">...</w:delText></w:r></w:del>
</w:p>
```
`w:pPr/w:rPr` 中 ins/del 标记必须是 `rPr` 的第一个子元素。
**行内词级修订**:在新段落内按词级 diff 拆分 run;删除片段生成带 `<w:delText>` 的新 run(继承最近可见的 `rPr` 格式),插入片段包 `<w:ins>`。
**复杂块回退**:含图片、`m:oMath` 公式、超链接等"原子"元素且 diff 边界无法对齐时,整段回退为"删旧段 + 插新段",不要强行拆 run。
## 3. 包级要求
- `word/settings.xml` 加入 `<w:trackChanges/>`,位置在 `<w:doNotTrackMoves>` 之前(无则放 `<w:defaultTabStop>` 前,再无则追加)。
- 被删段落深拷贝自旧文档:剥除 `w:bookmarkStart/End`、`w:proofErr`、`w:permStart/End`(避免 id 冲突)。
- 旧段落中的 `r:id` / `r:embed` / `r:link` 必须重映射到新包的 rels;图片部件按需复制(前缀 `tracked_` 防重名)。
- zip 其余部件原样拷贝。
## 4. 已知失败模式
| 症状 | 原因 | 修法 |
|---|---|---|
| Word 打开报"无法读取的内容" | `<w:del>` 内残留 `<w:t>`;或 id 重复;或 r:id 悬空 | 跑 `verify_tracked.py` 定位 |
| 删除段落在 Word 中显示为空行 | 段落标记未标 del(缺 `pPr/rPr/del`) | 见第 2 节 |
| 修订显示但"拒绝修订"后文本不对 | 段落边界标记被误判(验证脚本需把 pPr/rPr 内的 ins/del 视为段落级标记) | 用 `verify_tracked.py` 的 accept/reject 模拟核对 |
| 修订未显示(文档看似干净) | settings.xml 缺 `w:trackChanges` | 见第 3 节 |
| 引用旧版图片的删除段落图片丢失 | rId 未重映射 / media 未复制 | 见第 3 节 |EVALUATION.md
# 🧪 Evaluation Report — Swarm-Style Paired Testing English | [中文摘要](#-中文摘要) This document records the evaluation that `docx-trackdiff` went through before release. The evaluation followed the **skill-creator swarm protocol**: paired `with_skill` vs. `baseline` executions on an identical real-world task, blind grading by an independent verifier agent, then a fix-and-re-verify loop. > **TL;DR** — The skill-produced output passed all checks in ~1 minute. The > blind grader caught a genuine image-fidelity defect in the skill's own script > that its text-level verifier could not see. The bug was fixed, the verifier > was hardened from 5 to 7 checks, and both outputs now pass 7/7. --- ## 1. Setup | | | |---|---| | **Eval task** | "Compare two versions of a paper (.docx) and produce a Word tracked-changes file that can be accepted/rejected per revision." | | **Inputs** | Two real successive drafts of an academic paper (~6.4k → ~8.0k words, 150 vs 177 paragraphs, 14 tables, embedded figures, footnotes, hyperlinks) | | **Revision metadata required** | author `Big Stephen`, date `2026-08-14` | | **Run A — with_skill** | Agent reads `SKILL.md`, follows its workflow (bundled scripts only) | | **Run B — baseline** | Agent solves from scratch, explicitly forbidden from reading the skill directory | | **Grader** | Independent verifier agent; did **not** know which output used the skill | Both executors received the same prompt, the same input files, and the same output expectations. The grader received both outputs labeled only A and B. ## 2. Results | | 🅰️ with_skill | 🅱️ baseline | |---|---|---| | **Wall-clock effort** | **~1 minute** (script run + verify + render) | ~15 minutes (own implementation, 2 fix-rebuild cycles) | | **Revision marks** | 811 `<w:ins>` / 411 `<w:del>` | 2,463 `<w:ins>` / 387 `<w:del>` | | **Unique revision IDs** | ✅ 1,222, zero duplicates | ✅ 2,850, zero duplicates | | **author / date on every revision** | ✅ | ✅ | | **`w:trackChanges` enabled** | ✅ | ✅ | | **No stray `w:t` inside `w:del`** | ✅ | ✅ | | **Accept-all == NEW text** (728 paras) | ✅ | ✅ | | **Reject-all == OLD text** (701 paras) | ✅ | ✅ | | **LibreOffice PDF render** | ✅ clean | ✅ clean | | **Changed-figure fidelity** | ❌ **defect found** (see §3) | ✅ old bytes preserved | | **Spurious revisions** | ✅ none | ⚠️ 1 (byte-identical renumbered image marked del+ins) | ## 3. 🐞 The bug the grader caught The skill's script reused relationship targets **by file name** when remapping deleted-paragraph images into the new package. Both drafts contained figures at the same media paths (e.g. `word/media/rId13.png`) but with **different bytes**. Result: the deletion mark for a replaced figure pointed at the *new* image — the old figure's bytes were silently lost, and "reject change" would have restored the wrong picture. Crucially, **the skill's own 5-check verifier passed this output**, because its accept/reject simulation was text-only. The blind grader caught it by hash
AionUi
Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!
activepieces
AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
cherry-studio
AI productivity studio with smart chat, autonomous agents, and 300+ assistants.
CopilotKit
The Frontend for Agents & Generative UI. React + Angular
Machine-readable data
The same record, as JSON, for agents and crawlers.
{
"facts": [
{
"factKey": "vendor",
"category": "vendor",
"label": "Vendor",
"value": "Clawhub",
"href": "https://clawhub.ai/stephenlzc/skills/docx-trackdiff",
"sourceUrl": "https://clawhub.ai/stephenlzc/skills/docx-trackdiff",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-10T07:00:09.036Z",
"isPublic": true
},
{
"factKey": "protocols",
"category": "compatibility",
"label": "Protocol compatibility",
"value": "OpenClaw",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-stephenlzc-docx-trackdiff/contract",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-stephenlzc-docx-trackdiff/contract",
"sourceType": "contract",
"confidence": "medium",
"observedAt": "2026-10-10T07:00:09.036Z",
"isPublic": true
},
{
"factKey": "traction",
"category": "adoption",
"label": "Adoption signal",
"value": "1.6K downloads",
"href": "https://clawhub.ai/stephenlzc/docx-trackdiff",
"sourceUrl": "https://clawhub.ai/stephenlzc/docx-trackdiff",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-10T07:00:09.036Z",
"isPublic": true
},
{
"factKey": "latest_release",
"category": "release",
"label": "Latest release",
"value": "0.1.0",
"href": "https://clawhub.ai/stephenlzc/docx-trackdiff",
"sourceUrl": "https://clawhub.ai/stephenlzc/docx-trackdiff",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-08-15T18:28:08.707Z",
"isPublic": true
},
{
"factKey": "handshake_status",
"category": "security",
"label": "Handshake status",
"value": "UNKNOWN",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-stephenlzc-docx-trackdiff/trust",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-stephenlzc-docx-trackdiff/trust",
"sourceType": "trust",
"confidence": "medium",
"observedAt": null,
"isPublic": true
}
],
"events": [
{
"eventType": "release",
"title": "Release 0.1.0",
"description": "- Initial release: compare two `.docx` files and generate a single Word document with native tracked changes showing all differences. - Uses the NEW version as the base, preserving all its formatting, images, and styles. - Allows control over diff granularity with a `--threshold` parameter for more accurate paragraph-level or inline changes. - Requires user-supplied author name and revision date for tracked changes (defaults provided if omitted). - Verifies output for document integrity and tracked changes correctness. - Reports change statistics (inserted/deleted/modified paragraphs, fallbacks) after comparison. - Output file opens in Word's revision mode, making it easy to accept or reject individual changes.",
"href": "https://clawhub.ai/stephenlzc/docx-trackdiff",
"sourceUrl": "https://clawhub.ai/stephenlzc/docx-trackdiff",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-08-15T18:28:08.707Z",
"isPublic": true
}
]
}Record generated Oct 10, 2026.
