Debug Enhancement Framework
Enhances ClawHub skills with structured logging, error recovery, performance monitoring, circuit breaker, and self-healing for robust debugging and stability.
orionshaowswmw
@orionshaowswmw
Install
$ openclaw skills install @orionshaowswmw/debug-enhancement-frameworkDebug Enhancement Framework for ClawHub Skills
Version: 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.
When to Use
- Adding debugging capabilities to any ClawHub skill
- Fixing bugs and errors in skill implementations
- Adding error recovery and self-healing to skills
- Performance monitoring and optimization
- Creating robust, production-ready skills
Quick Start
# Install this framework
npx --yes clawhub@latest install debug-enhancement-framework --no-input
# Use in any skill
source debug-enhancement-framework/scripts/debugger.sh
Core Features
1. Universal Debugger (debugger.sh / debugger.py)
# 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
2. Error Recovery System
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())
3. Performance Monitor
# Profile any command
profile_command "python3 my_script.py"
# Monitor memory usage
monitor_memory --threshold 500MB --alert webhook
4. Self-Healing Mechanisms
- Auto-restart failed services
- Repair corrupted files
- Recover from network failures
- Rollback to stable state
Enhanced Skill Template
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
Debugging Best Practices
1. Structured Logging
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"})
2. Error Classification
from debug_enhancement import ErrorClassifier
classifier = ErrorClassifier()
error_type = classifier.classify(exception)
# Returns: NetworkError, ConfigurationError, ValidationError, etc.
3. Circuit Breaker Pattern
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
4. Health Checks
# Add health check endpoint
curl http://localhost:8080/health
# Returns: {"status": "healthy", "checks": {...}}
Bug Fixing Workflow
- Reproduce: Use
dbg_reproduceto capture failure state - Diagnose: Run
dbg_diagnosefor root cause analysis - Fix: Apply
dbg_fixwith suggested patches - Verify: Run
dbg_verifyto confirm fix - Document: Log fix in
.debug_config.json
Integration with Skills
Add 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
API Reference
debugger.py
| Function | Description |
|---|---|
setup_logging() | Configure structured logging |
log_error() | Log with full context |
capture_state() | Save execution state |
analyze_trace() | Analyze execution trace |
recovery.py
| Function | Description |
|---|---|
retry_with_backoff() | Retry with exponential backoff |
circuit_breaker() | Circuit breaker decorator |
rollback() | Rollback to previous state |
heal() | Auto-heal common issues |
Testing
# 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
Changelog
2.0.0
- Added circuit breaker pattern
- Improved error classification
- Added performance monitoring
- Self-healing mechanisms
1.0.0
- Initial release
- Basic debugging utilities
- Error logging
- Retry logic
Top skills in this category
Openclaw Command Center
@jontsaiMission control dashboard for OpenClaw - real-time session monitoring, LLM usage tracking, cost intelligence, and system vitals. View all your AI agents in o...
Interview Simulator
@wscatsSimulates mock interviews for any role and experience level with tailored technical, behavioral, and case questions plus detailed feedback and scoring.
moltbook-interact
@lunarcmdInteract with Moltbook social network for AI agents. Post, reply, browse, and analyze engagement. Use when the user wants to engage with Moltbook, check their feed, reply to posts, or track their activity on the agent social network.
Web Development
@ivangdavilaBuild, debug, and deploy websites using HTML, CSS, JavaScript, and modern frameworks following production best practices.
Baidu Wenku AI picture book of video
@ide-rea百度文库AI绘本是一个基于人工智能制作绘本视频的工具,支持生成静态绘本和动态绘本(URL输出)。能帮助文本内容创作者们在缺乏绘画技能的情况下,快速生成精美绘本视频,提高内容生产效率。无论是在儿童教育、亲子互动、品牌营销,还是在社交媒体内容创作等领域都能应用。