Claude Code status lines that show git status
Claude Code tells you the model and the directory, but not what git is doing. These status lines add the branch, and some layer on dirty-file counts or ahead and behind markers, so you can see where a session is about to commit before it happens.
Every preview below is rendered from the real script against the same example sessions, including one in a directory with no git repo, so you can check how each one degrades.
Pick a one-liner if you only need the branch. Pick dirty-file counts if you commit from the session. Pick ahead and behind markers if you track remotes.
Claude Code does not send git state in the status line's stdin JSON. Scripts that show a branch run git themselves in workspace.current_dir, for example git branch --show-current. Dirty-file counts come from git status --porcelain. Handle the no-repo case, or the line prints an error outside a repository. Each preview below includes a directory with no repo.
1 published status line.
Updated 2026-07-07
Status lines
Common questions
What does the status line show outside a git repository?
Whatever the script prints when git fails. A careful script runs git rev-parse --is-inside-work-tree first and skips the git segment when it fails. Each preview includes a directory with no repo, so you can see how a config handles it.
Can the status line show the pull request?
Claude Code can send an optional pr object with number, url, and review_state. It is not always present, so check for it before printing.
More ways to browse: