Knowing which worktree Claude is in
a one-line ccstatusline widget for Claude Code
· ccstatusline, claude-code, git, statusline, superset, tooling, worktrees
When you're running multiple Claude Code sessions across git worktrees, one for each ticket, it's easy to lose track of which checkout the agent is in. The branch name tells you what you're on, but not where.
One tiny ccstatusline custom-command widget fixes it. Drop this into ~/.config/ccstatusline/settings.json:
{
"id": "worktree-indicator",
"type": "custom-command",
"color": "yellow",
"commandPath": "g=$(git rev-parse --path-format=absolute --git-dir 2>/dev/null) && c=$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null) && [ \"$g\" != \"$c\" ] && printf 'WT:%s' \"$(basename \"$(git rev-parse --show-toplevel)\")\"",
"maxWidth": 30,
"timeout": 500,
"merge": true
}
Ask git, not the path
My first version looked for /.claude/worktrees/ in the path from git rev-parse --show-toplevel. It worked for worktrees Claude Code creates itself, and printed nothing for anything else. A path is a convention, and conventions change.
Git knows the answer. In a linked worktree --git-dir points to .git/worktrees/<name>, while --git-common-dir points to the main .git. In the main checkout both are the same. If they differ, you are in a linked worktree, and the widget prints the folder name. In the main checkout, or outside a repo, it prints nothing.
--path-format=absolute needs git 2.31 or newer. Without it the two paths can come back in different forms and never compare equal.
Claude Code
Nothing special here. Worktrees from claude --worktree or EnterWorktree are normal linked worktrees, so the widget shows the name Claude gave them.
Superset
Superset puts its worktrees in ~/.superset/worktrees/<repo>/<name>. That is why the path only version fails, it never matches. The git version doesn't care where the worktree lives.
Small thing. Saves a lot of "wait, am I in the right tree?"