python-heredoc-fallback
यह क्या करती है
यह स्किल दिखाती है कि सैंडबॉक्स काम न करे तो AI एजेंट शेल में heredoc से Python कैसे चलाए। यह उन लोगों के लिए है जिन्हें Python से बने चार्ट, Word दस्तावेज़ या स्प्रेडशीट चाहिए।
कब इस्तेमाल करें
- ✓जब कोड सैंडबॉक्स सेटअप या कनेक्शन एरर से विफल हो।
- ✓जब आपको Python से चार्ट इमेज, Word दस्तावेज़ या स्प्रेडशीट बनवानी हो।
- ✓जब सैंडबॉक्स में फ़ाइल बनाने का काम बार-बार विफल हो।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/python-heredoc-fallback/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरी input.xlsx से एक बार चार्ट बनाइए और उसे PNG के रूप में सहेजिए। सैंडबॉक्स बार-बार विफल हो रहा है।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट पहले ज़रूरी पैकेज इंस्टॉल करता है, फिर Python कोड heredoc के ज़रिए शेल में चलाता है। कोड फ़ाइल बनाता है और काम पूरा होने पर संदेश छापता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Python Heredoc Fallback for Code Execution
When to Use
Use this pattern when execute_code_sandbox fails with e2b initialization errors, sandbox connection issues, or other execution environment problems. This is especially reliable for file generation tasks.
Core Pattern
Instead of execute_code_sandbox, run Python code directly in the shell using a heredoc:
python3 << 'EOF'
# Your Python code here
import sys
print("Python code executing in shell")
EOF
Key Syntax Rules
- Use single-quoted EOF (
<< 'EOF') to prevent shell variable expansion within the Python code - No indentation before EOF - the closing delimiter must be at the start of the line
- Install packages first if needed, before the Python heredoc block
Common Use Cases
1. Matplotlib Graph Generation
python3 << 'EOF'
import matplotlib.pyplot as plt
import pandas as pd
# Load data
data = pd.read_excel('input.xlsx')
# Create visualization
plt.figure(figsize=(10, 6))
plt.plot(data['x'], data['y'])
plt.xlabel('X Label')
plt.ylabel('Y Label')
plt.title('Graph Title')
plt.savefig('output_graph.png', dpi=300, bbox_inches='tight')
plt.close()
print("Graph saved successfully")
EOF
2. Python-docx Document Creation
pip install python-docx -q
python3 << 'EOF'
from docx import Document
from docx.shared import Inches, Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
doc = Document()
# Add title
title = doc.add_heading('Document Title', 0)
title.alignment = WD_ALIGN_PARAGRAPH.CENTER
# Add sections
doc.add_heading('Section 1', level=1)
doc.add_paragraph('Content for section 1.')
# Add table
table = doc.add_table(rows=3, cols=3)
table.style = 'Table Grid'
# Save document
doc.save('output.docx')
print("Document created successfully")
EOF
3. General File Operations
python3 << 'EOF'
import json
import os
# Read input file
with open('input.json', 'r') as f:
data = json.load(f)
# Process data
result = {'processed': True, 'items': len(data)}
# Write output
with open('output.json', 'w') as f:
json.dump(result, f, indent=2)
print(f"Processed {result['items']} items")
EOF
Best Practices
- Install dependencies first: Run
pip install package-name -qbefore the Python block if packages aren't guaranteed to be available - Verify file paths: Files are read from and written to the current working directory
- Add print statements: Include progress/output messages to verify execution succeeded
- Close resources: Explicitly close matplotlib figures and file handles
- Handle errors gracefully: Add try/except blocks for production code
Troubleshooting
| Issue | Solution |
|---|---|
| Module not found | Add pip install <module> -q before Python block |
| File not found | Verify file exists in current directory with ls |
| Permission denied | Check file permissions and directory write access |
| Syntax errors | Ensure proper Python indentation within heredoc |
Advantages Over execute_code_sandbox
- No initialization overhead - runs immediately in existing shell
- Persistent environment - maintains state across multiple commands
- Direct file system access - no sandbox isolation issues
- Full system Python - access to all installed packages
- Reliable for large files - no sandbox size restrictions
अक्सर पूछे जाने वाले सवाल
यह किस तरह की फ़ाइलें बना सकता है?
स्किल Python लाइब्रेरी से चार्ट, Word दस्तावेज़ और स्प्रेडशीट के उदाहरण देती है।
क्या एजेंट पैकेज इंस्टॉल करता है?
हाँ, स्किल कहती है कि Python ब्लॉक चलने से पहले ज़रूरी पैकेज इंस्टॉल करें।
EOF की समाप्ति वाली पंक्ति बाईं ओर से क्यों शुरू होनी चाहिए?
शेल तभी समाप्ति मार्कर पढ़ता है जब वह किसी पंक्ति की शुरुआत में हो।
जानकारी
लोकप्रियता
- GitHub स्टार
- 7.8k
- रैंकिंग में स्थान
- #12960
- लाइसेंस
- 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 खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।