Repository navigation
Add /usage-all to show usage and limit resets for every Claude account - #256
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/usageshows plan usage for one account only, and I switch between three: the default login,~/.claude-automation, and~/.claude-personal. Nothing shows which account is out of room or when each limit resets, and nothing shows which account docket and/gowill review on next./usage-allfinds every signed-in account (the default login, each~/.claude-*directory, and each account in docket'sconfig.toml) and calls/api/oauth/usagewith that account's token from the keychain. That's the same endpoint/usageuses. The token goes to curl on stdin, so it never shows up in argv or in the output. When a token has expired, the script runsclaude mcp getunder that account so Claude Code refreshes the token itself. Writing credentials from the script could race a running session's refresh and invalidate the rotated refresh token.claude mcp listrefreshed a real expired token, but it took 22 seconds.mcp getreaches the same refresh path in about a second, but I haven't yet watched it refresh a token whose refresh token is still valid. If it doesn't, the report prints the/logincommand to run.The report ends with docket's rotation, the account the next review runs on, and each limit docket recorded. Those lines come from a new
run-review.py accountssubcommand. It sharesreview_accounts()with/go's launch path, so the report and/gocan't disagree.Test plan
ai/skills/usage-all/scripts/tests/test-claude-usage.sh(30 cases, offline shims forsecurity,curl,claude), on macOS and in anubuntu:24.04container with jq 1.7python3 ai/skills/go/scripts/tests/test_run_review.py(85 tests, 2 new foraccounts)ai/tests/test-skill-spec.shandai/tests/test-canonical-skills.shai/install.sh, run/usage-allonce the automation token has expired, to confirmmcp getrefreshes ithttps://claude.ai/code/session_01EgGS8yEU8u5bLREUrkqhKS