用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/HKUDS/OpenSpace --skill fallback-python-shell命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | fallback-python-shell |
| description | Use run_shell with Python heredoc when execute_code_sandbox or read_file fail |
Use this fallback pattern when:
execute_code_sandbox returns 'unknown error'read_file returns 'unknown error' for supported formatsRun Python code through run_shell using a heredoc. This bypasses sandbox execution issues while maintaining Python's full capabilities for file I/O and data processing.
python3 << 'EOF'
# Your Python code here
import json
import os
# Example: Read and process a file
with open('/path/to/file.txt', 'r') as f:
content = f.read()
print(content)
EOF
python3 << 'EOF' (quoted EOF prevents variable expansion in the heredoc)EOF on its own line with no leading/trailing whitespacepython3 << 'EOF'
import json
# Read text file
with open('document.txt', 'r') as f:
content = f.read()
print(content)
# Read JSON file
with open('data.json', 'r') as f:
data = json.load(f)
print(json.dumps(data, indent=2))
EOF
python3 << 'EOF'
import pandas as pd
# Read Excel file
df = pd.read_excel('data.xlsx', sheet_name='Sheet1')
print(df.to_string())
print(f"Shape: {df.shape}")
# Read CSV
df = pd.read_csv('data.csv')
print(df.head(10))
EOF
python3 << 'EOF'
import fitz # PyMuPDF
doc = fitz.open('document.pdf')
for page_num in range(len(doc)):
page = doc[page_num]
text = page.get_text()
print(f"=== Page {page_num + 1} ===")
print(text)
doc.close()
EOF
python3 << 'EOF'
from docx import Document
doc = Document('document.docx')
for para in doc.paragraphs:
print(para.text)
EOF
python3 << 'EOF'
import pandas as pd
import numpy as np
df = pd.read_csv('data.csv')
# Basic statistics
print(f"Shape: {df.shape}")
print(f"Columns: {list(df.columns)}")
print(df.describe())
# Filter and aggregate
result = df.groupby('category').agg({'value': 'sum'})
print(result)
EOF
Error Handling: Wrap file operations in try/except blocks
python3 << 'EOF'
try:
with open('file.txt', 'r') as f:
content = f.read()
print(content)
except FileNotFoundError:
print("ERROR: File not found")
except Exception as e:
print(f"ERROR: {e}")
EOF
Large Output: For large files, process in chunks or print summaries
python3 << 'EOF'
with open('large_file.csv', 'r') as f:
for i, line in enumerate(f):
if i < 10:
print(line.strip())
else:
print("... truncated ...")
break
EOF
Working Directory: Remember run_shell executes in the current working directory. Use absolute paths or ensure you're in the right directory.
Multiple Steps: Chain related operations in a single heredoc rather than multiple calls
python3 << 'EOF'
# Do all related work in one call
with open('input.json') as f:
data = json.load(f)
processed = [transform(x) for x in data]
with open('output.json', 'w') as f:
json.dump(processed, f)
print("Processing complete")
EOF
open('file.txt', 'r', encoding='utf-8')