-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
Preflight Checklist
- I have searched existing requests and this feature hasn't been requested yet
- This is a single feature request (not multiple features)
Problem Statement
Currently, there is no built-in way to delete sessions from within Claude Code. When users want to remove old, test, or sensitive sessions, they must:
- Exit Claude Code or open a separate terminal
- Manually navigate to
~/.claude/projects/ - Find the correct
.jsonlsession file - Manually delete the file
This breaks the workflow and is error-prone — especially for users who frequently create sessions for testing or experimentation and want to keep their session list clean when using /resume.
The existing /clear command only clears conversation history within the current session — it does not delete the session itself. There is currently no way to permanently remove a session without leaving Claude Code.
Proposed Solution
Add a /delete command with two modes:
Mode 1: Delete current session
/delete
Deletes the currently active session, prompts for confirmation, then exits or starts a new session.
> /delete
Delete current session "portfolio-fixes"? (y/n): y
Session deleted. Starting new session...
Mode 2: Delete session by name
/delete <session-name>
Deletes a specific session by name, similar to how /resume <session-name> works. Shows a list if the name matches multiple sessions.
> /delete my-old-session
Delete session "my-old-session"? (y/n): y
Session deleted.
Ambiguous name handling:
> /delete test
Multiple sessions found:
1. test-auth-flow
2. test-database-migration
3. test-ui-components
Select a session to delete (1-3): 2
Delete session "test-database-migration"? (y/n): y
Session deleted.
Detailed behavior:
| Scenario | Expected Behavior |
|---|---|
/delete with no arguments |
Targets the current active session |
/delete <name> with exact match |
Targets that specific session |
/delete <name> with multiple matches |
Shows numbered list to choose from |
/delete <name> with no match |
Error: No session found matching "<name>" |
Confirmation declined (n) |
Cancels, returns to current session |
| Deleting current active session | Starts a new session or exits |
| Deleting a non-active session | Remains in current session |
Alternative Solutions
No response
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
- I'm working on a project and create multiple test sessions to experiment with different approaches
- After finding the right approach, I have 5-10 leftover test sessions cluttering my
/resumelist - One of those test sessions accidentally contains an API key I pasted during debugging
- Currently, I have to exit Claude Code, navigate to
~/.claude/projects/, figure out which.jsonlfiles correspond to which sessions, and delete them manually - With
/delete, I could simply type/delete test-session-3and confirm — done in seconds without leaving Claude Code - This keeps the session list clean and the sensitive data removed immediately
Additional Context
This feature would complete the session lifecycle within Claude Code:
Create → Work → Resume → Clear → Delete
Currently the lifecycle is incomplete — users can create, work in, resume, and clear sessions, but cannot delete them without leaving the CLI.
How /delete fits with existing commands:
| Command | What It Does |
|---|---|
/resume |
Lists and resumes a previous session |
/clear |
Clears conversation history (session still exists) |
/delete (proposed) |
Permanently deletes a session file |
Additional considerations:
- A
--forceor-fflag could skip the confirmation prompt for power users - Session files are stored as
.jsonlin~/.claude/projects/ - Should handle edge cases: non-existent sessions, permission errors, deleting the last session