Feature: Add git branch/worktree info to statusLine data

Resolved 💬 2 comments Opened Feb 3, 2026 by mstege Closed Mar 3, 2026

Summary

The statusLine API currently provides workspace info but no git context. Adding git branch and worktree information would be useful for users working with multiple branches or git worktrees.

Current Behavior

The statusLine script receives this data via stdin:

{
  "model": {...},
  "workspace": {
    "current_dir": "/path/to/project"
  },
  ...
}

Proposed Enhancement

Add git context to the workspace data:

{
  "workspace": {
    "current_dir": "/path/to/project",
    "git_branch": "feature-xyz",
    "git_worktree": "small-fixes"
  }
}
  • git_branch: Current branch name (from git branch --show-current or HEAD)
  • git_worktree: Worktree name if in a git worktree (parsed from .git file), null otherwise

Use Case

When working with git worktrees, users often have multiple Claude Code sessions open in different worktrees of the same project. Having the worktree/branch visible in the statusLine helps identify which context you're in.

Current Workaround

Custom statusLine scripts must parse the .git file themselves:

function getWorktreeInfo(dir) {
  const gitPath = path.join(dir, '.git');
  if (fs.existsSync(gitPath) && fs.statSync(gitPath).isFile()) {
    const gitContent = fs.readFileSync(gitPath, 'utf8').trim();
    const match = gitContent.match(/worktrees\/([^/\s]+)/);
    if (match) return match[1];
  }
  return null;
}

This is redundant work that could be done once by Claude Code and provided to all statusLine scripts.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗