shell-error-debug-workflow
What it does
This workflow helps the AI agent figure out why a shell command fails when the error message says little. It is for people whose commands work on their own machine but fail when run by the agent.
When to use it
- ✓When a shell command returns an unknown error with no clear message.
- ✓When a command works on your computer but fails when the agent runs it.
- ✓When failures come and go and the cause is not obvious.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/shell-error-debug-workflow/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“My shell command gives an unknown error. Find out why, starting with the full error output and the folder it runs from.”
5 new skills a week. 1 minute to read.
How it works
The agent captures error output by sending stderr to the same place as normal output. It then checks the working folder and its contents, confirms the needed command exists, and switches to absolute paths if relative ones cause trouble.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Shell Error Debug Workflow
When run_shell returns an 'unknown error' or ambiguous failure, apply this systematic troubleshooting workflow to diagnose and resolve the issue.
When to Use This Skill
run_shellreturns an 'unknown error' message- Shell command fails without clear error output
- Command works locally but fails in the agent environment
- Intermittent or unexplained shell failures
Step-by-Step Troubleshooting Workflow
Step 1: Capture Explicit Stderr
Redirect stderr to stdout to capture all error output:
# Instead of:
run_shell command="some-command"
# Use:
run_shell command="some-command 2>&1"
This ensures error messages are captured in the output rather than being lost.
Step 2: Verify Working Directory
Confirm the current working directory and its contents:
run_shell command="pwd && ls -la"
Check that:
- You're in the expected directory
- Required files/directories exist
- Permissions are correct
Step 3: Check Tool/Command Availability
Verify the required command or tool exists and is accessible:
run_shell command="which some-command || command -v some-command || type some-command"
If the tool is not found, check PATH or install the required package.
Step 4: Use Absolute Paths
Replace relative paths with absolute paths to avoid directory-related issues:
# Instead of:
run_shell command="python script.py"
# Use:
run_shell command="$(pwd)/script.py"
# or
run_shell command="/absolute/path/to/script.py"
Step 5: Test with Minimal Command
Isolate the issue by running a minimal version of the command:
# Test basic functionality first
run_shell command="echo 'test'"
# Then gradually add complexity
run_shell command="some-command --version"
run_shell command="some-command --help"
Step 6: Check Environment Variables
Some commands depend on specific environment variables:
run_shell command="env | grep -i relevant_var"
Complete Diagnostic Sequence
For persistent unknown errors, run this complete diagnostic:
# 1. Capture full environment
run_shell command="pwd && echo '---' && ls -la && echo '---' && env"
# 2. Test command with full error capture
run_shell command="your-command 2>&1 | head -50"
# 3. Check command availability
run_shell command="which your-command || echo 'Command not found in PATH'"
# 4. Try with absolute path
run_shell command="/full/path/to/your-command 2>&1"
Common Causes and Solutions
| Symptom | Likely Cause | Solution |
|---|---|---|
| No output, unknown error | stderr not captured | Add 2>&1 to command |
| File not found | Wrong working directory | Use pwd to verify, use absolute paths |
| Permission denied | File/directory permissions | Check with ls -la, adjust permissions |
| Command not found | Tool not installed or not in PATH | Use which to check, install or specify full path |
| Intermittent failures | Race conditions or timing | Add delays, check for file locks |
Example: Troubleshooting a Python Script Failure
# Initial failing command
run_shell command="python process.py"
# Returns: unknown error
# Apply diagnostic workflow:
# Step 1: Capture stderr
run_shell command="python process.py 2>&1"
# Step 2: Verify directory
run_shell command="pwd && ls -la"
# Step 3: Check Python availability
run_shell command="which python && python --version"
# Step 4: Use absolute path
run_shell command="$(pwd)/process.py 2>&1"
# or
run_shell command="/usr/bin/python3 $(pwd)/process.py 2>&1"
Best Practices
- Always capture stderr when debugging:
2>&1 - Verify assumptions about working directory and file locations
- Start simple before running complex commands
- Use absolute paths in production/repeatable scripts
- Check tool versions when behavior seems inconsistent
- Document environment when errors are hard to reproduce
When to Escalate
If this workflow does not resolve the issue:
- The error may be environmental (container/runtime specific)
- Consider using
shell_agentfor complex shell tasks that require autonomous error handling - Check for resource constraints (disk space, memory, timeouts)
FAQ
What does capturing stderr show?
It makes sure error messages appear in the output instead of being lost.
How does the agent check a command exists?
It uses the which or command -v commands to see if the tool is installed and on the path.
Why use absolute paths?
Absolute paths avoid errors caused by running from the wrong folder.
Details
Original description by the author
Systematic workflow for diagnosing and resolving unknown errors from run_shell commands
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #13000
- License
- MIT
- Updated
- 11/1/2026
Comments
- …
More skills from this repository
agentpilot
7.8kHelps your agent improve a project step by step by preparing a task and running the AgentPilot loop that proposes, tests and scores changes.
openspace
7.8kHelps your agent set up OpenSpace, a tool that stores and fetches agent skills, and connect it to your AI app through MCP.
rsi-arena
7.8kHelps your agent set up and run standard AI benchmark tests, such as AIME and Terminal-Bench, to compare different improvement methods.
experiment-guide
7.8kHelps your agent plan small experiments, read their results and record findings while it investigates how to improve a program.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.