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

run-shell-fallback

하는 일

이 스킬은 파일 리더나 코드 샌드박스가 고장 날 때 AI 에이전트의 믿을 수 있는 예비 방법입니다. 간단한 작업에서도 AI 도구가 알 수 없는 오류를 계속 내는 사람에게 맞습니다.

사용하는 경우

  • ✓코드 샌드박스가 알 수 없는 오류나 시간 초과로 실패할 때.
  • ✓파일 리더가 실제로 있는 것이 확인된 파일을 열지 못할 때.
  • ✓작업을 이어 가려고 간단한 파일 읽기나 짧은 Python 계산이 필요한 경우.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/run-shell-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/run-shell-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에게 요청하는 예시

“파일 리더가 제 notes.txt 파일에서 계속 실패합니다. 셸로 읽고 내용을 알려 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 cat으로 텍스트 파일을 읽고, 구조화된 분석이나 짧은 계산에는 셸에서 인라인 Python을 씁니다. 명령을 실행하고 출력된 결과를 읽습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Run Shell Fallback Pattern

This skill provides a reliable workaround when execute_code_sandbox or read_file fail with 'unknown error' by switching to run_shell with inline Python code.

When to Use

Apply this pattern when you encounter:

  • execute_code_sandbox fails with "unknown error" or timeout
  • read_file fails to read accessible files with "unknown error"
  • Sandbox environment is unreliable for your specific task

How to Implement

1. File Reading Fallback

When read_file fails, use run_shell with Python or cat:

For text files:

run_shell(command="cat /path/to/file.txt")

For structured parsing (Python one-liner):

run_shell(command="python3 -c \"import json; print(json.load(open('/path/to/file.json')))\"")

For multi-line Python processing:

run_shell(command="python3 << 'EOF'
with open('/path/to/file.txt', 'r') as f:
    content = f.read()
    # Process content here
    print(content.upper())
EOF")

2. Code Execution Fallback

When execute_code_sandbox fails, use run_shell with inline Python:

Simple one-liners:

run_shell(command="python3 -c \"print('Hello'); import os; print(os.getcwd())\"")

Multi-line scripts (heredoc):

run_shell(command="python3 << 'EOF'
import os
import json

def process_data(data):
    return {k: v.upper() if isinstance(v, str) else v for k, v in data.items()}

with open('input.json') as f:
    data = json.load(f)
    
result = process_data(data)
print(json.dumps(result, indent=2))
EOF")

With inline file write:

run_shell(command="python3 << 'EOF'
result = {'status': 'success', 'count': 42}
with open('output.json', 'w') as f:
    json.dump(result, f, indent=2)
print('File written successfully')
EOF")

3. Decision Flow

1. Attempt execute_code_sandbox or read_file
2. If failure with 'unknown error':
   a. Determine task type (code execution vs file reading)
   b. Choose inline Python approach (-c for simple, heredoc for complex)
   c. Execute via run_shell
   d. Parse output as needed
3. Continue with task using results from run_shell

Best Practices

  1. Escape quotes properly in -c commands: Use \" for double quotes inside the command string

  2. Use heredoc for complex scripts: When code exceeds 2-3 lines or needs multiple imports, use << 'EOF' syntax

  3. Quote EOF marker: Use << 'EOF' (with quotes) to prevent variable expansion in the heredoc

  4. Capture stdout: Design your inline Python to print results to stdout for easy capture

  5. Error handling: Add try/except blocks in your inline Python to catch and report errors clearly

  6. File paths: Use absolute paths when possible, or ensure working directory is correct

Examples

Example 1: Read and parse JSON after read_file failure

run_shell(command="python3 -c \"import json; data=json.load(open('config.json')); print(data['key'])\"")

Example 2: Process CSV data after execute_code_sandbox failure

run_shell(command="python3 << 'EOF'
import csv
with open('data.csv', 'r') as f:
    reader = csv.DictReader(f)
    rows = list(reader)
    print(f\"Total rows: {len(rows)}\")
    for row in rows[:5]:
        print(row)
EOF")

Example 3: Transform and write output file

run_shell(command="python3 << 'EOF'
import json
with open('input.json') as f:
    data = json.load(f)
transformed = [item.upper() if isinstance(item, str) else item for item in data]
with open('output.json', 'w') as f:
    json.dump(transformed, f, indent=2)
print('Transformation complete')
EOF")

Limitations

  • run_shell executes in the shell environment, not the sandbox - ensure paths and dependencies are available
  • Output is limited to stdout/stderr - use file writes for large data
  • Complex multi-file projects may require creating temporary script files first
자주 묻는 질문

텍스트 파일을 읽는 명령은 무엇인가요?

cat을 써서 셸에 파일 내용을 출력합니다.

JSON 파일을 분석할 수 있나요?

네, 스킬은 JSON 파일을 불러와 출력하는 한 줄 Python 명령을 보여 줍니다.

긴 스크립트에도 인라인 Python을 써도 되나요?

네, 스킬은 여러 줄 스크립트에 heredoc을 써서 긴 코드도 읽기 쉽게 유지한다고 설명합니다.

상세 정보

작성자의 원본 설명

Use run_shell with inline Python as a reliable fallback when execute_code_sandbox or read_file fail

repo: HKUDS/AgentPilot

인기도

GitHub 스타
7.8k
순위
#12979
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬