run-shell-fallback
यह क्या करती है
यह स्किल AI एजेंट के लिए भरोसेमंद बैकअप है, जब उसका फ़ाइल रीडर या कोड सैंडबॉक्स टूट जाए। यह उन लोगों के लिए है जिनके AI टूल सरल कामों पर भी अज्ञात एरर लौटाते हैं।
कब इस्तेमाल करें
- ✓जब कोड सैंडबॉक्स अज्ञात एरर या टाइम आउट दे।
- ✓जब फ़ाइल रीडर ऐसी फ़ाइल न खोल पाए जो आपको दिख रही है।
- ✓जब कोई सरल फ़ाइल पढ़ना या छोटा Python हिसाब चाहिए ताकि काम आगे बढ़े।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/run-shell-fallback/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरी notes.txt फ़ाइल पर फ़ाइल रीडर बार-बार विफल हो रहा है। शेल से इसे पढ़िए और बताइए कि इसमें क्या लिखा है।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट टेक्स्ट फ़ाइलें पढ़ने के लिए cat इस्तेमाल करता है, और संरचित पार्सिंग या छोटे हिसाब के लिए शेल के ज़रिए इनलाइन Python। वह कमांड चलाता है और छपे हुए आउटपुट को पढ़ता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Run Shell Fallback Pattern
This skill provides a reliable workaround when execute_code_sandbox or read_file fail with 'unknown error' by switching to run_shell with inline Python code.
When to Use
Apply this pattern when you encounter:
execute_code_sandboxfails with "unknown error" or timeoutread_filefails to read accessible files with "unknown error"- Sandbox environment is unreliable for your specific task
How to Implement
1. File Reading Fallback
When read_file fails, use run_shell with Python or cat:
For text files:
run_shell(command="cat /path/to/file.txt")
For structured parsing (Python one-liner):
run_shell(command="python3 -c \"import json; print(json.load(open('/path/to/file.json')))\"")
For multi-line Python processing:
run_shell(command="python3 << 'EOF'
with open('/path/to/file.txt', 'r') as f:
content = f.read()
# Process content here
print(content.upper())
EOF")
2. Code Execution Fallback
When execute_code_sandbox fails, use run_shell with inline Python:
Simple one-liners:
run_shell(command="python3 -c \"print('Hello'); import os; print(os.getcwd())\"")
Multi-line scripts (heredoc):
run_shell(command="python3 << 'EOF'
import os
import json
def process_data(data):
return {k: v.upper() if isinstance(v, str) else v for k, v in data.items()}
with open('input.json') as f:
data = json.load(f)
result = process_data(data)
print(json.dumps(result, indent=2))
EOF")
With inline file write:
run_shell(command="python3 << 'EOF'
result = {'status': 'success', 'count': 42}
with open('output.json', 'w') as f:
json.dump(result, f, indent=2)
print('File written successfully')
EOF")
3. Decision Flow
1. Attempt execute_code_sandbox or read_file
2. If failure with 'unknown error':
a. Determine task type (code execution vs file reading)
b. Choose inline Python approach (-c for simple, heredoc for complex)
c. Execute via run_shell
d. Parse output as needed
3. Continue with task using results from run_shell
Best Practices
Escape quotes properly in
-ccommands: Use\"for double quotes inside the command stringUse heredoc for complex scripts: When code exceeds 2-3 lines or needs multiple imports, use
<< 'EOF'syntaxQuote EOF marker: Use
<< 'EOF'(with quotes) to prevent variable expansion in the heredocCapture stdout: Design your inline Python to print results to stdout for easy capture
Error handling: Add try/except blocks in your inline Python to catch and report errors clearly
File paths: Use absolute paths when possible, or ensure working directory is correct
Examples
Example 1: Read and parse JSON after read_file failure
run_shell(command="python3 -c \"import json; data=json.load(open('config.json')); print(data['key'])\"")
Example 2: Process CSV data after execute_code_sandbox failure
run_shell(command="python3 << 'EOF'
import csv
with open('data.csv', 'r') as f:
reader = csv.DictReader(f)
rows = list(reader)
print(f\"Total rows: {len(rows)}\")
for row in rows[:5]:
print(row)
EOF")
Example 3: Transform and write output file
run_shell(command="python3 << 'EOF'
import json
with open('input.json') as f:
data = json.load(f)
transformed = [item.upper() if isinstance(item, str) else item for item in data]
with open('output.json', 'w') as f:
json.dump(transformed, f, indent=2)
print('Transformation complete')
EOF")
Limitations
- run_shell executes in the shell environment, not the sandbox - ensure paths and dependencies are available
- Output is limited to stdout/stderr - use file writes for large data
- Complex multi-file projects may require creating temporary script files first
अक्सर पूछे जाने वाले सवाल
टेक्स्ट फ़ाइल कौन सा कमांड पढ़ता है?
स्किल शेल में फ़ाइल की सामग्री छापने के लिए cat इस्तेमाल करती है।
क्या JSON फ़ाइलें पार्स हो सकती हैं?
हाँ, स्किल एक लाइन का Python कमांड दिखाती है जो JSON फ़ाइल लोड करके छापता है।
क्या लंबी स्क्रिप्ट के लिए इनलाइन Python सुरक्षित है?
बहु-पंक्ति स्क्रिप्ट के लिए स्किल heredoc इस्तेमाल करती है, जिससे लंबा कोड पढ़ने योग्य रहता है।
जानकारी
लेखक का मूल विवरण
Use run_shell with inline Python as a reliable fallback when execute_code_sandbox or read_file fail
repo: HKUDS/AgentPilot
लोकप्रियता
- GitHub स्टार
- 7.8k
- रैंकिंग में स्थान
- #12979
- लाइसेंस
- 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 खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।