pdf-ingestion

A guide for sending PDF documents to a language model while preserving useful structure and controlling how much text enters its context. It covers direct PDF input, text extraction, chunking, summaries, and OCR for scanned pages.

In plain words
What is it for?
Use it to decide how to process reports, invoices, forms, articles, scanned PDFs, tables, figures, and documents that will be queried repeatedly.
Why use it?
It helps avoid losing tables, figures, forms, or page structure, and prevents very long documents from exceeding the model's context limit. It also helps choose the right preparation method for the document.

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/archive228/loopkit/pdf-ingestion
Any agent
npx skills add Archive228/loopkit --skill pdf-ingestion
Clone the repo
git clone --depth 1 https://github.com/Archive228/loopkit

Made for: Claude Code, Codex.

Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 941 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.00043 $0.00941
Opus 5 $0.00022 $0.00470
Sonnet 5 $0.00009 $0.00188
Haiku 4.5 $0.00004 $0.00094

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

Security

Grade A, and why

pdf-ingestion 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.

skills/pdf-ingestion/SKILL.md · 60 lines

How it starts

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

PDF Ingestion

Three ways to feed a PDF to the model, in increasing order of preprocessing:

  1. Native PDF input — pass the file directly. Model sees pages as images + extracted text. Best for docs under ~100 pages with meaningful layout (tables, figures, forms). Preserves structure.

  2. Text extraction then sendpdftotext / pypdf / equivalent, then send the text. Loses layout but cheap. Fine for prose-heavy docs where tables don't matter.

  3. Extract → chunk → summarize → send — for docs >100 pages or when you'll query the same doc many times. Preprocess once, cache the summary.

Deciding which path

Doc shape Path
<20 pages, layout matters (report, form, invoice) Native
<20 pages, pure prose (article, memo) Text extraction
20-100 pages, mixed Native, but chunk if context tight
>100 pages Extract → chunk → summarize
Scanned PDF (no text layer) OCR first (Tesseract or vision model), then treat as extracted text
Tables are the point Native — text extractors mangle tables
Figures/diagrams are the point Native + explicit "describe the figure on page N" prompt

Native PDF — the good defaults

  • Cache the PDF at a prompt-caching breakpoint (see prompt-caching). Native PDFs are large — every uncached turn costs full input price on the whole doc.
  • Ask about specific pages ("summarize section 3.2 on page 14") rather than the whole doc. The model handles targeted queries better than "summarize this 80-page report".
  • Follow up with page-cited claims — "on which page does the doc say X?" — as a sanity check the model isn't hallucinating.

Extract-then-send — the traps

  • pdftotext reading order. Multi-column PDFs come out as interleaved lines. Use pdftotext -layout for column preservation, or pdftotext -raw for straight reading order — pick per doc, don't guess.
  • Tables become word soup. If tables are load-bearing, native or per-table image extraction. Not text.
  • Headers/footers repeat on every page. Strip them before sending, or the model will treat them as content.
  • Footnotes drift to random positions in the extracted stream. Filter or accept the noise.

Read the full file on GitHub · 60 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 · 60 lines · 43 tokens per session scan A a252437b132d

Subscribe to this mod's changes

pdf-ingestion is a skill published in the GitHub repository Archive228/loopkit (753 stars, last pushed 1mo ago), licensed MIT. It adds 43 tokens to every session and 941 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.

Related

Other skills, from other repositories

wowerpoint

Turn one document into a kawaii NotebookLM slide-deck PDF. Use for "wowerpoint this", "make a deck about ", "turn this report into slides", or any request to render a single document as shareable narrative slides.

thedotmack/claude-mem · 55 tokens

save-as-pdf

Reformat the current HTML design into a paginated, paper-ready PDF. The "Instant" export already gives the user a PDF at the design's native pixel size — this path is for when they want real pages.

asgeirtj/system_prompts_leaks · 9 tokens

pdf

当用户需要对PDF文件进行任何操作时,请使用此技能。包括从 PDF 中读取或提取文本/表格、合并多个 PDF、拆分 PDF、旋转页面、添加水印、创建新PDF、填写PDF表单、加密/解密 PDF、提取图片,以及对扫描版 PDF 进行 OCR 使其可搜索。如果用户提到 .pdf 文件或要求生成 PDF,请使用此技能。.

agentscope-ai/QwenPaw · 95 tokens

doc-reader

Read any common document/data file — PDF, Word (.docx), Excel (.xlsx/.xls), PowerPoint (.pptx), images (OCR), CSV/TSV, plain text, JSON/YAML/TOML, HTML/XML, and most source-code files. Use the readdocument tool.

HKUDS/Vibe-Trading · 65 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

brain-pdf

Generate a publication-quality PDF from any brain page via the gstack make-pdf binary. Strips YAML frontmatter, sanitizes emoji, applies running headers and page numbers. Brain page is always the source of truth; PDF is a rendering.

garrytan/gbrain · 53 tokens