xyliu-cs/openspace-gdpval/python-execution-fallback-9d4989

Claude Code and agent skill by xyliu-cs/openspace-gdpval

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Fallback method for executing Python when execute_code_sandbox fails with unknown errors

Install

npx vskill@latest install xyliu-cs/openspace-gdpval/python-execution-fallback-9d4989

SKILL.md

The same SKILL.md was published earlier as xyliu-cs/openspace-gdpval/python-execution-fallback-9d4989.

Python Execution Fallback

When to Use

Use this skill when execute_code_sandbox returns 'unknown error' or fails unexpectedly, even on simple Python code like print statements.

Solution

Switch to using run_shell with Python heredoc syntax instead of execute_code_sandbox.

Basic Syntax
bash
python3 << 'EOF'
# Your Python code here
print("Hello World")
result = 2 + 2
print(f"Result: {result}")
EOF
How to Call

Instead of:

python
execute_code_sandbox(code="print('Hello')")

Use:

python
run_shell(command="python3 << 'EOF'\nprint('Hello')\nEOF")

For multi-line code, build the command string:

python
code = """
import json
data = {"status": "ok", "count": 42}
print(json.dumps(data))
"""
run_shell(command=f"python3 << 'EOF'\n{code}\nEOF")

Why This Works

  • run_shell executes commands directly in the shell environment, bypassing sandbox issues
  • Heredoc syntax (<< 'EOF') allows clean multi-line Python code without complex escaping
  • Single quotes around EOF prevent unwanted shell variable expansion
  • More reliable for simple to moderate Python execution tasks

Guidelines

  1. Always use single quotes around EOF ('EOF') to prevent variable expansion
  2. Test with a simple print statement first to verify Python is available
  3. For longer scripts, consider writing to a .py file first, then executing:

``python run_shell(command="python3 /path/to/script.py") ``

  1. Capture stdout from run_shell to get Python output
  2. Handle errors by checking run_shell's stderr output

Example: Complete Workflow

python
# Step 1: Try execute_code_sandbox
try:
result = execute_code_sandbox(code="print(2+2)")
except Exception as e:
# Step 2: Fallback to run_shell with heredoc
result = run_shell(command="python3 << 'EOF'\nprint(2+2)\nEOF")
# Parse stdout to get the output
output = result.stdout.strip()

Troubleshooting

IssueSolution
Python not foundUse which python3 to verify installation
Heredoc not workingEnsure single quotes around EOF delimiter
Complex imports failInstall required packages or write to .py file
Output not capturedCheck run_shell stdout, not return value

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/xyliu-cs/openspace-gdpval/python-execution-fallback-9d4989/badge)](https://verified-skill.com/skills/xyliu-cs/openspace-gdpval/python-execution-fallback-9d4989)

Something wrong with this skill or its page? Tell us.