跳到正文
cccskills
免费在 GitHub 公开

run-shell-fallback

Continue file reading and data processing when read_file or execute_code_sandbox fails. The skill uses run_shell with short Python commands or multiline scripts to inspect files, parse data, and save transformed output.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Use run_shell with inline Python as a reliable fallback when execute_code_sandbox or read_file fail

查看安装方法

适用场景

  • Reading accessible files after read_file errors
  • Inspecting JSON settings through Python
  • Checking CSV rows after sandbox execution fails
  • Transforming data and saving a JSON file

包含的文件(2)

  • SKILL.md4.0 KB
  • .skill_id32 B

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

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_sandbox fails with "unknown error" or timeout
  • read_file fails 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

  1. Escape quotes properly in -c commands: Use \" for double quotes inside the command string

  2. Use heredoc for complex scripts: When code exceeds 2-3 lines or needs multiple imports, use << 'EOF' syntax

  3. Quote EOF marker: Use << 'EOF' (with quotes) to prevent variable expansion in the heredoc

  4. Capture stdout: Design your inline Python to print results to stdout for easy capture

  5. Error handling: Add try/except blocks in your inline Python to catch and report errors clearly

  6. 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

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Prepare audio stems, the separate parts of a track, for mixing by matching their durations with silence, loops, or crossfades. Verify each generated and processed file before moving to the next production step.

中文简介正在准备中。当前显示英语简介。

  • Match audio parts with different durations
  • Extend drums and melodic parts using suitable methods
  • Check audio specifications before mixing
HKUDS/OpenSpace77582026年8月13日 更新

Produce audio in separate stems, meaning individual instrument tracks, and verify each output as you go. Align track lengths with silence, loops, or crossfades, then apply effects, mix a master, and package the files.

中文简介正在准备中。当前显示英语简介。

  • Align instrument tracks to a reference audio file
  • Choose how to extend tracks that are too short
  • Verify audio properties after generation and effects
HKUDS/OpenSpace77582026年8月13日 更新

Build serverless endpoints that relay external API requests for a dashboard while keeping API keys on the server. Includes Vercel examples for input checks, caching, cross-origin access, and consistent JSON responses.

中文简介正在准备中。当前显示英语简介。

  • Connect a dashboard to external APIs without exposing API keys
  • Create endpoints for stock quotes and news
  • Standardize API responses and error handling
HKUDS/OpenSpace77582026年8月13日 更新

Produce a master track and separate audio parts through a structured Python workflow. Apply filters and reverb, export WAV files with consistent settings, package them in a ZIP archive, and check that the deliverables meet the requested specifications.

中文简介正在准备中。当前显示英语简介。

  • Export a master track with separate audio parts
  • Apply filters and reverb to audio
  • Check duration and format across deliverables
HKUDS/OpenSpace77582026年8月13日 更新

Keep document creation moving when web searches and page retrieval repeatedly fail. The skill preserves the original task, uses the model’s existing knowledge, and clearly identifies information that could not be checked against external sources.

中文简介正在准备中。当前显示英语简介。

  • Continue drafting after repeated web retrieval failures
  • Preserve task requirements during network errors
  • Mark information that could not be externally verified
HKUDS/OpenSpace77582026年8月13日 更新

When Python execution repeatedly fails in execute_code_sandbox, use a file-based alternative: save the script, run it through the shell, and capture results or errors. The guidance covers paths, imports, timeouts, structured output, and optional cleanup.

中文简介正在准备中。当前显示英语简介。

  • Retry Python work through the shell after repeated sandbox failures
  • Run longer tasks with an adjusted timeout
  • Execute Python work that needs multiple files or system utilities
HKUDS/OpenSpace77582026年8月13日 更新

查看 HKUDS 的全部技能

报告此技能的问题