claude-code - 💡(How to fix) Fix [BUG] Worktree isolation spams duplicate custom-title entries, causing title 'sticking' across sessions

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When using isolation: "worktree" with the Agent tool, Claude Code writes duplicate custom-title entries to the session JSONL file on every action. This causes:

  1. Session file bloat (100+ duplicate entries)
  2. Title "sticking" — the same title appears for multiple unrelated sessions in /resume picker

Root Cause

When using isolation: "worktree" with the Agent tool, Claude Code writes duplicate custom-title entries to the session JSONL file on every action. This causes:

  1. Session file bloat (100+ duplicate entries)
  2. Title "sticking" — the same title appears for multiple unrelated sessions in /resume picker

Fix Action

Workaround

Manually clean duplicate custom-title entries:

# Keep only last custom-title entry in each file
for f in ~/.claude/projects/PROJECT/*.jsonl; do
  last=$(grep '"custom-title"' "$f" | tail -1)
  grep -v '"custom-title"' "$f" > "$f.tmp"
  [ -n "$last" ] && echo "$last" >> "$f.tmp"
  mv "$f.tmp" "$f"
done

Code Example

# Count duplicate custom-title entries per session
for f in ~/.claude/projects/PROJECT/*.jsonl; do
  count=$(grep -c '"custom-title"' "$f" 2>/dev/null)
  if [ "$count" -gt 5 ]; then
    echo "$count duplicates in $(basename $f)"
  fi
done

# Output:
# 117 duplicates in 09b4aeea-....jsonl
# 44 duplicates in c53abaa8-....jsonl
# 42 duplicates in 77e2bf9f-....jsonl
# ... (10+ files affected)

---

> попробуй найди агентом репозиторий... (Branch)
  10 minutes ago · master · 1.2MB

  попробуй найди агентом репозиторий... (Branch)
  55 minutes ago · master · 261.2KB

  попробуй найди агентом репозиторий... (Branch)  
  3 hours ago · master · 1.4MB

---

# Keep only last custom-title entry in each file
for f in ~/.claude/projects/PROJECT/*.jsonl; do
  last=$(grep '"custom-title"' "$f" | tail -1)
  grep -v '"custom-title"' "$f" > "$f.tmp"
  [ -n "$last" ] && echo "$last" >> "$f.tmp"
  mv "$f.tmp" "$f"
done
RAW_BUFFERClick to expand / collapse

Summary

When using isolation: "worktree" with the Agent tool, Claude Code writes duplicate custom-title entries to the session JSONL file on every action. This causes:

  1. Session file bloat (100+ duplicate entries)
  2. Title "sticking" — the same title appears for multiple unrelated sessions in /resume picker

Environment

  • Claude Code version: 2.1.143
  • OS: Windows 10 Pro
  • Shell: Git Bash

Steps to Reproduce

  1. Start a new session
  2. Use Agent tool with isolation: "worktree"
  3. Let the agent perform multiple actions
  4. Check the session JSONL file for custom-title entries

Expected Behavior

  • custom-title should be written once (or deduplicated)
  • Each session should have its own unique title based on content

Actual Behavior

  • custom-title with (Branch) suffix is written on every action (up to 117 times in one session)
  • The title "sticks" and appears for multiple different sessions in /resume picker
  • New sessions inherit the previous worktree session's title

Evidence

# Count duplicate custom-title entries per session
for f in ~/.claude/projects/PROJECT/*.jsonl; do
  count=$(grep -c '"custom-title"' "$f" 2>/dev/null)
  if [ "$count" -gt 5 ]; then
    echo "$count duplicates in $(basename $f)"
  fi
done

# Output:
# 117 duplicates in 09b4aeea-....jsonl
# 44 duplicates in c53abaa8-....jsonl
# 42 duplicates in 77e2bf9f-....jsonl
# ... (10+ files affected)

Screenshot

Multiple sessions showing the same title in /resume picker:

> попробуй найди агентом репозиторий... (Branch)
  10 minutes ago · master · 1.2MB

  попробуй найди агентом репозиторий... (Branch)
  55 minutes ago · master · 261.2KB

  попробуй найди агентом репозиторий... (Branch)  
  3 hours ago · master · 1.4MB

Workaround

Manually clean duplicate custom-title entries:

# Keep only last custom-title entry in each file
for f in ~/.claude/projects/PROJECT/*.jsonl; do
  last=$(grep '"custom-title"' "$f" | tail -1)
  grep -v '"custom-title"' "$f" > "$f.tmp"
  [ -n "$last" ] && echo "$last" >> "$f.tmp"
  mv "$f.tmp" "$f"
done

Related Issues

  • #32150 - Session titles revert to last-prompt text
  • #53338 - Session auto-titler reverts manual rename
  • #36379 - AI-generated titles override custom-title entries

Suggested Fix

  1. Deduplicate custom-title writes — check if title already exists before writing
  2. Don't propagate worktree session title to parent/sibling sessions
  3. Clear title cache when starting a new session

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING