Use run_shell as fallback when execute_code_sandbox or shell_agent fail on filesystem operations
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-fallback-file-ops-db8925e3c3d2 ,按照其中的说明把「fallback-file-ops」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
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.
execute_code_sandbox returns 'unknown error' on file/directory creationshell_agent fails to write files or create nested directoriesMonitor for these failure patterns:
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
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"
run_shell for all filesystem operations (mkdir, write, copy, move)execute_code_sandbox or shell_agent for code execution, compilation, or other non-filesystem tasks# 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
mkdir -p for nested structures