document-python-direct-exec
What it does
This skill has the AI agent run Python directly for spreadsheet, PDF and document jobs. It is for people whose document tasks hit step limits or unclear errors through a shell agent.
When to use it
- ✓When a document job would need many steps and might run past a shell agent's step limit.
- ✓When you need a PDF checklist, report or form with exact layout control.
- ✓When you want error messages that are clear and immediate.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/spreadsheet-direct-python-merged-343937/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Make a PDF checklist and an Excel tracker for my onboarding. Run the Python directly so I get clear errors if something goes wrong.”
5 new skills a week. 1 minute to read.
How it works
The agent writes the Python script to a file and runs it in one shell step. Because it runs without a shell agent's iteration limits, the script can finish the whole job and show its errors right away.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Direct Python Execution for Spreadsheet and Document Tasks
When to Use This Skill
Use direct run_shell with Python scripts for structured document operations when:
- Spreadsheets: Reading or writing complex Excel files with multiple sheets, applying formulas, formatting, or data transformations
- PDFs: Generating PDF checklists, reports, invoices, or forms with precise layout control
- Documents: Creating Word documents, HTML reports, or other structured output formats
- Complex Operations: The task involves multiple steps that could exceed agent step limits
- Precision Needed: You need precise control over error handling, debugging, and library imports
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 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
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 > process_document.py << 'EOF'
# Your document/spreadsheet code here
EOF
# Step 2: Execute the script
python3 process_document.py
Alternative Pattern: Inline Heredoc (Simple Scripts Only)
For short, simple scripts when NOT using shell_agent as the executor:
python3 << 'EOF'
# Your code here
EOF
Spreadsheet Examples
Example 1: Read and Transform Excel Data
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')
Example 3: Complex Formatting Operations
from openpyxl import load_workbook
from openpyxl.styles import Font, PatternFill, Alignment
wb = load_workbook('report.xlsx')
ws = wb.active
# Apply header styling
header_fill = PatternFill(start_color='4472C4', fill_type='solid')
header_font = Font(bold=True, color='FFFFFF')
for cell in ws[1]:
cell.fill = header_fill
cell.font = header_font
cell.alignment = Alignment(horizontal='center')
wb.save('report_formatted.xlsx')
PDF Generation Examples
Example 4: Generate PDF Checklist with ReportLab
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
def create_checklist(pdf_path, items):
c = canvas.Canvas(pdf_path, pagesize=letter)
width, height = letter
# Title
c.setFont("Helvetica-Bold", 16)
c.drawString(1*inch, height - 1*inch, "Safety Checklist")
# Checklist items
c.setFont("Helvetica", 12)
y_position = height - 1.5*inch
for i, item in enumerate(items, 1):
checkbox_x = 1*inch
text_x = 1.3*inch
c.drawString(checkbox_x, y_position, "☐") # Empty checkbox
c.drawString(text_x, y_position, f"{i}. {item}")
y_position -= 0.3*inch
# New page if needed
if y_position < 1*inch:
c.showPage()
y_position = height - 1*inch
c.save()
print(f"Created checklist: {pdf_path}")
# Usage
items = [
"Verify equipment is powered off",
"Check safety gear is available",
"Inspect work area for hazards",
"Confirm emergency contacts are posted"
]
create_checklist('safety_checklist.pdf', items)
Example 5: Generate PDF Report with Tables
from reportlab.lib import colors
from reportlab.lib.pagesizes import letter
from reportlab.
FAQ
What file types does it cover?
The skill lists spreadsheets, PDF checklists, reports and Word or HTML documents.
Why avoid the shell agent here?
The skill notes that shell agents can hit step limits or fail on heredoc parsing.
Does the agent still check the output?
The skill tells the agent to read the printed output to confirm success.
Details
Original description by the author
Use direct Python execution for reliable spreadsheet and document/PDF generation operations
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #13012
- License
- MIT
- Updated
- 11/1/2026
Comments
- …
More skills from this repository
agentpilot
7.8kHelps your agent improve a project step by step by preparing a task and running the AgentPilot loop that proposes, tests and scores changes.
openspace
7.8kHelps your agent set up OpenSpace, a tool that stores and fetches agent skills, and connect it to your AI app through MCP.
rsi-arena
7.8kHelps your agent set up and run standard AI benchmark tests, such as AIME and Terminal-Bench, to compare different improvement methods.
experiment-guide
7.8kHelps your agent plan small experiments, read their results and record findings while it investigates how to improve a program.
Similar skills
feishu-doc
394kHelps your agent read, create, and edit Feishu cloud documents, including text, images, and tables, using the document tool.
feishu-drive
394kLets your agent browse, organize, and comment on files in a Feishu cloud folder that has been shared with the bot.
feishu-perm
394kHelps your agent check and change who can access a Feishu file, choosing the smallest permission that meets your request.