Session Cleanup for Openclaw

A specialized utility for Openclaw Skills designed to safely purge orphan .jsonl files and expired session data to reclaim storage space.

irideas
v0.3.0
Mar 6, 2026
0
1.3k
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install session-cleanup-pro

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install session-cleanup-pro using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Session Cleanup?

The Session Cleanup skill provides a robust mechanism for maintaining the storage health of your AI agent environment. It is specifically engineered to identify and remove orphan .jsonl files—data residues that exist on disk but are no longer tracked in the session registry—as well as pruning outdated session logs. This ensures that Openclaw Skills maintain high performance and a clean workspace by preventing the accumulation of redundant data.

This skill prioritizes data safety through a multi-step audit process. It protects recent sessions within a 72-hour window and ensures that critical system sessions are never deleted. By generating a comprehensive cleanup plan before execution, it gives developers full control over their data lifecycle management.

Session Cleanup Use Cases

  • Decluttering session lists when history becomes unmanageable or disorganized.
  • Reclaiming disk space by purging large, accumulated .jsonl log files.
  • Auditing storage to identify and remove orphan files not registered in the system.
  • Managing the lifecycle of temporary agent interactions to keep the Openclaw Skills environment lean.

How Session Cleanup Works

  1. The skill initiates a read-only scan of the session directory using a specialized bash script.
  2. It cross-references files on the disk with the entries in the sessions.json registry to detect orphan files.
  3. It categorizes sessions into stale (older than 72 hours), protected (recent), and permanent (core system agents).
  4. A summary report is generated, detailing the number of files to be removed and the estimated disk space to be freed.
  5. The skill waits for explicit user confirmation before executing any deletion commands.
  6. Upon confirmation, it removes the files and updates the session registry to maintain data integrity.

Session Cleanup Setup

To use this skill within your Openclaw Skills setup, ensure that bash and node are available in your environment.

First, make the scan script executable:

chmod +x ./skills/session-cleanup/scripts/scan_sessions.sh

Run the scan to generate a report:

./skills/session-cleanup/scripts/scan_sessions.sh scan

Session Cleanup Data Schema & Taxonomy

The skill interacts with the following data structures to manage Openclaw Skills storage:

Component Type Description
orphanFiles List Files present on disk but missing from sessions.json.
staleSessions List Sessions older than 72 hours and not marked as protected.
protectedSessions List Recent sessions and essential core agent data.
sessions.json Registry The primary index used to validate session existence.

Session Cleanup Advanced Features

  • Intelligent orphan detection for files disconnected from the main session registry.
  • Configurable 72-hour safety window to prevent the loss of recent session data.
  • Hard-coded protection for core agents like agent:main:main to prevent system instability.
  • JSON-formatted reporting for easy integration with other automation pipelines in Openclaw Skills.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Requires
Bins bashnode
Github Stars: 0
forks: 0

Featured*