Claude Tips mascot
Claude Tips & Tricks
Claude Code intermediate

Add a Custom Status Line to Track Costs

Configure a custom status line script that displays real-time token usage, costs, model info, and git branch directly in your Claude Code terminal.

Claude Code can display a custom status line at the bottom of your terminal that updates in real-time. Show token counts, estimated costs, model name, or git branch.

Setup

Add this to your .claude/settings.json:

{
  "statusLine": {
    "type": "command",
    "command": "/path/to/your/statusline.sh"
  }
}

Example Script

Create statusline.sh:

#!/bin/bash
INPUT=$(cat)

MODEL=$(echo "$INPUT" | jq -r '.model // "unknown"')
INPUT_TOKENS=$(echo "$INPUT" | jq -r '.tokenUsage.input // 0')
OUTPUT_TOKENS=$(echo "$INPUT" | jq -r '.tokenUsage.output // 0')
COST=$(echo "$INPUT" | jq -r '.costUsd // 0')
GIT_BRANCH=$(git branch --show-current 2>/dev/null || echo "no-git")

COST_FMT=$(printf "%.4f" "$COST")

echo "$MODEL | In: ${INPUT_TOKENS} Out: ${OUTPUT_TOKENS} | \$${COST_FMT} | ${GIT_BRANCH}"
chmod +x statusline.sh

What You Can Display

  • Model being used (Opus, Sonnet, Haiku)
  • Token counts (input/output/thinking)
  • Running cost in dollars
  • Current git branch
  • Custom alerts when costs exceed thresholds
Paste into Claude Code
Set up a custom Claude Code status line that shows token usage, estimated cost, and current git branch. Create the status script and update .claude/settings.json.