| name | cmd_prune |
| description | Remove stale session files from the workspace sessions/ directory older than a given age. |
| user-invocable | true |
| origin | openclaw-mas |
| argument-hint | <project-path> [--max-age N] [--dry-run] |
Project Path
The first argument is the project path. Before doing anything else:
- Extract the project path from the first argument
- Verify the path exists
- Work within that directory for all file operations and shell commands
Prune Sessions
Removes old session files from ~/.openclaw/workspace-main/sessions/ that are
older than the specified age threshold. Helps keep the workspace tidy.
Usage
/skill cmd_prune <project-path> # Delete sessions older than 30 days
/skill cmd_prune <project-path> --max-age 60 # Custom age threshold (days)
/skill cmd_prune <project-path> --dry-run # Preview without deleting
Flags
--max-age <N> — age threshold in days (default: 30)
--dry-run — show what would be deleted without deleting
What to Do
-
Determine the sessions directory: ~/.openclaw/workspace-main/sessions/
If it does not exist or is empty, report: "No sessions found." Stop.
-
Parse --max-age from arguments (default: 30 days).
-
List all *.md files in the sessions directory and check their modification time:
find ~/.openclaw/workspace-main/sessions/ -name "*.md" -mtime +<max-age>
-
If no files match, report: "No sessions older than days found." Stop.
-
Show the files that would be deleted:
Sessions to delete (<count>, older than <max-age> days):
- session-2026-01-01.md (modified: 2026-01-01)
- session-2026-01-15.md (modified: 2026-01-15)
-
If --dry-run is set, stop here.
-
Ask: "Delete session files? (yes/no)"
If the user declines, stop.
-
Delete the files:
find ~/.openclaw/workspace-main/sessions/ -name "*.md" -mtime +<max-age> -delete
-
Report:
Pruned <count> session files older than <max-age> days.
Sessions directory: ~/.openclaw/workspace-main/sessions/
Notes
- Only session files in workspace-main/sessions/ are pruned
- The latest session file is always safe — the find command uses mtime, not the filename
- MEMORY.md is never touched by this command