fallback-script-execution
できること
このスキルは、2段階でPythonのスクリプトを実行する繰り返し可能な方法で、より分かりやすいエラーメッセージが得られます。通常のツールでは動かないコードをデバッグする人向けです。
使う場面
- ✓ヘルパーエージェントが、コードを実行する際に不明確なメッセージで繰り返し失敗するとき。
- ✓同じコードで、サンドボックスがタイムアウトまたはエラーを返すとき。
- ✓コードを毎回書き直さずに、スクリプトを修正して再実行したいとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-script-execution/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“ヘルパーが私のスクリプトを実行すると失敗し続けます。スクリプトをファイルとして保存して実行し、完全なエラーを見せてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIは、自己完結したエラー処理付きのスクリプトをファイルに書き、シェルコマンドで実行します。これにより、完全なスタックトレースと出力が見えます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Fallback Script Execution with write_file + run_shell
When to Use This Skill
Use this pattern when:
shell_agentfails repeatedly with unclear error messagesexecute_code_sandboxconsistently errors or times out- You need better visibility into what's happening during execution
- Debugging inline code or delegated agents proves difficult
Core Pattern
Instead of delegating execution to an agent or running inline code, use this two-step approach:
- Write script to file using
write_file - Execute script using
run_shellwithpython script.py
This provides:
- Clearer error messages (full stack traces visible in run_shell output)
- Easier debugging (script persists for inspection)
- Better control over execution environment
- Ability to modify and re-run without rewriting code
Step-by-Step Instructions
Step 1: Write the Script File
Use write_file to create a self-contained Python script:
write_file with:
path: "path/to/script_name.py"
content: |
#!/usr/bin/env python3
# Your complete script here
# Include imports, logic, and error handling
Best Practices:
- Include descriptive comments
- Add try/except blocks for error handling
- Print intermediate results for debugging
- Use absolute or clear relative paths
Step 2: Execute the Script
Use run_shell to execute the script:
run_shell with:
command: "python path/to/script_name.py"
Best Practices:
- Capture and examine full output
- If errors occur, the script file is still available for inspection
- You can re-run with modifications without starting over
Example: Data Processing Task
❌ Problematic Approach (shell_agent fails repeatedly)
shell_agent with:
task: "Load Excel file, calculate correlations, save results"
Result: Agent struggles with path handling, unclear errors
✅ Recommended Approach (write_file + run_shell)
# Step 1: Write script
write_file with:
path: "correlation_analysis.py"
content: |
import pandas as pd
import sys
try:
# Load data
df = pd.read_excel('data.xlsx', sheet_name='Returns')
print(f"Loaded {len(df)} rows")
# Calculate correlation
corr = df.corr()
print(f"Correlation matrix shape: {corr.shape}")
# Save results
with pd.ExcelWriter('output.xlsx') as writer:
df.to_excel(writer, sheet_name='Returns')
corr.to_excel(writer, sheet_name='Correlation')
print("SUCCESS: output.xlsx created")
except Exception as e:
print(f"ERROR: {type(e).__name__}: {e}", file=sys.stderr)
sys.exit(1)
# Step 2: Execute script
run_shell with:
command: "python correlation_analysis.py"
Debugging Tips
- Add print statements at key points to trace execution
- Check file paths - use
run_shellwithls -la path/to verify files exist - Inspect errors - run_shell output shows full Python stack traces
- Modify and re-run - edit the script file and execute again without rewriting
When to Escalate
If this pattern also fails:
- Verify Python is available:
run_shellwithwhich pythonorpython --version - Check file permissions:
run_shellwithls -la script.py - Try explicit Python path:
run_shellwith/usr/bin/python script.py - Consider task complexity - may need to break into smaller scripts
よくある質問
デバッグにファイルが向いているのはなぜですか?
スクリプトがディスクに残るので、確認や変更後の再実行ができるからです。
エラーの出力を分かりやすくするものは?
完全なスタックトレースが、隠されずにシェルの出力に表示されることです。
スクリプトには何を含めるべきですか?
インポート、メインのロジック、tryとexceptのブロック、表示される進行状況のメッセージです。
詳細
作者による元の説明
Two-step script execution workflow for debugging when shell_agent and execute_code_sandbox consistently fail
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #12884
- ライセンス
- MIT
- 更新日
- 2026/11/1
コメント
- …
このリポジトリの他のスキル
agentpilot
7.8kエージェントが、作業を準備し、変更案を提案してテストし、評価するAgentPilotのループを実行することで、プロジェクトを段階的に改善できるよう支援します。
openspace
7.8kエージェントが、スキルを保存し取り出すツールであるOpenSpaceをセットアップし、MCPを通じてAIアプリに接続できるよう支援します。
rsi-arena
7.8kエージェントが、AIMEやTerminal-Benchなどの標準的なAIベンチマークテストをセットアップして実行し、異なる改善方法を比較できるよう支援します。
experiment-guide
7.8kエージェントが、プログラムを改善する方法を調べる間に、小さな実験を計画し、その結果を読み、発見を記録できるよう支援します。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。