Skip to content
execution-recovery logo

Execution Recovery

execution-recovery

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.

SKILL.md

Full skill instructions

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
  1. Diagnose the specific line:

    # Python syntax checking
    python -m py_compile filename.py
    # or specific line diagnosis
    python -c "import ast; ast.parse(open('filename.py').read())"
    
    # JavaScript syntax checking  
    node -c filename.js
    npm install eslint --save-dev && npx eslint filename.js
    
  2. 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
  3. Heredoc Management (for shell scripts):

    # Validate heredoc syntax
    cat << 'EOF' > script.sh
    # script content here
    EOF
    
Import/​Dependency Recovery
  1. Diagnose missing dependencies:

    # Python imports
    python -c "import missing_module" 2>&1 | grep ModuleNotFoundError
    
    # Node.js
    npm ls missing-package
    
  2. Install solutions:

    # Python
    pip install missing-package
    # Add to requirements.txt
    
    # Node.js
    npm install missing-package
    # Add to package.json dependencies
    
  3. Version conflicts:

    # Check versions
    pip show package-name
    npm list package-name
    
    # Install specific version
    pip install package==version
    npm install package@version
    
Path/​File Recovery
  1. Path validation:

    # Check if file exists
    ls -la file-path
    dirname file-path && ls -la $(dirname file-path)
    
    # Current working directory
    pwd
    
    # Relative vs absolute path testing
    echo $(pwd)/​relative-path
    
  2. Permission fixes:

    # Make executable
    chmod +x script.sh
    
    # Read/​write permissions
    chmod 644 file.txt
    chmod 755 directory/
    
  3. Directory creation:

    # Create parents as needed
    mkdir -p path/​to/​directory
    
    # Safe file creation
    touch new-file.txt
    
Network/​Connection Recovery
  1. Connectivity testing:

    # Test basic connectivity
    ping -c 3 example.com
    curl -I https://example.com
    
    # Check specific ports
    telnet host port
    nc -zv host port
    
  2. DNS resolution:

    # Check DNS
    nslookup hostname
    dig hostname
    
    # Test different DNS servers
    nslookup hostname 8.8.8.8
    
  3. Authentication and retries:

    # Retry with exponential backoff
    # Use auth tokens appropriately
    # Check rate limits and wait periods
    

3. Advanced Recovery Techniques

Heredoc Repair (for shell scripts)
# Fix indentation in heredoc
cat << 'EOF' > fixed-script.sh
#!/​bin/​bash
echo "Fix indentation issues"
# Other commands
EOF
Session Recovery
# Detect stuck tmux/​session issues
tmux list-sessions
tmux kill-session -t session-name

# Start fresh session
tmux new-session -d -s work-session
Long-Running Task Management
# Resume interrupted tasks
# Check progress of long operations
# Implement timeouts for very long commands
timeout 300s command-that-might-hang

4. Systematic Debugging Process

  1. Capture the exact error message
  2. Reproduce the error to isolate cause
  3. Check recent changes that might have broken things
  4. Apply the appropriate recovery strategy
  5. 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

# Container not found
docker ps -a
docker logs container-name

# Port conflicts
netstat -tulpn | grep port-number
docker run -p different-port:port

Database Connection Problems

# Connection testing
psql -h host -U user -d database -c "SELECT 1;"
mysql -h host -u user -e "SELECT 1;"

# Service status
systemctl status postgresql
systemctl status mysql

Git Repository Issues

# Permission denied
git config --global core.sharedRepository group

# Corrupted repository
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.

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View