# Five Hour Window Tracker Claude Code 5-hour rolling session window tracker with visual progress bar, time remaining countdown, and expiry warnings for usage management. --- ## Metadata **Title:** Five Hour Window Tracker **Category:** statuslines **Author:** JSONbored **Added:** October 2025 **Tags:** 5-hour-window, session-tracking, usage-limits, countdown, rolling-window **URL:** https://claudepro.directory/statuslines/five-hour-window-tracker ## Overview Claude Code 5-hour rolling session window tracker with visual progress bar, time remaining countdown, and expiry warnings for usage management. ## Content #!/usr/bin/env bash 5-HOUR SESSION WINDOW TRACKER FOR CLAUDE CODE TRACKS CLAUDE'S UNIQUE 5-HOUR ROLLING SESSION WINDOW READ JSON FROM STDIN read -r input EXTRACT SESSION DURATION IN MILLISECONDS totaldurationms=$(echo "$input" | jq -r '.cost.totaldurationms // 0') CONVERT TO MINUTES AND HOURS durationminutes=$((totalduration_ms / )) durationhours=$((durationminutes / 60)) remainingminutes=$((durationminutes % 60)) 5-HOUR WINDOW IS MINUTES WINDOW_LIMIT= timeremaining=$((WINDOWLIMIT - duration_minutes)) CALCULATE PERCENTAGE OF WINDOW USED if [ $duration_minutes -gt 0 ]; then percentageused=$(( (durationminutes * ) / WINDOW_LIMIT )) else percentage_used=0 fi PREVENT OVERFLOW (SESSIONS CAN CONTINUE BEYOND 5 HOURS IN PRACTICE) if [ $percentage_used -gt ]; then percentage_used= time_remaining=0 fi COLOR CODING BASED ON WINDOW USAGE if [ $percentage_used -lt 50 ]; then STATUS_COLOR="\[38;5;46m" # Green: 80% used STATUS_ICON="⏰" fi BUILD PROGRESS BAR (20 CHARACTERS WIDE) barfilled=$(( percentageused / 5 )) # Each char = 5% barempty=$(( 20 - barfilled )) bar=$(printf "█%.0s" $(seq 1 $barfilled))$(printf "░%.0s" $(seq 1 $barempty)) FORMAT TIME REMAINING if [ $time_remaining -gt 60 ]; then remaininghours=$((timeremaining / 60)) remainingmins=$((timeremaining % 60)) timedisplay="${remaininghours}h ${remaining_mins}m" elif [ $time_remaining -gt 0 ]; then timedisplay="${timeremaining}m" else time_display="EXPIRED" fi RESET="\[0m" OUTPUT STATUSLINE echo -e "${STATUSICON} 5H Window: ${STATUSCOLOR}${bar}${RESET} ${percentageused}% | ${STATUSCOLOR}${time_display}${RESET} left" KEY FEATURES ? Claude Code specific 5-hour rolling window tracking ( minutes) ? Visual progress bar showing window consumption (20-char bar, each █ = 5%) ? Time remaining countdown in hours/minutes format ? Color-coded status alerts (green 80%) ? Expiry warning when window approaches limit ? Percentage used calculation for quick assessment ? Handles overflow gracefully (sessions beyond 5 hours) ? Lightweight bash implementation with no external dependencies CONFIGURATION Format: bash Refresh Interval: 1000ms Position: left USE CASES ? Managing Claude Code's unique 5-hour billing window ? Preventing unexpected session expiry during critical work ? Planning work sessions around 5-hour limit ? Tracking multiple overlapping 5-hour windows ? Budget management for usage-limited accounts ? Session planning for long coding marathons TROUBLESHOOTING 1) Progress bar not updating or showing as empty boxes Solution: Ensure terminal supports Unicode block characters (█ and ░). Test with: echo -e '█████░░░░░'. If unsupported, replace with ASCII: barfilled uses '#' and barempty uses '-' instead of Unicode blocks. 2) Time remaining showing negative or EXPIRED incorrectly Solution: Check cost.totaldurationms field in JSON: echo '$input' | jq .cost.totaldurationms. Verify calculation: durationminutes should be totalduration_ms / . If sessions overlap, this tracks CURRENT session only, not aggregate time. 3) Percentage exceeds % showing incorrect progress Solution: Script caps percentage at % with overflow protection. Claude sessions can continue beyond 5 hours in practice. If you see % + EXPIRED, session has exceeded window. This is expected behavior, not a bug. Start new session to reset window. 4) Warning colors not displaying at correct thresholds Solution: Verify color thresholds: 80% red. Check percentageused calculation: (durationminutes * ) / . Test with known durations: min should be 50% yellow, min should be 83% red. 5) Multiple overlapping sessions not reflected in tracker Solution: Statusline tracks CURRENT session only (based on session_id in JSON). Claude supports multiple overlapping 5-hour windows simultaneously. To track multiple sessions, run separate statusline instances or modify script to read from multiple session files. TECHNICAL DETAILS Documentation: https://docs.claude.com/en/docs/claude-code/statusline PREVIEW ✓ 5H Window: ████████████░░░░░░░░ 60% | 2h 0m left --- Source: Claude Pro Directory Website: https://claudepro.directory URL: https://claudepro.directory/statuslines/five-hour-window-tracker This content is optimized for Large Language Models (LLMs). For full formatting and interactive features, visit the website.