fallback-file-ops
它能做什么
这项技能是当高层工具返回模糊错误或静默失败时,用于创建文件夹和文件的备用方法。它适合 AI 项目设置持续失败的人。
适用场景
- ✓当沙箱在创建文件或文件夹时返回未知错误的时候。
- ✓当辅助智能体声称已创建文件,但文件实际上并不存在的时候。
- ✓当我需要正确构建嵌套的项目文件夹结构的时候。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/fallback-file-ops/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请创建包含多层嵌套文件夹和文件的项目结构。辅助工具一直失败,请改用 shell。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会切换到 mkdir、重定向写入等 shell 命令,然后用 ls 或 test 命令逐项检查,确认每个项目确实存在。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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_sandboxreturns 'unknown error' on file/directory creationshell_agentfails 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_shellfor all filesystem operations (mkdir, write, copy, move) - Continue using
execute_code_sandboxorshell_agentfor 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
- Be explicit: Always use full paths or confirm working directory
- Create parent directories: Use
mkdir -pfor nested structures - Verify before proceeding: Check files exist before dependent operations
- Log tool switches: Note when you fall back to run_shell for debugging
- 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
常见问题
AI 怎么知道某一步失败了?
它会注意未知的错误信息,或是在声称成功后文件却未出现的情况。
使用了哪些命令?
例如 mkdir -p、echo 或带 heredoc 的 cat,以及用于检查结果的 ls 或 test。
必须进行验证吗?
是的。指南要求在每个文件或文件夹创建后进行验证。
详情
作者的原始描述
Use run_shell as fallback when execute_code_sandbox or shell_agent fail on filesystem operations
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #12881
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
agentpilot
7.8k帮你的智能体准备任务并运行 AgentPilot 循环,逐步改进项目:循环会提出修改、测试修改并为其打分。
openspace
7.8k帮你的智能体设置 OpenSpace,这是一个用于存储和获取智能体技能的工具,并通过 MCP 将其连接到你的 AI 应用。
rsi-arena
7.8k帮你的智能体设置并运行标准 AI 基准测试,例如 AIME 和 Terminal-Bench,用来比较不同的改进方法。
experiment-guide
7.8k帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。