read-pdf

Reads local and Google Drive PDFs and answers questions about their contents.

Updated Mar 29, 2024
One-click install
npx skills add https://github.com/petobens/ai-harness --skill read-pdf-petobens
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: read-pdf
Source: https://github.com/petobens/ai-harness/tree/main/skills/read-pdf
Command: npx skills add https://github.com/petobens/ai-harness --skill read-pdf-petobens

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Reading a PDF inside an AI agent is inconsistent: some agents parse PDFs natively while others only see raw bytes, and PDFs stored in Google Drive must be downloaded first. This Skill provides a single workflow that detects the running agent, picks the right reading path, and handles both local files and Drive-hosted documents. ## Core Features & Use Cases - Agent-aware reading: Detects whether Claude Code or Codex is running and uses the native PDF reader or CLI tools (pdfinfo, pdftotext, pdftoppm) accordingly. - Google Drive support: Downloads Drive PDFs by file ID using gws, delegating file discovery to the google-drive skill, then reads the local copy. - Scanned PDF fallback: Renders image-only pages to PNGs at 150 DPI for visual inspection when no text layer exists. - Use Case: A user shares a Google Drive link to a 60-page contract and asks for the termination clause. The Skill downloads the PDF, reads it in page windows, and answers with the relevant pages cited. ## Quick Start Read the PDF at ./reports/q3.pdf and tell me how many pages it has and what it covers.

Frequently Asked Questions about read-pdf

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I read a PDF file with an AI agent?

Detect which agent is running first: Claude Code reads PDFs natively with its built-in Read tool, while Codex and other agents use CLI tools. Run pdfinfo for page count, then pdftotext -layout to extract the text layer to stdout.

How to read a PDF stored in Google Drive?

Download the Drive PDF first using gws drive files get with the bare file ID and alt=media, saving to a relative path in the current directory. Then read the downloaded local copy with the agent-appropriate method.

Can I extract text from a scanned or image-only PDF?

Scanned PDFs have no text layer, so pdftotext returns little or nothing. Render pages to PNGs at 150 DPI with pdftoppm and view them if the agent accepts image input; otherwise no OCR is available and the limitation is reported.

Why does reading a PDF return raw bytes instead of text?

This happens when an agent without a native PDF parser, such as Codex, points its file read at a PDF. Use the CLI path instead: pdftotext -layout extracts the text layer, with -f and -l flags for page windows.

How do I read a long PDF without overloading context?

Read long PDFs in page windows rather than all at once. Claude Code accepts a pages range like 1-5 with a maximum of about 20 pages per read, and pdftotext supports -f and -l flags to bound the extraction.