claude-code - 💡(How to fix) Fix Worktree directories should use meaningful names instead of random session names [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#46098Fetched 2026-04-11 06:29:03
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
labeled ×2commented ×1
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this is not a duplicate
  • This is a single, focused feature request

Problem Statement

When Claude Code creates a git worktree via the EnterWorktree tool, the worktree directory is named after the auto-generated session name (e.g., .claude/worktrees/hopeful-proskuriakova/). These names are completely random — there is no way to tell which task, branch, or session a given worktree belongs to without running git worktree list or inspecting the directory contents.

Proposed Solution

Use the git branch name (sanitized for filesystem use) as the worktree directory name instead of the session name. For example, a worktree for branch feature/my-task would be placed at .claude/worktrees/feature-my-task/.

If the branch name is not available at worktree creation time, fall back to a truncated task/prompt description, or keep the session name as a last resort.

Priority Level

Low - Nice to have

Feature Category

Configuration

Alternative Solutions

  • Users can manually rename worktree directories after creation (but requires updating the git worktree reference too)
  • git worktree list shows the branch for each worktree path, but requires the user to cross-reference

Use Case Example

A user runs multiple parallel worktrees for different features. After a week, .claude/worktrees/ contains hopeful-proskuriakova/, cranky-wescoff/, youthful-lehmann/ — none of which indicate what work was done there. With branch-named directories, they'd see feature-auth/, fix-dashboard-bug/, refactor-api/ instead.

extent analysis

TL;DR

Use the git branch name as the worktree directory name to improve identifiability.

Guidance

  • Modify the EnterWorktree tool to use the git branch name (sanitized for filesystem use) as the worktree directory name.
  • If the branch name is not available, consider falling back to a truncated task/prompt description or the current session name.
  • Update the worktree reference accordingly when renaming worktree directories.
  • Test the new naming convention with various branch names and edge cases to ensure correct functionality.

Example

No explicit code example is provided due to the lack of specific implementation details in the issue.

Notes

The proposed solution assumes that the git branch name is available and can be sanitized for use as a directory name. Additional error handling may be necessary for cases where the branch name is not available or cannot be used.

Recommendation

Apply workaround: Modify the EnterWorktree tool to use the git branch name as the worktree directory name, as this provides a more identifiable and user-friendly naming convention.

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