Session Cleanup for Openclaw

A safety-first utility for identifying and removing orphaned files and expired session history within your agent workspace.

irideas
v0.2.1
Mar 6, 2026
0
937
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install bobo-session-cleanup

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 bobo-session-cleanup 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 systematic, audit-friendly approach to managing the storage footprint of your AI agents. It is designed to identify two primary types of data clutter: orphan .jsonl files that are physically present on disk but no longer indexed in the session registry, and stale sessions that have exceeded the standard 72-hour retention window. By prioritizing data safety, it ensures that active or protected sessions—specifically the core main agent session—remain untouched while reclaiming valuable disk space. Incorporating this utility into your Openclaw Skills library helps maintain a lean, high-performance development environment by preventing session bloat.

Session Cleanup Use Cases

  • Reclaiming disk space by identifying and deleting untracked .jsonl session files.
  • Automated auditing of stale agent conversations older than 72 hours.
  • Ensuring the integrity of the sessions.json registry by removing references to missing files.
  • Performing a safety-first cleanup before migrating or backing up agent data in Openclaw Skills.

How Session Cleanup Works

  1. Initialize a read-only scan of the local session directory using the provided shell script.
  2. Cross-reference physical .jsonl files against the sessions.json registry to detect orphans.
  3. Categorize sessions into stale, protected, or main categories based on age and metadata.
  4. Present a detailed cleanup plan to the user, including the number of files and estimated disk space to be freed.
  5. Await explicit user confirmation to ensure no critical data is lost.
  6. Execute the deletion of confirmed orphans and update the registry to reflect the cleaned state.

Session Cleanup Setup

To get started with this skill within your Openclaw Skills environment, ensure you have bash and node installed. Run the following command to perform an initial scan:

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

This will generate a JSON report identifying orphan files and stale sessions without making any changes to your filesystem.

Session Cleanup Data Schema & Taxonomy

The skill manages data across the local agent workspace with a focus on session persistence and metadata accuracy.

Path Description
~/.openclaw/agents/main/sessions/*.jsonl Individual session history files containing message logs.
sessions.json The central registry mapping session IDs to their respective metadata and file paths.
scripts/scan_sessions.sh The primary execution script that outputs the scan results in JSON format.
references/policy.md Documentation defining the retention policies used by Openclaw Skills.

Session Cleanup Advanced Features

  • Hardcoded protection for the agent:main:main session to prevent accidental deletion of core agent state.
  • Automated 72-hour protection window for all recent sessions to preserve ongoing work.
  • JSON-formatted output for easy integration with custom scripts or other Openclaw Skills.
  • Multi-step verification workflow (Scan > Plan > Confirm > Execute) designed for professional developer environments.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Requires
Bins bashnode
Github Stars: 0
forks: 0

Featured*