Skip to content

Instantly share code, notes, and snippets.

@ryanconmeo
Last active May 16, 2026 04:55
Show Gist options
  • Select an option

  • Save ryanconmeo/0a595d08ea09be781e0ceb57c47e0511 to your computer and use it in GitHub Desktop.

Select an option

Save ryanconmeo/0a595d08ea09be781e0ceb57c47e0511 to your computer and use it in GitHub Desktop.
show me the money — Claude Code live cost tracker

Claude Code Cost Status Bar

Adds a live cost tracker to the Claude Code CLI status bar:

Request: $0.0023 | Session: $0.0042 | Total: $1.2345

Install

1. Create the script

cat > ~/.claude/statusline.sh << 'EOF'
#!/usr/bin/env bash

PREV_COST_FILE="/tmp/claude_prev_cost"
GRAND_TOTAL_FILE="$HOME/.claude/grand_total_cost"

input=$(cat)

current=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')

if [ -f "$PREV_COST_FILE" ]; then
  prev=$(cat "$PREV_COST_FILE")
else
  prev=0
fi

echo "$current" > "$PREV_COST_FILE"

delta=$(awk "BEGIN { printf \"%.10f\", $current - $prev }")

if [ -f "$GRAND_TOTAL_FILE" ]; then
  grand=$(cat "$GRAND_TOTAL_FILE")
else
  grand=0
fi

grand=$(awk "BEGIN { printf \"%.10f\", $grand + $delta }")
echo "$grand" > "$GRAND_TOTAL_FILE"

if awk "BEGIN { exit !($delta == 0) }"; then
  printf "Session: \$%.4f | Total: \$%.4f" "$current" "$grand"
else
  printf "Request: \$%.4f | Session: \$%.4f | Total: \$%.4f" "$delta" "$current" "$grand"
fi
EOF
chmod +x ~/.claude/statusline.sh

2. Add to ~/.claude/settings.json

Add this inside the top-level {}:

"statusLine": {
  "type": "command",
  "command": "bash ~/.claude/statusline.sh"
}

3. Restart Claude Code

The status bar appears at the bottom of the interface.

Note: Grand total persists in ~/.claude/grand_total_cost across restarts. Requires jq (brew install jq on macOS).

Remove

rm ~/.claude/statusline.sh
rm ~/.claude/grand_total_cost   # optional — deletes cost history

Then remove the "statusLine": { ... } block from ~/.claude/settings.json and restart Claude Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment