ocr

A command that reads existing captured book-page images and extracts their text with OCR. It can use vision processing first and request additional agent re-reading for pages with poor or failed results.

In plain words
What is it for?
Use it after page captures already exist to create or improve extracted book text. It expects WebP or PNG files in the configured book-capture directory.
Why use it?
It recovers text from page images when the first extraction is uncertain or incomplete. It also reports extraction statistics so low-quality pages can be identified.

Command

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 commands/masterleopold/book-capture/ocr
Clone the repo
git clone --depth 1 https://github.com/masterleopold/book-capture
Per session 14 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 488 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.00014 $0.00488
Opus 5 $0.00007 $0.00244
Sonnet 5 $0.00003 $0.00098
Haiku 4.5 $0.00001 $0.00049

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

Security

Grade A, and why

ocr 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.

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.

commands/ocr.md · 53 lines

What it actually says

OCR Text Extraction

Run OCR on existing page captures. Requires page_* image files (WebP, or PNG for books captured before the WebP switch) to already exist in the captures directory.

Setup

  • PLUGIN_SCRIPTS = ${CLAUDE_PLUGIN_ROOT}/scripts
  • Resolve CAPTURES_BASE from .claude/book-capture.local.md or default Books/files/book-captures
  • Parse $ARGUMENTS for BookID
  • OUTPUT_DIR = <CAPTURES_BASE>/<BookID>

Verify captures exist:

Glob: <OUTPUT_DIR>/page_*.{webp,png}

If no captures found, tell the user to run /book-capture:capture first.

Step 1: Vision OCR

bash "${CLAUDE_PLUGIN_ROOT}/scripts/setup.sh" --check-only || bash "${CLAUDE_PLUGIN_ROOT}/scripts/setup.sh"
node "${CLAUDE_PLUGIN_ROOT}/scripts/extract-text.mjs" "<OUTPUT_DIR>" --concurrency 5 --claude-threshold 0.6

Report stats from raw_text.json.

Step 2: Agent Re-reading (if needed)

Check stats in raw_text.json. If vision-low or failed pages exist, ask user if they want agent re-reading.

Generate a unique SESSION_ID (first 8 chars of random hex) to avoid temp file collisions.

Dispatch 4-8 parallel agents (subagent_type: book-capture:ocr-reader), each handling ~20-30 pages. Write to /tmp/ocr_batch_<SESSION_ID>_NN.json.

After agents complete, merge batch results from /tmp/ocr_batch_<SESSION_ID>_*.json back into raw_text.json. Clean up temp files.

Step 3: Report

Report final OCR stats:

  • Total pages
  • Vision (good) count
  • Vision (low) count
  • Agent-read count
  • Failed count
  • Average confidence
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 · 53 lines · 14 tokens per session scan A 3ff415120fac

Subscribe to this mod's changes

ocr is a command published in the GitHub repository masterleopold/book-capture (10 stars, last pushed 1mo ago), licensed MIT. It adds 14 tokens to every session and 488 once invoked, about $0.0001 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.