resilient-spreadsheet-workflow
它能做什么
这项技能在沙箱返回错误时,为 AI 智能体提供了一套谨慎的电子表格工作流程。它适合需要清理或汇总 CSV 或 Excel 文件的人。
适用场景
- ✓当你处理 CSV 或 Excel 文件时,代码沙箱返回未知错误的时候。
- ✓当你需要查明某个文件夹中有哪些电子表格文件,以及它们有多大的时候。
- ✓当你希望在下一步开始前,检查电子表格任务的每一步的时候。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/resilient-spreadsheet-workflow/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在我的文件夹中找到电子表格,然后清理销售 CSV 并保存摘要。过程中请检查每一步。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会先借助辅助工具列出电子表格文件及其大小。然后它把处理脚本写入文件并运行,并在每个阶段检查输出后再继续。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Resilient Spreadsheet Workflow
This skill provides a robust workflow for processing spreadsheet files (CSV, XLSX) when execute_code_sandbox encounters failures. It uses a combination of tools to ensure reliable execution and clear error diagnosis.
When to Use
- Processing spreadsheet files when
execute_code_sandboxreturns unknown errors - Need to debug why spreadsheet operations fail
- Require reliable file I/O with verification at each step
Step-by-Step Workflow
Step 1: Initial Exploration with shell_agent
Start by using shell_agent to explore the file structure and understand what files exist:
Use shell_agent to:
- List files in the working directory
- Identify spreadsheet files (CSV, XLSX)
- Examine file sizes and basic structure
Example task for shell_agent:
Explore the current directory to find all spreadsheet files (CSV, XLSX).
List their sizes and identify which files need processing.
Step 2: Write Processing Script with write_file
Create a standalone script file rather than executing inline code:
# Use write_file to create a script like "process_sheet.py"
content = """
import pandas as pd
import sys
try:
df = pd.read_csv('input.csv') # or pd.read_excel for XLSX
# Perform your processing
result = df.describe()
result.to_csv('output.csv', index=False)
print("Processing complete")
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)
"""
write_file(path="process_sheet.py", content=content)
Step 3: Execute with run_shell and Error Redirection
Execute the script with stderr redirected to stdout for complete error capture:
run_shell command="python process_sheet.py 2>&1"
The 2>&1 redirection ensures both stdout and stderr are captured together, making error messages visible.
Step 4: Isolate Errors with Verification Commands
If Step 3 fails, add targeted verification commands to diagnose the actual problem:
# Check if Python is available
run_shell command="which python 2>&1"
# Check if pandas is installed
run_shell command="python -c 'import pandas' 2>&1"
# Verify input file exists and is readable
run_shell command="ls -la input.csv 2>&1"
# Check file encoding/content
run_shell command="file input.csv 2>&1"
run_shell command="head -5 input.csv 2>&1"
Step 5: Verify Output Before Reading
Before reading results with read_file, verify the output file exists:
list_dir(path=".")
# Confirm output file appears in the listing
# Then proceed to read_file
Complete Example
1. shell_agent(task="Find and describe all CSV/XLSX files in current directory")
2. write_file(path="analyze_data.py", content="<processing script>")
3. run_shell(command="python analyze_data.py 2>&1")
4. If error: run_shell(command="python -c 'import pandas; print(pandas.__version__)' 2>&1")
5. list_dir(path=".") # Verify output exists
6. read_file(filetype="csv", file_path="output.csv")
Common Error Patterns
| Symptom | Diagnostic Command | Likely Cause |
|---|---|---|
| Module not found | python -c 'import pandas' |
Missing dependency |
| File not found | ls -la <filename> |
Wrong path or name |
| Permission denied | ls -la <filename> |
File permissions |
| Encoding error | file <filename> |
Wrong file format |
Best Practices
- Always use 2>&1 with run_shell for shell commands to capture full error output
- Verify before reading - use list_dir to confirm file existence before read_file
- Break into small steps - separate exploration, script writing, execution, and verification
- Use shell_agent for unknowns - when directory structure or file types are unclear
- Write scripts to files - more reliable than inline code execution for complex operations
常见问题
第一步做什么?
它列出工作文件夹中的电子表格文件,并记录它们的大小和结构。
为什么要写成脚本文件,而不是内联运行代码?
保存的脚本更容易重新运行和修复,也能避开沙箱失败的问题。
它同时处理 CSV 和 Excel 吗?
是的。这项技能涵盖 CSV 和 XLSX 文件,并分别展示了读取方法。
详情
作者的原始描述
Resilient multi-step workflow for spreadsheet processing when execute_code_sandbox fails, using shell_agent exploration, file-based scripts, and verification steps
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #12974
- 许可证
- 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帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。