PromptPetrol is a Rust terminal dashboard for monitoring Claude and Codex subscription usage. It renders five-hour and weekly utilization as an avionics multi-function display, with provider instrument bays flanking the active Codex session's context scope.
- Live Claude five-hour and weekly utilization from the Claude OAuth usage API.
- Local Codex five-hour and weekly limits from Codex CLI session logs.
- Active Codex context-window usage from the latest session.
- Full and medium avionics MFD layouts, including a dedicated 120×20 display mode.
- Compact odometer bars on narrower terminals.
- Four palettes across full and compact display modes: Murphy, Paper, Arctic, and Solarized Light. The latter three are light themes.
- A 2 Hz render loop separated from the configurable data-refresh interval.
- Incremental in-memory caching of unchanged Codex session files.
- Recursive Codex session discovery with idle backoff from 10 to 120 seconds.
- Config reload with
rand an in-app keyboard reference with?.
PromptPetrol currently displays subscription utilization and context usage. It does not calculate API spend, import provider billing records, or persist usage history.
- A terminal with color and Unicode support.
- Rust stable with edition 2024 support.
- Codex CLI session logs, Claude Code credentials, or both.
- macOS Keychain access for automatic Claude token discovery. On other systems, set the Claude OAuth token explicitly in the config file.
cargo runCommand-line options:
PromptPetrol - monitor AI subscription usage in your terminal
Usage: promptpetrol [OPTIONS]
Options:
--config-file <PATH> Use a specific configuration file
--refresh-interval-seconds <SECS> Refresh data at this interval [default: 10]
-h, --help Print help
-V, --version Print version
The refresh interval accepts positive fractional values such as 0.5. Avoid
very short intervals when Claude fetching is enabled because every data refresh
can make a network request.
q: quitr: reload the selected config file and refresh data?: toggle keyboard helpt: cycle through color themes for the current run
The default config path is ~/.config/promptpetrol/config.json. PromptPetrol
creates missing parent directories and restricts the config file to mode 0600
on Unix because it may contain an OAuth token.
{
"theme": "murphy",
"codex_import": {
"enabled": true,
"sessions_dir": null
},
"claude_import": {
"enabled": true
},
"claude_oauth_token": null
}theme: selectsmurphy,paper,arctic, orsolarized-light. Murphy is the default when the field is omitted. Pressingttemporarily overrides the configured theme until PromptPetrol exits.codex_import.enabled: enables local Codex session ingestion.codex_import.sessions_dir: overrides the default~/.codex/sessionspath.claude_import.enabled: enables Claude credential discovery and API fetching.claude_oauth_token: optional Claude OAuth token. Leaving itnullenables macOS Keychain discovery.
Unknown config fields are ignored for compatibility with older config files. If
a config reload fails, PromptPetrol keeps the last valid configuration and marks
the dashboard title with CONFIG ERROR.
The Claude token is resolved in this order:
- A non-empty
claude_oauth_tokenin the selected config file. - The macOS Keychain entry named
Claude Code-credentials.
PromptPetrol sends the token as a Bearer credential only to
https://api.anthropic.com/api/oauth/usage. The endpoint returns utilization
percentages and reset times, which are shown directly in the Claude gauges.
PromptPetrol recursively reads .jsonl files from ~/.codex/sessions, or from
the configured override. It uses the latest token_count events for rate limits
and context-window data.
Context-window fill is calculated as:
input_tokens - cached_input_tokens + output_tokens
Only files whose modification time or length changed are reparsed. File discovery starts at a 10-second cadence and gradually backs off to 120 seconds after idle cycles; changing the configured sessions directory invalidates the old cache immediately.
- No Codex gauges: confirm the sessions directory exists and contains readable
.jsonlfiles withtoken_countevents. - Stale Codex gauges: press
r; discovery may be in its idle backoff window. - No Claude gauges: set
claude_oauth_tokenor confirm the Claude Code Keychain item is available to the current user. Auth failed (401/403): refresh the Claude OAuth credential.CONFIG ERRORin the title: validate the selected JSON config file, then pressr.- Broken layout: enlarge the terminal. Below 24 columns or 6 rows, PromptPetrol displays an enlargement prompt.
Planning artifacts:
Run the same checks as CI:
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test --all-targetsIgnored tests are visual dumps and a local large-tree performance probe:
cargo test -- --ignored