Skip to content

feat(plugins): Sessions plugin for listing and deleting sessions#34168

Open
clipod wants to merge 1 commit into
anthropics:mainfrom
clipod:feat/sessions-plugin
Open

feat(plugins): Sessions plugin for listing and deleting sessions#34168
clipod wants to merge 1 commit into
anthropics:mainfrom
clipod:feat/sessions-plugin

Conversation

@clipod

@clipod clipod commented Mar 13, 2026

Copy link
Copy Markdown

Summary

Adds a sessions plugin with /sessions:list and /sessions:delete commands — the most requested
session management feature in this repo.

  • Project-scoped by default — only shows sessions for the current working directory, pass --all for
    all projects
  • Cross-platform — macOS (~/.claude), Linux ($XDG_CONFIG_HOME/claude), Windows
    (%APPDATA%\claude), and $CLAUDE_CONFIG_DIR override
  • Orphan detection — identifies conversation JSONL files that have no matching metadata
  • Full cleanup — deletes session JSONL, metadata file, and subagent logs directory
  • No unnecessary permission prompts — uses Read/Glob for discovery, only prompts for the actual
    deletion
  • Safe — always asks for confirmation, refuses to delete the active session, no wildcards or
    recursive deletion

Closes #16901
Related: #18502, #19574, #23423, #23979, #25304, #13780, #19138, #21347

Note: This implements the slash command approach (/sessions:list, /sessions:delete) as a
plugin. The CLI flag approach (claude --list-sessions, claude --delete-session) mentioned in #16901
would require changes to the core codebase.

Files Changed

plugins/session-manager/
├── .claude-plugin/plugin.json # Plugin metadata
├── commands/
│ ├── list.md # /sessions:list [--all | search term]
│ └── delete.md # /sessions:delete [session-id | search | --all]
└── README.md

.claude-plugin/marketplace.json # Registered under "productivity" category

How It Works

/sessions:list

Uses Glob with a UUID pattern (????????-????-????-????-????????????.jsonl) to find session files while
excluding subagent logs in nested directories. Reads first lines to extract titles, matches against
metadata for start times. Sessions without metadata are marked [orphan].

/sessions:delete

Same discovery, then presents a numbered list. User selects by number, UUID, search term, or "all". After
confirmation, deletes:

  1. {sessionId}/ subagent logs directory (rm -r)
  2. {sessionId}.jsonl conversation data (rm)
  3. {pid}.json metadata (rm)

Cross-Platform Config Resolution

Priority Platform Path
1 Any $CLAUDE_CONFIG_DIR
2 Windows %APPDATA%\claude%LOCALAPPDATA%\claude~\.claude
3 Linux $XDG_CONFIG_HOME/claude~/.claude
4 macOS ~/.claude

Test Plan

  • /sessions:list shows only current project's sessions (no permission prompts)
  • /sessions:list --all shows sessions across all projects
  • /sessions:delete presents numbered list, asks for confirmation
  • Deletion removes session JSONL, metadata JSON, and subagent directory
  • Current active session is protected from deletion
  • Orphaned sessions (JSONL without metadata) are detected and deletable
  • UUID glob pattern excludes subagent files from listings
  • Cross-platform path resolution tested on macOS

Context

This is one of the most requested features — #16901 has 44 upvotes with 8+ duplicate issues. While a
native CLI approach would require core changes, this plugin provides an immediate solution.

Adds /sessions:list and /sessions:delete commands to manage Claude Code
sessions stored locally. Project-scoped by default with cross-platform
support (macOS, Linux, Windows).

Features:
- UUID glob pattern to exclude subagent files from listings
- Orphan detection for sessions missing metadata
- Deletes session JSONL, metadata, and subagent logs
- Uses Read/Glob for discovery (no unnecessary permission prompts)
- Safe: confirms before deleting, protects active session

Closes anthropics#16901
Related: anthropics#18502, anthropics#19574, anthropics#23423, anthropics#23979, anthropics#25304, anthropics#13780, anthropics#19138, anthropics#21347
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.

[FEATURE] Add /list-sessions and /delete-session slash commands for better session management

1 participant