python-debug-execution
하는 일
이 스킬은 AI로 Python 코드를 실행하고 디버깅할 때 명확한 오류 출력을 얻는 간단한 방법을 설명합니다. AI를 통해 Python 스크립트를 실행하는 사람에게 맞습니다.
사용하는 경우
- ✓Python 스크립트가 멈췄는데 이유를 알 수 없을 때.
- ✓스크립트의 파일 작업이 실패하고 폴더가 잘못되었을 수 있을 때.
- ✓파일이 제대로 있는지 확인하려고 폴더 내용을 나열하고 싶은 경우.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/python-debug-execution/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 스크립트가 파일 경로에서 계속 실패합니다. 디버깅을 도와주고 스크립트가 어느 폴더에서 실행되는지 보여 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 오류 출력을 잡아 스크립트를 실행하고 종료 코드를 출력합니다. 스크립트가 읽거나 쓰기 전에 작업 폴더와 그 안의 파일을 출력하는 확인 항목을 추가합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Python Debug Execution Pattern
When executing Python scripts that may fail, use this pattern to surface clear error information and diagnose issues effectively.
Core Technique
1. Execute with Full Error Output
Always run Python scripts with stderr redirected to stdout and echo the exit code:
python3 script.py 2>&1 ; echo Exit code: $?
Why this works:
2>&1captures both stdout and stderr, ensuring tracebacks are visibleecho Exit code: $?reveals the actual exit status for debugging- Avoids opaque "command failed" errors that hide the real cause
2. Verify Working Directory in Script
Before any file operations in Python scripts, add working directory verification:
import os
# At the start of your script or before file operations
print(f"Current working directory: {os.getcwd()}")
# For debugging, also list directory contents
print(f"Directory contents: {os.listdir('.')}")
Why this works:
- File not found errors often stem from incorrect working directory assumptions
- Makes path-related failures immediately diagnosable
- Confirms the execution context matches expectations
Complete Debugging Workflow
Step 1: Add Diagnostic Code to Script
#!/usr/bin/env python3
import os
import sys
def main():
# Diagnostic: verify execution context
print(f"Working directory: {os.getcwd()}")
print(f"Python version: {sys.version}")
print(f"Directory listing: {os.listdir('.')}")
# Your actual logic here
# ...
if __name__ == "__main__":
main()
Step 2: Execute with Full Error Capture
python3 script.py 2>&1 ; echo Exit code: $?
Step 3: Analyze Output
Look for:
- Traceback messages (indicate code errors)
- Exit code (0 = success, non-zero = failure)
- Working directory confirmation
- Missing file/directory errors
Common Failure Patterns
| Symptom | Likely Cause | Debug Clue |
|---|---|---|
| FileNotFoundError | Wrong working directory | Check os.getcwd() output |
| ModuleNotFoundError | Missing dependencies | Traceback shows import path |
| PermissionError | File access issues | Traceback shows file path |
| Silent failure (exit 0, no output) | Logic bug, not crash | Add print statements |
When to Use This Pattern
- Running Python scripts in automated/agent contexts
- Debugging scripts that interact with files
- Troubleshooting CI/CD pipeline failures
- Any scenario where script output may be truncated or hidden
자주 묻는 질문
폴더 내용을 나열하는 이유는 무엇인가요?
어떤 파일이 있는지 보면 파일을 찾지 못하는 이유가 드러나는 경우가 많기 때문입니다.
특정 종류의 스크립트에만 쓰이나요?
아닙니다. 파일을 읽거나 쓰는 모든 Python 스크립트에 이 단계를 적용할 수 있습니다.
Python을 알아야 하나요?
아닙니다. 에이전트가 명령을 처리하고 각 출력이 무엇을 뜻하는지 설명합니다.
상세 정보
작성자의 원본 설명
Debug Python scripts with proper error surfacing and working directory verification
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12956
- 라이선스
- 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프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.