pdf-verification
What it does
This skill checks PDFs right after they are made, to catch wrong page counts, empty pages or corrupted files. It is for people who need confidence in PDF output before using it.
When to use it
- βWhen a PDF generation task has just finished.
- βWhen the task requires a specific number of pages.
- βWhen I want to be sure the PDF is not empty or corrupted before finishing.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-verification/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βI need the PDF to be two pages. Once it is made, please verify the page count and make sure it opens properly.β
5 new skills a week. 1 minute to read.
How it works
The AI installs PyPDF2 if needed, runs a short check through run_shell that opens the file, compares the page count with the target, and reports any mismatch.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
PDF Verification Skill
Purpose
After generating PDF files, always verify page counts and file integrity programmatically before declaring task completion. This catches formatting issues, empty pages, and corrupted files early.
When to Use
- After any PDF generation task
- When specific page counts are required
- Before marking a PDF-related task as complete
Verification Steps
1. Install PyPDF2 (if needed)
pip install PyPDF2
2. Verify Page Count and Integrity
Use run_shell to execute a Python verification script:
python -c "
from PyPDF2 import PdfReader
import sys
def verify_pdf(filepath, expected_pages=None):
try:
reader = PdfReader(filepath)
actual_pages = len(reader.pages)
print(f'β {filepath}: {actual_pages} pages')
if expected_pages and actual_pages != expected_pages:
print(f'β Page count mismatch: expected {expected_pages}, got {actual_pages}')
return False
# Check file is not empty/corrupted
if actual_pages == 0:
print(f'β Empty PDF: {filepath}')
return False
return True
except Exception as e:
print(f'β Error reading {filepath}: {e}')
return False
# Verify each PDF
results = []
results.append(verify_pdf('output.pdf', expected_pages=2))
print(f'All checks passed: {all(results)}')
sys.exit(0 if all(results) else 1)
"
3. Verify Multiple PDFs
For tasks with multiple PDFs, verify each one:
python -c "
from PyPDF2 import PdfReader
pdfs = {
'listings.pdf': 2,
'map.pdf': 1,
'summary.pdf': 1
}
all_passed = True
for filepath, expected in pdfs.items():
try:
reader = PdfReader(filepath)
actual = len(reader.pages)
status = 'β' if actual == expected else 'β'
print(f'{status} {filepath}: {actual}/{expected} pages')
if actual != expected:
all_passed = False
except Exception as e:
print(f'β {filepath}: {e}')
all_passed = False
print(f'Verification: {\"PASSED\" if all_passed else \"FAILED\"}')
"
4. Check File Size (Optional)
Add file size validation to catch empty or near-empty files:
python -c "
import os
from PyPDF2 import PdfReader
filepath = 'output.pdf'
min_size = 1000 # minimum bytes
file_size = os.path.getsize(filepath)
if file_size < min_size:
print(f'β File too small: {file_size} bytes')
else:
reader = PdfReader(filepath)
print(f'β {filepath}: {len(reader.pages)} pages, {file_size} bytes')
"
Best Practices
- Verify immediately after generation - Don't wait until the end of the task
- Check all required PDFs - Verify each file meets specifications
- Fail fast - If verification fails, regenerate before proceeding
- Log results - Print verification results for debugging
- Set reasonable minimums - Use file size checks to catch empty outputs
Common Issues Caught
- Wrong page counts (extra blank pages, missing content)
- Corrupted or unreadable PDF files
- Empty PDFs (0 pages)
- Files that appear generated but contain no actual content
Example Task Completion Check
# Final verification before marking task complete
python -c "
from PyPDF2 import PdfReader
import sys
required = {'listings.pdf': 2, 'map.pdf': 1}
passed = True
for f, pages in required.items():
try:
actual = len(PdfReader(f).pages)
if actual != pages:
print(f'FAIL: {f} has {actual} pages, expected {pages}')
passed = False
except Exception as e:
print(f'FAIL: Cannot read {f}: {e}')
passed = False
if passed:
print('SUCCESS: All PDFs verified')
sys.exit(0)
else:
sys.exit(1)
"
FAQ
Does it catch empty PDFs?
Yes, the script reports a PDF with zero pages as empty.
What happens on a mismatch?
The check prints the expected and actual counts, so the problem is visible.
When should the check run?
Right after generating the PDF and before marking the task complete.
Details
Original description by the author
Verify PDF page counts and file integrity programmatically using PyPDF2 after generation
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #12941
- License
- MIT
- Updated
- 11/1/2026
Comments
- β¦
More skills from this repository
agentpilot
7.8kHelps your agent improve a project step by step by preparing a task and running the AgentPilot loop that proposes, tests and scores changes.
openspace
7.8kHelps your agent set up OpenSpace, a tool that stores and fetches agent skills, and connect it to your AI app through MCP.
rsi-arena
7.8kHelps your agent set up and run standard AI benchmark tests, such as AIME and Terminal-Bench, to compare different improvement methods.
experiment-guide
7.8kHelps your agent plan small experiments, read their results and record findings while it investigates how to improve a program.
Similar skills
feishu-doc
394kHelps your agent read, create, and edit Feishu cloud documents, including text, images, and tables, using the document tool.
feishu-drive
394kLets your agent browse, organize, and comment on files in a Feishu cloud folder that has been shared with the bot.
feishu-perm
394kHelps your agent check and change who can access a Feishu file, choosing the smallest permission that meets your request.