pdf-gen-fallback-dee20c
できること
このスキルは、ライブラリの確認と目に見えるエラー処理を備えた、PDF生成の予備の方法です。PDFやレポートの作業が、はっきりした理由もなくサンドボックスで失敗する人向けです。
使う場面
- ✓PDFやレポートを作る中で、サンドボックスが不明確なエラーを返すとき。
- ✓エラーがどこで起きたのかを見られるよう、エラーメッセージを表示してほしいとき。
- ✓簡単なPDFをパソコンのファイルとして保存したいとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-gen-fallback-dee20c/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“タイトルと本文を入れた簡単なPDFを作ってください。サンドボックスが分かりやすいメッセージなしで失敗するので、シェルから実行して、エラーがあれば見せてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIは必要なライブラリを確認し、PDFを書いて成功メッセージを表示するPythonスクリプトをシェルから実行します。コードはエラー処理で囲まれています。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
PDF Generation Fallback Workflow
Purpose
When execute_code_sandbox returns opaque or unhelpful errors during document/PDF generation, use run_shell with direct python -c execution as a reliable alternative. This pattern includes library availability checks and explicit error handling.
When to Use
execute_code_sandboxfails with unclear error messages during document generation- PDF, report, or document creation tasks are failing unexpectedly
- You need more control over the Python execution environment
Step-by-Step Instructions
1. Check Library Availability
Before attempting generation, verify required libraries are installed:
run_shell: python -c "import reportlab; print('reportlab OK')"
run_shell: python -c "import fpdf; print('fpdf OK')"
run_shell: python -c "import PyPDF2; print('PyPDF2 OK')"
If a library is missing, install it:
run_shell: pip install reportlab --quiet
2. Execute Generation via run_shell
Instead of execute_code_sandbox, use run_shell with python -c:
run_shell: python -c "
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas('output.pdf', pagesize=letter)
c.drawString(100, 750, 'Document Content')
c.save()
print('PDF generated successfully')
"
3. Handle Errors Explicitly
Wrap generation code with try/except and capture stderr:
run_shell: python -c "
import sys
try:
# Your generation code here
from reportlab.pdfgen import canvas
c = canvas.Canvas('output.pdf')
c.drawString(100, 750, 'Content')
c.save()
print('SUCCESS: PDF created')
sys.exit(0)
except Exception as e:
print(f'ERROR: {type(e).__name__}: {e}', file=sys.stderr)
sys.exit(1)
" 2>&1
4. Verify Output File
After generation, confirm the file was created:
run_shell: ls -la output.pdf
run_shell: file output.pdf
5. Fallback Hierarchy
If the first approach fails, try alternatives in this order:
reportlab- Full-featured PDF generationfpdf- Simpler PDF librarywkhtmltopdf- HTML to PDF conversion- Direct text/Markdown output as last resort
Example: Complete Workflow
# Step 1: Check library
run_shell: python -c "import reportlab; print('OK')"
# Step 2: Generate with error handling
run_shell: python -c "
import sys
try:
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas('report.pdf', pagesize=letter)
c.setTitle('Surveillance Report')
c.drawString(100, 750, 'Revised Surveillance Report')
c.drawString(100, 730, 'Summary: Key findings documented')
c.save()
print('SUCCESS')
except Exception as e:
print(f'FAILED: {e}', file=sys.stderr)
sys.exit(1)
"
# Step 3: Verify
run_shell: test -f report.pdf && echo 'File exists' || echo 'File missing'
Troubleshooting
| Issue | Solution |
|---|---|
| Module not found | pip install <module> --quiet |
| Permission denied | Check output directory permissions |
| Font errors | Use default fonts or install font packages |
| Encoding issues | Specify encoding explicitly in string operations |
Best Practices
- Always capture both stdout and stderr for debugging
- Exit with proper status codes (0 for success, 1 for failure)
- Keep generation code concise when using
python -c - For complex generation, write a temporary
.pyfile instead - Test library availability before attempting generation
よくある質問
なぜコードをエラー処理で囲むのですか?
ガイドは、失敗が隠されず、はっきり表示されるようにするためだと述べています。
スクリプトは最後に何を表示しますか?
成功のメッセージを表示するので、結果を簡単に確認できます。
例ではどのライブラリを使いますか?
テキストを描いてPDFを保存するために、reportlabのcanvasを使います。
詳細
作者による元の説明
Fallback workflow for document generation when code sandbox returns opaque errors
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #12927
- ライセンス
- 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のファイルにアクセスできる人を確認し、変更するようエージェントを支援します。依頼を満たす最小の権限を選びます。