Claude Code can show a custom status line under the prompt, a single line of text you control. It’s the easiest way to keep the important things in view while you work: which model you’re on, which folder and git branch the session is in, and how full the context window is getting. This guide covers the quick way to set one up and how to write your own.
How the Claude Code status line works
The status line is just a command. Claude Code runs it, sends it a JSON description of the current session on standard input, and shows whatever the command prints. It runs again as the session changes, for example after each assistant message, after /compact, and when you switch permission mode.
It’s configured with a statusLine entry in your settings file: ~/.claude/settings.json for every project, or .claude/settings.json in one repository.
The quick way: /statusline
Type /statusline inside Claude Code and describe what you want in plain English:
/statusline show the model name, the current folder and the git branch
Claude writes a small script into ~/.claude/ and adds the statusLine entry to your settings for you. Run /statusline again to change it, or ask it to remove the status line.
Writing your own status line script
If you’d rather control it yourself, start with the settings entry:
{
"statusLine": {
"type": "command",
"command": "~/.claude/statusline.sh",
"padding": 0
}
}
Then create the script. This one uses jq to read the model name and working directory from the JSON input, and adds the git branch if there is one:
#!/bin/bash
input=$(cat)
model=$(echo "$input" | jq -r '.model.display_name')
dir=$(echo "$input" | jq -r '.workspace.current_dir')
branch=$(git -C "$dir" branch --show-current 2>/dev/null)
line="[$model] ${dir##*/}"
[ -n "$branch" ] && line="$line on $branch"
echo "$line"
Make it executable with chmod +x ~/.claude/statusline.sh and start a new session. You’ll see something like [Opus] my-project on main under the prompt.
Install jq first if you don’t have it (brew install jq on a Mac, sudo apt install jq on Debian or Ubuntu). Any language works, though: Python, Node or a compiled binary are all fine, as long as it reads standard input and prints a line.
What’s in the JSON input
The exact fields grow with each release, so check the official status line docs for the current list. The ones most people use are:
model.display_name: the model the session is using.workspace.current_dirandworkspace.project_dir: where you are and where the session started.session_idandtranscript_path: useful if you want to log or link sessions.- Cost and context fields: running cost and how much of the context window is used, handy for spotting when to compact.
To see exactly what your version sends, point the status line at a script that saves its input, start a session, then read the file:
#!/bin/bash
cat > /tmp/statusline-input.json
echo "debug"
Ideas worth putting in it
- Context use. A percentage tells you when you’re close to the limit, before Claude starts forgetting things. Claude Code context, /compact, /clear and CLAUDE.md explained covers what to do when it gets high.
- Session cost or usage. Useful on API billing, or if you keep hitting limits; see Claude Code usage limit reached for ways to use fewer tokens.
- Git state. Branch plus a marker for uncommitted changes (
git status --porcelain) stops you working on the wrong branch. - Colour. ANSI colour codes work, so you can turn the context figure red past a threshold.
Keep it fast
The status line runs often, so a slow script makes the interface feel sluggish. Avoid network calls, and cache anything expensive (such as a slow git status in a huge repository) to a temporary file for a few seconds. Print only one line; extra lines and stderr output just add noise.
Troubleshooting
- Nothing appears: check the script is executable and the path in settings is right. Run it by hand with sample JSON:
echo '{"model":{"display_name":"test"}}' | ~/.claude/statusline.sh. - It shows
null: the field name is wrong for your version. Capture the real input as shown above. - Settings ignored: a project
.claude/settings.jsonoverrides your user settings, so look there too.
Status lines pair well with Claude Code hooks, which use the same idea of small scripts reading JSON from Claude Code, but to allow or block actions rather than display information.

Leave a Reply
You must be logged in to post a comment.