Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 3 min read

How Claude Code and Codex tell you your limits (and why counting tokens doesn't work)

I use Claude Code and Codex every day. Both can tell you where you stand on your limits: /usage in Claude Code, /status in Codex. But when I'm in the middle of work, I don't want to stop and type a command just to see a

I use Claude Code and Codex every day. Both can tell you where you stand on your limits: /usage in Claude Code, /status in Codex. But when I'm in the middle of work, I don't want to stop and type a command just to see a number. I want to glance at it, the way I glance at the clock.

So I built a small Mac menu bar app for it. The hardest part was getting the same numbers the tools show.

Counting tokens doesn't match

A common approach is to read the local session logs, add up the tokens, and compare with a budget. But Anthropic and OpenAI don't publish a token budget for a subscription. The limit is a share of your plan in a rolling window, so an estimate from logs can drift a long way from what the tool reports. I skipped estimating and read the tools' own numbers.

Claude Code: the status line already has them

Claude Code can run a command to draw its status line, and it sends that command a JSON payload on stdin. On a subscription, recent versions (2.1.251 and later) include the limits:

{
  "rate_limits": {
    "five_hour": { "used_percentage": 35, "resets_at": 1761040800 },
    "seven_day": { "used_percentage": 60, "resets_at": 1761300000 }
  }
}

So the app sets a tiny helper as the status line in ~/.claude/settings.json. The helper:

  1. reads the payload from stdin,
  2. saves only five_hour and seven_day to a local file,
  3. runs your previous status line with the same payload and prints its output, so your status line looks exactly like before.

It backs up settings.json first, and disconnecting puts the old status line back.

The status line only runs while you use Claude Code, so usage on claude.ai shows up after your next Claude Code message. The app stores when each reading was seen and fades old ones, which keeps a 2-hour-old 60% from looking live.

Codex: ask the app server

Codex ships codex app-server, which speaks JSON-RPC over stdin and stdout, one JSON object per line. Three messages are enough:

{"id":1,"method":"initialize","params":{"clientInfo":{"name":"my-app","version":"1.0"}}}
{"method":"initialized","params":{}}
{"id":2,"method":"account/rateLimits/read","params":{}}

The answer to id: 2 has two windows:

{
  "primary":   { "usedPercent": 18, "windowDurationMins": 300,   "resetsAt": 1761042000 },
  "secondary": { "usedPercent": 81, "windowDurationMins": 10080, "resetsAt": 1761390000 }
}

windowDurationMins tells you which is the short limit and which is the weekly one. These are the numbers OpenAI's servers use, so when limits get reset early (it happens), the app sees it on the next read, every 30 seconds.

A menu bar app starts with a short PATH, and Homebrew's codex launcher needs node, which isn't on it. Add /opt/homebrew/bin and the binary's own folder to PATH before you start the server.

After codex logout, the server answers with an auth error. My card kept showing the last saved numbers, so it looked fine while being hours out of date. Now it clears them and says "run codex login".

Clipboard history

The other thing I kept missing on my MacBook is clipboard history. macOS only remembers the last thing you copied. Copy a second thing and the first is gone. I didn't want another paid app for that, so the same panel got a Clipboard tab: the last 30 copies for 24 hours, off until you turn it on, and it skips anything password managers mark as private. There's also a System tab for CPU, memory, storage and battery, since I was already building the panel.

Pikori

The app is called Pikori. It's free and shows both limits for Claude Code and Codex with reset times, sends a notification at 10%, and keeps your recent copies and your Mac's health in the same panel. A pixel character sits in the menu bar and gets nervous as you run low. There's no account, and the data stays on your Mac.

pikori.io Β· macOS 13+, Apple silicon and Intel.

If you're building something similar, I hope the two snippets above save you some digging.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.