Chuyển đến nội dung
Skillpedia
Lập trình chung7.8k · #12881

fallback-file-ops

Skill này làm gì

Skill này là phương án dự phòng để tạo thư mục và tệp khi các công cụ cấp cao trả về lỗi mơ hồ hoặc thất bại ngầm. Dành cho người có thiết lập dự án AI liên tục thất bại.

Khi nào nên dùng

  • ✓Khi sandbox trả về lỗi không rõ khi tạo tệp hoặc thư mục.
  • ✓Khi trợ lý nói đã tạo một tệp nhưng tệp thật sự không có ở đó.
  • ✓Khi tôi cần một cấu trúc thư mục dự án lồng nhau được tạo đúng.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-file-ops/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Hãy tạo cấu trúc thư mục dự án với nhiều thư mục và tệp lồng nhau. Trợ lý liên tục thất bại, nên hãy dùng shell.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

AI chuyển sang các lệnh shell như mkdir và ghi chuyển hướng, rồi kiểm tra từng mục bằng ls hoặc lệnh test để xác nhận nó tồn tại.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Fallback File Operations

Purpose

When execute_code_sandbox or shell_agent fail with 'unknown error' on filesystem operations, fall back to run_shell with explicit mkdir and file write commands. This hybrid approach is more reliable for creating complex project structures.

When to Apply

  • execute_code_sandbox returns 'unknown error' on file/directory creation
  • shell_agent fails to write files or create nested directories
  • You need to create complex project structures with multiple levels

Procedure

Step 1: Detect Tool Failure

Monitor for these failure patterns:

  • Error message contains "unknown error"
  • File operations silently fail (file not created)
  • Directory creation returns success but directory doesn't exist

Step 2: Switch to run_shell

When failures occur, immediately switch to run_shell for filesystem operations:

# Create directory structure explicitly
run_shell: mkdir -p /path/to/nested/directory

# Write files using shell redirection or echo
run_shell: echo "content" > /path/to/file.txt

# Or use cat with heredoc for multi-line files
run_shell: cat > /path/to/file.txt << 'EOF'
line 1
line 2
EOF

Step 3: Verify Creation

After each operation, verify the file/directory was created:

run_shell: ls -la /path/to/created/item
run_shell: test -f /path/to/file && echo "File exists"
run_shell: test -d /path/to/dir && echo "Directory exists"

Step 4: Continue with Hybrid Approach

  • Use run_shell for all filesystem operations (mkdir, write, copy, move)
  • Continue using execute_code_sandbox or shell_agent for code execution, compilation, or other non-filesystem tasks
  • Document which tool handles which operation for clarity

Example: Creating Project Structure

# Failed attempt with execute_code_sandbox
execute_code_sandbox: create directory src/components

# Fallback with run_shell
run_shell: mkdir -p src/components
run_shell: mkdir -p src/utils
run_shell: mkdir -p tests/unit
run_shell: echo "// Component file" > src/components/Button.tsx
run_shell: echo "// Utility file" > src/utils/helpers.ts

Best Practices

  1. Be explicit: Always use full paths or confirm working directory
  2. Create parent directories: Use mkdir -p for nested structures
  3. Verify before proceeding: Check files exist before dependent operations
  4. Log tool switches: Note when you fall back to run_shell for debugging
  5. Batch operations: Group related file operations in consecutive run_shell calls

Common Pitfalls

  • Don't assume filesystem state after tool failure
  • Don't mix tools for the same file operation (pick one and stick with it)
  • Don't skip verification steps when using fallback
Câu hỏi thường gặp

AI biết một bước thất bại bằng cách nào?

Nó theo dõi các thông báo lỗi không rõ, hoặc các tệp không xuất hiện sau khi được báo là thành công.

Những lệnh nào được dùng?

Các lệnh như mkdir -p, echo hoặc cat với heredoc, cùng ls hoặc test để kiểm tra kết quả.

Có bắt buộc xác minh không?

Có. Hướng dẫn yêu cầu xác minh từng tệp hoặc thư mục sau khi tạo.

Chi tiết

Mô tả gốc của tác giả

Use run_shell as fallback when execute_code_sandbox or shell_agent fail on filesystem operations

repo: HKUDS/AgentPilot

Độ phổ biến

Sao GitHub
7.8k
Vị trí xếp hạng
#12881
Giấy phép
MIT
Cập nhật
1/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự