Element guide
Claude Code statusline with git branch
Show the current git branch in your Claude Code statusline so you always know which branch the assistant is editing.
Why include the git branch?
When Claude Code spans multiple sessions, it is easy to lose track of which branch is checked out. With Git installed, the exported Bash and PowerShell scripts query the checkout using git -C <directory> rev-parse --abbrev-ref HEAD. They take the directory from workspace.current_dir, falling back to cwd in Claude Code's session JSON.
workspace.git_worktree is the name of a linked worktree, not a reliable branch name. It is absent in the main working tree, and the worktree name can differ from the branch checked out there. See Anthropic's official statusline field reference.
Branch context is especially helpful when you keep separate worktrees for review, experiment, and main lines of work. A glance at the bottom of the terminal confirms whether the agent is editing the right tree before you accept a multi-file edit.
How it looks
The preview above pairs the model name with a sample directory and branch, styled green and bold. Browser previews use sample session data; they do not inspect a Git checkout on your machine. Use the installed script to see your own branch.
For a missing or unexpected branch, check that Git is installed and the session directory is inside the intended repository. In detached HEAD state, the generated command reports HEAD. Do not use a linked worktree's name as a substitute for checking its branch.
How to add it
Open the visual builder, drag the Git Branch element onto the canvas, and pick a foreground color. The live preview re-renders on every change so you can iterate on styling without leaving the page. When the design looks right, hit Install and paste the one-line command into your terminal — the installer structurally merges your new statusline into ~/.claude/settings.json without touching any of your other settings.