Skip to content
Agentmart
Submit a tool

cleanup-sessions

Remove old pi session files to reclaim disk space

Skill by exoad

IndexedApache-2.0★ 9
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/exoad-cleanup-sessions

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Remove old pi session files to reclaim disk space

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/cleanup-sessions

What's inside

Skill name
cleanup-sessions
Description
Remove old pi session files to reclaim disk space
License
Apache-2.0
Instructions
140 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Cleanup Sessions

## Overview

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.

## Parameters

- **max_age_days** (optional, default: `7`): Delete sessions older than this many days. Ignored if `cutoff_date` is set.
- **cutoff_date** (optional): Absolute cutoff — delete sessions **before** this date. Accepts formats: `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SSZ`. If set, `max_age_days` is ignored.
- **dry_run** (optional, default: `false`): If true, only report what would be deleted without removing files.
- **project_filter** (optional): Only clean sessions for a specific project directory (e.g., `--Users-jmeng-kibi--`). If omitted, all project directories are scanned.

## Steps

### 1. Locate sessions directory

Run:

```bash
du -sh ~/.pi/agent/sessions/
```

If the directory does not exist or is empty, report "No sessions found" and stop.

### 2. Determine cutoff and identify files to delete

**If `cutoff_date` is set (absolute mode):**
Create a reference file with the cutoff timestamp, then find sessions older than it:

```bash
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):**

```bash
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.

### 3. Report findings

Show:

- Number of files that match the age threshold
- Total size that would be freed
- Breakdown by project directory (`du -sh ~/.pi/agent/sessions/*/`)

### 4. Confirm or skip

If **dry_run** is true, stop after step 3 and report "Dry run complete — no files deleted."

Otherwise, proceed to deletion.

### 5. Delete old sessions

**If `cutoff_date` is set (absolute mode):**

```bash
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):**

```bash
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.

### 6. Verify and report results

Run:

```bash
du -sh ~/.pi/agent/sessions/
du -sh ~/.pi/agent/sessions/*/
```

Report:

- Before size → After size → Freed
- Which project directories were emptied
- How many files were removed

## Troubleshooting

- **"find: -delete not supported"**: The rtk wrapper blocks compound predicates. Use `find ... -print0 | xargs -0 rm` instead.
- **Permission denied**: Sessions are owned by the current user — this should not occur. If it does, check file ownership with `ls -la`.
- **No files found**: All sessions are within the age threshold. Consider increasing `max_age_days` or running with `dry_run: false` to confirm.

## Examples

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

From exoad/bibo-agent, Apache-2.0.

More from exoad/bibo-agent

Signals

Stars
9
Forks
0
Open issues
0
Last commit (this folder)
May 10, 2026 (5 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from exoad

Cite this page

cleanup-sessions skill. Agent Mart. https://agentmart.dev/skills/exoad-cleanup-sessions (last updated 2026-10-24)