How ytl001g/claude-usage-tray works
Claude Usage Tray is a Windows desktop widget that periodically retrieves Claude plan usage, keeps local history, estimates whether weekly usage will last until reset, and presents alerts and a pixel-art display. The principal flow is the polling loop in main.py through Controller, which coordinates credential and usage retrieval, history/projection, and alert decisions before posting a view to the UI. The README also documents login, five-hour usage, usage breakdowns, configuration, and Windows startup behavior. Some subsystem details are documented but not fully sampled; those relationships are only included where the excerpts, source index, or README support them.
Main entry points: main.py App entry · controller.py Poll controller · ui.py Widget UI · usage_api.py Usage API
Components 15
Application flow
- App entry
main.py - Poll controller
tray/controller.py
Usage and analysis
- Usage API
tray/usage_api.py - Usage history
tray/history.py - Usage projection
tray/history.py - Alert rules
tray/alerts.py
Widget presentation
- Widget UI
tray/ui.py - Pixel renderer
tray/render.py - Date phrasing
tray/text.py
Local and Windows integration
- Configuration
tray/config.py - Windows helpers
tray/winsys.py
Other components
- User
- Anthropic API
- Claude Code
- Windows OS
Connections 23
- App entry → Poll controller: starts polling
main.py - App entry → Usage history: creates history
main.py - App entry → Alert rules: creates alerts
main.py - App entry → Widget UI: starts UI
main.py - App entry → Configuration: loads and saves
main.py - App entry → Windows helpers: configures startup
main.py - Poll controller → Usage API: fetches usage
tray/controller.py - Poll controller → Usage history: reads and records
tray/controller.py - Poll controller → Usage projection: calculates outlook
tray/controller.py - Poll controller → Alert rules: checks alerts
tray/controller.py - Poll controller → Configuration: uses settings
- Usage API → Anthropic API: requests usage
README.md - Usage API → Claude Code: reads credentials
tray/usage_api.py - Usage API → Claude Code: delegates refresh
tray/usage_api.py - App entry → Claude Code: starts login
main.py - Usage history → Usage projection: supplies readings
tray/history.py - Widget UI → Pixel renderer: renders views
tray/ui.py - Widget UI → Windows helpers: uses window helpers
tray/ui.py - Pixel renderer → Date phrasing: formats dates
tray/render.py - Widget UI → User: shows widget
README.md - User → Widget UI: interacts
README.md - Windows helpers → Windows OS: manages windows
tray/winsys.py - Configuration → Claude Code: locates credentials
tray/config.py