pdf-verification-check-112b09
Skill này làm gì
Skill này xác nhận các PDF do AI tạo ra tồn tại, không trống và có đúng số trang. Dành cho người cần tin tưởng tệp PDF trước khi dùng.
Khi nào nên dùng
- ✓Khi tác vụ đã tạo một PDF và cần được kiểm tra trước khi kết thúc.
- ✓Khi một PDF cần một số trang cụ thể.
- ✓Khi tác vụ tạo ra nhiều đầu ra PDF và tất cả đều cần kiểm tra.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-verification-check-112b09/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Sau khi bạn tạo PDF, hãy kiểm tra tệp có tồn tại, không trống và có đúng ba trang.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI cài PyPDF2 nếu cần, chạy một hàm Python ngắn để xác nhận tệp tồn tại, có nội dung và khớp số trang mong đợi, rồi báo kết quả.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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}"
Câu hỏi thường gặp
Kiểm tra xác nhận điều gì?
Tệp tồn tại, không trống và có thể mở được với số trang mong đợi.
PyPDF2 được dùng để làm gì?
Nó mở PDF và đếm số trang.
Nếu số trang sai thì sao?
Kiểm tra báo cáo sự không khớp để AI có thể sửa bước tạo.
Chi tiết
Mô tả gốc của tác giả
Verify generated PDF files using PyPDF2 to check page counts and integrity
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #12936
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentpilot
7.8kGiúp agent của bạn cải thiện dự án từng bước bằng cách chuẩn bị tác vụ và chạy vòng lặp AgentPilot, gồm đề xuất, kiểm thử và chấm điểm thay đổi.
openspace
7.8kGiúp agent của bạn thiết lập OpenSpace, công cụ lưu và lấy lại skill của agent, rồi kết nối nó với ứng dụng AI của bạn qua MCP.
rsi-arena
7.8kGiúp agent của bạn thiết lập và chạy các bài kiểm thử benchmark AI chuẩn, như AIME và Terminal-Bench, để so sánh các phương pháp cải tiến khác nhau.
experiment-guide
7.8kGiúp agent của bạn lên kế hoạch các thí nghiệm nhỏ, đọc kết quả và ghi lại phát hiện khi tìm cách cải thiện một chương trình.
Skill tương tự
feishu-doc
394kGiúp agent của bạn đọc, tạo và sửa tài liệu đám mây Feishu, gồm văn bản, hình ảnh và bảng, bằng công cụ tài liệu.
feishu-drive
394kCho phép agent của bạn duyệt, sắp xếp và bình luận các file trong một thư mục đám mây Feishu đã được chia sẻ với bot.
feishu-perm
394kGiúp agent của bạn kiểm tra và thay đổi ai có quyền truy cập một file Feishu, chọn quyền nhỏ nhất đáp ứng yêu cầu của bạn.