Skip to content

feat: Handle branch namespace prefixes (e.g., 'claude/', 'feature/') in worktree mismatch flag #3389

Description

@dmsmidt

Context

Currently, wt list displays a red flag (branch_worktree_mismatch) if the branch name does not exactly match the name of the physical directory it is checked out into.

While this is incredibly useful for spotting chaotic or orphaned workspaces, it creates massive visual noise when using modern workflows—specifically with AI coding agents (like Claude Code) or standard branching conventions (e.g., feature/*, bugfix/*).

The Problem

If an AI agent creates a branch named claude/frosty-kilby-92c7d3 and checks it out into a directory named frosty-kilby-92c7d3 (or handles it inside a subfolder like .claude/worktrees/frosty-kilby-92c7d3), wt list triggers the mismatch flag on every single row.

Because the tool does a strict string match on the full branch string vs. the folder basename, standard and healthy structural conventions look like errors:

+ claude/frosty-kilby-92c7d3       ⚑✗      ↑2 ↓22   +4K  -44   ./.claude/worktrees/frosty-kilby-92c7d3

When every single active row has a ⚑, the flag loses its utility because actual, accidental directory cross-wires get drowned out in the noise.

Suggested Solutions

Smart Basename Matching (Preferred):
Modify the mismatch logic to check if the directory name matches the last segment (the basename) of the branch name split by /. For example, a branch named claude/foo or feature/foo should perfectly match a directory named foo inside a parent named claude or feature repectively.

Configuration-based Ignore Prefixes:
Allow a user to define ignored branch prefixes in .gitconfig or via wt config.

wt config ignore-prefixes "claude/,feature/,bugfix/"

Subdirectory Agnosticism:
Ensure that if a worktree is placed inside a nested subdirectory structure (like ./.claude/worktrees/name), the path prefix is cleanly stripped before comparing it to the branch name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions