[FEATURE] Add /delete command to delete current session
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] 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
High - Significant impact on productivity
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
15 Comments
https://github.com/anthropics/claude-code/issues/25304, closed as duplicate but actually, this is not duplicated
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
+1, still a real pain point. Current workaround (manually
rm-ing~/.claude/projects/<project>/<uuid>.jsonl) is error-prone because session UUIDs aren't shown in/resume— you have to grep JSONL files to identify which one to delete. Sessions with accidentally-pasted secrets (API keys, tokens) stay on disk until a manual cleanup. The OP's/delete <name>design covers this use case completely; would be great to un-stale this.Wrote a stopgap for anyone still waiting on this: github.com/ihoooohi/claude-code-session-cleaner — works both as a shell script and a Claude Code slash command (
/delete-session).While implementing it I had to reverse-engineer the session JSONL format a bit. Three findings that might help the eventual official implementation:
/resume's display, the tool reads three record types in this order:type: custom-title— written by/rename. Every rename appends a new record;tail -1gives the current name. The OP's/delete <name>will need to match against this.type: last-prompt— appended on every user message; this is what/resumesurfaces for recent sessions.type: usermessage (skipping auto-injected<local-command-caveat>/<command-name>wrappers) — fallback for older sessions withoutlast-promptrecords.~/.claude/projects/<project>/<uuid>/containingsubagents/,tool-results/,memory/. Deleting only the.jsonlleaves orphan dirs — a real/deleteshould clean both. The listing side also needs to scope itsfindwith-maxdepth, otherwise subagent transcripts show up as independently-deletable sessions, which is confusing..jsonlupdates on every message, so mtime-based detection (mtime < 10 min) is a simple-enough refuse heuristic. An official implementation can use process state for a cleaner signal.All the format assumptions are documented in the script if Anthropic wants to reference it.
Came around to see if its implemented yet. This feature is so important to productivity it declutters my session history and saves space , I don't need to manually delete my sessions.
PS: should be able to delete all sessions or a particular session.
Even just having a key you could press during the resume UI to delete the currently selected session would be super helpful.
Related: #67201 specifically covers the server-side retention gap — deleting local
.jsonlfiles doesn't remove the session from Anthropic's servers, andclaude --resume <id>still restores the transcript after local deletion. This becomes a security issue when a session contains accidentally exposed secrets, since there's no surgical per-session deletion path short of a bulk privacy data request.The security issue is the exposing of the secrets itself. And the remediation is not to have the secrets removed from Anthropic's servers, but to treat them as compromised and _rotate them_.
A
/deletecommand would for sure be desired to clean up local disk usage, esp. on constrained machines, but it's not security-class. If you think it is - you're doing something horribly, horribly wrong in trusting in good faith that those credentials didn't already leak elsewhere.(Can you guarantee that Anthropic itself isn't suffering from a malicious actor being in their systems and exfiltrating things? No- you cannot. So don't assume that isn't the case.)
absolutely agree we should have a delete past session function; they have it in Antigravity-cli for God's sake. Here to upvote this pr.
any update on this?
+1, really annoying having empty sessions with names like "41a3ba8b". also removing them manually is a pain
They have added rename feature , put delete option is still not implemented.
Incase you are still troubled with being able to fully delete sessions here is a simple cli tool for mac and linux users : https://github.com/genie360s/claude-session-deleta .
Is this really that hard to implement? you have access to the best in-class AI models, probably even unreleased versions, yet you cant implement a simple delete?
I need this too, please!