reliable-script-execution
यह क्या करती है
यह स्किल AI एजेंट को Python कोड चलाने से पहले उसे फ़ाइल में सहेजने का निर्देश देती है। यह उन लोगों के लिए है जिनके इनलाइन Python रन अज्ञात एरर के साथ बार-बार विफल होते हैं।
कब इस्तेमाल करें
- ✓जब इनलाइन Python कोड अज्ञात एरर के साथ विफल हो, खासकर बहु-पंक्ति स्क्रिप्ट में।
- ✓जब कोड में बहुत सारे कोट्स या विशेष अक्षर हों जो इनलाइन रन को तोड़ें।
- ✓जब आप चलाई गई स्क्रिप्ट का रिकॉर्ड रखना चाहें।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/reliable-script-execution/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरे खर्चों की एक JSON रिपोर्ट बनाने वाली छोटी Python स्क्रिप्ट लिखिए, उसे सहेजिए और चलाइए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट कोड को किसी साफ़ फ़ोल्डर में एक .py फ़ाइल में लिखता है, फिर उसे शेल से तय समय सीमा के साथ चलाता है। काम पूरा होने पर वह अस्थायी फ़ाइल हटा सकता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Reliable Script Execution
When executing Python code via shell commands, avoid inline heredoc execution which can fail unpredictably with 'unknown error'. Use this two-step file-first approach for more reliable script execution.
Problem
Direct heredoc Python execution like:
python3 << 'EOF'
# complex code here
EOF
Can fail with 'unknown error', especially when:
- Script contains multiple lines or complex logic
- Special characters or quotes are present
- Working directory context matters
Solution: File-First Approach
Step 1: Write Python Script to File
Use write_file to save your Python code to a .py file:
write_file(path="./temp_script.py", content="""
import json
data = {"key": "value"}
print(json.dumps(data))
""")
Step 2: Execute via Shell
Use run_shell with explicit working directory:
run_shell(command="python3 ./temp_script.py", timeout=60)
Step 3: Clean Up (Optional)
Remove temporary files after execution:
run_shell(command="rm ./temp_script.py")
Complete Example
Task: Generate a JSON report with calculations
# Step 1: Write the script
write_file(
path="./generate_report.py",
content="""
import json
from datetime import datetime
revenue = 500000.00
expenses = 379577.06
net_income = revenue - expenses
report = {
"generated": datetime.now().isoformat(),
"revenue": revenue,
"expenses": expenses,
"net_income": net_income
}
print(json.dumps(report, indent=2))
"""
)
# Step 2: Execute
run_shell(command="python3 ./generate_report.py", timeout=60)
# Step 3: Clean up
run_shell(command="rm ./generate_report.py")
Best Practices
Use descriptive filenames: Name scripts according to their purpose (e.g.,
calculate_pnl.py,transform_data.py)Set appropriate timeouts: For data processing scripts, use longer timeouts (60-300 seconds)
Specify working directory: If the script depends on relative paths, include
cd /path && python3 script.pyHandle errors gracefully: Check shell output for errors and retry if needed
Clean up temporary files: Don't leave
.pyfiles cluttering the workspace unless they need to persist
When to Use This Pattern
- Executing multi-line Python code via shell
- Scripts with complex string handling or special characters
- When heredoc execution has failed previously
- Any scenario where reliability matters more than brevity
Anti-Pattern to Avoid
Do NOT rely on heredoc for production-critical scripts:
# Unreliable - may fail with 'unknown error'
python3 << 'EOF'
# Your code here
EOF
Use file-first approach instead for consistent, debuggable execution.
अक्सर पूछे जाने वाले सवाल
फ़ाइल इनलाइन कोड से ज़्यादा भरोसेमंद क्यों है?
स्किल कहती है कि इनलाइन heredoc रन अप्रत्याशित ढंग से विफल हो सकते हैं, जबकि सहेजी हुई फ़ाइल साफ़ नतीजा देती है।
क्या बाद में फ़ाइल हटानी चाहिए?
स्किल कहती है कि सफ़ाई वैकल्पिक है, इसलिए रिकॉर्ड के लिए आप फ़ाइल रख सकते हैं।
क्या मैं समय सीमा तय कर सकता हूँ?
हाँ, स्किल के उदाहरण में शेल कमांड को समय सीमा दी जाती है।
जानकारी
लेखक का मूल विवरण
Execute Python scripts reliably using file-first approach instead of heredoc
repo: HKUDS/AgentPilot
लोकप्रियता
- GitHub स्टार
- 7.8k
- रैंकिंग में स्थान
- #12969
- लाइसेंस
- MIT
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
agentpilot
7.8kआपके एजेंट को AgentPilot से प्रोजेक्ट को चरण-दर-चरण सुधारने में मदद करती है, जिसमें बदलाव सुझाए, परखे और स्कोर किए जाते हैं।
openspace
7.8kआपके एजेंट को OpenSpace सेट करने में मदद करती है, जो एजेंट स्किल्स सहेजता और वापस लाता है, और MCP के ज़रिए आपके AI ऐप से जुड़ता है।
rsi-arena
7.8kआपके एजेंट को AIME और Terminal-Bench जैसे मानक AI बेंचमार्क टेस्ट सेट करने और चलाने में मदद करती है, ताकि सुधार के तरीकों की तुलना हो सके।
experiment-guide
7.8kआपके एजेंट को छोटे प्रयोग बनाने, उनके नतीजे पढ़ने और जाँच के दौरान उपयोगी निष्कर्ष लिखने में मदद करती है।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।