TIL: You can read Claude Code quota locally (no scraping, no API) ~/.claude/settings.json:
cat ~/.claude/statusline_raw.json | jq '.rate_limits'
A couple implementation details:- The command must exit 0, otherwise Claude Code treats it as a failure - It should not write anything to stdout, or it will show up in the UI - Writing with `tmp && mv` avoids partial reads if something else is consuming the file - The quota data is not present until the first request comes back This is actually somewhat documented (the `statusLine` command receives structured JSON on stdin, including `rate_limits`), but I didn't notice till recently. I was trying to build a small widget that shows current quota usage, updates live, and notifies me when the 5-hour window resets if I've run out. |