session-cleanup

Clean up OpenClaw session storage across all agents. Removes tombstone files (.reset, .deleted, .bak), old cron session .jsonl files, orphan files, and stale sessions.json entries. Use when session folders are bloated, disk space is low, or as part of daily/nightly maintenance. Triggers on "clean sessions", "session cleanup", "session bloat", "free disk space", "maintenance", "clean up agents".

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "session-cleanup" with this command: npx skills add duolahypercho/hypercho-session-cleanup

Session Cleanup

Automated cleanup of OpenClaw session storage across all registered agents.

What It Cleans

  1. Tombstone files.reset.*, .deleted.*, .bak-* (always safe to remove)
  2. Old cron sessions.jsonl files + sessions.json entries older than 7 days for cron-type sessions
  3. Orphan files.jsonl files on disk not referenced by sessions.json
  4. Stale entriessessions.json entries pointing to missing .jsonl files (cron sessions only)

Safety Guarantees

  • Never touches .lock files or their corresponding active .jsonl
  • Never deletes sessions.json itself
  • Backs up sessions.json before modifying
  • Never removes non-cron sessions under 30 days old
  • Never removes main session entries

Usage

Run cleanup for all agents

python3 <skill_dir>/scripts/session_cleanup.py

Dry run (preview only)

python3 <skill_dir>/scripts/session_cleanup.py --dry-run

Single agent only

python3 <skill_dir>/scripts/session_cleanup.py --agent main

Agent Discovery

The script automatically discovers all agents by scanning ~/.openclaw/agents/*/sessions/. No hardcoded agent list needed — new agents are picked up automatically.

Cron Integration

Set up as a daily midnight cron job for automatic maintenance:

Schedule: 0 0 * * * (midnight local time)
Model: minimax/MiniMax-M2.7-highspeed
Thinking: low
Timeout: 600s

Cron task message:

Single task only: run session cleanup for all agents.

Command:
bash -lc 'python3 <skill_dir>/scripts/session_cleanup.py'

Return ONLY the command stdout (no extra commentary).

Output Format

The script prints a summary per agent showing what was cleaned, then a grand total:

Agents discovered: 22

  ada: 165 tombstones (21.1 MB), 7 old crons (372 KB)
  vera: 924 tombstones (31.6 MB), 4 old crons (252 KB)

✅ Session cleanup complete across 22 agents
   Freed: 171.6 MB
   Cleaned: ada, vera
   Already clean: main, clio, argus

If nothing needs cleaning, it reports "Already clean. Nothing to do."

Retention Policy

Session TypeRetentionAction
Tombstones (.reset/.deleted/.bak)0 daysAlways delete
Cron session files7 daysDelete after 7 days
Non-cron sessions30 daysKeep (no auto-delete)
Main sessionsForeverNever touched
Active sessions (.lock)ForeverNever touched

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

Canonry Setup

Agent-first AEO operating platform.

Registry SourceRecently Updated
4151arberx
Automation

Pilot Service Agents Entertainment

Games, manga/anime, trivia, and fandom APIs — PokeAPI, Jikan, CheapShark, misc. Use this skill when: 1. Pokémon / PokeAPI lookups 2. Anime or manga metadata...

Registry SourceRecently Updated
Automation

Pilot Service Agents Economics

Macroeconomic indicators — IMF DataMapper, World Bank, Eurostat SDMX, Coinbase reference prices. Use this skill when: 1. Country-level GDP, inflation, or une...

Registry SourceRecently Updated
Automation

Pilot Service Agents Flights

Aircraft tracking and aviation weather — ADS-B feeds (ICAO + bbox), airport directory, METAR/TAF/SIGMET. Use this skill when: 1. Live aircraft positions by I...

Registry SourceRecently Updated