Install
openclaw skills install @liujc007/context-cleaner-1Automatically compress large contexts and clean up expired sessions, sub-agents, and temporary files.
openclaw skills install @liujc007/context-cleaner-1Automatically manage session context size by compressing large contexts and cleaning up expired sessions, sub-agents, and temporary files.
| Situation | Action |
|---|---|
| Session exceeds size limit | Compress early messages |
| Sub-agent idle > 30min | Terminate automatically |
| Old sessions (> 7 days) | Archive or delete |
| Large context (> 10K tokens) | Summarize and compress |
No special setup required. The skill automatically:
The skill runs automatically during heartbeat checks when context size exceeds thresholds.
Request cleanup anytime:
"Clean up context now"
"Remove expired sessions"
"Compress my context"
Use sessions_list and subagents tools internally. The skill orchestrates:
When a session's context exceeds thresholds:
Expired session criteria:
Termination criteria:
Add to HEARTBEAT.md:
## 上下文管理
- [ ] 检查会话大小
- [ ] 清理过期子代理
- [ ] 压缩过大上下文
Schedule regular cleanup:
# Weekly full cleanup
cron add -name "weekly-context-clean" -schedule "0 3 * * 0" -payload "Compress contexts and clean expired sessions"
Convert:
User: Ask question
Model: Answer with detailed explanation
User: Follow-up
Model: More details
To:
User: Ask question
Model: ✅ Answered with 4-point explanation
User: Follow-up
Model: Continued discussion
Summarize long conversation threads:
Archive strategy:
workspace/
├── .archive/ # Archived sessions
│ ├── 2026-04/
│ │ ├── session-uuid-1/
│ │ └── session-uuid-2/
│ └── 2026-05/
├── .cache/ # Temporary compression data
└── .cleanup/ # Cleanup logs and reports
└── cleanup-report.md
Before any cleanup operation:
## Context Cleanup Report
**Time**: 2026-04-17 10:43
**Operations**:
- ✅ Compressed 3 large contexts (saved 15K tokens)
- ✅ Terminated 2 idle sub-agents
- ✅ Archived 1 old session (30 days)
- ⚠️ Skipped 1 active session (pending task)
**Impact**:
- Context size: Reduced by 25%
- Free tokens: ~50K available
- Active sessions: 5 (unchanged)
Note: This skill works alongside existing OpenClaw tools without requiring special permissions.