ContextClaw Plugin Usage
by @rmruss2022
Manage and analyze OpenClaw sessions by checking usage, pruning old sessions, cleaning orphaned files, and viewing stats via CLI or dashboard.
clawhub install contextclaw-usageπ About This Skill
ContextClaw Plugin Usage
When to Use
Use this skill when the user asks about:
Prerequisites
The ContextClaw plugin must be installed:
npm install -g @rmruss2022/contextclaw
openclaw plugins install @rmruss2022/contextclaw
Quick Start
Check if ContextClaw is installed and running:
openclaw contextclaw status
Commands
Analyze Sessions
Get comprehensive analysis of all sessions:openclaw contextclaw analyze
This shows:
Prune Old Sessions
Clean up sessions older than N days (default: 30):# Dry run (preview only, safe)
openclaw contextclaw prune --days 30Live run (actually deletes)
openclaw contextclaw prune --days 30 --dryRun false
Safety features:
Clean Orphaned Sessions
Remove session files not referenced in sessions.json:# Dry run
openclaw contextclaw clean-orphanedLive run
openclaw contextclaw clean-orphaned --dryRun false
Dashboard
Open the visual session management dashboard:openclaw contextclaw dashboard
This opens http://localhost:18797Quick Stats
Show brief status and statistics:openclaw contextclaw status
Configuration
Reconfigure port or OpenClaw home:openclaw contextclaw setup
Dashboard Features
The dashboard at http://localhost:18797 provides:
Example Usage
User asks: "How much storage are my sessions using?"
Response:
openclaw contextclaw analyze
Look at the "Total Size" metric in the summary table.User asks: "Clean up old sessions"
Response:
# First preview what would be deleted
openclaw contextclaw prune --days 30If approved, run live:
openclaw contextclaw prune --days 30 --dryRun false
User asks: "Which sessions are taking up the most space?"
Response:
openclaw contextclaw analyze
Check the "Largest Sessions" table, or open the dashboard:
openclaw contextclaw dashboard
User asks: "Remove orphaned session files"
Response:
# Preview first
openclaw contextclaw clean-orphanedIf user approves, run live:
openclaw contextclaw clean-orphaned --dryRun false
Session Types
ContextClaw categorizes sessions as:
Orphaned Sessions
A session is orphaned if:
.jsonl file exists in sessions directorysessions.jsonCommon causes:
Orphaned sessions are safe to delete.
Best Practices
1. Analyze regularly - Weekly or monthly: openclaw contextclaw analyze
2. Always dry-run first - Preview before deleting
3. Adjust age threshold - 30 days is default, adjust as needed
4. Review orphaned - Check before cleaning
5. Backup if worried - Though main/cron are protected
Troubleshooting
If dashboard won't load:
openclaw contextclaw status # Check if running
openclaw contextclaw start # Start if stopped
If port is in use:
openclaw contextclaw setup
Choose a different port
Technical Details
.jsonl files in ~/.openclaw/agents/main/sessions/Example Output
Analyze Command
π Session Analysisββββββββββββββββββββ¬βββββββββ
β Metric β Value β
ββββββββββββββββββββΌβββββββββ€
β Total Sessions β 45 β
β Total Messages β 3,842 β
β Total Tokens β 156,234β
β Total Size β 12.4 MBβ
β Orphaned β 8 β
ββββββββββββββββββββ΄βββββββββ
Prune Command
π§Ή Session Pruningβ οΈ DRY RUN MODE - No files will be deleted
Sessions older than 30 days:
β Would delete: 12
- Would keep: 33
- Space freed: 4.2 MB
? Run prune in LIVE mode (actually delete files)? (y/N)
Repository
GitHub: https://github.com/rmruss2022/ContextClaw npm: @rmruss2022/contextclaw
β‘ When to Use
π‘ Examples
Check if ContextClaw is installed and running:
openclaw contextclaw status
βοΈ Configuration
Reconfigure port or OpenClaw home:
openclaw contextclaw setup
π Tips & Best Practices
1. Analyze regularly - Weekly or monthly: openclaw contextclaw analyze
2. Always dry-run first - Preview before deleting
3. Adjust age threshold - 30 days is default, adjust as needed
4. Review orphaned - Check before cleaning
5. Backup if worried - Though main/cron are protected