openclaw-session-cleaner

Deletes stale OpenClaw cron session files and rebuilds sessions.json to match disk state.

733|99|Updated Dec 19, 2025
One-click install
npx skills add https://github.com/chujianyun/skills --skill openclaw-session-cleaner
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: openclaw-session-cleaner
Source: https://github.com/chujianyun/skills/tree/main/skills/operations/openclaw-session-cleaner
Command: npx skills add https://github.com/chujianyun/skills --skill openclaw-session-cleaner

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

OpenClaw accumulates thousands of old cron session files under ~/.openclaw/agents/main/sessions/, which bloats sessions.json and slows down session management. This Skill inspects the session directory, removes obsolete .jsonl files while preserving the main session, and rebuilds sessions.json so it only references files that still exist on disk.

Core Features & Use Cases

  • Session Inventory Check: Counts session files and measures sessions.json size before taking any action.
  • Safe Cleanup: Deletes old cron session .jsonl files while explicitly preserving the main session to avoid losing the primary conversation.
  • Index Rebuild: Reconstructs sessions.json so it only references sessions that still exist on disk, then reports before-and-after counts.
  • Use Case: After weeks of scheduled cron runs, your OpenClaw sessions.json has grown to several megabytes with thousands of stale entries. Invoke this Skill to prune the old cron sessions and shrink the index back to a healthy size.

Quick Start

Clean up my OpenClaw sessions by deleting old cron session files and rebuilding sessions.json.

Frequently Asked Questions about openclaw-session-cleaner

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I clean up old OpenClaw session files?

Check the file count and sessions.json size under ~/.openclaw/agents/main/sessions/, delete old cron .jsonl session files while keeping the main session, then rebuild sessions.json so it only references files still on disk.

Why is my OpenClaw sessions.json file so large?

Repeated cron runs create a new session file each time, and sessions.json keeps referencing all of them. Over weeks this accumulates thousands of stale entries, bloating the index and slowing session operations.

Will cleaning OpenClaw sessions delete my main conversation?

No. The cleanup explicitly preserves the main session and only removes old cron session files. After deletion, sessions.json is rebuilt to reference only sessions that still exist on disk.

How do I rebuild sessions.json after deleting session files?

After removing stale .jsonl files, regenerate sessions.json so every entry points to a session file that actually exists on disk. Then report the before-and-after file counts to confirm the cleanup completed.

When should I not delete OpenClaw session files?

Avoid deleting sessions if you need cron run history for auditing or debugging past executions. The cleanup targets only old cron sessions, so verify which files are stale before removal.