05Writing

claude-overnight: I made my Claude limits work the night shift

· claude-code · tools

You’re wasting your Claude subscription if it isn’t running at 3am.

I’m a heavy Claude Code user, and if you’re anything like me, you know the cycle. You hit the 5-hour cap mid-morning, wait it out till afternoon, hit it again in the evening, and then go to bed mildly annoyed because you know that there’s a whole limit refresh happening while you sleep and you’re not using any of it.

There’s a sort of dark pattern by Anthropic, where the weekly limit and the daily allowance don’t line up. I was capping out the 5-hour window every single day and still ending the week with some of my weekly quota left over. It doesn’t roll over, just expires while I sleep, on a subscription I pay money for (that too, in dollars!)

So I built claude-overnight. You queue questions during the day, they run at night when your limits have reset, and there are markdown reports waiting in the morning. Coding tasks work too, and land on a git branch. A summary page opens in your browser once the batch finishes, with a resume command sitting right next to each one, so you don’t even have to go looking for the reports.

How we check limits

Anthropic doesn’t expose subscription usage programmatically. But Claude Code shows your limits with /usage, so the data exists somewhere.

Claude Code stores an OAuth token locally. On a Mac it’s in the Keychain under Claude Code-credentials, elsewhere it's ~/.claude/.credentials.json. That token works against an undocumented endpoint:

GET https://api.anthropic.com/api/oauth/usage
Authorization: Bearer <accessToken>
anthropic-beta: oauth-2025-04-20

which returns a limits list:

{ "kind": "session",       "percent": 27.5, "resets_at": "..." },
{ "kind": "weekly_scoped", "percent": 44,   "resets_at": "...",
  "scope": { "model": { "display_name": "Fable" } } }

session is the rolling 5-hour window. This is the same trick every menubar limit-tracker uses, even the one by Peter Steinberger (yes, the OpenClaw guy).

The actual design problem

Running claude at 3am is trivial. Cron can do that. The hard part is not spending the quota you’ll want in the morning. The real trick to this sort of tool is restraint.

claude-overnight won’t start a batch if the 5-hour window is already more than 20% used. It stops once the batch pushes it past 60%. It won’t run at all if the weekly is past 80%. And it rechecks between every job, because one long research question can move the needle more than you’d expect.

The point was never “use maximum quota.” It was: convert quota that was going to expire into answers, and leave enough in the tank for breakfast.

Jobs run through claude -p with tools locked to web search, in an empty scratch directory. Coding jobs are the exception — they need to edit files and run tests, so they run in a throwaway git worktree on an overnight/* branch, and only against repos you've explicitly trusted.

Headless mode returns a session id. Using that we can do claude resume <id> so it reopens the exact conversation that produced a report or branch. So the morning workflow isn't "read a report" — it's read a report, then talk with the thing that wrote it. "Why did you rank this option first? You missed step X, redo that part." The batch summary that opens in your browser has the resume command for every job sitting right there, waiting for you.

And if you don’t want to engage right now, overnight followup <id> "compare against Yjs specifically" queues a continuation for the next night. Questions become threads that run for as many nights as you want.

Try it

uv tool install claude-overnight
overnight install        # scheduler + /queue slash command
/queue why is my sqlite db slow after 10M rows?

macOS and Linux, Claude Pro/Max. Zero dependencies, stdlib Python, MIT: github.com/rohanprichard/claude-overnight. Issues and PRs welcome.