[BUG] /clear inherits previous session name instead of resetting it, causing duplicate-named sessions in /resume
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
What's Wrong?
Running /clear in the CLI terminal clears conversation history but does not reset the session name. The previous session's name persists in the macOS title bar after /clear, marked with a * prefix (e.g., * My Session Name). The new post-clear session is created with the same name as the old one.
When using /resume, both sessions appear under the same name with no way to distinguish them from the picker.
Steps to Reproduce
- Start a new Claude Code session in the terminal CLI
- Rename it via
/rename(e.g., "My Test Session") - Confirm the name appears in the macOS title bar
- Run
/clear - Observe: title bar still shows
* My Test Session— name was not reset - Have a new conversation in this cleared session
- Run
/resumefrom a new session — both the original and post-clear session appear as "My Test Session" with no way to differentiate them
Expected Behavior
/clear should reset the session name so the new session starts unnamed and is treated as distinct in /resume.
Actual Behavior
Session name persists after /clear. The new session inherits the name, creating duplicate-named entries in /resume with different content and no way to tell them apart.
Is this a regression?
Yes, this worked in a previous version
Last Working Version
v2.1.89
Claude Code Version
v2.1.146
Platform
Claude Max
Operating System
macOS
Terminal/Shell
fish
Related Issues
- #59534:
/cleardoes not preserve the previous session for/resume(related regression, different symptom) - #60106:
clear(new)/clear(reset)orphans sessions in agents-view under duplicate titles (same duplicate-title failure mode, different surface) - #37451:
/clearsemantics discussion (context)
15 Comments
Found 2 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
These both look like the same bug, but they're already closed (one completed in Feb, one stale). Since it works in v2.1.89 but not v2.1.146, this seems like a regression worth keeping open. Happy to share more details if useful.
Yes this bug is certainly still open or did re-appear. It is quiet annoying when you work a lot with sessions and have many duplicates of the same session name appearing under /resume 🫠 and you have to guess which was the one you actually meant and which were others which you did not explicitly rename.
Also reproducing on Windows 11 (PowerShell), Claude Code v2.1.181. Same repro as the original post. This issue is labelled
platform:macos, but it's happening on Windows too, so it doesn't look macOS-specific. Might be worth addingplatform:windowsor droppingplatform:macosto reflect that.FYI for anyone following: this repo's stale bot exempts issues with 10+ 👍 reactions on the original post, so reacting there is the most useful way to keep this open.
Reproducing on macOS CLI, v2.1.179 (also affected, with quantified data).
Same bug, plain
/clearin the terminal (no VS Code, no worktree isolation). Environment: macOS (Darwin 25.5.0), Claude Code v2.1.179.I scanned all 55 of my session JSONL files to measure the blast radius. Findings that may help pin the mechanism:
/clearsession's first records are duplicatedcustom-titleentries carrying the previous session's name - written at line 0 and** line 2 of the new file, before/clearand before the first real prompt. This matches the now-closed #59237 ("custom-title written twice at the top"), so that report and this one are the same bug./clear(each on a different topic). All three showed up under that one name in/resume./renameafterward. Sessions I happened to/renameself-corrected; the ones I didn't stayed permanently mislabeled./clear. Evidence: a session started after a 6-day gap (guaranteed fresh process) got the correct title, never inheriting anything. So fully quitting and relaunching Claude Code instead of using/clearavoids the leak entirely - a fresh process has no cached title to flush. That is a more reliable workaround than re-/renameing, for anyone hitting this.Confirming this is a CLI bug, not the VS Code last-prompt-override path (#32150/#40787). +1 to keep it open.
Confirming this regression also reproduces on Windows (not just macOS), on a newer version than reported here —
Claude Code v2.1.209, Windows Server 2022.
Working from a single long-lived project directory with many accumulated sessions, I found the same pattern
described above: several .jsonl session files with completely unrelated conversation content (different topics,
different dates, different session IDs) all sharing an identical customTitle value, with that value written as the
very first line of the file — before any conversation content exists — and no corresponding agent-name (manual
rename) event to explain it. One title string was reused across at least 3 sessions; another across 7 sessions
spanning multiple weeks. The /resume picker shows all of these as indistinguishable duplicate entries, matching the symptom in #59242.
This suggests the fix for #59237/#59242 either didn't fully address the root cause, or the regression reintroduced
it — and it isn't macOS-specific.
Possibly related: filed #81813 for what looks like the same underlying mechanism (a session's auto-generated name isn't freshly derived from its own conversation, but is instead carried over/reused from another, unrelated session), just triggered differently — opening a new session in a working directory another session was recently active in, rather than
/clearwithin the same session.Evidence in #81813: two sessions with different
sessionIds, samecwd, ended up with the identical name. One session's name was a correct summary of its own (extensive) conversation; the other session — which never discussed that topic at all — inherited that same name anyway. The two sessions' active time windows were adjacent/overlapping.If a maintainer confirms this is the same root cause as this issue, #81813 could probably be closed as a duplicate of this one — leaving that judgment call to you.
Correction to my earlier comment: #81813 turned out to be caused by a third-party
UserPromptSubmithook emittinghookSpecificOutput.sessionTitleon every prompt (title derived from a project file, identical for all sessions in the same cwd) — not by core title inheritance. It has been closed as not-a-Claude-Code-bug and is unrelated to this issue after all. Sorry for the noise.Reproducing this as well (macOS). Also noticed the companion problem:
/colorhas no way to persist across/clearor new sessions either — see the (closed as duplicate/not-planned) requests #28708, #41887, #50393. Both/renameand/colorstate seem to get lost or corrupted around/clear, would be great to see both addressed together since they're clearly related session-metadata issues.Still reproducing on v2.1.227, macOS (Darwin 25.5.0), zsh. Adding a detail that I don't think is in the thread yet, because it makes the mechanism concrete and pins down where the name actually lives.
The carried-over name is persisted on disk, not just held in memory
An earlier comment describes the title as "held in memory per-process and flushed into the new session on
/clear." The per-process part is right, but it isn't in-memory — there is an on-disk, PID-keyed registry at:Here is that record on my machine, taken from a session created by
/clear(paths and the name redacted):Note it holds both
sessionIdandname.Timeline evidence that
/clearrewrites one and not the other/clearcycles.b7dee760-….jsonlwas created Aug 12 12:34:23, by a/clear.sessionId: b7dee760-…(the new, post-/clearsession),updatedAtseconds ago — whilenameis still the value inherited from a session started the previous day.So on
/clearthis record is updated in place:sessionIdis repointed at the freshly minted session, andnameis carried across untouched — then re-stamped into the new transcript as the duplicatedcustom-titlerecords at lines 0 and 2 that others have described. The process is the carrier, which is consistent with the observation that fully quitting and relaunching avoids the leak: a new process gets a new PID and a new registry entry.Why the name is process-scoped at all
That same file carries
messagingSocketPath,peerProtocol, and a livestatusfield, and a second concurrent session in another directory is registered alongside it. So this registry is the live cross-session peer/messaging directory, andnameappears to serve as that process's address there. That would explain why the name is scoped to the process rather than to the conversation. Flagging that as my reading of the artifact, not a confirmed root cause.Blast radius here
Across 44 session transcripts in one project directory: 4 distinct leaked titles, the worst covering 6 unrelated sessions spanning three different git branches and two days of work. All 6 render as identical rows in
/resume, distinguishable only by size/age/branch in the subtitle. Sessions predating the first/renamehave nocustom-titlerecord at all and get correct auto-generated titles — the leak only affects the chain after a rename.Minor surface discrepancy vs. the original report
The body reports the macOS title bar keeps showing the stale name with a
*prefix. On v2.1.227 I see the opposite in the TUI: the session-name indicator in the input area clears on/clear, while both the registrynameand the new transcript'scustomTitlestill hold the old value. That's arguably worse than the title-bar case — the UI signals a reset that did not happen, so there's no cue to re-/rename, and the next/clearsilently produces another duplicate.Suggested direction
Decouple the conversation title from the process name.
/clearalready mints a new session ID and a new transcript file; the name state should be reset the same way. If the process registry needs a stablenamefor peer addressing, that's process identity and shouldn't be the same field that seeds a transcript'scustomTitle— otherwise every/clearin a long-lived process inherits it by construction. Whatever the fix,/clearshould yield something indistinguishable from a fresh session in/resume.Reproduced on v2.1.233 (macOS).
Steps:
claudein an empty project directory./rename My Test Session, then send any message./clear, then send another message in the cleared session.claude --resume.Observed: the resume picker shows two entries both named "My Test Session" — the original session and the post-
/clearsession. The new session's transcript starts with the old name before any prompt is sent, even though the name indicator in the input area disappears after/clear(on current versions the title bar no longer keeps the*name described in the original report, but the on-disk name still carries over). Each further/clearin the same process carries the name again, which is why several commenters see one name spread across many unrelated sessions.Expected (per the report): after
/clearthe new session starts unnamed and is distinguishable in/resume.Assessment: Intended today, but the expectation is reasonable and this is worth making clearer. The name carry-over was added deliberately around v2.1.111 (which matches the "worked in v2.1.89, not in v2.1.146" window here) so that a name set with
/renameor--namekeeps working for--resume <name>and the statusline after/clear; before that,/cleardropping the name was treated as the bug. It's documented at https://code.claude.com/docs/en/sessions under/clear: "You keep a name you set with--nameor/renamein the new conversation, but not an AI-generated session title." The mental model is that the name is your handle for what you're working on now, so it follows you into the fresh conversation; the archived conversation keeps it too because it had it when it was saved. If you want the name to stay only on the conversation you're leaving, use/clear <name>— that names the archived session and starts the new one untitled.That said, ending up with several identical rows in the resume picker with nothing to tell them apart is a real usability problem. We should make this clearer — for example, tell you after
/clearthat the name carried over (with a nudge to/renameor use/clear <name>), and/or mark the archived conversation in the picker so duplicates are distinguishable. Same underlying behavior as #78264.🤖 Generated with Claude Code
Confirmed — reproduced on 2.1.233 (Linux), so this is still current behavior.
What I did: fresh config dir → started a session →
/rename My Test Session→/clear→ checked the terminal title and the session store, then opened/resumefrom a new instance.What I observed:
/clearthe terminal title still shows✳ My Test Session./resumelists two sessions both named "My Test Session", telling them apart only by age/size — exactly what you reported.Marking this as a confirmed bug:
/clearshould either reset the custom name for the new session or the picker should disambiguate. (I didn't independently verify the 2.1.89 regression point, but the behavior is present on the latest release.)🤖 Generated with Claude Code
Still reproduces on 2.1.272, Windows 11 (PowerShell).
/rename b219→/clear→ new session id, and itscustom-title.jsonwas created at the exacttimestamp of the
/clearwith the old name./resumeshows two rows namedb219, distinguishable only by age and size.@bcherny's 2026-08-20 comment lists two acceptable fixes: reset the name on
/clear, or make the picker disambiguate. I want to argue that only the firstis consistent with what the sessions doc already commits to. Quotes below are verbatim from https://code.claude.com/docs/en/sessions.md (fetched
2026-09-15).
1. The doc defines the name as a resume handle that resolves to one session.
> Give sessions descriptive names so they're findable in the session picker and resumable by name.
>
claude --resume <name>| Resumes the named session directly> Sessions you don't name still get two labels that Claude Code assigns. Only the generated title works as a resume handle: […] The default isn't a resume
handle. If you pass it to
claude --resumeor/resume, Claude Code doesn't find the session."Resume handle" is the doc's own term, and "resumes the named session" is singular.
2. The doc enforces uniqueness of that handle, and lists the exceptions.
> When you start or resume an interactive session with a name that another live session on this machine already uses, or rename a session into such a
name, Claude Code leaves the name with the session that already has it, renames yours to a variant with a two-word suffix, such as
auth-refactor-graceful-unicorn, and tells you. […] Before v2.1.232, both sessions kept the name.> In three cases Claude Code doesn't rename the duplicate, so you can still see two sessions with the same name in listings:
> * It doesn't check AI-generated titles or default display names.
> * It doesn't check the
--nameof a background or-psession at startup.> * It can't rename a session on an earlier version of Claude Code.
/clearis not on that list, yet it is the one code path that mints a duplicate handle by design:> With no argument, the new conversation keeps a name you set with
--nameor/rename, but not an AI-generated session title.It slips past the uniqueness check only because the archived transcript has just stopped being "live". The doc never says what
--resume <name>does whentwo stored transcripts share the name.
3. Why reset, not disambiguate.
consistent.
--resume <name>undefined on duplicates. It fixes the symptom thepicker shows and nothing else.
/clear <name>(names the archived one, newstarts blank) and by
/rename. A one-line notice after/clear("name not carried over;/renameto set one") covers the discoverability concern raisedon 08-15.
From the user's side, the thing you can address is the transcript: you resume it, rename it, preview it. A label that follows "what I'm working on" is
never selectable anywhere, so a name that outlives the transcript it identified has stopped doing the one job the doc gives it.
Reproduced on Claude Code 2.1.278, Linux (WSL2 Ubuntu).
clear-hello-world)./clear.{"type":"custom-title","customTitle":"clear-hello-world"}and{"type":"agent-name","agentName":"clear-hello-world"}as its first transcript lines.Expected:
/clearstarts a fully fresh session and keeps nothing from the previous one, including its name. Today the only way to get a truly clean session is to exit and relaunchclaude.Still reproduces on 2.1.294, Windows 11. Not adding another repro, though: The open question is whether this is still considered a bug.
The sessions doc now describes the carry-over as intended (https://code.claude.com/docs/en/sessions,
/clearentry):That contradicts the
bug/reproducedlabels and @bcherny's confirmation above that/clearshould reset the name. Could a maintainer say which one is it moving forward with? Or if it's moving forward at all?Options I propose:
/clearstarts the new conversation unnamed, and the docs are updated to match. (ideal for me)clearKeepsSessionNamesetting). People who want the name kept (#38649, #88367) and people who don't would both be covered. (Feel like it's the sensible way)/clear <name>works as a workaround, but it only helps if you remember the argument every time. Forget it once and you get another duplicate entry in/resume. Over time you end up with several same-named sessions.