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가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
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_sandboxfails with "unknown error" or timeoutread_filefails 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
Escape quotes properly in
-ccommands: Use\"for double quotes inside the command stringUse heredoc for complex scripts: When code exceeds 2-3 lines or needs multiple imports, use
<< 'EOF'syntaxQuote EOF marker: Use
<< 'EOF'(with quotes) to prevent variable expansion in the heredocCapture stdout: Design your inline Python to print results to stdout for easy capture
Error handling: Add try/except blocks in your inline Python to catch and report errors clearly
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.
댓글
- …
이 저장소의 다른 스킬
agentpilot
7.8k작업을 준비하고 AgentPilot 루프를 실행해 변경을 제안, 테스트, 점수화하면서 프로젝트를 단계적으로 개선하도록 돕습니다.
openspace
7.8k에이전트 스킬을 저장하고 가져오는 도구인 OpenSpace를 설정하고, MCP를 통해 AI 앱에 연결하도록 돕습니다.
rsi-arena
7.8kAIME나 Terminal-Bench 같은 표준 AI 벤치마크 테스트를 설정하고 실행해 서로 다른 개선 방법을 비교하도록 돕습니다.
experiment-guide
7.8k프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.