pdf-verification
できること
このスキルは、PDFを作った直後に確認し、ページ数の誤り、空のページ、壊れたファイルを見つけます。使う前にPDFの出力を信頼したい人向けです。
使う場面
- ✓PDFを生成するタスクが終わったばかりのとき。
- ✓タスクで特定のページ数が要求されているとき。
- ✓完了の前に、PDFが空でも壊れてもいないことを確かめたいとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-verification/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“PDFは2ページである必要があります。作ったら、ページ数を確認して、正しく開けることを確かめてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIは必要ならPyPDF2をインストールし、run_shellで短い確認を実行してファイルを開き、ページ数を目標と比べて、食い違いがあれば報告します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)を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)
"
よくある質問
空のPDFを見つけられますか?
はい。スクリプトは、0ページのPDFを空として報告します。
食い違いがあったらどうなりますか?
想定した数と実際の数を表示するので、問題が見えるようになります。
確認はいつ行いますか?
PDFを生成した直後、タスクを完了と言う前に行います。
詳細
作者による元の説明
Verify PDF page counts and file integrity programmatically using PyPDF2 after generation
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #12941
- ライセンス
- MIT
- 更新日
- 2026/11/1
コメント
- …
このリポジトリの他のスキル
agentpilot
7.8kエージェントが、作業を準備し、変更案を提案してテストし、評価するAgentPilotのループを実行することで、プロジェクトを段階的に改善できるよう支援します。
openspace
7.8kエージェントが、スキルを保存し取り出すツールであるOpenSpaceをセットアップし、MCPを通じてAIアプリに接続できるよう支援します。
rsi-arena
7.8kエージェントが、AIMEやTerminal-Benchなどの標準的なAIベンチマークテストをセットアップして実行し、異なる改善方法を比較できるよう支援します。
experiment-guide
7.8kエージェントが、プログラムを改善する方法を調べる間に、小さな実験を計画し、その結果を読み、発見を記録できるよう支援します。
似ているスキル
feishu-doc
394kテキスト、画像、表を含むFeishuのクラウドドキュメントを、ドキュメントツールを使って読み、作成し、編集するようエージェントを支援します。
feishu-drive
394kボットと共有されたFeishuのクラウドフォルダ内のファイルを閲覧、整理、コメントできるようエージェントを支援します。
feishu-perm
394kFeishuのファイルにアクセスできる人を確認し、変更するようエージェントを支援します。依頼を満たす最小の権限を選びます。