shell-python-fallback
하는 일
이 스킬은 AI 에이전트의 코드 도구가 알 수 없는 오류를 낼 때 Python 작업의 대체 방법을 제공합니다. 데이터 처리나 PDF 생성을 안정적으로 끝내야 하는 사람을 위한 스킬입니다.
사용하는 경우
- ✓같은 작업에서 코드 도구가 알 수 없는 오류를 두 번 이상 낼 때.
- ✓데이터 처리, 파일 분석 또는 PDF 생성을 Python으로 해야 할 때.
- ✓스크립트를 실행해 확인할 수 있는 분명한 출력이 필요할 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/shell-python-fallback/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 코드 도구가 이 데이터 정리 작업에서 계속 알 수 없는 오류를 냅니다. Python을 셸로 실행하고 출력을 보여 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 heredoc을 사용해 셸 명령 안에 Python 스크립트를 넣습니다. 스크립트를 실행하고 출력을 읽어 성공이나 오류를 확인하며, 필요하면 코드를 고칩니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Shell Python Fallback
When to Use
Use this pattern when execute_code_sandbox or shell_agent tools consistently fail with "unknown error" for tasks such as:
- Data processing and transformation
- PDF generation (reportlab, etc.)
- File parsing and manipulation
- Any Python script execution that requires reliability
The Pattern
Instead of using code execution tools, embed your Python script directly in a run_shell command using a heredoc:
python3 << 'EOF'
# Your Python code here
import sys
print("Hello from embedded Python")
EOF
Step-by-Step Instructions
Identify the failure: When
execute_code_sandboxorshell_agentreturns "unknown error" repeatedly (2+ attempts), switch to this fallback.Write your Python script: Prepare the complete Python code you need to execute.
Embed in run_shell: Use
run_shellwith a heredoc syntax:
Command: python3 << 'EOF'
import json
# Your complete script here
data = {"key": "value"}
print(json.dumps(data))
EOF
Handle multi-line scripts: For longer scripts, ensure proper indentation is preserved. The heredoc preserves whitespace exactly.
Check output: Parse the stdout from
run_shellto verify success or capture errors.
Example: PDF Generation
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 World")
c.save()
print("PDF created successfully")
EOF
Example: Data Processing
python3 << 'EOF'
import csv
import json
data = []
with open('input.csv', 'r') as f:
reader = csv.DictReader(f)
for row in reader:
data.append(row)
with open('output.json', 'w') as f:
json.dump(data, f, indent=2)
print(f"Processed {len(data)} records")
EOF
Best Practices
- Quote the EOF delimiter (
<< 'EOF'not<< EOF) to prevent shell variable expansion in your Python code - Include error handling in your Python script with try/except blocks
- Print status messages to stdout so you can verify execution succeeded
- Use absolute paths or ensure working directory is correct
- Test incrementally: Start with a minimal script, then expand
Troubleshooting
| Issue | Solution |
|---|---|
| Script doesn't run | Ensure python3 is available in the shell environment |
| Indentation errors | Check that heredoc preserves spaces (use spaces, not tabs) |
| Module not found | Use python3 -m pip install <module> before running script |
| File not found | Use absolute paths or pwd to verify working directory |
Why This Works
The run_shell tool executes commands directly in the system shell, bypassing the sandbox restrictions or internal errors that affect execute_code_sandbox and shell_agent. The heredoc approach allows multi-line Python scripts while keeping everything in a single shell command.
자주 묻는 질문
몇 번 실패해야 전환하나요?
스킬은 알 수 없는 오류가 두 번 이상 나면 전환하라고 안내합니다.
heredoc은 들여쓰기를 유지하나요?
네, 스킬은 heredoc이 공백을 정확히 유지하므로 여러 줄 코드가 그대로 남는다고 설명합니다.
PDF도 만들 수 있나요?
네, 스킬은 reportlab을 사용하는 PDF 예시를 제공합니다.
상세 정보
작성자의 원본 설명
Use run_shell with embedded Python heredoc as reliable fallback when code execution tools fail
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #13001
- 라이선스
- 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프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.