# Burn Rate Monitor Real-time burn rate monitor showing cost per minute, tokens per minute, and projected daily spend to prevent budget overruns during Claude Code sessions. --- ## Metadata **Title:** Burn Rate Monitor **Category:** statuslines **Author:** JSONbored **Added:** October 2025 **Tags:** burn-rate, cost-tracking, budget, monitoring, real-time **URL:** https://claudepro.directory/statuslines/burn-rate-monitor ## Overview Real-time burn rate monitor showing cost per minute, tokens per minute, and projected daily spend to prevent budget overruns during Claude Code sessions. ## Content #!/usr/bin/env bash BURN RATE MONITOR STATUSLINE FOR CLAUDE CODE CALCULATES REAL-TIME COST/MINUTE AND TOKENS/MINUTE READ JSON FROM STDIN read -r input EXTRACT VALUES totalcost=$(echo "$input" | jq -r '.cost.totalcost_usd // 0') totaldurationms=$(echo "$input" | jq -r '.cost.totaldurationms // 1') linesadded=$(echo "$input" | jq -r '.cost.totallines_added // 0') linesremoved=$(echo "$input" | jq -r '.cost.totallines_removed // 0') CALCULATE DURATION IN MINUTES (AVOID DIVISION BY ZERO) if [ "$totaldurationms" -gt 0 ]; then durationminutes=$(echo "scale=2; $totalduration_ms / " | bc) else duration_minutes= # Prevent division by zero fi CALCULATE BURN RATE (COST PER MINUTE) if (( $(echo "$duration_minutes > 0" | bc -l) )); then costperminute=$(echo "scale=4; $totalcost / $durationminutes" | bc) else costperminute=0 fi CALCULATE TOTAL TOKENS (ESTIMATE: LINES * 10 TOKENS PER LINE AVG) totaltokens=$(( (linesadded + lines_removed) * 10 )) CALCULATE TOKENS PER MINUTE if (( $(echo "$duration_minutes > 0" | bc -l) )); then tokensperminute=$(echo "scale=0; $totaltokens / $durationminutes" | bc) else tokensperminute=0 fi PROJECT DAILY SPEND (ASSUMING CURRENT BURN RATE FOR 24 HOURS) if (( $(echo "$costperminute > 0" | bc -l) )); then dailyprojection=$(echo "scale=2; $costper_minute * " | bc) # minutes in 24 hours else daily_projection=0 fi COLOR CODING FOR BURN RATE ALERTS if (( $(echo "$costperminute > " | bc -l) )); then BURN_COLOR="\[38;5;196m" # Red: High burn rate (>$/min) elif (( $(echo "$costperminute > " | bc -l) )); then BURN_COLOR="\[38;5;226m" # Yellow: Medium burn rate ($-$/min) else BURN_COLOR="\[38;5;46m" # Green: Low burn rate ($/min) ? Prevents budget overruns with live spending visibility ? Lightweight bash script with bc for floating-point math ? Works with any Claude Code model (Opus, Sonnet, Haiku) ? Zero external dependencies beyond jq and bc CONFIGURATION Format: bash Refresh Interval: 500ms Position: left USE CASES ? Budget-conscious developers tracking spending in real-time ? Teams with daily/monthly Claude Code budget limits ? Freelancers billing clients for AI-assisted development time ? Identifying expensive sessions before costs spiral ? Optimizing model selection based on burn rate feedback ? Production environments monitoring AI cost efficiency TROUBLESHOOTING 1) Burn rate showing 0 or incorrect values despite active session Solution: Verify cost.totalcostusd and cost.totaldurationms fields exist in JSON: echo '$input' | jq .cost. Ensure bc is installed: which bc. Check division by zero protection is working for very short sessions. 2) bc command not found error when running script Solution: Install bc calculator: brew install bc (macOS), apt install bc (Linux). Alternative: use awk for calculations if bc unavailable: awk -v cost=$totalcost -v dur=$durationminutes 'BEGIN {print cost/dur}' 3) Daily projection seems unrealistically high Solution: Daily projection assumes CONTINUOUS usage at current burn rate for 24 hours. This is intentional for worst-case budgeting. Actual daily cost will be lower if you don't use Claude Code 24/7. Adjust multiplier from to expected active minutes. 4) Token per minute calculation inaccurate Solution: Script estimates 10 tokens per line (conservative average). Actual token count varies by language/verbosity. For precise tracking, integrate with Claude API token counting if exposed in future JSON fields. Current estimate is sufficient for burn rate trend monitoring. 5) Color coding not displaying or showing escape codes as text Solution: Ensure terminal supports ANSI colors. Test: echo -e '\[38;5;196mRED\[0m' (should show red text). Verify statusline script outputs to stdout not stderr. Check Claude Code settings.json has correct command path. TECHNICAL DETAILS Documentation: https://docs.claude.com/en/docs/claude-code/statusline PREVIEW 🔥 Burn: $/min | 📊 1, tok/min | 📅 Daily: $ --- Source: Claude Pro Directory Website: https://claudepro.directory URL: https://claudepro.directory/statuslines/burn-rate-monitor This content is optimized for Large Language Models (LLMs). For full formatting and interactive features, visit the website.