document-direct-python
できること
このスキルは、AIエージェントがExcelブック、PDFレポート、フォームなどの文書を、Pythonの直接実行で作るよう導きます。シェルエージェントの遅れなしに、これらのファイルを作りたい人向けです。
使う場面
- ✓Pythonで、PDF文書、チェックリスト、レポートが必要なとき。
- ✓文書の作業に複数の手順があり、エージェントの上限を超えるかもしれないとき。
- ✓シェルエージェントが書式設定やブックの読み取りで失敗したとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/spreadsheet-direct-python-merged/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のデータから、reportlabでPDFレポートを、openpyxlでExcelブックを作ってください。コードは直接実行してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントはPythonコードをファイルに書き、python3を使ってシェルで実行します。コードは文書のライブラリを使ってファイルを作り、エージェントは表示された出力でエラーがないかを確認します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Direct Python Execution for Document Generation Tasks
When to Use This Skill
Use direct run_shell with Python scripts for document operations when:
- Reading or writing complex Excel files with multiple sheets
- Generating PDF documents, checklists, or reports
- Applying formulas, formatting, or data transformations
- Working with
openpyxl,pandas,reportlab,FPDF, or similar libraries - The operation involves multiple steps that could exceed agent step limits
- You need precise control over error handling and debugging
- Complex scripts benefit from file-based execution for better reliability
Why Direct Execution?
The shell_agent tool can:
- Hit maximum step limits on complex multi-step operations
- Produce unexplained errors on formatting operations
- Fail on intricate document reads/writes due to iterative parsing
- Fail to parse heredoc syntax correctly, causing 'unknown error' failures
Direct run_shell with Python is more reliable because it:
- Executes in a single step with no iteration limits
- Provides clearer, immediate error messages
- Handles complex operations without step constraints
- Gives full control over library imports and execution flow
- Writing scripts to
.pyfiles first avoids shell_agent parsing issues with heredocs
How to Use
Handling Web Research Failures
When web research tools (search_web, read_webpage) fail or return 'unknown error':
- Assess what you need: Determine if the information is from well-documented regulatory frameworks, standards, or common knowledge that you can provide from internal knowledge.
- Proceed with available knowledge: For pharmacy compliance, OSHA standards, GDPR requirements, and similar well-established frameworks, generate documents using your training knowledge rather than waiting for web access.
- Document assumptions: Clearly note that materials were generated based on standard practices when source verification was unavailable.
- Use direct Python execution: Continue with the recommended
run_shellpattern to generate documents even without web-sourced content.
Example contingency workflow for pharmacy compliance:
# When web research fails, proceed with established regulatory knowledge
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
checklist_items = [
"Verify pharmacist license is current and displayed",
"Maintain controlled substance inventory logs",
"Ensure proper storage temperatures for medications",
"Keep patient counseling records for controlled substances",
"Display required pharmacy signage and notices"
]
# Generate PDF using these standard compliance items
This approach was successfully used in task 045aba2e-4093-42aa-ab7f-159cc538278c_phase2 where all web tools failed but pharmacy compliance PDFs were still created successfully.
Recommended Pattern: Write Script to File First
For complex multi-line scripts, especially when using shell_agent as executor:
# Step 1: Write the Python script to a file
cat > generate_document.py << 'EOF'
import openpyxl
from openpyxl import Workbook
# Your document code here
wb = openpyxl.load_workbook('file.xlsx')
# ... operations ...
wb.save('output.xlsx')
print('Success')
EOF
# Step 2: Execute the script
python3 generate_document.py
Alternative Pattern: Inline Heredoc (Simple Scripts Only)
For short, simple scripts when NOT using shell_agent as the executor:
python3 << 'EOF'
import pandas as pd
df = pd.read_excel('input.xlsx')
df.to_excel('output.xlsx', index=False)
print('Done')
EOF
Spreadsheet Examples
Example 1: Read and Transform Excel Data
Write to file first, then execute:
import pandas as pd
# Load data from specific sheet
df = pd.read_excel('input.xlsx', sheet_name='Revenue')
# Apply transformations
df['Net_Revenue'] = df['Gross_Revenue'] * (1 - df['Tax_Rate'])
# Save results
df.to_excel('output.xlsx', index=False, sheet_name='Processed')
Example 2: Multi-Sheet Operations with openpyxl
from openpyxl import load_workbook
wb = load_workbook('tour_data.xlsx')
# Iterate through sheets
for sheet_name in wb.sheetnames:
ws = wb[sheet_name]
# Apply formatting or calculations
for row in ws.iter_rows(min_row=2, max_col=5):
# Process cells
pass
wb.save('tour_data_processed.xlsx')
PDF Generation Examples
Example 3: Generate PDF Checklist with reportla
よくある質問
直接実行の主な利点は何ですか?
スキルは、1回の手順で実行され、エラーメッセージがすぐに分かりやすく表示されると述べています。
Wordファイルも作れますか?
はい。スキルは、対応する出力の種類としてWord文書を挙げています。
エージェントは必ず先にファイルを使いますか?
スキルは、複雑な複数行のコードでは、スクリプトをファイルに書くよう勧めています。
詳細
作者による元の説明
Use direct Python execution for reliable document creation including spreadsheets, PDFs, and structured reports
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #13014
- ライセンス
- 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のファイルにアクセスできる人を確認し、変更するようエージェントを支援します。依頼を満たす最小の権限を選びます。