[BUG] /clear after /rename: new session inherits the previous session's custom-title
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)
- [x] I am using the latest version of Claude Code
What's Wrong?
Summary
When a session is renamed with /rename <name> and then /clear is invoked (without an argument), the freshly created session JSONL inherits the previous session's customTitle in its very first records, even though /clear creates a brand new session (new sessionId, parentUuid:null, SessionStart:clear hook). This produces multiple separate sessions that all show up under the same name in /resume.
## Steps to reproduce
- Start a new session.
- Run
/rename my_session_name. - Do some work so the session has content.
- Run
/clear(with no argument). - Inspect
~/.claude/projects/<project-slug>/<new-session-uuid>.jsonl.
## Expected
The new session JSONL should have no custom-title record, or a fresh empty/default title — /clear is supposed to start a new session. (For the explicit case, /clear <name> exists since v2.1.136 — see #57445.)
Actual
The first two lines of the new session's JSONL are duplicated custom-title records carrying the previous session's name:
``jsonl``
{"type":"custom-title","customTitle":"my_session_name","sessionId":"<NEW-UUID>"}
{"type":"custom-title","customTitle":"my_session_name","sessionId":"<NEW-UUID>"}
{"type":"file-history-snapshot", ...}
{"parentUuid":null,"isSidechain":false,"attachment":{"type":"hook_success","hookName":"SessionStart:clear", ...}}
Notes from the evidence:
parentUuidisnulland the hook isSessionStart:clear, confirming this is a new session, not a continuation.- The
custom-titlerecord is written twice at the top of the file, which also looks suspicious — possibly a separate bug in/rename's write path.
## Impact
/resumelists multiple sessions under the same name with no way to disambiguate them.- Combined with the UI bug filed separately, the user cannot reliably return to a previously named session after a
/clear.
## Environment
- Claude Code v2.1.141
- OS: Windows 11 Pro 26200
- Shell: PowerShell / Git Bash
What Should Happen?
The new session JSONL should have no custom-title record, or a fresh empty/default title — /clear is supposed to start a new session. (For the explicit case, /clear <name> exists since v2.1.136 — see #57445.)
Error Messages/Logs
Steps to Reproduce
- Start a new session.
- Run
/rename my_session_name. - Do some work so the session has content.
- Run
/clear(with no argument). - Inspect
~/.claude/projects/<project-slug>/<new-session-uuid>.jsonl.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
v2.1.141
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗