Developer Tool Warns Claude MAX Users Before 5-Hour Token Cap Cuts Sessions
A developer has built a shell script called token-budget-advisor.sh that monitors token usage in Claude MAX sessions and alerts users before they hit the platform's 5-hour output token cap. Unlike the built-in status line, which only shows a percentage, the tool translates usage into absolute token counts, flagging sessions as dangerous above 800,000 tokens and critical past 1.2 million. The script integrates with a dashboard and status line, pulling data from both the ccusage command-line tool and a local cost-log.jsonl file, preferring ccusage values when available. A key technical fix addresses a double-counting bug in cost-log.jsonl, where cumulative mid-session entries under the same session ID inflate token totals two to three times over; the script resolves this by retaining only the latest entry per session. The tool is designed to fail open on errors and remain compatible with Bash 3.2, making it suitable for unattended background workflows where hitting the cap silently would otherwise stall all pending tasks.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in