मुख्य सामग्री पर जाएँ
Skillpedia
सामान्य कोडिंग7.8k · #12981

safe-script-execution

यह क्या करती है

यह स्किल AI एजेंट को तब स्क्रिप्ट बनाने और चलाने का हाथ से किया जाने वाला तरीका देती है, जब उसके स्वचालित टूल अपेक्षित आउटपुट न दें। यह उन लोगों के लिए है जो हर चरण पर साफ़ नियंत्रण चाहते हैं।

कब इस्तेमाल करें

  • ✓जब कोड सैंडबॉक्स या शेल एजेंट बार-बार वह आउटपुट न दे जिसकी आपको उम्मीद थी।
  • ✓जब आप चाहें कि कोई फ़ाइल बनाने से पहले एजेंट अपना वर्किंग फ़ोल्डर पक्का करे।
  • ✓जब स्क्रिप्ट में कोट्स या विशेष अक्षर हों जो सरल कमांड तोड़ दें।

Skill का लिंक

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/safe-script-execution/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/safe-script-execution/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरी स्क्रिप्ट सैंडबॉक्स में बार-बार विफल हो रही है। इसे पूरे पाथ वाली फ़ाइल में सहेजकर चलाइए, और बताइए कि आउटपुट सही लगता है या नहीं।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट मौजूदा फ़ोल्डर जाँचता है, एक अनोखे समाप्ति मार्कर वाले heredoc से स्क्रिप्ट फ़ाइल लिखता है, उसे चलाने योग्य बनाता है और पूरे पाथ से चलाता है। रिपोर्ट करने से पहले वह आउटपुट जाँचता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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:

  1. Check script syntax: python3 -m py_compile /path/to/script.py
  2. Check permissions: ls -l /path/to/script.py
  3. Check available disk space: df -h .
  4. 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 pwd first

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 (file command or type-specific inspection)
अक्सर पूछे जाने वाले सवाल

स्क्रिप्ट को पूरे पाथ से क्यों चलाएँ?

पूरा पाथ रिलेटिव पाथ या गलत वर्किंग फ़ोल्डर से होने वाली गलतियों को रोकता है।

heredoc में समाप्ति मार्कर कोट्स में क्यों है?

कोट्स शेल को स्क्रिप्ट के अंदर डॉलर चिह्न या दूसरे प्रतीक बदलने से रोकते हैं।

अगर स्क्रिप्ट में समाप्ति मार्कर का ही टेक्स्ट हो तो?

स्किल कहती है कि एक अलग अनोखा मार्कर चुनें, ताकि फ़ाइल बीच में न कटे।

जानकारी

लेखक का मूल विवरण

Fallback workflow for code execution when automated tools fail, using shell heredoc with verification

repo: HKUDS/AgentPilot

लोकप्रियता

GitHub स्टार
7.8k
रैंकिंग में स्थान
#12981
लाइसेंस
MIT
अपडेट की गई
1/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills