# Session Health Score Claude Code session health aggregator providing A-F grade based on cost efficiency, latency performance, productivity velocity, and cache utilization with actionable recommendations. --- ## Metadata **Title:** Session Health Score **Category:** statuslines **Author:** JSONbored **Added:** October 2025 **Tags:** health-score, session-grade, performance-aggregator, quality-metrics, optimization-recommendations **URL:** https://claudepro.directory/statuslines/session-health-score ## Overview Claude Code session health aggregator providing A-F grade based on cost efficiency, latency performance, productivity velocity, and cache utilization with actionable recommendations. ## Content #!/usr/bin/env bash SESSION HEALTH SCORE FOR CLAUDE CODE AGGREGATES MULTIPLE METRICS INTO OVERALL HEALTH GRADE (A-F) READ JSON FROM STDIN read -r input EXTRACT METRICS totalcost=$(echo "$input" | jq -r '.cost.totalcost_usd // 0') totaldurationms=$(echo "$input" | jq -r '.cost.totaldurationms // 1') apidurationms=$(echo "$input" | jq -r '.cost.totalapiduration_ms // 0') linesadded=$(echo "$input" | jq -r '.cost.totallines_added // 0') linesremoved=$(echo "$input" | jq -r '.cost.totallines_removed // 0') cachereadtokens=$(echo "$input" | jq -r '.cost.cachereadinput_tokens // 0') cachecreatetokens=$(echo "$input" | jq -r '.cost.cachecreationinput_tokens // 0') regularinputtokens=$(echo "$input" | jq -r '.cost.input_tokens // 0') CONVERT DURATION TO MINUTES if [ "$totaldurationms" -gt 0 ]; then durationminutes=$(echo "scale=2; $totalduration_ms / " | bc) else duration_minutes= fi METRIC 1: COST EFFICIENCY (25 POINTS) TARGET: $ = POOR if (( $(echo "$duration_minutes > 0" | bc -l) )); then costperminute=$(echo "scale=4; $totalcost / $durationminutes" | bc) else costperminute=0 fi if (( $(echo "$costperminute 3s = poor networktime=$((totaldurationms - apiduration_ms)) networkseconds=$(echo "scale=2; $networktime / " | bc) if (( $(echo "$network_seconds 30 lines/min = excellent, = good, 0" | bc -l) )); then linesperminute=$(echo "scale=1; $totalchanged / $durationminutes" | bc) else linesperminute=0 fi if (( $(echo "$linesperminute > 30" | bc -l) )); then productivity_score=25 elif (( $(echo "$linesperminute > 15" | bc -l) )); then productivity_score=18 elif (( $(echo "$linesperminute > 5" | bc -l) )); then productivity_score=12 else productivity_score=5 fi METRIC 4: CACHE UTILIZATION (25 POINTS) TARGET: >40% HIT RATE = EXCELLENT, % = GOOD, 30 L/MIN ? Cache utilization metric (25 points): hit rate vs target >40% ? Actionable recommendations identifying weakest metric with optimization tips ? Metric breakdown display showing individual scores (C:25 L:18 P:12 K:25) ? Color-coded grading (green A, blue B, yellow C, orange D, red F) CONFIGURATION Format: bash Refresh Interval: 2000ms Position: left USE CASES ? Quick session quality assessment at a glance ? Identifying performance bottlenecks across multiple dimensions ? Comparing session health across different projects/workflows ? Optimizing Claude Code usage based on weakest metric feedback ? Team performance benchmarking with standardized grading ? Historical session quality tracking for improvement trends TROUBLESHOOTING 1) Health score always showing F grade despite good session Solution: Verify all JSON fields exist: cost.totalcostusd, cost.totaldurationms, cost.totalapidurationms, cost.totallinesadded, cost.totallinesremoved, cost.cachereadinputtokens. Missing fields default to 0, causing low scores. Check: echo '$input' | jq .cost. Ensure Claude Code version exposes all required metrics. 2) Individual metric scores seem incorrect Solution: Check thresholds: Cost (30 L/min = 25pt, >15 = 18pt), Cache (>40% hit = 25pt, >20% = 18pt). Verify calculations: costperminute = totalcost / durationminutes. Test each metric independently. 3) Recommendation not showing despite low grade Solution: Recommendations only display for grades C (), D (), or F ( latency > productivity > cache). 5) Cache score always showing 5 despite caching enabled Solution: Cache score requires cachereadinputtokens field. Verify: echo '$input' | jq .cost.cachereadinputtokens. If missing/null, defaults to 0 giving minimum score (5pt). Check that prompt caching is properly configured and Claude Code version supports cache metrics. Zero cachereadtokens = no cache benefit detected. 6) Metric breakdown abbreviations confusing Solution: Abbreviations: C = Cost efficiency, L = Latency performance, P = Productivity velocity, K = Cache utilization (K for Kache to avoid confusion with C). Each shows score out of 25 points. Add legend to documentation or customize METRICS string for clarity. TECHNICAL DETAILS Documentation: https://docs.claude.com/en/docs/claude-code/statusline PREVIEW ✓ Health: B (82/) | GOOD | C:25 L:18 P:22 K:17 --- Source: Claude Pro Directory Website: https://claudepro.directory URL: https://claudepro.directory/statuslines/session-health-score This content is optimized for Large Language Models (LLMs). For full formatting and interactive features, visit the website.