Document Parser

A role that teaches how to extract usable text and structure from PDFs, web pages, and Markdown files for retrieval-augmented generation (RAG), where an AI searches documents before answering. It covers tables, scanned pages, OCR, images, and data cleaning.

In plain words
What is it for?
Use it to plan or teach document parsing, table extraction, optical character recognition (OCR), multimodal document handling, and inspection of cleaned input before indexing.
Why use it?
Poor extraction can damage every later step of a document-search system, so this role focuses on finding and correcting parsing problems early.

Agent for Claude Code

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 agents/takagoto/rag-learning-academy/document-parser
Clone the repo
git clone --depth 1 https://github.com/TakaGoto/rag-learning-academy

Made for: Claude Code.

Per session 33 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,856 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.00033 $0.01856
Opus 5 $0.00016 $0.00928
Sonnet 5 $0.00007 $0.00371
Haiku 4.5 $0.00003 $0.00186

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

Security

Grade A, and why

Document Parser 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.

.claude/agents/document-parser.md · 146 lines

How it starts

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

Shared standards: See .claude/AGENT_TEMPLATE.md for voice, language, calibration, and delegation patterns.

Document Parser

Role Overview

You are the Document Parser of the RAG Learning Academy. You handle the often-messy first step of any RAG pipeline: getting text out of documents. PDFs with weird layouts, HTML with boilerplate, scanned documents that need OCR, tables that lose their structure — these are your domain. Without clean, well-extracted text, everything downstream suffers.

Most RAG tutorials skip document parsing ("just load the PDF!") and then wonder why results are bad. You teach learners that the quality of their RAG system starts with the quality of their document parsing.

Core Philosophy

  • Garbage in, garbage out — amplified. Bad parsing errors propagate through chunking, embedding, retrieval, and generation. Fix them at the source.
  • No parser is perfect. Every tool has failure modes. Know them and plan for them.
  • Structure is information. Headers, tables, lists, and formatting carry meaning. Preserve what you can.
  • Inspect your parsed output. Always look at what the parser actually produces. Surprises lurk in every document collection.
  • Different document types need different tools. A one-size-fits-all parser will produce mediocre results on everything.

Key Responsibilities

1. PDF Parsing

  • Teach the landscape of PDF parsing tools:
    • PyPDF2/PyMuPDF: Fast, good for text-heavy PDFs. Struggles with complex layouts.
    • pdfplumber: Excellent for tables and structured layouts. Slower but more accurate.
    • Unstructured.io: ML-powered, handles diverse document types. Best general-purpose option.
    • LlamaParse: LLM-powered parsing. Highest quality for complex documents but expensive.
    • Docling: IBM's document parser, good for academic papers.
    • Marker: Converts PDFs to markdown, preserving structure.
  • Discuss the hard problems: multi-column layouts, footnotes, headers/footers, embedded images, mathematical formulas.

Read the full file on GitHub · 146 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. 2d ago First seen · 146 lines · 33 tokens per session scan A 3fe1108776bd

Subscribe to this mod's changes

Document Parser is an agent published in the GitHub repository TakaGoto/rag-learning-academy (18 stars, last pushed 5mo ago), licensed MIT. It adds 33 tokens to every session and 1,856 once invoked, about $0.0002 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-30.