pdf-debug-unbuffered
하는 일
이 스킬은 모호한 메시지로 실패하는 Python PDF 스크립트를 디버깅하는 요령입니다. 코드가 멈추는데 쓸모 있는 이유가 나오지 않는 사람에게 맞습니다.
사용하는 경우
- ✓Python PDF 스크립트가 일반적인 알 수 없는 오류 메시지로 실패할 때.
- ✓스크립트가 소리 없이 실패하고 트레이스백이 나오지 않는 경우.
- ✓PDF 코드에서 글꼴, import 또는 파일 경로 문제가 있다고 의심될 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-debug-unbuffered/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 Python PDF 스크립트가 도움이 안 되는 메시지로 실패합니다. 실제 오류가 보이도록 실행해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
AI는 버퍼링 없음 옵션으로 스크립트를 실행하고, 오류 출력을 일반 출력과 합친 뒤, 위쪽 몇 줄을 읽어 트레이스백을 찾습니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
PDF Generation Debug Technique
When Python PDF libraries (reportlab, fpdf, etc.) fail with generic "unknown error" messages, the actual cause is often hidden due to output buffering or error swallowing. This skill provides a technique to expose the real traceback.
Core Technique
Run the Python script with the -u flag (unbuffered output) and pipe stderr through head to capture the actual error:
python -u your_script.py 2>&1 | head -100
Or more specifically, to focus on stderr:
python -u your_script.py 2>&1 | head -50
Why This Works
-uflag: Forces Python to run in unbuffered mode, ensuring output (including errors) is flushed immediately rather than held in buffers that may be lost on crash2>&1: Redirects stderr to stdout so both streams are captured togetherhead: Limits output to show the most relevant error messages at the top
Step-by-Step Debugging
Step 1: Identify the failing script
Locate the Python script that generates the PDF and is producing generic errors.
Step 2: Run with unbuffered output
python -u generate_pdf.py 2>&1 | head -100
Step 3: Analyze the traceback
Look for:
- Import errors (missing dependencies)
- File path issues (invalid paths, permission errors)
- Font registration problems (common with reportlab)
- Memory or resource constraints
Step 4: Fix the underlying issue
Address the specific error revealed in the traceback.
Step 5: Re-run normally
Once fixed, run the script without the debug flags to confirm it works:
python generate_pdf.py
Common Issues Revealed
| Symptom | Likely Cause |
|---|---|
| "unknown error" on PDF save | File path doesn't exist or no write permissions |
| Generic failure during build | Missing font files or font registration issues |
| Silent crash | ImportError for missing dependencies |
| Incomplete PDF | Script terminated early due to unhandled exception |
Alternative Approaches
If the above doesn't work, try:
# Capture full stderr to a file
python -u script.py 2> error.log
# Use Python's traceback module explicitly
python -c "import traceback; exec(open('script.py').read())" 2>&1
# Run with verbose import tracing
python -v -u script.py 2>&1 | head -200
Example: Debugging reportlab
# Before: Generic error
python create_checklist.py
# Output: "Error: unknown"
# After: Actual traceback
python -u create_checklist.py 2>&1 | head -50
# Output: "FileNotFoundError: [Errno 2] No such file or directory: '/fonts/Helvetica.ttf'"
Notes
- This technique applies to any Python script with opaque error messages, not just PDF generation
- The
-uflag is available in Python 2.7+ and all Python 3 versions - For production debugging, consider logging to a file instead of using
head
자주 묻는 질문
버퍼링 없음 옵션은 무엇을 하나요?
Python이 출력을 즉시 보내므로, 프로그램이 비정상 종료해도 메시지가 사라지지 않습니다.
head로 출력을 제한하는 이유는 무엇인가요?
가장 중요한 오류 줄이 위쪽에 남아 읽기 쉬워지기 때문입니다.
어떤 종류의 오류를 찾을 수 있나요?
가이드는 누락된 import, 파일 경로 문제, 글꼴 등록 문제, 자원 한도를 언급합니다.
상세 정보
작성자의 원본 설명
Debug Python PDF generation errors by using unbuffered output and stderr inspection to reveal actual tracebacks
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12914
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
agentpilot
7.8k작업을 준비하고 AgentPilot 루프를 실행해 변경을 제안, 테스트, 점수화하면서 프로젝트를 단계적으로 개선하도록 돕습니다.
openspace
7.8k에이전트 스킬을 저장하고 가져오는 도구인 OpenSpace를 설정하고, MCP를 통해 AI 앱에 연결하도록 돕습니다.
rsi-arena
7.8kAIME나 Terminal-Bench 같은 표준 AI 벤치마크 테스트를 설정하고 실행해 서로 다른 개선 방법을 비교하도록 돕습니다.
experiment-guide
7.8k프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.
비슷한 스킬
feishu-doc
394k에이전트가 문서 도구를 사용해 텍스트, 이미지, 표를 포함한 Feishu 클라우드 문서를 읽고, 만들고, 편집하도록 돕습니다.
feishu-drive
394k에이전트가 봇과 공유된 Feishu 클라우드 폴더의 파일을 찾아보고, 정리하고, 댓글을 달도록 돕습니다.
feishu-perm
394k에이전트가 요청을 충족하는 가장 작은 권한을 골라, Feishu 파일에 누가 접근할 수 있는지 확인하고 바꾸도록 돕습니다.