safe-script-execution
Fungsinya
Skill ini memberi agent AI cara manual untuk membuat dan menjalankan skrip saat alat otomatisnya tidak menghasilkan output yang diharapkan. Skill ini ditujukan untuk orang yang ingin kontrol yang jelas atas setiap langkah.
Kapan dipakai
- βSaat sandbox kode atau agent shell berulang kali gagal menghasilkan output yang Anda harapkan.
- βSaat Anda ingin agent memastikan folder kerjanya sebelum membuat file apa pun.
- βSaat skrip berisi tanda kutip atau karakter khusus yang merusak perintah yang lebih sederhana.
Link skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/safe-script-execution/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βSkrip saya terus gagal di sandbox. Simpan sebagai file dengan path lengkap, jalankan, dan beri tahu saya apakah outputnya sudah benar.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent memeriksa folder saat ini, menulis skrip ke file memakai heredoc dengan penanda akhir yang unik, membuatnya dapat dieksekusi, lalu menjalankannya memakai path lengkap. Setelah itu agent memeriksa output sebelum melapor.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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)
Pertanyaan umum
Mengapa memakai path lengkap untuk menjalankan skrip?
Path lengkap menghindari kesalahan akibat path relatif atau folder kerja yang salah.
Mengapa heredoc memakai penanda akhir yang dikutip?
Tanda kutip mencegah shell mengubah tanda dolar atau simbol lain di dalam skrip.
Bagaimana jika skrip berisi teks penanda akhir?
Skill ini meminta Anda memilih penanda lain yang unik agar file tidak terpotong.
Detail
Deskripsi asli dari pembuat
Fallback workflow for code execution when automated tools fail, using shell heredoc with verification
repo: HKUDS/AgentPilot
Popularitas
- Bintang GitHub
- 7.8k
- Peringkat
- #12981
- Lisensi
- MIT
- Diperbarui
- 1/11/2026
Komentar
- β¦
Skill lain dari repositori ini
agentpilot
7.8kMembantu agent Anda meningkatkan proyek langkah demi langkah dengan menyiapkan tugas dan menjalankan loop AgentPilot yang mengusulkan, menguji, dan memberi skor pada perubahan.
openspace
7.8kMembantu agent Anda menyiapkan OpenSpace, alat yang menyimpan dan mengambil skill agent, lalu menghubungkannya ke aplikasi AI Anda melalui MCP.
rsi-arena
7.8kMembantu agent Anda menyiapkan dan menjalankan tes benchmark AI standar, seperti AIME dan Terminal-Bench, untuk membandingkan berbagai metode perbaikan.
experiment-guide
7.8kMembantu agent Anda merencanakan eksperimen kecil, membaca hasilnya, dan mencatat temuan saat menyelidiki cara memperbaiki sebuah program.
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.