Claude Code Status Line: Display Model, Cost, and Git Branch in Your Terminal
Set up a custom Claude Code status line showing model name, git branch, cost tracking, and context usage. Includes bash, Python, and Node.js scripts you can copy.
Your Claude Code terminal is missing useful information. The status line fixes that by putting model name, git branch, session cost, and context usage right at the bottom of the interface.
Think of it like PS1 for Claude Code. If you've ever customized a shell prompt with Oh-my-zsh or Starship, this is the same idea. One line of real-time info that keeps you oriented while you work.
What the Status Line Shows
The status line sits at the bottom of the Claude Code interface and updates every time the conversation changes. It can display anything your script outputs: the current model, which git branch you're on, how much you've spent this session, or how full your context window is.
Here's what a configured status line looks like in practice:
That single line tells you the model, the project folder, the git branch, the session cost so far, and the percentage of your context window used. All updated automatically.
Quick Setup with /statusline
The fastest path to a working status line is the built-in /statusline command. Type it directly into Claude Code and it generates a script for you.
Claude Code will create a status line script that mirrors your terminal prompt by default. But you can also give it specific instructions:
That's it. Claude Code writes the script, configures the settings, and the status line appears. If you want more control, keep reading for manual setup.
Manual Setup via settings.json
For full control, add a statusLine entry to your project's .claude/settings.json (or your global ~/.claude/settings.json for all projects):
Three fields to know:
- type: Always
"command"for script-based status lines - command: Path to the script that generates your status line output
- padding: Number of empty lines above the status line (0 is typical)
After adding this, create the script file and make it executable:
The chmod +x step matters. If your status line doesn't appear, a missing execute permission is almost always the reason.
How the Status Line Engine Works
Understanding the mechanics helps when debugging or building custom scripts:
- Update trigger: The status line refreshes whenever conversation messages change
- Throttle: Updates run at most every 300ms to avoid performance issues
- Output handling: Only the first line of stdout from your script becomes the status line text
- Colors: Full ANSI color code support for styling
- Input: Claude Code pipes a JSON object with session data into your script via stdin
That last point is the key. Your script receives structured JSON containing the current model, workspace paths, session cost, context window stats, and more. Parse it, format it, print one line to stdout.
The JSON Input Your Script Receives
Every time the status line updates, your script gets this JSON structure via stdin:
The fields that matter most for practical status lines:
- model.display_name: Short model name like "Opus" or "Sonnet"
- workspace.current_dir: Where you're working right now
- cost.total_cost_usd: Running cost of the session in dollars
- cost.total_lines_added / total_lines_removed: Track code changes
- context_window.used_percentage: Pre-calculated context usage (0-100)
- context_window.context_window_size: Total context window capacity
Status Line Scripts You Can Copy
Here are complete, runnable scripts in multiple languages. Pick the one that fits your setup.
Simple Bash Status Line
The simplest useful status line. Shows model name and current directory:
Output: [Opus] my-project
This script uses jq for JSON parsing. If you don't have it installed, run brew install jq on macOS or sudo apt install jq on Ubuntu.
Git-Aware Bash Status Line
Adds the current git branch, which is useful when you're juggling feature branches:
Output: [Opus] my-project | feature/auth
Full-Featured Bash Status Line
Model, git branch, cost, and context percentage all in one line:
Output: [Opus] my-project | main | $0.42 | Ctx: 37%
Bash with ANSI Colors
Color-coded output makes information scannable at a glance:
The context percentage turns green below 50%, yellow between 50-80%, and red above 80%. You can immediately see when it's time to manage your context window.
Helper Function Approach for Complex Scripts
When your status line script grows, helper functions keep things readable:
Output: [Opus] my-project | $0.42 | Ctx:37% | +156/-23
The +156/-23 shows lines added and removed in the session. A quick way to gauge how much code has changed.
Python Status Line
If you prefer Python over bash:
Node.js Status Line
For JavaScript developers:
Tracking Context Window Usage
Watching your context window is one of the most practical uses for the status line. When context fills up, Claude Code compacts the conversation and you lose detail. Knowing where you stand helps you decide when to start fresh or compact strategically.
Simple approach using the pre-calculated percentage:
Advanced approach with manual calculation from raw token counts:
The manual approach lets you see raw token numbers alongside the percentage. Useful when you want to know exactly how many tokens you have left, especially when picking between different models with different context sizes.
Tracking Session Cost
The cost.total_cost_usd field updates in real time. Displaying it in your status line keeps spending visible without needing to check the dashboard:
If you're on a budget or tracking costs per feature, this is immediately useful. Pair it with model selection strategies to switch models when a task doesn't need the most expensive option.
Troubleshooting
Status line doesn't appear at all
The most common cause is a missing execute permission on the script file. Fix it with:
Script runs but output is empty
Your script might be writing to stderr instead of stdout. The status line only reads the first line of stdout. Add a simple echo "test" to verify output, then build from there.
Testing your script manually
You can test without running Claude Code by piping mock JSON into your script:
If that prints the expected output, the script works. If it doesn't, the issue is in parsing.
jq not found
Install it with your package manager:
Creative Status Line Ideas
Once you have the basics working, here are some ideas to make your status line more useful:
- Lines changed tracker: Show
+added/-removedto monitor session productivity - Session duration: Calculate elapsed time from
total_duration_ms - Model ID display: Show the full model identifier when testing different model configurations
- Project vs current directory: Show both when Claude Code navigates into subdirectories
- Cost-per-minute: Divide
total_cost_usdbytotal_duration_msto see burn rate - Context window bar: Replace the percentage with a visual bar like
[========--] - Conditional warnings: Flash a color when context exceeds 80% or cost passes a threshold
The status line runs a script you control. If you can write it in bash, Python, or Node.js, you can display it.
What to Try Next
Your status line is set up. Here are natural next steps:
- Manage context proactively: Use your context percentage display alongside context buffer management strategies
- Set up the terminal environment: Learn terminal control techniques for a complete Claude Code workspace
- Configure project settings: Make sure your configuration basics are solid so every session starts with the right context
Last updated on