Install
openclaw skills install @denq04/session-storage-managementAnalyze and clean up OpenClaw session storage files. Use when the user wants to manage session files, clean up old sessions, delete cron/heartbeat, or organize session storage. Triggers on phrases like "clean up sessions", "delete old sessions", "manage session storage", "remove cron sessions", "session cleanup".
openclaw skills install @denq04/session-storage-managementThis skill helps analyze and clean up OpenClaw session files stored in the agents sessions directory. It categorizes sessions by type (cron, chat, deleted, reset, heartbeat), presents them to the user for review, and handles safe deletion while protecting the current active session.
Scan the sessions directory and categorize all session files:
Active .jsonl files - Current session files
.deleted.<timestamp> files - Previously deleted sessions
.reset.<timestamp> files - Sessions from /new or /reset commands
Always identify and exclude the current session from deletion candidates:
# Get current session ID from session context
# It will be in the system prompt or can be extracted from the current session file
The current session should NEVER be deleted without explicit user confirmation in a separate step.
Show summary statistics:
📊 Session Analysis Summary:
├── Active .jsonl files: N total
│ ├── Cron sessions: N
│ ├── Heartbeat sessions: N
│ ├── Chat sessions: N
│ └── Other sessions: N
├── .deleted files: N
└── .reset files: N
✅ Current session (protected): <session-id>
Then ask the user:
"Would you like me to:
- Show the full detailed list of all sessions with descriptions
- Delete specific categories (e.g., 'delete all cron and .deleted files')
- Delete everything except the current session"
If the current session appears in any deletion category (it shouldn't, but check anyway), display a prominent warning:
⚠️ WARNING: Your current session was found in the deletion list!
Session: <session-id>
This is the session you're currently using. Deleting it will not affect
your current conversation, but the session file will be removed.
Do you want to delete your current session file as well? (yes/no)
After user confirmation:
Analyze session content to determine type:
# Example analysis
content=$(head -10 "$file" | jq -r '.message.content[]? | select(.type=="text") | .text' 2>/dev/null | head -5)
if echo "$content" | grep -qiE "cron.*[a-f0-9-]{36}"; then
type="cron"
elif echo "$content" | grep -qiE "heartbeat|HEARTBEAT"; then
type="heartbeat"
elif echo "$content" | grep -qiE "new session|Session Startup"; then
type="chat"
else
type="other"
fi
╔══════════════════════════════════════════════════════════════╗
║ SESSION ANALYSIS ║
╚══════════════════════════════════════════════════════════════╝
📁 Location: ~/.openclaw/agents/main/sessions/
Category Breakdown:
🕐 Cron sessions: 13 (isolated job runs)
💓 Heartbeat sessions: 1
💬 Chat sessions: 2
🗑️ .deleted files: 14
🔄 .reset files: 23
Total files: 56
Estimated size: 12 MB
✅ Protected: <current-session-id> (current conversation)