python-heredoc-fallback
하는 일
이 스킬은 샌드박스가 작동하지 않을 때 셸에서 heredoc으로 Python을 실행하는 방법을 보여 줍니다. Python으로 만든 차트, Word 문서, 스프레드시트 같은 파일이 필요한 사람에게 맞습니다.
사용하는 경우
- ✓코드 샌드박스가 설정이나 연결 오류로 실패할 때.
- ✓Python으로 만든 차트 이미지, Word 문서 또는 스프레드시트가 필요할 때.
- ✓파일 생성 작업이 샌드박스에서 계속 실패하는 경우.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/python-heredoc-fallback/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“input.xlsx로 막대 차트를 만들어 PNG로 저장해 주세요. 샌드박스가 계속 실패합니다.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 먼저 필요한 패키지를 설치한 뒤, heredoc으로 셸에서 Python 코드를 실행합니다. 코드가 파일을 만들고 끝나면 메시지를 출력합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Python Heredoc Fallback for Code Execution
When to Use
Use this pattern when execute_code_sandbox fails with e2b initialization errors, sandbox connection issues, or other execution environment problems. This is especially reliable for file generation tasks.
Core Pattern
Instead of execute_code_sandbox, run Python code directly in the shell using a heredoc:
python3 << 'EOF'
# Your Python code here
import sys
print("Python code executing in shell")
EOF
Key Syntax Rules
- Use single-quoted EOF (
<< 'EOF') to prevent shell variable expansion within the Python code - No indentation before EOF - the closing delimiter must be at the start of the line
- Install packages first if needed, before the Python heredoc block
Common Use Cases
1. Matplotlib Graph Generation
python3 << 'EOF'
import matplotlib.pyplot as plt
import pandas as pd
# Load data
data = pd.read_excel('input.xlsx')
# Create visualization
plt.figure(figsize=(10, 6))
plt.plot(data['x'], data['y'])
plt.xlabel('X Label')
plt.ylabel('Y Label')
plt.title('Graph Title')
plt.savefig('output_graph.png', dpi=300, bbox_inches='tight')
plt.close()
print("Graph saved successfully")
EOF
2. Python-docx Document Creation
pip install python-docx -q
python3 << 'EOF'
from docx import Document
from docx.shared import Inches, Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
doc = Document()
# Add title
title = doc.add_heading('Document Title', 0)
title.alignment = WD_ALIGN_PARAGRAPH.CENTER
# Add sections
doc.add_heading('Section 1', level=1)
doc.add_paragraph('Content for section 1.')
# Add table
table = doc.add_table(rows=3, cols=3)
table.style = 'Table Grid'
# Save document
doc.save('output.docx')
print("Document created successfully")
EOF
3. General File Operations
python3 << 'EOF'
import json
import os
# Read input file
with open('input.json', 'r') as f:
data = json.load(f)
# Process data
result = {'processed': True, 'items': len(data)}
# Write output
with open('output.json', 'w') as f:
json.dump(result, f, indent=2)
print(f"Processed {result['items']} items")
EOF
Best Practices
- Install dependencies first: Run
pip install package-name -qbefore the Python block if packages aren't guaranteed to be available - Verify file paths: Files are read from and written to the current working directory
- Add print statements: Include progress/output messages to verify execution succeeded
- Close resources: Explicitly close matplotlib figures and file handles
- Handle errors gracefully: Add try/except blocks for production code
Troubleshooting
| Issue | Solution |
|---|---|
| Module not found | Add pip install <module> -q before Python block |
| File not found | Verify file exists in current directory with ls |
| Permission denied | Check file permissions and directory write access |
| Syntax errors | Ensure proper Python indentation within heredoc |
Advantages Over execute_code_sandbox
- No initialization overhead - runs immediately in existing shell
- Persistent environment - maintains state across multiple commands
- Direct file system access - no sandbox isolation issues
- Full system Python - access to all installed packages
- Reliable for large files - no sandbox size restrictions
자주 묻는 질문
어떤 종류의 파일을 만들 수 있나요?
스킬은 Python 라이브러리로 만든 차트, Word 문서, 스프레드시트 예시를 보여 줍니다.
에이전트가 패키지를 설치하나요?
네, 스킬은 Python 블록을 실행하기 전에 필요한 패키지를 설치하라고 말합니다.
EOF 끝 줄은 왜 왼쪽 끝에 있어야 하나요?
셸은 줄의 맨 앞에 있는 경우에만 끝 표시를 인식하기 때문입니다.
상세 정보
인기도
- GitHub 스타
- 7.8k
- 순위
- #12960
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
agentpilot
7.8k작업을 준비하고 AgentPilot 루프를 실행해 변경을 제안, 테스트, 점수화하면서 프로젝트를 단계적으로 개선하도록 돕습니다.
openspace
7.8k에이전트 스킬을 저장하고 가져오는 도구인 OpenSpace를 설정하고, MCP를 통해 AI 앱에 연결하도록 돕습니다.
rsi-arena
7.8kAIME나 Terminal-Bench 같은 표준 AI 벤치마크 테스트를 설정하고 실행해 서로 다른 개선 방법을 비교하도록 돕습니다.
experiment-guide
7.8k프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.