xyliu-cs/openspace-gdpval/reliable-script-execution
Claude Code and agent skill by xyliu-cs/openspace-gdpval
- community
Checking that the SKILL.md file is still in the repository.
Execute Python scripts reliably using file-first approach instead of heredoc
Install
npx vskill@latest install xyliu-cs/openspace-gdpval/reliable-script-executionSKILL.md
The same SKILL.md was published earlier as xyliu-cs/openspace-gdpval/reliable-script-execution.
Reliable Script Execution
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.
Problem
Direct heredoc Python execution like:
Can fail with 'unknown error', especially when:
- Script contains multiple lines or complex logic
- Special characters or quotes are present
- Working directory context matters
Solution: File-First Approach
Step 1: Write Python Script to File
Use write_file to save your Python code to a .py file:
Step 2: Execute via Shell
Use run_shell with explicit working directory:
Step 3: Clean Up (Optional)
Remove temporary files after execution:
Complete Example
Task: Generate a JSON report with calculations
Best Practices
- 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
.pyfiles cluttering the workspace unless they need to persist
When to Use This Pattern
- Executing multi-line Python code via shell
- Scripts with complex string handling or special characters
- When heredoc execution has failed previously
- Any scenario where reliability matters more than brevity
Anti-Pattern to Avoid
Do NOT rely on heredoc for production-critical scripts:
Use file-first approach instead for consistent, debuggable execution.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinggdpval_bench/skills/reliable-script-execution/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/xyliu-cs/openspace-gdpval/reliable-script-execution)