shell-python-heredoc

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

A method for running multi-line Python code through a shell heredoc after a code-sandbox tool fails.

In plain words
What is it for?
Use it for tasks such as PDF generation, data processing, or file parsing that need a short multi-line Python program.
Why use it?
It offers a reliable fallback for scripts with imports and gives clearer access to their standard output and errors.

Skill for Claude CodeCodex

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

Good fit Use it for tasks such as PDF generation, data processing, or file parsing that need a short multi-line Python program.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hkuds/openspace/shell-python-heredoc
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,534 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 shell-python-heredoc
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 shell-python-heredoc

README.md
[![agentmods](https://agentmods.dev/badge/skills/hkuds/openspace/shell-python-heredoc.svg)](https://agentmods.dev/skills/hkuds/openspace/shell-python-heredoc)
Your own site
<a href="https://agentmods.dev/skills/hkuds/openspace/shell-python-heredoc"><img src="https://agentmods.dev/badge/skills/hkuds/openspace/shell-python-heredoc.svg" alt="Measured on agentmods" height="20"></a>
Per session 21 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 693 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.00021 $0.00693
Opus 5 $0.00010 $0.00347
Sonnet 5 $0.00004 $0.00139
Haiku 4.5 $0.00002 $0.00069

Measured 4d ago against content hash 2027979d571a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

shell-python-heredoc 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 4d 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/shell-python-heredoc/SKILL.md · 106 lines

How it starts

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

Shell Python Heredoc (Fallback Pattern)

Overview

When 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.

When to Use

  • execute_code_sandbox has failed 2+ times with unexplained errors
  • You need to run Python code with multiple imports (e.g., ReportLab, pandas)
  • The script is too complex for a one-liner but doesn't require persistence between calls
  • You need better error visibility from raw stdout/stderr

How to Use

Basic Pattern

run_shell(
    command="""python3 << 'EOF'
import sys
# Your Python code here
print("Hello from heredoc")
EOF""",
    timeout=300
)

Key Syntax Rules

  1. Use << 'EOF' (with single quotes) to prevent shell variable expansion
  2. Indent Python code relative to the heredoc delimiter
  3. End with EOF on its own line (no leading whitespace)
  4. Capture output from stdout/stderr for debugging

Example: Generating a PDF with ReportLab

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
)

Example: Multi-file Data Processing

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
)

Advantages Over execute_code_sandbox

  • More reliable for complex imports (no sandbox isolation issues)
  • Full stdout/stderr access for debugging
  • Longer timeout flexibility (60s default vs 30s)
  • Direct filesystem access without ARTIFACT_PATH indirection

Read the full file on GitHub · 106 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. 4d ago First seen · 106 lines · 21 tokens per session scan A 2027979d571a

Subscribe to this mod's changes

shell-python-heredoc is a skill published in the GitHub repository HKUDS/OpenSpace (7,534 stars, last pushed 26d ago), licensed MIT. It adds 21 tokens to every session and 693 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

nutrient-python-sdk

Nutrient Python SDK — the nutrient-sdk PyPI package for in-process server-side PDF and document processing in Python. Brand-new (launched Q1 2026); the older third-party pspdfkit PyPI package is unrelated to Nutrient and unmaintained. No external server, no DWS dependency — runs natively inside the Python process.…

PSPDFKit-labs/nutrient-skills · 108 tokens

reportlab

PDF generation toolkit. Create invoices, reports, certificates, forms, charts, tables, barcodes, QR codes, Canvas/Platypus APIs, for professional document automation.

Microck/ordinary-claude-skills · 38 tokens

xberg

Extract text, tables, metadata, and images from 107 document formats (PDF, Office, images, HTML, email, archives, academic) using Xberg. Use when writing code that calls Xberg APIs in Python, Node.js/TypeScript, Rust, or CLI. Covers installation, extraction (sync/async), configuration (OCR, chunking, output format)…

xberg-io/xberg · 87 tokens

azure-ai-formrecognizer-java

Build document analysis applications with Azure Document Intelligence (Form Recognizer) SDK for Java. Use when extracting text, tables, key-value pairs from documents, receipts, invoices, or buildi...

benjaminasterA/antigravity-awesome-skills · 45 tokens

azure-ai-document-intelligence-ts

Extract text, tables, and structured data from documents using Azure Document Intelligence (@azure-rest/ai-document-intelligence). Use when processing invoices, receipts, IDs, forms, or building cu...

benjaminasterA/antigravity-awesome-skills · 45 tokens

neo4j-knowledge-graph

Use when designing, importing, querying, or modernizing Neo4j knowledge graphs from CSV, Excel, pandas, Cypher, py2neo, the official neo4j Python driver, vector indexes, or GraphRAG workflows.

MazzaWill/neo4j-python-pandas-py2neo-v3 · 55 tokens