Skip to content

Comments

feat: add session-manager plugin for listing, deleting, and cleaning up sessions#26328

Open
Kropiunig wants to merge 1 commit intoanthropics:mainfrom
Kropiunig:feat/session-manager-plugin
Open

feat: add session-manager plugin for listing, deleting, and cleaning up sessions#26328
Kropiunig wants to merge 1 commit intoanthropics:mainfrom
Kropiunig:feat/session-manager-plugin

Conversation

@Kropiunig
Copy link

Summary

Adds a session-manager plugin with three commands that address the most-requested missing feature in Claude Code: session lifecycle management.

  • /session-manager:delete — Delete a session by name, UUID prefix, or interactive numbered selection. Always confirms before deleting.
  • /session-manager:list — Cross-project session overview showing timestamps, file sizes, and first-prompt previews — what /resume lacks.
  • /session-manager:cleanup — Bulk-remove sessions by age (--older-than=30d) or size (--smaller-than=5KB) with --dry-run support.

Why this matters

Session history accumulates rapidly. Every claude invocation creates a .jsonl file under ~/.claude/projects/, and there is currently no way to delete or review sessions without manually navigating the filesystem. This is the single most duplicated feature request in the repo:

This plugin provides a working solution today while native support is developed.

Design decisions

  • Plugin, not core change — Keeps the blast radius small. Users opt in by installing the plugin, and the approach follows the same pattern as commit-commands and other utility plugins in this repo.
  • Confirmation-gated deletion — Every destructive operation requires explicit user approval. Cleanup supports --dry-run for preview.
  • Companion directory handling — Sessions may have a sibling directory (same UUID) with tool results and subagent data. Both the .jsonl and the directory are cleaned up together.
  • Cross-platform — Commands use ~/.claude/projects/ which resolves correctly on macOS, Linux, and Windows (Git Bash / WSL).

Plugin structure

plugins/session-manager/
├── .claude-plugin/
│   └── plugin.json
├── commands/
│   ├── delete.md
│   ├── list.md
│   └── cleanup.md
└── README.md

Follows the standard plugin structure used by commit-commands, code-review, and other plugins in this directory.

Test plan

  • Install plugin locally and verify /session-manager:list shows sessions across multiple projects
  • Run /session-manager:delete with no args — confirm interactive numbered list appears
  • Run /session-manager:delete <uuid-prefix> — confirm single-match direct deletion with confirmation
  • Verify deleted session's .jsonl file and companion directory are both removed
  • Run /session-manager:cleanup --dry-run --older-than=7d — confirm preview without deletion
  • Run /session-manager:cleanup --older-than=7d — confirm deletion after approval
  • Test on macOS and Windows (Git Bash) to verify path handling

…up sessions

Session history accumulates rapidly with no built-in way to manage it.
Users must manually navigate ~/.claude/projects/ to find and delete
JSONL files — a workflow that is error-prone and breaks flow.

This plugin adds three commands that close the session lifecycle gap:

- /session-manager:delete — delete a session by name, ID prefix, or
  interactive selection with confirmation
- /session-manager:list — cross-project session overview with timestamps,
  sizes, and first-prompt previews
- /session-manager:cleanup — bulk-remove sessions by age or size with
  dry-run support

All operations are local, require explicit confirmation before deletion,
and handle companion data directories alongside JSONL files.

Addresses anthropics#2562, anthropics#16901
@Kropiunig
Copy link
Author

Bumping this — it's been 4 days since opening with no CI failures (no checks configured on this branch).

This adds a \ plugin with three commands addressing session lifecycle management — the most-requested missing feature. Happy to adjust scope, naming, or implementation approach based on maintainer feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant