Zum Inhalt springen
Skillpedia
Allgemeines Programmieren7.8k · #13001

shell-python-fallback

Was er macht

Dieser Skill gibt dem KI-Agenten eine Ausweichlösung für Python-Arbeit, wenn seine Code-Werkzeuge unbekannte Fehler melden. Er richtet sich an Personen, die Datenverarbeitung oder PDF-Erstellung zuverlässig erledigt haben wollen.

Wann du ihn nutzt

  • ✓Wenn die Code-Werkzeuge bei demselben Job zweimal oder öfter unbekannte Fehler melden.
  • ✓Wenn du Datenverarbeitung, Dateianalyse oder PDF-Erstellung mit Python brauchst.
  • ✓Wenn ein Skript laufen soll und du eine klare Ausgabe zur Prüfung willst.

Link zum Skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/shell-python-fallback/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/shell-python-fallback/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Mein Code-Werkzeug gibt bei dieser Datenbereinigung immer wieder unbekannte Fehler aus. Führe das Python über die Shell aus und zeig mir die Ausgabe.”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Der Agent bettet das Python-Skript mit einem Heredoc in einen Shell-Befehl ein. Er führt es aus, liest die ausgegebene Meldung, um Erfolg oder Fehler zu erkennen, und passt den Code bei Bedarf an.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

Shell Python Fallback

When to Use

Use this pattern when execute_code_sandbox or shell_agent tools consistently fail with "unknown error" for tasks such as:

  • Data processing and transformation
  • PDF generation (reportlab, etc.)
  • File parsing and manipulation
  • Any Python script execution that requires reliability

The Pattern

Instead of using code execution tools, embed your Python script directly in a run_shell command using a heredoc:

python3 << 'EOF'
# Your Python code here
import sys
print("Hello from embedded Python")
EOF

Step-by-Step Instructions

  1. Identify the failure: When execute_code_sandbox or shell_agent returns "unknown error" repeatedly (2+ attempts), switch to this fallback.

  2. Write your Python script: Prepare the complete Python code you need to execute.

  3. Embed in run_shell: Use run_shell with a heredoc syntax:

Command: python3 << 'EOF'
import json
# Your complete script here
data = {"key": "value"}
print(json.dumps(data))
EOF
  1. Handle multi-line scripts: For longer scripts, ensure proper indentation is preserved. The heredoc preserves whitespace exactly.

  2. Check output: Parse the stdout from run_shell to verify success or capture errors.

Example: PDF Generation

python3 << 'EOF'
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

c = canvas.Canvas("output.pdf", pagesize=letter)
c.drawString(100, 750, "Hello World")
c.save()
print("PDF created successfully")
EOF

Example: Data Processing

python3 << 'EOF'
import csv
import json

data = []
with open('input.csv', 'r') as f:
    reader = csv.DictReader(f)
    for row in reader:
        data.append(row)

with open('output.json', 'w') as f:
    json.dump(data, f, indent=2)

print(f"Processed {len(data)} records")
EOF

Best Practices

  • Quote the EOF delimiter (<< 'EOF' not << EOF) to prevent shell variable expansion in your Python code
  • Include error handling in your Python script with try/except blocks
  • Print status messages to stdout so you can verify execution succeeded
  • Use absolute paths or ensure working directory is correct
  • Test incrementally: Start with a minimal script, then expand

Troubleshooting

Issue Solution
Script doesn't run Ensure python3 is available in the shell environment
Indentation errors Check that heredoc preserves spaces (use spaces, not tabs)
Module not found Use python3 -m pip install <module> before running script
File not found Use absolute paths or pwd to verify working directory

Why This Works

The run_shell tool executes commands directly in the system shell, bypassing the sandbox restrictions or internal errors that affect execute_code_sandbox and shell_agent. The heredoc approach allows multi-line Python scripts while keeping everything in a single shell command.

Häufige Fragen

Nach wie vielen Fehlern wird gewechselt?

Der Skill sagt, nach zwei oder mehr unbekannten Fehlern umzuschalten.

Behält der Heredoc die Einrückung?

Der Skill sagt, dass der Heredoc Leerzeichen genau erhält, sodass mehrzeiliger Code intakt bleibt.

Kann er PDFs erstellen?

Ja. Der Skill enthält ein PDF-Beispiel mit reportlab.

Details

Originalbeschreibung des Autors

Use run_shell with embedded Python heredoc as reliable fallback when code execution tools fail

repo: HKUDS/AgentPilot

Beliebtheit

GitHub-Sterne
7.8k
Platz im Ranking
#13001
Lizenz
MIT
Aktualisiert
1.11.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills