fallback-file-creation
Skill này làm gì
Skill này cho AI một cách thủ công, dựa trên shell, để tạo và kiểm tra tệp khi công cụ thực thi code liên tục thất bại. Dành cho người cần các định dạng tệp cụ thể được tạo đáng tin cậy.
Khi nào nên dùng
- ✓Khi công cụ thực thi code hoặc trợ lý shell đã thất bại nhiều lần với một tác vụ tệp.
- ✓Khi tôi cần tệp PDF hoặc Word được tạo và các công cụ thông thường không hoạt động.
- ✓Khi tôi muốn mỗi tệp được kiểm tra sau khi ghi.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-file-creation/SKILL.mdSao 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
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Các công cụ code liên tục thất bại với tệp của tôi. Hãy kiểm tra thư mục, viết script trong shell và xác nhận tệp thật sự có ở đó.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI xác nhận thư mục làm việc, viết script bằng heredoc shell, chạy chúng với đường dẫn rõ ràng, và kiểm tra từng tệp đầu ra có 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 Creation Workflow
Use this skill when execute_code_sandbox or shell_agent fails repeatedly for file creation tasks. This pattern provides a manual but reliable approach to create and verify files.
When to Use
- Code execution tools fail after multiple retries
- You need to create specific file formats (PDF, DOCX, etc.)
- Direct shell commands are more reliable than generated scripts
- You need explicit verification of file outputs
Step-by-Step Instructions
Step 1: Verify Working Directory
Before any file operations, confirm your current location:
pwd
ls -la
This ensures you're creating files in the correct workspace directory.
Step 2: Create Scripts via Heredoc
Use shell heredocs to create scripts with properly escaped syntax:
cat > /path/to/script.sh << 'EOF'
#!/bin/bash
# Your script content here
# Variables are NOT expanded inside 'EOF' (quoted)
echo "Creating file..."
# Commands to generate output
EOF
Key escaping rules:
- Use
'EOF'(quoted) to prevent variable expansion inside the heredoc - Use
EOF(unquoted) if you want shell variables to expand - Escape any
$, backticks, or special characters if using unquoted EOF
Step 3: Execute with Explicit Path
Always run scripts with their full or explicit relative path:
chmod +x /path/to/script.sh
/path/to/script.sh
# or
bash /path/to/script.sh
Avoid relying on . or implicit paths.
Step 4: Verify Output
After execution, verify files were created correctly:
# Check file exists and size
ls -lh /path/to/output.file
# For PDFs: inspect metadata
pdfinfo /path/to/output.pdf
# For DOCX: check structure
unzip -l /path/to/output.docx | head -20
# For any file: check content preview
file /path/to/output.file
head -c 500 /path/to/output.file
Step 5: Iterative Debugging
If verification fails:
- Check error messages from script execution
- Verify all dependencies are available (
which command) - Test individual commands from the script manually
- Re-run with verbose output (
bash -x script.sh)
Example: Creating a PDF Document
# Step 1: Verify directory
pwd
ls -la
# Step 2: Create conversion script
cat > /workspace/create_pdf.sh << 'EOF'
#!/bin/bash
cd /workspace
libreoffice --headless --convert-to pdf checklist.odt --outdir .
EOF
# Step 3: Execute
chmod +x /workspace/create_pdf.sh
/workspace/create_pdf.sh
# Step 4: Verify
ls -lh /workspace/checklist.pdf
pdfinfo /workspace/checklist.pdf
Example: Creating a DOCX Document
# Step 1: Verify directory
pwd
ls -la
# Step 2: Create document script
cat > /workspace/create_docx.sh << 'EOF'
#!/bin/bash
cd /workspace
pandoc -f markdown -t docx action_tracker.md -o action_tracker.docx
EOF
# Step 3: Execute
chmod +x /workspace/create_docx.sh
/workspace/create_docx.sh
# Step 4: Verify
ls -lh /workspace/action_tracker.docx
unzip -l /workspace/action_tracker.docx | head -20
Best Practices
- Always verify before and after - Check directory state before starting and after completion
- Use absolute or explicit paths - Avoid ambiguity in file locations
- Quote heredoc delimiters - Use
'EOF'to prevent unwanted variable expansion - Make scripts executable - Always
chmod +xbefore running - Inspect file metadata - Use format-specific tools (pdfinfo, unzip -l, file) to verify content
- Keep scripts simple - Each script should do one thing well
- Clean up temporary files - Remove intermediate files after successful completion
Troubleshooting
| Issue | Solution |
|---|---|
| Script not found | Use full path: /workspace/script.sh |
| Permission denied | Run chmod +x script.sh |
| File not created | Check script output, verify working directory in script |
| Wrong file format | Verify conversion tool supports target format |
| Corrupted output | Re-run with verbose mode, check intermediate files |
Câu hỏi thường gặp
Vì sao dùng heredoc?
Nó cho phép AI ghi cả một script vào tệp chỉ trong một lệnh shell.
Vì sao kiểm tra thư mục làm việc trước?
Điều này đảm bảo các tệp được tạo đúng trong không gian làm việc.
Biến có được mở rộng trong script không?
Khi dấu đánh dấu EOF được đặt trong dấu nháy thì không, nhờ vậy văn bản script được giữ đúng như đã viết.
Chi tiết
Mô tả gốc của tác giả
Fallback pattern for reliable file creation when code execution tools fail
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #12880
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentpilot
7.8kGiúp agent của bạn cải thiện dự án từng bước bằng cách chuẩn bị tác vụ và chạy vòng lặp AgentPilot, gồm đề xuất, kiểm thử và chấm điểm thay đổi.
openspace
7.8kGiúp agent của bạn thiết lập OpenSpace, công cụ lưu và lấy lại skill của agent, rồi kết nối nó với ứng dụng AI của bạn qua MCP.
rsi-arena
7.8kGiúp agent của bạn thiết lập và chạy các bài kiểm thử benchmark AI chuẩn, như AIME và Terminal-Bench, để so sánh các phương pháp cải tiến khác nhau.
experiment-guide
7.8kGiúp agent của bạn lên kế hoạch các thí nghiệm nhỏ, đọc kết quả và ghi lại phát hiện khi tìm cách cải thiện một chương trình.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.