Fallback workflow for reliable file creation and verification when automated code execution fails
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-verified-script-execution-00d7535448f8 ,按照其中的说明把「verified-script-execution」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
When execute_code_sandbox or shell_agent fails repeatedly, use this manual fallback pattern to reliably create and verify files through explicit shell commands.
execute_code_sandboxshell_agent produces repeated errors without progressAlways confirm your current location before creating any files:
pwd
ls -la
This ensures you're writing to the correct workspace directory and reveals any existing files that might conflict.
Use shell heredoc syntax to create scripts with proper escaping. Choose the heredoc delimiter style based on your needs:
For literal content (no variable expansion):
cat > script_name.sh << 'EOF'
#!/bin/bash
# Your script content here
# Variables like $VAR will NOT be expanded
echo "Literal text with $symbols"
EOF
For content requiring variable expansion:
cat > script_name.sh << EOF
#!/bin/bash
OUTPUT_DIR="$PWD/output"
# Variables WILL be expanded
echo "Working in $OUTPUT_DIR"
EOF
Key escaping rules:
<< 'EOF' (quoted delimiter) to prevent variable expansion and command substitution<< EOF (unquoted delimiter) when you need shell variables expanded'\''EOF and INNER)chmod +x script_name.sh
./script_name.sh
Or use the explicit full path for certainty:
bash /full/path/to/script_name.sh
Always verify file creation and inspect content:
# Check file exists and see size
ls -lh expected_output.pdf
ls -lh expected_output.docx
# For PDFs, verify structure and page count
pdfinfo expected_output.pdf
# For Word docs, inspect internal structure
unzip -l expected_output.docx | head -20
# Step 1: Verify directory
pwd
ls -la
# Step 2: Create document generation script
cat > generate_deliverables.sh << 'EOF'
#!/bin/bash
set -e
# Create PDF checklist
cat > checklist_content.txt << 'CONTENT'
Safety Checklist
================
Page 1: Overview
Page 2: Requirements
Page 3: Verification Steps
Page 4: Sign-off
CONTENT
# Create Word action tracker
cat > tracker_content.txt << 'CONTENT'
Action Tracker
==============
Item,Owner,Due,Status
Task 1,Team A,2024-01-15,Pending
Task 2,Team B,2024-01-20,In Progress
CONTENT
# Convert to target formats (adapt to available tools)
echo "Files created in: $(pwd)"
ls -lh *.txt
EOF
# Step 3: Execute with explicit path
chmod +x generate_deliverables.sh
./generate_deliverables.sh
# Step 4: Verify all outputs
ls -lh checklist_content.txt tracker_content.txt
# For PDFs: pdfinfo output.pdf
# For DOCX: unzip -l output.docx | head -20
set -e in scripts to fail fast on errors$ symbolschmod +x before script executionpwd verificationOnce files are created successfully with this pattern:
execute_code_sandbox formatThis pattern prioritizes reliability over iteration efficiency, ensuring deliverables are created correctly even when automated tools struggle.