ocr-grammar-fixer — Claude Code subagent: cleans up OCR text
A Claude subagent that fixes OCR output: character recognition errors, broken spacing, punctuation and grammar, with the original meaning kept intact.
npx claude-code-templates@latest --agent ocr-extraction-team/ocr-grammar-fixerWhat ocr-grammar-fixer does
The ocr-grammar-fixer subagent takes text that has already been through OCR and hunts for the usual artifacts. It knows the classic mix-ups: rn read as m, l against I and 1, 0 against O, cl against d, li against h. It also checks word boundaries, so missing or extra spaces, merged and split words, displaced punctuation and random capitalisation all get caught.
Correction runs in five passes. First it scans for odd letter combinations and spacing patterns, then reads the surrounding words to work out what was meant. After that it restores business and marketing terminology, fixes punctuation and capitalisation, and finally checks that the result reads naturally. Meaning wins over a literal character-by-character match.
It has Read, Write and Edit available, which is enough to open a file, apply fixes and save the result. By default it returns only the corrected text with no commentary; ask for the reasoning and it will show the artifacts it found. Handy when scanned documents or PDFs leave you with garbled characters and retyping by hand is not worth the time.
What it helps with
- clean up recognition errors in OCR-processed text
- restore missing and extra spaces between words
- fix random capitalisation and displaced punctuation
- recover correct spelling of business and marketing terms
- turn scanned text into something publishable
Example prompts for the agent
- fix the OCR errors in
report.txtand save the result - clean up
scan.md: spacing, capitalisation, punctuation - list the OCR artifacts you found and explain each fix
How to install ocr-grammar-fixer
1claude-code-templates
npx claude-code-templates@latest --agent ocr-extraction-team/ocr-grammar-fixer2Manually: put the files in place
.claude/agents/ocr-grammar-fixer.mdFor all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention
Manually: put the files in place
.codex/agents/ocr-grammar-fixer.tomlCodex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/
Manually: put the files in place
.cursor/agents/ocr-grammar-fixer.mdCursor also reads .claude/agents/
Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean
Questions about ocr-grammar-fixer
How do I install ocr-grammar-fixer in Claude?
Run npx claude-code-templates@latest --agent ocr-extraction-team/ocr-grammar-fixer; the agent file lands at .claude/agents/ocr-grammar-fixer.md.
What does ocr-grammar-fixer do?
It corrects text that came out of OCR: confused characters, broken word boundaries, punctuation and capitalisation. The intended meaning of the original stays the same.
Which tools does the subagent use?
It has Read, Write and Edit, which covers reading a file, making the corrections and writing the result back.