| name | execution-recovery |
| description | Handle common execution failures with specialized recovery strategies. Fix syntax errors, import/dependency issues, path/file problems, permission denial, and connection timeouts. Use proactively when encountering errors or as automatic recovery mechanism. |
| allowed-tools | Read, Edit, Execute, Grep |
Execution Recovery
Apex2's execution optimization suite implemented as a Claude Code skill. Provides robust recovery from common execution failures.
Instructions
When invoked (automatically on errors or explicitly when help is needed), diagnose and fix execution problems:
1. Immediate Error Triage
Quickly categorize the error type to apply the right recovery strategy:
Syntax Errors:
- Python: SyntaxError, IndentationError, NameError
- JavaScript: SyntaxError, ReferenceError
- Shell: syntax error near token, unexpected operator
Import/Module Errors:
- ModuleNotFoundError, ImportError (Python)
- Cannot find module (Node.js)
- dependency resolution failures
Path/File Issues:
- No such file or directory
- Permission denied
- File already exists
- Directory not empty
Network/Connection Problems:
- Connection refused, timeout
- DNS resolution failures
- Authentication failures
- Rate limiting
2. Recovery Strategies by Error Type
Syntax Error Recovery
-
Diagnose the specific line:
python -m py_compile filename.py
python -c "import ast; ast.parse(open('filename.py').read())"
node -c filename.js
npm install eslint --save-dev && npx eslint filename.js
-
Common fixes to apply:
- Fix missing parenthesis, brackets, quotes
- Correct indentation (Python-specific)
- Add missing semicolons (JS-specific)
- Escape special characters in strings
- Fix function call syntax
-
Heredoc Management (for shell scripts):
cat << 'EOF' > script.sh
EOF
Import/Dependency Recovery
-
Diagnose missing dependencies:
python -c "import missing_module" 2>&1 | grep ModuleNotFoundError
npm ls missing-package
-
Install solutions:
pip install missing-package
npm install missing-package
-
Version conflicts:
pip show package-name
npm list package-name
pip install package==version
npm install package@version
Path/File Recovery
-
Path validation:
ls -la file-path
dirname file-path && ls -la $(dirname file-path)
pwd
echo $(pwd)/relative-path
-
Permission fixes:
chmod +x script.sh
chmod 644 file.txt
chmod 755 directory/
-
Directory creation:
mkdir -p path/to/directory
touch new-file.txt
Network/Connection Recovery
-
Connectivity testing:
ping -c 3 example.com
curl -I https://example.com
telnet host port
nc -zv host port
-
DNS resolution:
nslookup hostname
dig hostname
nslookup hostname 8.8.8.8
-
Authentication and retries:
3. Advanced Recovery Techniques
Heredoc Repair (for shell scripts)
cat << 'EOF' > fixed-script.sh
echo "Fix indentation issues"
EOF
Session Recovery
tmux list-sessions
tmux kill-session -t session-name
tmux new-session -d -s work-session
Long-Running Task Management
timeout 300s command-that-might-hang
4. Systematic Debugging Process
- Capture the exact error message
- Reproduce the error to isolate cause
- Check recent changes that might have broken things
- Apply the appropriate recovery strategy
- Verify the fix works before proceeding
5. Prevention Strategies
Add safeguards to prevent recurrence:
- Input validation in scripts
- Error handling that catches common failures
- Automated testing before deployment
- Configuration validation on startup
Error Categories and Fixes
Docker/Microservice Issues
docker ps -a
docker logs container-name
netstat -tulpn | grep port-number
docker run -p different-port:port
Database Connection Problems
psql -h host -U user -d database -c "SELECT 1;"
mysql -h host -u user -e "SELECT 1;"
systemctl status postgresql
systemctl status mysql
Git Repository Issues
git config --global core.sharedRepository group
git fsck
git gc --prune=now
Output Format
Provide structured recovery report:
Error Analysis:
Type: [syntax/import/path/network/other]
Severity: [low/medium/high]
Criticality: [blocking/warning/info]
Root Cause:
Immediate cause: [what happened]
Underlying issue: [why it happened]
Contributing factors: [other factors]
Recovery Applied:
Step 1: [action taken]
Result: [success/failure]
Step 2: [next action if needed]
Result: [success/failure]
Solution Details:
Code fixed: [show corrected code]
Command executed: [show command]
Changes made: [describe modifications]
Verification:
Test performed: [how fix was verified]
Result: [successful/unsuccessful]
Additional steps: [if needed]
Prevention:
Future safeguards: [how to prevent recurrence]
Monitoring: [what to watch]
Documentation: [what to update]
When to Use
This recovery skill is designed for:
- Automatic recovery when execution commands fail
- Manual intervention when complex errors occur
- Debugging mysterious failures
- Learning from mistakes to prevent recurrence
- Building robust execution pipelines
The goal is to turn execution failures into learning opportunities, with the system becoming more reliable through each recovery.