DEV Community

Danil Redko
Danil Redko

Posted on

Where Claude Code and Codex keep your usage limits, and how to read them yourself

Both Claude Code and Codex already know how much of your limit you've used. They just don't put it anywhere you look while a task is running. Here is where the numbers live, as of December 2026, and how to read them with a few lines of script.

Codex: it's in the session logs

Every Codex session writes a JSONL file under ~/.codex/sessions (on Windows, %USERPROFILE%\.codex\sessions; if you set CODEX_HOME, it's under that folder instead). Files are grouped by date, one line per event.

Some of those lines carry a rate_limits object with two windows:

  • primary: the short window (5 hours)
  • secondary: the weekly window

Each window has used_percent, window_minutes, and either resets_in_seconds or resets_at. So the last line that contains rate_limits in your newest session file is your current state.

A quick PowerShell check:

$dir  = Join-Path $env:USERPROFILE ".codex\sessions"
$file = Get-ChildItem $dir -Recurse -Filter *.jsonl | Sort-Object LastWriteTime | Select-Object -Last 1
$line = Select-String -Path $file.FullName -Pattern '"rate_limits"' | Select-Object -Last 1
[regex]::Matches($line.Line, '"used_percent":\s*([\d.]+)') | ForEach-Object { $_.Groups[1].Value + "%" }
Enter fullscreen mode Exit fullscreen mode

The first number is the 5-hour window, the second is the week. If resets_in_seconds is what you get, add it to the line's timestamp to know when the window clears.

Claude Code: ask the status line

Claude Code can run a command of your choice after each reply and show its output as the status line. That command receives a JSON payload on stdin, and the payload includes rate_limits with five_hour and seven_day, each with used_percentage and resets_at. These are the same numbers the usage panel shows, not an estimate.

Register the command in ~/.claude/settings.json:

{
  "statusLine": { "type": "command", "command": "~/.claude/limits.sh", "padding": 0 }
}
Enter fullscreen mode Exit fullscreen mode

And a minimal limits.sh with jq:

#!/bin/bash
jq -r '"5h \(.rate_limits.five_hour.used_percentage // "?")%  week \(.rate_limits.seven_day.used_percentage // "?")%"'
Enter fullscreen mode Exit fullscreen mode

Now the percentages sit under the prompt and update after every answer. Older Claude Code versions don't send rate_limits; in that case the // "?" fallback prints a question mark instead of breaking.

If you'd rather not touch settings, ~/.claude/projects holds the raw session logs with token counts per message. You can estimate from those, but the plan limits aren't published as token numbers, so treat it as a rough guide.

When you want it outside the terminal

The status line only helps while you're looking at that terminal. I wanted the number visible all the time on Windows, with a warning before the limit and not after, so I put the two readers above into a small tray app called Quotabar. It does exactly what's described here: reads the Codex logs and receives Claude Code's status line payload, nothing else. It's free, with a one-time paid tier for warnings and auto-resume after a reset.

The scripts above are enough if a status line is all you need.

Top comments (0)