python-shell-fallback

python-shell-fallback is a skill for Claude Code, Codex from HKUDS/OpenSpace. It costs 17 tokens per session (697 once invoked), scanned A, original, MIT.

A fallback procedure for running Python with external packages through the shell when the code sandbox cannot provide them.

In plain words
What is it for?
Use it for PDF generation, charts, data processing, and other Python tasks that need installed libraries.
Why use it?
It helps execute library-dependent code when the sandbox reports missing packages or environment errors.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it for PDF generation, charts, data processing, and other Python tasks that need installed libraries.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hkuds/openspace/python-shell-fallback
About the project

OpenSpace is a skill-management layer for AI agents that stores, retrieves, evaluates, shares, and improves reusable workflows. It is intended for people using multiple coding agents who want skills to be reused and refined based on task outcomes. The catalogue provides 200 skills for use with OpenSpace and the agents it supports.

HKUDS/OpenSpace · 7,544 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add HKUDS/OpenSpace --skill python-shell-fallback
Clone the repo
git clone --depth 1 https://github.com/HKUDS/OpenSpace

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for python-shell-fallback

README.md
[![agentmods](https://agentmods.dev/badge/skills/hkuds/openspace/python-shell-fallback.svg)](https://agentmods.dev/skills/hkuds/openspace/python-shell-fallback)
Your own site
<a href="https://agentmods.dev/skills/hkuds/openspace/python-shell-fallback"><img src="https://agentmods.dev/badge/skills/hkuds/openspace/python-shell-fallback.svg" alt="Measured on agentmods" height="20"></a>
Per session 17 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 697 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00017 $0.00697
Opus 5 $0.00009 $0.00349
Sonnet 5 $0.00003 $0.00139
Haiku 4.5 $0.00002 $0.00070

Measured 5d ago against content hash 5c42b4f5b474, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

python-shell-fallback scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

benchmarks/gdpval/skills/python-shell-fallback/SKILL.md · 100 lines

How it starts

The opening of the file, as written. The whole thing — 100 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Shell Fallback

When execute_code_sandbox fails for Python code that depends on external libraries, use run_shell with a heredoc Python script as a reliable fallback. The shell environment typically has better access to installed packages and system configuration than the sandbox.

When to Use This Pattern

Apply this skill when:

  • execute_code_sandbox returns errors related to missing libraries (e.g., ModuleNotFoundError)
  • The code requires packages that may not be installed in the sandbox environment
  • You need PDF generation, data visualization, or other library-heavy operations
  • Previous sandbox execution attempts have failed with import errors

How to Implement

Step 1: Identify the Failure

Check if the sandbox error indicates a library/dependency issue:

  • ModuleNotFoundError: No module named 'xxx'
  • ImportError: cannot import name 'xxx'
  • Similar package-related errors

Step 2: Convert to Shell Execution

Rewrite the code execution using run_shell with a heredoc:

python3 << 'EOF'
# Your Python code here
import library_name
# ... rest of code
EOF

Step 3: Execute via run_shell

Call run_shell with the heredoc Python script:

command: python3 << 'EOF'
import reportlab
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

# Your library-dependent code here
c = canvas.Canvas("output.pdf", pagesize=letter)
c.drawString(100, 750, "Hello World")
c.save()
EOF

Example: PDF Generation Fallback

Sandbox attempt (fails):

# execute_code_sandbox call fails with:
# ModuleNotFoundError: No module named 'reportlab'

Shell fallback (works):

python3 << 'EOF'
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

c = canvas.Canvas("legal_memo.pdf", pagesize=letter)
c.setTitle("Legal Memorandum")
c.drawString(100, 750, "CONFIDENTIAL LEGAL MEMORANDUM")
c.save()
print("PDF created successfully")
EOF

Best Practices

  1. Use quoted heredoc (<< 'EOF') - Prevents variable expansion, keeping Python code intact
  2. Verify output - Check stdout/stderr from run_shell to confirm success
  3. Handle file paths - Ensure output files are written to accessible directories
  4. Test incrementally - For complex scripts, test in smaller chunks first
  5. Include error handling - Add try/except blocks to capture issues gracefully

Read the full file on GitHub · 100 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 100 lines · 17 tokens per session scan A 5c42b4f5b474

Subscribe to this mod's changes

python-shell-fallback is a skill published in the GitHub repository HKUDS/OpenSpace (7,544 stars, last pushed 26d ago), licensed MIT. It adds 17 tokens to every session and 697 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

sk-create-diff

Local, Git-free before/after review of an edited document (text, Markdown, HTML, DOCX, text PDF) as a self-contained HTML report.

MichelKerkmeester/skilled-agent-harness_spec-driven-loops · 37 tokens

latex-rescue

Diagnose and fix LaTeX compilation errors. Handles undefined control sequences, missing brackets, math mode violations, package conflicts, undefined references, and environment mismatches.

Calix-L/awesome-latex-skills · 37 tokens

overleaf-compile

Recompile an Overleaf project and extract its build logs, errors and warnings in a standardized format. Use when asked to compile/recompile an Overleaf paper, debug why a PDF build fails, see what's broken after pushing changes, or pull LaTeX/biber errors and warnings out of an Overleaf project. Drives an…

mrshu/agent-skills · 83 tokens

tikz

Audit and fix TikZ visual collisions in any .tex file. Use when labels overlap arrows, text sits on boxes, or arrows cross each other. Applies mathematical gap calculations and Bézier depth formulas — no eyeballing.

franklee16/academic-research-skills · 47 tokens

latex-compilation-fix

Auto-diagnose and fix common LaTeX compilation errors for the PKU thesis template including missing packages, font issues, citation undefined, overfull hboxes, and float placement. Use when xelatex fails or produces warnings.

newtontech/PKU_PhD_Latex_Templete · 53 tokens

foundry-hosted-agent-validation

Step-by-step process for validating a Python Foundry hosted agent sample (under python/samples/04-hosting/foundry-hosted-agents/) end to end — running it locally (native runtime and azd ai agent run) and after deploying it to an Azure AI Foundry project with azd. Use this when asked to validate a hosted agent sample.

microsoft/agent-framework · 82 tokens