← 返回
开发者工具 中文

Swarm Janitor

Enterprise-grade OpenClaw skill for cleaning up orphaned subagent processes, archiving transcripts to SuperMemory, and freeing disk space without losing work. Features dry-run mode, configurable retention policies, and comprehensive safety checks.
企业级OpenClaw技能,用于清理孤立子代理进程、将记录归档至SuperMemory,并在保留工作的同时释放磁盘空间。支持试运行模式、可配置保留策略及全面的安全检查。
lvcidpsyche lvcidpsyche 来源
开发者工具 clawhub v0.1.0 1 版本 99939.3 Key: 无需
★ 2
Stars
📥 1,606
下载
💾 23
安装
1
版本
#latest

概述

Swarm Janitor

Enterprise-grade cleanup tool for OpenClaw subagent management.

What It Does

Automatically identifies and cleans up orphaned subagent sessions while preserving important work through SuperMemory archival.

Core Functions

  • Scan: Analyze session directory for orphaned/abandoned subagents
  • Archive: Save transcripts to SuperMemory before deletion
  • Clean: Safely remove orphaned sessions freeing disk space
  • Report: Generate detailed cleanup reports

Safety First

This skill implements multiple safety layers:

  • Never deletes active sessions — checks process status
  • Dry-run mode — preview changes before executing
  • SuperMemory backup — transcripts archived before deletion
  • Configurable retention — customize age thresholds
  • Detailed logging — full audit trail of all actions

Quick Start

# Preview what would be cleaned (dry-run)
python3 scripts/swarm_janitor.py --dry-run

# Archive old sessions to SuperMemory, then clean
python3 scripts/swarm_janitor.py --archive --clean

# Custom retention (7 days instead of default 3)
python3 scripts/swarm_janitor.py --retention-days 7 --clean

Installation

  1. Copy this skill to your OpenClaw workspace:

```bash

cp -r skills/swarm-janitor ~/.openclaw/workspace/skills/

```

  1. Configure retention policy (optional):

```bash

# Edit config to customize

nano references/config.yaml

```

  1. Run first scan:

```bash

python3 ~/.openclaw/workspace/skills/swarm-janitor/scripts/swarm_janitor.py --dry-run

```

Usage Patterns

Daily Maintenance (Cron)

# Run daily at 3 AM, archive sessions older than 3 days
0 3 * * * python3 ~/.openclaw/workspace/skills/swarm-janitor/scripts/swarm_janitor.py --archive --clean --retention-days 3 >> /var/log/swarm-janitor.log 2>&1

Manual Cleanup

# See what would be deleted
python3 scripts/swarm_janitor.py --dry-run --verbose

# Archive transcripts to SuperMemory
python3 scripts/swarm_janitor.py --archive

# Clean without archiving (not recommended)
python3 scripts/swarm_janitor.py --clean --no-archive

# Full report
python3 scripts/swarm_janitor.py --report --output json

Emergency Cleanup

# Aggressive cleanup with 1-day retention
python3 scripts/swarm_janitor.py --clean --retention-days 1 --force

Configuration

See references/config.yaml for:

  • Retention policies
  • Archive destinations
  • Safety thresholds
  • Logging options

How It Works

  1. Discovery: Scans ~/.openclaw/agents/main/sessions/
  2. Analysis: Determines session age, activity status, size
  3. Classification: Identifies orphaned vs active sessions
  4. Archival: Saves transcripts to SuperMemory (if enabled)
  5. Cleanup: Safely removes orphaned session files
  6. Reporting: Generates summary of actions taken

Safety Mechanisms

CheckDescription
--------------------
Process CheckVerifies no active process owns the session
Age VerificationOnly processes sessions older than threshold
Size LimitsWarns on unusually large deletions
Dry-Run DefaultPreview mode is default — explicit action required
Backup FirstArchives to SuperMemory before any deletion

Troubleshooting

Q: It says "permission denied"

A: Ensure you have write access to the sessions directory

Q: Sessions not being detected

A: Check the path in config.yaml matches your OpenClaw installation

Q: SuperMemory archive failing

A: Verify SuperMemory skill is configured with valid API key

Enterprise Features

  • Audit Logging: All actions logged with timestamps
  • Configurable Policies: YAML-based configuration
  • Metrics Export: JSON/CSV output for monitoring
  • Dry-Run Mode: Test changes before applying
  • Retention Policies: Age-based and count-based rules

License

MIT - Created by OpenClawdad (Redclay) for the OpenClaw community.

版本历史

共 1 个版本

  • v0.1.0 当前
    2026-03-28 20:29 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,385 📥 321,018
ai-agent

self-improving agent

pskoett
捕获经验教训、错误及修正内容,以实现持续改进。适用于以下场景:(1)命令或操作意外失败;(2)用户纠正Claude(如“不,那不对……”“实际上……”);(3)用户请求的功能不存在;(4)外部API或工具出现故障;(5)Claude发现自身
★ 4,086 📥 814,857
it-ops-security

Bomb Dog Sniff

lvcidpsyche
OpenClaw的安全优先技能管理——如同嗅探炸弹的警犬。在安装前嗅探恶意载荷(加密窃贼、键盘记录器、反向Shell)。执行隔离→扫描→仅安装安全项目的流程。
★ 2 📥 1,857