Session Cleanup Pro
Clean orphan .jsonl files and stale sessions in OpenClaw session storage with safe confirmation flow. 适用于会话列表杂乱、历史会话堆积、需要释放存储空间场景;默认保护 72 小时内会话,删除前必须用户确认。
MIT-0 · Free to use, modify, and redistribute. No attribution required.
⭐ 0 · 176 · 0 current installs · 0 all-time installs
by@irideas
MIT-0
Security Scan
OpenClaw
Benign
high confidencePurpose & Capability
Name/description, included script (scripts/scan_sessions.sh), and SKILL.md are consistent: the skill scans sessions.json and the sessions directory for orphan .jsonl and stale sessions. Required binaries (bash, node) are appropriate for the provided scripts. No unrelated credentials, config paths, or third-party services are requested.
Instruction Scope
SKILL.md enforces a scan → confirm → apply flow and documents destructive commands (rm) to remove orphan .jsonl and update sessions.json. The provided script only performs a read-only scan and outputs JSON; deletion instructions are explicit in SKILL.md but not implemented as an automated delete in scripts. This is coherent, but the instructions do include direct rm commands (destructive) so operator confirmation and backups are essential.
Install Mechanism
No install spec (instruction-only + one local script). Nothing is downloaded or extracted from external URLs; code is included in the package. This is low-risk from an install perspective.
Credentials
The skill does not require credentials or config paths. The script honors optional environment overrides OPENCLAW_STATE_DIR and OPENCLAW_AGENT_ID (with safe defaults). Those are proportional and relevant to locating session files.
Persistence & Privilege
always is false and the skill is user-invocable. It does not attempt to modify other skills or agent-wide settings. It does not persist credentials or try to enable itself automatically.
Assessment
This skill appears to do what it says: scan the OpenClaw session directory and propose deletions. Before running any cleanup: 1) Run the scan only (./skills/session-cleanup/scripts/scan_sessions.sh scan) and carefully inspect the JSON output. 2) Back up sessions.json and any .jsonl files you might want to keep (or archive them to a different directory) rather than immediate rm. 3) Be mindful of OPENCLAW_STATE_DIR and OPENCLAW_AGENT_ID environment overrides — if they are set, the script will operate on those paths instead of the defaults. 4) Prefer archiving/moving orphan files first; only perform hard deletes after a second, explicit confirmation. 5) Note that the provided script is read-only; the SKILL.md contains example rm commands which are destructive and must be executed deliberately. There are no network calls or hidden endpoints in the package. If you want extra safety, test on a copy of your state directory or run the scan in a non-production environment first.Like a lobster shell, security has layers — review code before you run it.
Current versionv0.3.0
Download ziplatest
License
MIT-0
Free to use, modify, and redistribute. No attribution required.
Runtime requirements
🧹 Clawdis
Binsbash, node
SKILL.md
Session Cleanup
清理 OpenClaw 会话目录中的孤儿文件与过期会话,优先安全、可审计。
使用方式
先扫描,再确认,再执行:
- 扫描(只读)
- 生成清理计划
- 用户确认
- 执行清理并回报结果
关键文件
- 扫描脚本:
scripts/scan_sessions.sh - 清理策略:
references/policy.md
扫描命令(必做)
./skills/session-cleanup/scripts/scan_sessions.sh scan
返回 JSON 包含:
orphanFiles:磁盘存在但sessions.json未登记的.jsonlstaleSessions:超过 72 小时且非受保护会话protectedSessions:当前会话 + 72 小时保护窗口内会话
执行规则
- 必须先扫描并展示摘要
- 必须询问用户确认后才清理
- 默认不删除受保护会话
- 永不删除
agent:main:main
清理建议
A. 先处理孤儿文件(优先)
在用户确认后删除孤儿文件:
rm ~/.openclaw/agents/main/sessions/<orphan>.jsonl
B. 再处理过期会话(谨慎)
仅在用户明确确认后执行,删除对应 .jsonl,并更新 sessions.json 去除条目。
输出模板
🧹 会话清理扫描完成
- 注册会话:X
- 磁盘 jsonl:Y
- 孤儿文件:A
- 过期会话:B
- 受保护会话:C
预计可释放:N MB
是否按上述计划执行清理?
发布前自检
# 1) 脚本可执行
./skills/session-cleanup/scripts/scan_sessions.sh scan >/tmp/session-cleanup-report.json
# 2) 输出为有效 JSON
node -e "JSON.parse(require('fs').readFileSync('/tmp/session-cleanup-report.json','utf8')); console.log('OK')"
Files
4 totalSelect a file
Select a file to preview.
Comments
Loading comments…
