/clear creates a new session instead of clearing current context — misleading command semantics

Resolved 💬 4 comments Opened Mar 22, 2026 by Loong0x00 Closed May 24, 2026

Bug Description

/clear is described as "Clear conversation history and free up context", but it actually creates a new session with a new UUID, identical to /new. This is semantically wrong — "clear" universally means "reset the current state", not "abandon current and create new".

Evidence from source

// Command definition
{
  name: "clear",
  description: "Clear conversation history and free up context",
  aliases: ["reset", "new"],  // ← "reset" and "new" are NOT synonyms
}

// Handler
async function clearConversation({setMessages, setConversationId, ...}) {
  setMessages(() => []);
  setConversationId(randomUUID());  // ← creates entirely new session
}

setConversationId(randomUUID()) generates a new session ID, meaning all subsequent messages go to a new JSONL file. The old session is effectively abandoned.

Expected behavior

/clear should:

  • Clear the conversation messages from context
  • Stay in the same session (same JSONL file, same session ID)
  • Preserve session metadata (custom title, tags, working directory)
  • Free up context window for new conversation

/new should:

  • Create a new session with a new UUID
  • Start fresh with no metadata carried over

These are fundamentally different operations. In no programming context does "clear" mean "create new":

  • console.clear() — clears the console, doesn't open a new terminal
  • clear (terminal) — clears the screen, same shell session
  • localStorage.clear() — empties storage, doesn't create a new origin
  • git stash clear — deletes stashes, doesn't create a new repo
  • Array.clear() / .length = 0 — empties the array, doesn't allocate a new one

Impact

  • Users who /rename a session then /clear lose their named session — the name stays on the old (now abandoned) session, and the new session has no name
  • Session continuity is broken: tools, working directory context, and session-level state are reset unexpectedly
  • Users who want to actually clear context within a session have no command to do so

Related

  • #31220 — Feature request for /clear --keep-session (workaround for this bug)

Environment

  • Claude Code 2.1.81
  • OS: Arch Linux

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗