Skip to content

jugaad-lab/clawdscan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

clawdscan logo

[![ClawHub](https://img.shields.io/badge/ClawHub-clawdscan-teal)](https://clawhub.ai/skills/clawdscan) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![GitHub Repo stars](https://img.shields.io/github/stars/jugaad-lab/clawdscan?style=social)](https://github.com/jugaad-lab/clawdscan/stargazers)

**Install via ClawHub:** `clawhub install clawdscan`

⭐ Found this useful? Star this repo to help others discover it!

ClawdScan - Clawdbot Session Health Analyzer πŸ”

⭐ Found this useful? Star this repo to help others discover it!

A comprehensive diagnostic tool for Clawdbot sessions. Analyze JSONL session files to identify performance issues, bloated sessions, zombie processes, and get actionable cleanup recommendations.

πŸ“Œ If you find this useful, please ⭐ star this repo! It helps other developers discover session health tools.

Features

  • πŸ” Session Health Analysis - Detect bloated sessions, high message counts, disk usage patterns
  • πŸ’€ Zombie Detection - Find sessions created but never used
  • πŸ—“οΈ Stale Session Identification - Identify sessions inactive for configurable periods
  • πŸ“Š Tool Usage Analytics - Track which tools are being used and how frequently
  • πŸ€– Model Usage Patterns - Monitor model switching and usage trends
  • πŸ’Ύ Disk Space Management - Breakdown of storage usage by agent and session
  • 🧹 Automatic Cleanup - Safe archive and deletion of problematic sessions
  • πŸ“ˆ Trend Tracking - Historical analysis of session health over time
  • πŸ’“ Heartbeat Integration - Automated monitoring and alerts

Quick Start

# Install as Clawdbot skill
clawdbot skill install clawdscan

# Or run standalone
chmod +x clawdscan.py
./clawdscan.py scan

Example Output

πŸ” ClawdScan v0.1.0 β€” Clawdbot Session Health Analysis
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ“Š Overview
  Total Sessions: 42
  Total Size: 23.4 MB
  Agents: main(38), dj(4)

⚠️  Issues Found
  πŸ”₯ Bloated: 3 sessions (>1MB or >300 msgs)
  πŸ’€ Zombies: 2 sessions (created but unused)  
  πŸ—“οΈ  Stale: 7 sessions (inactive >7 days)

πŸ” Top Sessions by Size
  1. main-20240108-143022  4.2 MB  (1,247 msgs)
  2. main-20240107-091534  2.8 MB  (892 msgs)
  3. dj-20240105-220145    1.9 MB  (734 msgs)

πŸ’‘ Recommendations
  β€’ Archive 2 zombie sessions β†’ save 145 KB
  β€’ Clean 7 stale sessions β†’ save 3.2 MB
  β€’ Consider shorter session lifetimes

Available Commands

Command Description Example
scan Full health scan clawdscan scan
top Top sessions by size/messages clawdscan top -n 10
inspect Deep-inspect specific session clawdscan inspect session-id
tools Tool usage analytics clawdscan tools
models Model usage patterns clawdscan models
disk Disk usage breakdown clawdscan disk
clean Safe session cleanup clawdscan clean --zombies
history Health trends over time clawdscan history --days 7

Installation

As Clawdbot Skill

# Install from skill repository
clawdbot skill install clawdscan

# Or install from local directory
cd /path/to/clawdscan
clawdbot skill link .

Standalone Installation

# Make executable
chmod +x clawdscan.py

# Add to PATH (optional)
ln -s $(pwd)/clawdscan.py /usr/local/bin/clawdscan

# Test installation
clawdscan --version

Package Structure

clawdscan/
β”œβ”€β”€ clawdscan.py              # Main executable
β”œβ”€β”€ skill.json               # Clawdbot skill metadata  
β”œβ”€β”€ SKILL.md                 # Complete documentation
β”œβ”€β”€ LICENSE                  # MIT license
β”œβ”€β”€ heartbeat-integration.md # Heartbeat integration guide
β”œβ”€β”€ TASK.md                 # Development task spec
└── README.md               # This file

Development

Testing

# Test against live sessions
clawdscan scan

# Test all commands
clawdscan top -n 5
clawdscan history --days 7
clawdscan disk

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

Integration Examples

Heartbeat Monitoring

# Add to HEARTBEAT.md
clawdscan scan --json /tmp/health.json
if [[ $(jq '.bloated_sessions | length' /tmp/health.json) -gt 5 ]]; then
  echo "πŸ”₯ Bloated sessions detected - cleanup needed"
fi

Cron Jobs

# Daily health check
0 2 * * * clawdscan scan --json /var/log/clawdscan-$(date +\%Y\%m\%d).json

# Weekly cleanup
0 3 * * 0 clawdscan clean --stale-days 14 --execute

Python Integration

import subprocess
import json

result = subprocess.run(['clawdscan', 'scan', '--json', '/tmp/scan.json'])
with open('/tmp/scan.json') as f:
    data = json.load(f)
    
if len(data['bloated_sessions']) > 5:
    notify_admin("Clawdbot cleanup needed")

Configuration

Environment Variables

  • CLAWDBOT_DIR - Override default Clawdbot directory
  • NO_COLOR - Disable colored output
  • CLAWDSCAN_AUTO_CLEANUP - Enable automatic cleanup

Thresholds (customizable)

  • Bloat Size: 1 MB
  • Bloat Messages: 300
  • Stale Threshold: 7 days
  • Zombie Threshold: 48 hours

Addresses

This tool addresses GitHub Issue #1808 - Clawdbot session bloat and disk usage management.

🀝 Contributing

Found a bug? Have an idea? Open an issue or submit a PR!

If this tool saved you time, please ⭐ star this repo β€” it helps others find it.

License

MIT License - see LICENSE for details.

Support

  • πŸ“– Documentation: SKILL.md
  • πŸ› Issues: GitHub Issues
  • πŸ’¬ Community: Clawdbot Discord server

More from Jugaad Lab πŸ”§

Tool What it does
claude-code-mastery Master Claude Code with subagents & automation
tokenmeter Track AI token usage & costs locally
clawguard Security blacklist for AI agents
clawdscan Session health analyzer for OpenClaw
skilldoc Skill health checker for OpenClaw
tribe-protocol Trust & access control for AI bots
discord-voice-plugin Voice conversations with AI in Discord
worldmonitor Real-time global intelligence dashboard

⭐ Found these useful? Star the repos you like!


Version 0.1.0 - Built with ❀️ for the Clawdbot community

About

Session health analyzer for Clawdbot/OpenClaw. Diagnose bloat, find zombies, reclaim disk space. Zero dependencies.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages