session-cleaner

Remove OpenClaw sessions, back up sessions.json, and restart the gateway.

1|Updated Jan 30, 2026
One-click install
npx skills add https://github.com/xdrshjr/JR-Agent-Skills --skill session-cleaner
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: session-cleaner
Source: https://github.com/xdrshjr/JR-Agent-Skills/tree/main/session-cleaner
Command: npx skills add https://github.com/xdrshjr/JR-Agent-Skills --skill session-cleaner

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill automates the cleanup of OpenClaw sessions, clearing context and restarting the gateway to provide a clean state for the next user interaction.

Core Features & Use Cases

  • Session cleanup: closes all sub-agent sessions and purges transient data.
  • Context reset: clears runtime context to avoid data leakage between runs.
  • Safe recovery: backs up current sessions.json and restarts the gateway to recover a clean state.

Quick Start

Quick cleanup (keep current session) commands: openclaw sessions list pkill -9 -f "openclaw-gateway" python3 ~/clawd/skills/session-cleaner/scripts/clean_sessions.py openclaw gateway start

Full reset workflow: User should send: /new Then run the cleanup steps above

Frequently Asked Questions about session-cleaner

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

FAQPage Schema
How do I clean up OpenClaw sessions and reset the runtime context?

To clean up OpenClaw sessions, the script removes all sessions and resets the runtime context. It backs up sessions.json, preserves the main current session by default, and restarts the gateway to finalize the cleanup.

How do I perform a full context reset for all OpenClaw sub-agents?

A full context reset for sub-agents requires sending the /new command before running the cleanup steps. This purges transient data across all user sessions and clears the runtime context to avoid data leakage between runs.

Does session cleanup preserve my current OpenClaw session?

Session cleanup preserves your current OpenClaw session by default. The process backs up sessions.json before closing all sub-agent sessions, ensuring you retain your main active session while clearing transient data.

Why do I need to restart the OpenClaw gateway after clearing sessions?

Restarting the OpenClaw gateway is required to finalize the session cleanup and recover a clean state. The script stops the gateway process using pkill before executing the cleanup and restarts it afterward.

What is the best way to safely back up sessions.json before an OpenClaw context reset?

The safest way to back up sessions.json before a context reset is to use the cleanup script, which automatically creates a backup of the file. This safe recovery mechanism ensures your session data is preserved before purging transient runtime data.

Can I use session cleanup scripts for quick cleanup without losing my active session?

You can use the cleanup script for quick cleanup without losing your active session. The script backs up sessions.json and preserves the main current session by default while closing all sub-agent sessions and clearing runtime context.