agentleFS
apappascsapappascs/claude-code-sessions/skills/session-cleanup/SKILL.md

session-cleanup

Skill2 starsChanged 26 days agoMITView on GitHub

Finds old, empty, or tiny Claude Code session files that are candidates for deletion. Use when the user wants to clean up sessions, free disk space, says "clean up old sessions", or asks about session storage usage.

7 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use handoff.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MicrosoftSkill

    handoff

    Compact the current conversation into a handoff document for another agent to pick up.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 7 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If confirmed, delete each session using the delete command:

    line 39
  2. Distinctive:

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

    line 55
  3. Distinctive:

    If orphans are found, present them:

    line 61
  4. Very specific:

    Ask: "Found N orphan task lists with no matching session.

    line 66
  5. Distinctive:

    If confirmed, delete using:

    line 68
  6. Distinctive:

    Always show the full list before asking for confirmation

    line 82
  7. Distinctive:

    Delete one file at a time, reporting each

    line 83
  8. Distinctive:

    If in doubt, suggest the user review the list first

    line 84

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.