cleanup-sessions
Remove old pi session files to reclaim disk space
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Remove old pi session files to reclaim disk space
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Consolidate and clean up existing brain memory. Run this periodically (like a sleep cycle) to dedupe, decay, merge, and relocate memories to vault.
Testing-focused coding workflow. Extends code-assist with enhanced test generation, coverage analysis, and test quality gates.
Systematic debugging workflow for diagnosing and fixing issues. Follows a structured approach to isolate problems, form hypotheses, and verify fixes.
Generate documentation from code or scratch - READMEs, API docs, changelogs, and user guides. Complements codebase-summary which analyzes existing code.
Extract durable learnings and preferences from the current conversation for memory capture. Use this after a conversation to capture what should be remembered.
Track skill usage with correctness scoring, generate reports, and identify unused or misused skills for pruning.
| name | cleanup-sessions |
| description | Remove old pi session files to reclaim disk space |
| kind | sop |
Delete old session JSONL files from ~/.pi/agent/sessions/ to reclaim disk space. Supports two cutoff modes: relative (N days ago) or absolute (specific date/time). Reports what will be removed before deleting, and summarizes results.
7): Delete sessions older than this many days. Ignored if cutoff_date is set.YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ. If set, max_age_days is ignored.false): If true, only report what would be deleted without removing files.--Users-jmeng-kibi--). If omitted, all project directories are scanned.Run:
du -sh ~/.pi/agent/sessions/
If the directory does not exist or is empty, report "No sessions found" and stop.
If cutoff_date is set (absolute mode):
Create a reference file with the cutoff timestamp, then find sessions older than it:
touch -t "$(date -j -f '%Y-%m-%dT%H:%M:%SZ' '{cutoff_date}' '+%Y%m%d%H%M.%S' 2>/dev/null || date -j -f '%Y-%m-%d' '{cutoff_date}' '+%Y%m%d0000.00')" /tmp/_session_cutoff
find ~/.pi/agent/sessions/ -name "*.jsonl" ! -newer /tmp/_session_cutoff | wc -l
find ~/.pi/agent/sessions/ -name "*.jsonl" ! -newer /tmp/_session_cutoff -exec du -ch {} + | tail -1
rm -f /tmp/_session_cutoff
If max_age_days is set (relative mode, default 7):
find ~/.pi/agent/sessions/ -name "*.jsonl" -mtime +{max_age_days} | wc -l
find ~/.pi/agent/sessions/ -name "*.jsonl" -mtime +{max_age_days} -exec du -ch {} + | tail -1
If project_filter is set, scope the find to that subdirectory (e.g., ~/.pi/agent/sessions/{project_filter}/).
Note: If the find command is wrapped by rtk (which does not support compound predicates like ! -newer), use a shell script or xargs pipeline instead.
Show:
du -sh ~/.pi/agent/sessions/*/)If dry_run is true, stop after step 3 and report "Dry run complete — no files deleted."
Otherwise, proceed to deletion.
If cutoff_date is set (absolute mode):
touch -t "$(date -j -f '%Y-%m-%dT%H:%M:%SZ' '{cutoff_date}' '+%Y%m%d%H%M.%S' 2>/dev/null || date -j -f '%Y-%m-%d' '{cutoff_date}' '+%Y%m%d0000.00')" /tmp/_session_cutoff
find ~/.pi/agent/sessions/ -name "*.jsonl" ! -newer /tmp/_session_cutoff -print0 | xargs -0 rm -v
rm -f /tmp/_session_cutoff
If max_age_days is set (relative mode):
find ~/.pi/agent/sessions/ -name "*.jsonl" -mtime +{max_age_days} -print0 | xargs -0 rm -v
Note: If the find command is wrapped by rtk (which does not support compound predicates), pipe through xargs -0 rm as shown above.
Run:
du -sh ~/.pi/agent/sessions/
du -sh ~/.pi/agent/sessions/*/
Report:
find ... -print0 | xargs -0 rm instead.ls -la.max_age_days or running with dry_run: false to confirm.Clean sessions older than 7 days (default):
/skill run cleanup-sessions
Clean sessions older than 3 days:
/skill run cleanup-sessions max_age_days=3
Clean sessions before a specific date:
/skill run cleanup-sessions cutoff_date=2026-05-01
Clean sessions before a specific date and time:
/skill run cleanup-sessions cutoff_date=2026-05-07T00:00:00Z
Preview what would be deleted (no actual removal):
/skill run cleanup-sessions dry_run=true
Only clean kibi project sessions:
/skill run cleanup-sessions project_filter=--Users-jmeng-kibi--