safe-script-execution
하는 일
이 스킬은 자동 도구가 기대한 결과를 내지 못할 때 AI 에이전트가 스크립트를 직접 만들고 실행하는 방법을 보여 줍니다. 단계마다 확실히 통제하고 싶은 사람을 위한 스킬입니다.
사용하는 경우
- ✓코드 샌드박스나 셸 에이전트가 기대한 결과를 반복해서 내지 못할 때.
- ✓파일을 만들기 전에 에이전트가 작업 폴더를 먼저 확인하기를 원할 때.
- ✓스크립트에 따옴표나 특수 문자가 있어서 간단한 명령이 깨질 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/safe-script-execution/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“샌드박스에서 스크립트가 계속 실패합니다. 전체 경로를 사용해 파일로 저장하고 실행한 뒤, 결과가 맞아 보이는지 알려 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 먼저 현재 폴더를 확인합니다. 그다음 고유한 종료 표시를 사용하는 heredoc으로 스크립트를 파일에 쓰고, 실행 권한을 준 뒤 전체 경로로 실행합니다. 결과를 확인한 다음 보고합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Safe Script Execution Fallback
When to Use This Skill
Use this pattern when execute_code_sandbox or shell_agent repeatedly fails to produce expected outputs. This manual fallback provides explicit control over script creation and execution with built-in verification.
Step-by-Step Instructions
Step 1: Verify Working Directory
Before creating any scripts, confirm your current location and permissions:
pwd
ls -la
Document the absolute path. All subsequent file operations should use explicit paths from this point.
Step 2: Create Script via Heredoc
Use shell heredoc syntax to create scripts. This avoids issues with multi-line string escaping:
cat > /full/path/to/script.py << 'HEREDOC_END'
#!/usr/bin/env python3
# Your script content here
# Single quotes around delimiter prevent variable expansion
print("Hello from script")
HEREDOC_END
Key escaping rules:
- Use single quotes around heredoc delimiter (
'EOF') to prevent shell variable expansion - If script contains the delimiter string, choose a different unique delimiter
- For bash scripts containing special characters, escape
$, backticks, and!
Step 3: Make Executable and Run with Explicit Path
chmod +x /full/path/to/script.py
/full/path/to/script.py
Always use the full absolute path, never rely on . or relative paths.
Step 4: Verify Output
Confirm files were created and inspect their properties:
# Check file exists with size
ls -lh /full/path/to/output.file
# For PDFs, inspect metadata
pdfinfo /full/path/to/output.pdf 2>/dev/null || file /full/path/to/output.pdf
# For Word docs, check file type
file /full/path/to/output.docx
Step 5: Error Handling
If execution fails:
- Check script syntax:
python3 -m py_compile /path/to/script.py - Check permissions:
ls -l /path/to/script.py - Check available disk space:
df -h . - Review stderr output carefully
Example: PDF Generation Fallback
# Step 1: Verify directory
pwd
ls -la
# Step 2: Create Python script
cat > /workspace/generate_pdf.py << 'SCRIPT_END'
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas("/workspace/output.pdf", pagesize=letter)
c.drawString(100, 750, "Generated PDF")
c.save()
SCRIPT_END
# Step 3: Execute
chmod +x /workspace/generate_pdf.py
python3 /workspace/generate_pdf.py
# Step 4: Verify
ls -lh /workspace/output.pdf
pdfinfo /workspace/output.pdf 2>/dev/null || echo "PDF created, pdfinfo unavailable"
Anti-Patterns to Avoid
- ❌ Don't use relative paths like
./script.py- always use absolute paths - ❌ Don't rely on unquoted heredoc delimiters if script contains variables
- ❌ Don't skip verification steps - always confirm output exists and has expected size
- ❌ Don't assume working directory - always
pwdfirst
Troubleshooting Checklist
- Working directory confirmed with
pwd - Script file exists after heredoc creation (
ls -l) - Script has execute permissions (
chmod +x) - Output file exists with non-zero size (
ls -lh) - File type verified (
filecommand or type-specific inspection)
자주 묻는 질문
에이전트는 왜 스크립트를 전체 경로로 실행하나요?
전체 경로를 쓰면 상대 경로나 잘못된 작업 폴더 때문에 생기는 실수를 막을 수 있습니다.
heredoc의 종료 표시는 왜 따옴표로 감싸나요?
따옴표를 쓰면 셸이 스크립트 안의 달러 기호나 다른 기호를 바꾸지 않습니다.
스크립트 안에 종료 표시와 같은 글자가 있으면 어떻게 하나요?
스킬은 파일이 중간에 잘리지 않도록 다른 고유한 종료 표시를 고르라고 안내합니다.
상세 정보
작성자의 원본 설명
Fallback workflow for code execution when automated tools fail, using shell heredoc with verification
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12981
- 라이선스
- 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프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.