pdf-verification-check-112b09
できること
このスキルは、AIが作ったPDFが存在し、空ではなく、正しいページ数を持つことを確かめます。使う前にPDFを信頼する必要がある人向けです。
使う場面
- ✓タスクでPDFが生成され、完了を言う前に確認が必要なとき。
- ✓特定のページ数が必要なとき。
- ✓タスクで複数のPDFが作られ、それぞれを確認する必要があるとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-verification-check-112b09/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“PDFを作った後、ファイルが存在し、空ではなく、ちょうど3ページあることを確認してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIは必要ならPyPDF2をインストールし、ファイルの存在、内容、想定したページ数を確認する短いPython関数を実行して、結果を報告します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
PDF Verification Check
After generating PDF files, always programmatically verify their structure and integrity before declaring task completion. This catches formatting errors, incorrect page counts, and corrupted files early.
When to Use
Use this skill whenever your task involves:
- Generating PDF documents
- Creating PDFs with specific page count requirements
- Producing multi-part PDF outputs (e.g., listings + maps)
Verification Steps
1. Install PyPDF2 (if not available)
pip install PyPDF2
2. Verify PDF Page Count and Integrity
Create a verification script or run inline Python:
from PyPDF2 import PdfReader
import os
def verify_pdf(pdf_path, expected_pages=None):
"""Verify PDF file exists, is readable, and has expected page count."""
try:
# Check file exists
if not os.path.exists(pdf_path):
return False, f"File not found: {pdf_path}"
# Check file size (non-empty)
file_size = os.path.getsize(pdf_path)
if file_size == 0:
return False, f"Empty file: {pdf_path}"
# Open and verify PDF structure
reader = PdfReader(pdf_path)
actual_pages = len(reader.pages)
# Check page count if expected
if expected_pages is not None and actual_pages != expected_pages:
return False, f"Expected {expected_pages} pages, got {actual_pages}"
return True, f"Valid PDF with {actual_pages} page(s)"
except Exception as e:
return False, f"PDF verification failed: {str(e)}"
# Example usage
pdf_files = [
("listings.pdf", 2),
("map.pdf", 1),
]
all_valid = True
for pdf_path, expected in pdf_files:
valid, message = verify_pdf(pdf_path, expected)
print(f"{pdf_path}: {'✓' if valid else '✗'} {message}")
if not valid:
all_valid = False
if not all_valid:
raise Exception("PDF verification failed - review and regenerate")
3. Use run_shell for Verification
Execute the verification using run_shell:
python -c "
from PyPDF2 import PdfReader
import sys
pdf_path = 'output.pdf'
expected = 2
try:
reader = PdfReader(pdf_path)
actual = len(reader.pages)
if actual != expected:
print(f'ERROR: Expected {expected} pages, got {actual}')
sys.exit(1)
print(f'OK: {pdf_path} has {actual} page(s)')
except Exception as e:
print(f'ERROR: {e}')
sys.exit(1)
"
4. Verify Before Completion
Critical: Only mark your task as complete after ALL PDF verification checks pass. If verification fails:
- Examine the error message
- Regenerate the PDF with corrected formatting
- Re-run verification
- Repeat until all checks pass
Common Issues Caught
- Wrong page counts (e.g., content spilling to extra pages)
- Empty or corrupted PDF files
- PDFs that fail to open properly
- Missing expected sections due to formatting errors
Example Workflow
# 1. Generate PDF
generate_pdf("listings.pdf", content)
# 2. Verify before completion
valid, msg = verify_pdf("listings.pdf", expected_pages=2)
if not valid:
# Fix and regenerate
regenerate_pdf("listings.pdf", corrected_content)
valid, msg = verify_pdf("listings.pdf", expected_pages=2)
# 3. Only complete if verification passes
assert valid, f"Cannot complete: {msg}"
よくある質問
この確認は何を確かめますか?
ファイルが存在し、空ではなく、想定したページ数で開けることを確かめます。
PyPDF2は何に使いますか?
PDFを開き、ページ数を数えるために使います。
数が違っていたら?
確認は食い違いを報告するので、AIは生成のステップを直せます。
詳細
作者による元の説明
Verify generated PDF files using PyPDF2 to check page counts and integrity
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #12936
- ライセンス
- 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のファイルにアクセスできる人を確認し、変更するようエージェントを支援します。依頼を満たす最小の権限を選びます。