Install
openclaw skills install @orionshaowswmw/debug-enhancement-frameworkEnhances ClawHub skills with structured logging, error recovery, performance monitoring, circuit breaker, and self-healing for robust debugging and stability.
openclaw skills install @orionshaowswmw/debug-enhancement-frameworkVersion: 2.0.0
Owner: orionshaowswmw
Metadata: {"openclaw":{"emoji":"🛠️"}}
Description: Universal debugging, error handling, and bug-fixing enhancement framework for AI agent skills. Adds comprehensive logging, error recovery, performance monitoring, and self-healing capabilities to any skill.
# Install this framework
npx --yes clawhub@latest install debug-enhancement-framework --no-input
# Use in any skill
source debug-enhancement-framework/scripts/debugger.sh
# Initialize debugging session
DEBUGGER_INIT=true
source debug-enhancement-framework/scripts/debugger.sh
# Log with levels
dbg_log "INFO" "Starting operation"
dbg_log "WARN" "Memory usage high"
dbg_log "ERROR" "Failed to connect"
# Enable verbose tracing
export DEBUG_LEVEL=verbose
from debug_enhancement import ErrorRecovery, RetryPolicy
# Add retry with exponential backoff
@RetryPolicy(max_attempts=3, backoff="exponential")
def fragile_operation():
# Your code here
pass
# Handle specific errors
recovery = ErrorRecovery()
recovery.handle(FileNotFoundError, lambda e: create_default_file())
# Profile any command
profile_command "python3 my_script.py"
# Monitor memory usage
monitor_memory --threshold 500MB --alert webhook
All skills should include this debugging structure:
skill-name/
├── SKILL.md # Enhanced with debugging section
├── scripts/
│ ├── main.py # Main logic with error handling
│ ├── debugger.py # Debugging utilities
│ └── recovery.py # Error recovery handlers
├── tests/
│ └── test_skill.py # Unit tests
└── .debug_config.json # Debug configuration
import logging
from debug_enhancement import setup_logging
setup_logging(
level=logging.DEBUG,
format="json", # or "human"
output="both" # stdout + file
)
logger = logging.getLogger(__name__)
logger.info("Operation started", extra={"operation_id": "abc123"})
from debug_enhancement import ErrorClassifier
classifier = ErrorClassifier()
error_type = classifier.classify(exception)
# Returns: NetworkError, ConfigurationError, ValidationError, etc.
from debug_enhancement import CircuitBreaker
breaker = CircuitBreaker(
failure_threshold=5,
recovery_timeout=60,
half_open_requests=3
)
@breaker
def external_api_call():
# Protected call
pass
# Add health check endpoint
curl http://localhost:8080/health
# Returns: {"status": "healthy", "checks": {...}}
dbg_reproduce to capture failure statedbg_diagnose for root cause analysisdbg_fix with suggested patchesdbg_verify to confirm fix.debug_config.jsonAdd this to any skill's SKILL.md:
## Debugging
This skill includes debug enhancement framework.
### Enable Debug Mode
export SKILL_DEBUG=true
### View Logs
tail -f /tmp/skill-name-debug.log
### Run Diagnostics
python3 scripts/debugger.py --diagnose
| Function | Description |
|---|---|
setup_logging() | Configure structured logging |
log_error() | Log with full context |
capture_state() | Save execution state |
analyze_trace() | Analyze execution trace |
| Function | Description |
|---|---|
retry_with_backoff() | Retry with exponential backoff |
circuit_breaker() | Circuit breaker decorator |
rollback() | Rollback to previous state |
heal() | Auto-heal common issues |
# Run skill tests
python3 -m pytest tests/ -v
# Run with coverage
python3 -m pytest tests/ --cov=scripts --cov-report=html
# Simulate failures
python3 scripts/debugger.py --simulate-network-error