Claude-code-sessions session-cleanup

install
source · Clone the upstream repo
git clone https://github.com/apappascs/claude-code-sessions
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/apappascs/claude-code-sessions "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/session-cleanup" ~/.claude/skills/apappascs-claude-code-sessions-session-cleanup && rm -rf "$T"
manifest: skills/session-cleanup/SKILL.md
source content

Session Cleanup

Find session files that are candidates for cleanup.

Step 1: Identify candidates

bun run ${CLAUDE_PLUGIN_ROOT}/lib/session-store.ts cleanup --min-messages 3

To also find old sessions:

bun run ${CLAUDE_PLUGIN_ROOT}/lib/session-store.ts cleanup --older-than 30d --min-messages 3

Step 2: Present candidates

The script outputs a JSON object with

candidates
array and
total_size_bytes
. Present as a table:

#Session IDProjectReasonMessagesAgeSize

Show the total reclaimable space.

Step 3: Confirm before deleting

NEVER delete without explicit user confirmation. Present the list and ask:

"Found N sessions (X total) that could be cleaned up. Want me to delete them? (yes/no)"

If confirmed, delete each session using the delete command:

bun run ${CLAUDE_PLUGIN_ROOT}/lib/session-store.ts delete-session <session-id>

This will also report any task lists that become orphaned.

For manual deletion, the file path is also shown:

rm "<path-to-session.jsonl>"

Report each deletion. If the user wants to keep some, ask which ones to skip.

Step 4: Check for orphan task lists

After cleanup, check for task lists that no longer have matching sessions:

bun run ${CLAUDE_PLUGIN_ROOT}/lib/session-store.ts orphan-task-lists

If orphans are found, present them:

Task List IDTasksLast Modified

Ask: "Found N orphan task lists with no matching session. Delete them? (yes/no/select)"

If confirmed, delete using:

bun run ${CLAUDE_PLUGIN_ROOT}/lib/session-store.ts delete-task-list <task-list-id>

Or the user can inspect and delete manually:

ls ~/.claude/tasks/<task-list-id>/
rm -r ~/.claude/tasks/<task-list-id>/

Safety

  • The script only identifies candidates — it never deletes
  • Always show the full list before asking for confirmation
  • Delete one file at a time, reporting each
  • If in doubt, suggest the user review the list first