Skip to content

[FEATURE] Add /delete command to delete current session #25304

@rstar327

Description

@rstar327

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:

  1. Exit Claude Code or open a separate terminal
  2. Manually navigate to ~/.claude/projects/
  3. Find the correct .jsonl session file
  4. 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

  1. I'm working on a project and create multiple test sessions to experiment with different approaches
  2. After finding the right approach, I have 5-10 leftover test sessions cluttering my /resume list
  3. One of those test sessions accidentally contains an API key I pasted during debugging
  4. Currently, I have to exit Claude Code, navigate to ~/.claude/projects/, figure out which .jsonl files correspond to which sessions, and delete them manually
  5. With /delete, I could simply type /delete test-session-3 and confirm — done in seconds without leaving Claude Code
  6. 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 --force or -f flag could skip the confirmation prompt for power users
  • Session files are stored as .jsonl in ~/.claude/projects/
  • Should handle edge cases: non-existent sessions, permission errors, deleting the last session

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions