ocr-run

ocr-run is a skill for Claude Code, Codex from MidnightDarling/collate. It costs 214 tokens per session (3,852 once invoked), scanned A, original, Apache-2.0.

A workflow for converting cleaned historical-document PDFs into searchable Markdown using optical character recognition, or OCR. It supports scanned pages, including traditional Chinese, vertical text, older characters, and modern simplified Chinese.

In plain words
What is it for?
Use it to recognize text in scanned papers and books, extract images and tables, record uncertain pages, and prepare files for proofreading.
Why use it?
It turns page images into editable text and provides a side-by-side preview so the result can be checked against the original.

Skill for Claude CodeCodex

Installs and runs on its own, but its text points at files inside its plugin — anything it tells you to read at a ${CLAUDE_PLUGIN_ROOT} path is only there once the plugin is installed. Installing the plugin gets both.

Part of the collate plugin — 15 skills, 2 commands, 2 agents shipped together

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/ocr-run
Any agent
npx skills add MidnightDarling/collate --skill ocr-run
Clone the repo
git clone --depth 1 https://github.com/MidnightDarling/collate

Made for: Claude Code, Codex.

Or install collate, the plugin that ships this one along with the rest of its 15 skills, 2 commands, 2 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ocr-run

README.md
[![agentmods](https://agentmods.dev/badge/skills/midnightdarling/collate/ocr-run.svg)](https://agentmods.dev/skills/midnightdarling/collate/ocr-run)
Your own site
<a href="https://agentmods.dev/skills/midnightdarling/collate/ocr-run"><img src="https://agentmods.dev/badge/skills/midnightdarling/collate/ocr-run.svg" alt="Measured on agentmods" height="20"></a>
Per session 214 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,852 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.00214 $0.03852
Opus 5 $0.00107 $0.01926
Sonnet 5 $0.00043 $0.00770
Haiku 4.5 $0.00021 $0.00385

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

Security

Grade A, and why

ocr-run 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 3d ago.

The scan reads SKILL.md. This mod also ships 8 executable files (scripts/apply_corrections.py, scripts/baidu_client.py, scripts/extract_text_layer.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/ocr-run/SKILL.md · 287 lines

How it starts

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

OCR 执行 — 历史文献专用双引擎

Task

把清理过的 PDF 交给 OCR API,拿回 Markdown + 附件 + 对照预览 HTML。

为什么支持两个引擎

  • MinerU(上海 AI Lab):对繁体、竖排、古籍版式、公式、表格识别更强,默认推荐。
  • 百度 OCR:稳定、额度大、响应快,适合大批量现代简体论文。

~/.env 里的 OCR_ENGINE=mineruOCR_ENGINE=baidu 决定默认引擎。命令行 --engine=xxx 可临时覆盖。

输出结构(权威规范见插件 references/workspace-layout.md):

<pdf-basename>.ocr/
├── README.md                    自动生成的目录地图(workspace_readme.py)
├── source.pdf                   被 OCR 的 PDF(prep-scan 的 cleaned.pdf 副本,或用户直接传入)
├── raw.md                       OCR 原始 Markdown(含 <!-- page N --> 标记)
├── meta.json                    引擎、耗时、页数、low_confidence_pages
├── assets/                      OCR 抽出的图片附件(古籍插图、论文图表)
├── previews/
│   └── ocr-preview.html         原图 + OCR 文本并排。人工协作模式下可点击右栏编辑
├── _internal/                   Pipeline 簿记(MinerU 原生 full.md、导入 provenance)
└── ...                          其他 skill 会继续填充 review/ prep/ output/

raw.md / meta.json / assets/ 在根目录,下游(proofread / diff-review / to-docx)读相对路径 assets/xxx.png 不需修改;过程产物(HTML 预览、簿记文件)全部收进子目录。

Process

Step 0:决定走哪条路径(默认本地 mineru CLI)

Agent 默认走 run_mineru.py(本地 mineru[pipeline]),不再按 OCR_ENGINE 环境变量选云 API:

which mineru   # 检查 mineru CLI 是否在 PATH

判断:

条件 路径
mineru 在 PATH 路径 Arun_mineru.py 本地跑
mineru 没装 路径 B:提示 pip install 'mineru[pipeline]' 或跑 /collate:setup
离线 / 环境装不上 / PDF 有可用文字层且用户急 路径 D:extract_text_layer.py 兜底(质量会打折)

具体四条路径的决策语义与失败兜底全文见 agents/ocr-pipeline-operator.md——ocr-run skill 只负责调脚本,不重复 决策逻辑。

旧的 OCR_ENGINE=baidu|mineru 环境变量仍然被 mineru_client.py / baidu_client.py 读,但新工作流不走这两个——它们是兼容分支。

Step 1(已合并到 Step 0)

Step 2:建输出目录

支持两种输入形态(任选其一,脚本自动适配):

  • 形态 A<workspace>/source.pdf(prep-scan 已跑过,工作区已存在)
  • 形态 B:任意 PDF 路径(用户跳过 prep-scan 直接 OCR,没有预处理痕迹)
PDF="<input-pdf-path>"
DIR=$(dirname "$PDF")

# 如果传入的是 .ocr/source.pdf,OUT 就是它的上级目录(工作区已存在)
# 否则按 basename 建新的 .ocr/ 工作区
if [[ "$DIR" == *.ocr ]]; then
    OUT="$DIR"
else
    BASE=$(basename "$PDF" .pdf)
    OUT="$DIR/$BASE.ocr"
fi
mkdir -p "$OUT/assets" "$OUT/previews" "$OUT/_internal"
# 确保 source.pdf 在根目录(外部传入时复制一份)
[ -f "$OUT/source.pdf" ] || cp "$PDF" "$OUT/source.pdf"

Read the full file on GitHub · 287 lines

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. 3d ago First seen · 287 lines · 214 tokens per session scan A afa1da0e34a2

Subscribe to this mod's changes

ocr-run is a skill published in the GitHub repository MidnightDarling/collate (6 stars, last pushed 3mo ago), licensed Apache-2.0. It adds 214 tokens to every session and 3,852 once invoked, about $0.0011 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.

Related

Other skills, from other repositories

markitdown

Convert files, URLs, and documents to Markdown using the markitdown MCP server. Activate when the user asks to convert, extract, or read content from PDFs, Word docs, PowerPoints, spreadsheets, images, audio files, or any URL.

RashadAnsari/myagents · 54 tokens

pdf-conversion

Convert PDF documents to well-structured Markdown files. Use when user asks to convert PDFs, extract text from PDFs, or transform PDF documents to markdown format.

rangerrick337/operator-os · 35 tokens

foundry-hosted-agent-validation

Step-by-step process for validating a Python Foundry hosted agent sample (under python/samples/04-hosting/foundry-hosted-agents/) end to end — running it locally (native runtime and azd ai agent run) and after deploying it to an Azure AI Foundry project with azd. Use this when asked to validate a hosted agent sample.

microsoft/agent-framework · 82 tokens

pdf-processing

Extract text from PDFs, fill forms, and merge documents.

PrefectHQ/fastmcp · 11 tokens

pdf

Manipulate PDF files — merge, split, extract pages/text, PDF↔images, OCR, info — via the qpdf / poppler / ocrmypdf CLIs. Use to combine, slice, convert, or OCR PDFs.

AtomicBot-ai/atomic-agent · 56 tokens

liteparse

Parse documents into LLM-ready content entirely on the local machine — PDF / DOCX / XLSX / PPTX / images → Markdown, structured JSON (with bounding boxes), or page screenshots, via the lit CLI. No cloud, no LLM, works offline. Use whenever the user attaches or points to a document that must be read before reasoning…

Prismer-AI/PrismerCloud · 90 tokens