Dev.to
7/17/2026

Stop Before You Hit the 5-Hour Block Cap: A Token Sentinel Built from ccusage and a Cost Log
Short summary
The author built a token-budget-advisor.sh script that monitors Claude Code's 5-hour block output-token ceiling in real time, using ccusage as the authoritative source and cost-log.jsonl as fallback. Warn threshold is 800k output tokens; critical is 1.2M, prompting heavy work to move to the next block. The dual-source design cross-checks accuracy and flags drift, preventing silent rate-limit exhaustion during unattended automation runs.
- •Script monitors Claude Code 5-hour block token usage with warn (800k) and critical (1.2M) thresholds
- •Dual-source design uses ccusage as authoritative and cost-log.jsonl as fallback for reliability
- •Designed for unattended launchd automation jobs where token cap exhaustion goes unnoticed
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



