How nimaansari/cli-usage works
cli-usage is a tray/menu-bar monitor for Claude Code, Codex CLI, and Gemini CLI. A user opens either frontend; it periodically or on demand calls the shared data layer, which detects installed tools, reads local auth/account details, and fetches and validates live usage from Claude and Codex endpoints. Gemini currently provides local credential detection only. The frontends turn returned rows into status icons and menus, and offer terminal shortcuts. The graph reflects README capabilities alongside sampled frontend/core behavior; unsampled core details are represented only where documented. Installer and setup machinery are omitted.
Main entry points: cli_usage_core.py Usage collection · cli_usage_gtk.py GTK tray · cli_usage_xplat.py Cross-platform tray
Components 13
Tray frontends
- GTK tray
cli_usage_gtk.py - Cross-platform tray
cli_usage_xplat.py
Shared data layer
- Usage collection
cli_usage_core.py - CLI detection
cli_usage_core.py - Auth and account lookup
cli_usage_core.py - Usage requests and validation
cli_usage_core.py - Usage rows and status
cli_usage_core.py
Provider services
- Anthropic usage API
- ChatGPT Codex usage API
Local environment
- CLI credential files
- CLI executables
Other components
- User
- System terminal
Connections 18
- User → GTK tray: opens or refreshes
- User → Cross-platform tray: opens or refreshes
- GTK tray → Usage collection: requests data
- Cross-platform tray → Usage collection: requests data
- Usage collection → CLI detection: checks tools
- CLI detection → CLI executables: checks availability
- Usage collection → Auth and account lookup: gets account state
- Auth and account lookup → CLI credential files: reads local auth
- Usage collection → Usage requests and validation: gets live usage
- Usage requests and validation → Anthropic usage API: requests usage
- Usage requests and validation → ChatGPT Codex usage API: requests usage
- Usage requests and validation → Usage rows and status: validates response
- Auth and account lookup → Usage rows and status: supplies account state
- Usage rows and status → Usage collection: returns rows
- Usage collection → GTK tray: returns tool data
- Usage collection → Cross-platform tray: returns tool data
- GTK tray → System terminal: launches CLI shortcut
- Cross-platform tray → System terminal: launches CLI shortcut