Execute complex Python code via run_shell heredoc when execute_code_sandbox fails
67
80%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./benchmarks/gdpval/skills/shell-python-heredoc/SKILL.mdWhen execute_code_sandbox fails repeatedly (e.g., with "unknown error"), use run_shell with a Python heredoc as a reliable fallback for executing multi-line Python scripts with imports.
execute_code_sandbox has failed 2+ times with unexplained errorsrun_shell(
command="""python3 << 'EOF'
import sys
# Your Python code here
print("Hello from heredoc")
EOF""",
timeout=300
)<< 'EOF' (with single quotes) to prevent shell variable expansionEOF on its own line (no leading whitespace)run_shell(
command="""python3 << 'EOF'
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas("output.pdf", pagesize=letter)
c.drawString(100, 750, "Hello PDF")
c.save()
print("PDF created successfully")
EOF""",
timeout=300
)run_shell(
command="""python3 << 'EOF'
import pandas as pd
import json
# Load and process data
df = pd.read_csv("data.csv")
summary = df.describe()
# Output results
print(summary.to_string())
with open("summary.json", "w") as f:
json.dump(summary.to_dict(), f)
print("Processing complete")
EOF""",
timeout=300
)| Issue | Solution |
|---|---|
EOF not recognized | Ensure EOF is on its own line with no leading spaces |
| Import errors | Verify packages are installed in the shell environment |
| File not found | Use absolute paths or check working directory with pwd |
| Syntax errors | Check Python indentation within heredoc |
execute_code_sandbox for simpler scripts when availableshell_agent for tasks requiring autonomous iteration and error recovery.py files for complex, reusable codec5a9c4b
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.