본문으로 건너뛰기
Skillpedia
일반 코딩7.8k · #13001

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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/shell-python-fallback/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

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

  1. Identify the failure: When execute_code_sandbox or shell_agent returns "unknown error" repeatedly (2+ attempts), switch to this fallback.

  2. Write your Python script: Prepare the complete Python code you need to execute.

  3. Embed in run_shell: Use run_shell with a heredoc syntax:

Command: python3 << 'EOF'
import json
# Your complete script here
data = {"key": "value"}
print(json.dumps(data))
EOF
  1. Handle multi-line scripts: For longer scripts, ensure proper indentation is preserved. The heredoc preserves whitespace exactly.

  2. Check output: Parse the stdout from run_shell to 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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬