diff-review

A review tool that compares the original OCR Markdown with the corrected final Markdown and shows the changes in an HTML page.

In plain words
What is it for?
Use it to review paragraph-level edits, connect changes to A/B/C proofreading labels, and produce a change summary.
Why use it?
After proofreading, it is easy to forget which suggestions were accepted, rejected, or missed. The comparison helps confirm that important OCR errors were handled.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/midnightdarling/collate/diff-review
Any agent
npx skills add MidnightDarling/collate --skill diff-review
Clone the repo
git clone --depth 1 https://github.com/MidnightDarling/collate

Made for: Claude Code, Codex.

Per session 153 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,508 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00153 $0.03508
Opus 5 $0.00077 $0.01754
Sonnet 5 $0.00031 $0.00702
Haiku 4.5 $0.00015 $0.00351

Measured 2d ago against content hash c5b01c89a3f7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

diff-review scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/md_diff.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/diff-review/SKILL.md · 285 lines

How it starts

The opening of the file, as written. The whole thing — 285 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Diff Review — 校对改动核对

Task

校对闭环的最后一关。用户按 raw.review.md 改完 raw.md → final.md 后,用户需要回答三个问题:

  1. 用户接受了 agent 的哪些建议?(自己脑子里记不住改了哪些)
  2. 用户拒绝或漏改了哪些?(最常见:手滑漏掉一两条 A 类)
  3. 清单外修正了哪些 agent 未标注的段?(用于积累校对风格)

不核对就改,等于校对没闭环——用户可能漏了明显的 OCR 错就拿去生成 Word,回头被编辑或读者发现,返工。

这个 skill 生成一份段落级 HTML 对照 + 标注交叉表,用户花 5 分钟扫一遍就能判断闭环是否闭上。


Process

Step 1 — 确认输入

RAW="<raw-md-path>"
FINAL="<final-md-path>"
OCR="$(dirname "$RAW")"                # 工作区根 = raw.md 的父目录
REVIEW="${REVIEW:-$OCR/review/raw.review.md}"

test -f "$RAW"   || { echo "raw.md 不存在:$RAW"; exit 1; }
test -f "$FINAL" || { echo "final.md 不存在:$FINAL"; exit 1; }
# review 可选;无则降级为纯 diff

如果用户没显式传 --review,默认去 $OCR/review/raw.review.md 找清单(proofread 的默认输出位置)。找到就带上,找不到降级为纯 diff,不做标注关联,并告知用户。

Step 2 — 调 diff 脚本

mkdir -p "$OCR/previews" "$OCR/review"
python3 "${CLAUDE_PLUGIN_ROOT}/skills/diff-review/scripts/md_diff.py" \
    --raw "$RAW" \
    --final "$FINAL" \
    $( [ -f "$REVIEW" ] && echo "--review $REVIEW" ) \
    --out "$OCR/previews/diff-review.html" \
    --summary "$OCR/review/diff-summary.md"

固定路径约定(权威规范见插件 references/workspace-layout.md):

  • HTML 预览 → previews/diff-review.html
  • Markdown 摘要 → review/diff-summary.md 不再用 ${FINAL%.md}.diff.html 这种衍生路径 —— 那会把过程文件落在工作区根部,反规范。

Step 3 — 脚本必须实现的行为规范

md_diff.py 的职责边界由以下规范强制定义。实现时不许偷工——以下每条都是契约,不是建议。

3.1 段落切分

两份文件都按「连续非空行 = 一段」规则切分。每段保留:

  • raw_line_start / raw_line_end(在 raw.md 中的起止行号)
  • final_line_start / final_line_end(在 final.md 中的起止行号)
  • paragraph_text(段落文本,保留段内换行)

保留原始行号是为了和 raw.review.md 的 "Line N" 标注做锚定。

3.2 段落对齐

difflib.SequenceMatcher段落为 opcode 粒度(不是行、不是字符)做对齐。产出四类 opcode:

opcode 含义 HTML 显示
equal 段落完全一致 折叠,默认只显示"第 N 段未修改",可展开查看
replace 段落被改写 左栏 raw(删除高亮)+ 右栏 final(新增高亮),段内做字符级 diff
delete raw 有 final 无 左栏显示 + 标签"已删除整段"
insert final 有 raw 无 右栏显示 + 标签"新增段落"

不允许用行级对齐。中文一段可能 300 字一行,行级 diff 会把"改一个字"显示为"删一整行 + 增一整行",噪音压过信号。

Read the full file on GitHub · 285 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 285 lines · 153 tokens per session scan A c5b01c89a3f7

Subscribe to this mod's changes

diff-review is a skill published in the GitHub repository MidnightDarling/collate (6 stars, last pushed 3mo ago), licensed Apache-2.0. It adds 153 tokens to every session and 3,508 once invoked, about $0.0008 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.