Skip to content

feature: add /codex:usage command to show rate limits and account plan#103

Open
gignac-cha wants to merge 1 commit intoopenai:mainfrom
gignac-cha:feature/usage-command
Open

feature: add /codex:usage command to show rate limits and account plan#103
gignac-cha wants to merge 1 commit intoopenai:mainfrom
gignac-cha:feature/usage-command

Conversation

@gignac-cha
Copy link
Copy Markdown

Summary

  • Add a new /codex:usage slash command that displays the current account's rate limit status
  • Read ~/.codex/auth.json and call the Codex backend usage API (/wham/usage) to fetch rate limits
  • New command file: plugins/codex/commands/usage.md
  • New handler: handleUsage in codex-companion.mjs
  • New render functions: renderUsageReport and formatUsageWindow in lib/render.mjs
  • Update tests/commands.test.mjs to include usage.md in the expected command list
  • Add /codex:usage section to README.md

Problem

There is currently no way to check Codex rate limits from within Claude Code. Users must switch to the Codex TUI and run /status to see how much of their 5h or weekly limit remains.

Example output

# Codex Usage

Plan: Plus

Limits:
- 5h limit: 73% left (resets 1 Apr, 18:22)
- Weekly limit: 54% left (resets 5 Apr, 09:15)
- Code review Weekly limit: 91% left (resets 7 Apr, 14:30)

Implementation notes

  • The Codex CLI does not currently expose a codex usage subcommand, so the plugin reads ~/.codex/auth.json directly and calls the usage endpoint. The API path (/wham/usage) was identified from the open-source Codex CLI codebase.
  • --json flag outputs the raw API response for structured consumption.
  • Handles expired tokens (401/403) with a hint to re-authenticate.

Testing

  • Verified usage and usage --json output manually
  • Existing test suite passes (the commands.test.mjs hardcoded list is updated)

Fixes #102


This PR was authored with the assistance of Claude Code (Anthropic).

Add a new /codex:usage slash command that reads ~/.codex/auth.json
and calls the Codex backend usage API to display rate limit status.

- New command file: plugins/codex/commands/usage.md
- New handler: handleUsage in codex-companion.mjs
- New render function: renderUsageReport and formatUsageWindow in render.mjs
- Update tests/commands.test.mjs to include usage.md
- Add /codex:usage section to README.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gignac-cha gignac-cha requested a review from a team April 1, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add /codex:usage command to show rate limits and usage

1 participant