Feature request: show when the current directory is a git worktree

Author: Gabriel-bl-HAPCreated Sep 30, 2026Updated Sep 30, 2026
Labelsenhancement

Summary

More and more Claude Code workflows rely on git worktree (parallel agents, EnterWorktree, isolated branches per task). Today the git segment renders git:(<branch>) identically whether Claude runs in the main checkout or in a linked worktree.

When juggling several worktrees of the same repo, it's easy to lose track of where the session actually is — and that matters (e.g. a Docker stack that only mounts the main checkout, a dev server bound to one directory, uncommitted changes living in another tree).

Problem to Solve

The visual doesn't show if the current code is comming from a Worktree or not

Proposed Solution

Add a worktree indicator to the git segment, opt-in via config.

Detection

A directory is a linked worktree when --git-dir and --git-common-dir resolve to different paths:

bash
git rev-parse --path-format=absolute --git-dir --git-common-dir
# main checkout : /repo/.git         /repo/.git
# linked worktree: /repo/.git/worktrees/feat-x   /repo/.git
  • One extra git rev-parse call (can be merged into a single invocation returning both lines), same 1s timeout as resolveGitRef.
  • Worktree name = basename of the --git-dir path (or basename of --show-toplevel).
  • --path-format=absolute requires git ≥ 2.31; fallback: resolve both relative paths against cwd before comparing.

Rendering (suggestions)

Situation Current Proposed
Main checkout git:(master) git:(master) (unchanged)
Linked worktree git:(feat/x) git:(feat/x) ⎇ wt
Linked worktree, with name git:(feat/x) git:(feat/x) ⎇ feat-x

Main checkout rendering stays untouched so existing users see no change.

Config

Alongside the existing gitStatus options (showDirty, showAheadBehind, showFileStats, branchOverflow):

json
{
  "gitStatus": {
    "showWorktree": false,
    "worktreeStyle": "badge"
  }
}
  • showWorktree (boolean, default false) — enable the indicator.
  • worktreeStyle ("badge" | "name", default "badge") — short marker vs. worktree directory name.

Also exposed in /claude-hud:configure.

Implementation notes

  • getGitStatus in src/git.ts would return an extra worktree: { isLinked: boolean; name: string | null } field.
  • Detached HEAD (detached:<sha>) and tag refs from resolveGitRef keep working as-is; the indicator is orthogonal to the ref.
  • Bare repos / non-git dirs: no indicator.

Happy to open a PR if the approach sounds good.