DEV Community

Cover image for 🐒 and πŸ‡ in My Claude Code Status Line: Now Watching the Week
yukihiro amadatsu
yukihiro amadatsu

Posted on

🐒 and πŸ‡ in My Claude Code Status Line: Now Watching the Week

I recently built a tortoise-and-hare status line for Claude Code that shows whether you're burning tokens faster than a steady pace. That post is here.

Then Anthropic raised the 5h limit but tightened the weekly cap. Suddenly the 7-day limit became the one that actually bites β€” with the relaxed 5h window, hitting 100% in five hours takes real effort. The weekly cap doesn't.

So I updated the script: 7d gets the full-width tortoise/hare bar, 5h keeps the same logic in a shorter bar on the right:

[Sonnet 4.6] Β·Β·Β·Β·Β·Β·Β·Β·πŸ’Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·πŸ‡ 7d:105% ⚠️@5/14 | Β·Β·πŸ’Β·Β·πŸ‡Β·Β·Β· 5h:70% ⚠️@18:00
Enter fullscreen mode Exit fullscreen mode

(The 7d:105% is real β€” that's what I'm seeing right now. Going over 100% means you're into Claude Code's additional usage allowance beyond the base weekly limit. The πŸ‡ flies off the right edge of the bar when that happens.)

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

MODEL=$(echo "$input" | jq -r '.model.display_name')
FIVE_H_PCT=$(echo "$input" | jq -r '(.rate_limits.five_hour.used_percentage // 0)')
SEVEN_D_PCT=$(echo "$input" | jq -r '(.rate_limits.seven_day.used_percentage // 0)')
FIVE_H_RESETS=$(echo "$input" | jq -r '.rate_limits.five_hour.resets_at // empty')
SEVEN_D_RESETS=$(echo "$input" | jq -r '.rate_limits.seven_day.resets_at // empty')

NOW=$(date +%s)
TZ=Asia/Tokyo  # change to your local timezone
W7=20; W5=10   # bar widths: 7d full, 5h half

make_bar() {
    local actual=$1 ideal=$2 width=$3 bar="" i
    for i in $(seq 0 $((width - 1))); do
        if [ "$i" -eq "$ideal" ] && [ "$i" -eq "$actual" ]; then bar="${bar}πŸ’πŸ‡"
        elif [ "$i" -eq "$ideal" ]; then bar="${bar}🐒"
        elif [ "$i" -eq "$actual" ]; then bar="${bar}πŸ‡"
        else bar="${bar}Β·"
        fi
    done
    [ "$actual" -ge "$width" ] && bar="${bar}πŸ‡"
    echo "$bar"
}

# 7-day window (main bar, width=20)
if [ -n "$SEVEN_D_RESETS" ]; then
    REMAINING_7D=$((SEVEN_D_RESETS - NOW))
    RESET_7D_MD=$(date -r "$SEVEN_D_RESETS" "+%m/%d" | awk -F/ '{printf "%d/%d", $1, $2}')
    RESET_7D_TAG="@${RESET_7D_MD}"
    if [ "$REMAINING_7D" -gt 0 ] && [ "$REMAINING_7D" -lt 604800 ]; then
        IDEAL_7D=$(( (604800 - REMAINING_7D) * W7 / 604800 ))
    else
        IDEAL_7D=0
    fi
else
    IDEAL_7D=0; RESET_7D_TAG="@?"
fi
ACTUAL_7D=$(awk "BEGIN {print int($SEVEN_D_PCT * $W7 / 100)}")
BAR_7D=$(make_bar "$ACTUAL_7D" "$IDEAL_7D" "$W7")
[ "$ACTUAL_7D" -gt "$IDEAL_7D" ] && WARN_7D=" ⚠️" || WARN_7D=""
SEVEN_D_DISP=$(printf "%.0f" "$SEVEN_D_PCT")

# 5-hour window (half bar, width=10)
if [ -n "$FIVE_H_RESETS" ]; then
    REMAINING_5H=$((FIVE_H_RESETS - NOW))
    RESET_5H_JST=$(date -r "$FIVE_H_RESETS" "+%H:%M")
    RESET_5H_TAG="@${RESET_5H_JST}"
    if [ "$REMAINING_5H" -gt 0 ] && [ "$REMAINING_5H" -lt 18000 ]; then
        IDEAL_5H=$(( (18000 - REMAINING_5H) * W5 / 18000 ))
    else
        IDEAL_5H=0
    fi
else
    IDEAL_5H=0; RESET_5H_TAG="@?"
fi
ACTUAL_5H=$(awk "BEGIN {print int($FIVE_H_PCT * $W5 / 100)}")
BAR_5H=$(make_bar "$ACTUAL_5H" "$IDEAL_5H" "$W5")
[ "$ACTUAL_5H" -gt "$IDEAL_5H" ] && WARN_5H=" ⚠️" || WARN_5H=""
FIVE_H_DISP=$(printf "%.0f" "$FIVE_H_PCT")

echo "[${MODEL}] ${BAR_7D} 7d:${SEVEN_D_DISP}%${WARN_7D}${RESET_7D_TAG} | ${BAR_5H} 5h:${FIVE_H_DISP}%${WARN_5H}${RESET_5H_TAG}"
Enter fullscreen mode Exit fullscreen mode

W7=20 and W5=10 control bar widths. 18000 = 5 hours in seconds, 604800 = 7 days. Change TZ=Asia/Tokyo at the top to your local timezone.

Top comments (2)

Collapse
 
johns23424234324234 profile image
John

Nice update. Splitting the 7d and 5h views is the part that makes this actually useful, since those limits create totally different behavior. I’d probably also keep the reset date/time visible exactly like you did, because percent alone hides the urgency.

Collapse
 
suruseas profile image
yukihiro amadatsu • Edited

Sorry for the late reply, I didn't notice your comment until now! And thank you for it.
I've been running this setup as-is for about three weeks now, and I've gotten much better at pacing myself, so I no longer hit the limit. So from my side too, I think it turned out to be a good updateπŸ˜€