用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/HKUDS/OpenSpace --skill reliable-script-execution命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | reliable-script-execution |
| description | Execute Python scripts reliably using file-first approach instead of heredoc |
When executing Python code via shell commands, avoid inline heredoc execution which can fail unpredictably with 'unknown error'. Use this two-step file-first approach for more reliable script execution.
Direct heredoc Python execution like:
python3 << 'EOF'
# complex code here
EOF
Can fail with 'unknown error', especially when:
Use write_file to save your Python code to a .py file:
write_file(path="./temp_script.py", content="""
import json
data = {"key": "value"}
print(json.dumps(data))
""")
Use run_shell with explicit working directory:
run_shell(command="python3 ./temp_script.py", timeout=60)
Remove temporary files after execution:
run_shell(command="rm ./temp_script.py")
Task: Generate a JSON report with calculations
# Step 1: Write the script
write_file(
path="./generate_report.py",
content="""
import json
from datetime import datetime
revenue = 500000.00
expenses = 379577.06
net_income = revenue - expenses
report = {
"generated": datetime.now().isoformat(),
"revenue": revenue,
"expenses": expenses,
"net_income": net_income
}
print(json.dumps(report, indent=2))
"""
)
# Step 2: Execute
run_shell(command="python3 ./generate_report.py", timeout=60)
# Step 3: Clean up
run_shell(command="rm ./generate_report.py")
Use descriptive filenames: Name scripts according to their purpose (e.g., calculate_pnl.py, transform_data.py)
Set appropriate timeouts: For data processing scripts, use longer timeouts (60-300 seconds)
Specify working directory: If the script depends on relative paths, include cd /path && python3 script.py
Handle errors gracefully: Check shell output for errors and retry if needed
Clean up temporary files: Don't leave .py files cluttering the workspace unless they need to persist
Do NOT rely on heredoc for production-critical scripts:
# Unreliable - may fail with 'unknown error'
python3 << 'EOF'
# Your code here
EOF
Use file-first approach instead for consistent, debuggable execution.