Query Claude Code usage programmatically from PowerShell. Monitor your 5-hour, 7-day, and Opus usage limits directly from your terminal.
- ✅ Automatic token reading from
~/.claude/.credentials.json - ✅ Token expiration checking
- ✅ Multiple output modes: Default, Brief, ShowAll, Raw
- ✅ Color-coded utilization: Green (<50%), Yellow (50-80%), Red (>80%)
- ✅ Detailed information: utilization, next reset time, time remaining
- ⏹️ Claude Max support: 7-day, Opus, and OAuth app limits
- ⏹️ Cross-platform: Windows, macOS, Linux
Install-Module -Name ClaudeUsage -Scope CurrentUser# Clone or download the repository
git clone https://github.com/backmind/ClaudeUsage.git
# Copy to your PowerShell modules directory
Copy-Item -Path .\ClaudeUsage -Destination "$env:USERPROFILE\Documents\PowerShell\Modules\" -Recurse
# Import the module
Import-Module ClaudeUsage# Full formatted output
Get-ClaudeUsageOutput:
============================================
Claude Code - Usage Status
============================================
5-Hour Window:
Utilization: 54%
Next reset: 2025-10-15 00:00:00
Time remaining: 3h 16m
# Minimal output
Get-ClaudeUsage -BriefOutput:
54% | 3h 16m remaining
Perfect for status bars, prompts, or quick checks!
# Display all available usage windows (Claude Max)
Get-ClaudeUsage -ShowAllOutput:
============================================
Claude Code - Usage Status
============================================
5-Hour Window:
Utilization: 54%
Next reset: 2025-10-15 00:00:00
Time remaining: 3h 16m
7-Day Window: Not available (requires Claude Max)
7-Day OAuth Apps: Not available
7-Day Opus: Not available (requires Claude Max)
# Get the raw API response
Get-ClaudeUsage -RawOutput:
{
"five_hour": {
"utilization": 96,
"resets_at": "2025-10-14T22:00:00.111065+00:00"
},
"seven_day": null,
"seven_day_oauth_apps": null,
"seven_day_opus": null
}Perfect for scripting, piping to other tools, or saving to a file!
# Use a specific token
Get-ClaudeUsage -Token "sk-ant-oat01-..."Add to your PowerShell profile ($PROFILE):
# Import module
Import-Module ClaudeUsage
# Create short alias
Set-Alias -Name clau -Value Get-ClaudeUsageThen use it:
clau # Full output
clau -Brief # One-liner
clau -ShowAll # All limitsAdd Claude usage to your prompt:
function prompt {
$usage = (Get-ClaudeUsage -Brief).Utilization
Write-Host "[$usage%] " -NoNewline -ForegroundColor $(if ($usage -lt 50) { "Green" } elseif ($usage -lt 80) { "Yellow" } else { "Red" })
"PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "
}# Check usage every hour and alert if >80%
while ($true) {
$result = Get-ClaudeUsage -Brief
if ($result.Utilization -gt 80) {
Write-Host "WARNING: Claude usage at $($result.Utilization)%!" -ForegroundColor Red
}
Start-Sleep -Seconds 3600
}- PowerShell 5.1 or higher
- Claude Code CLI installed and authenticated (
claude setup-token) - Active Claude Pro or Max subscription
The module:
- Reads your OAuth token from
~/.claude/.credentials.json - Checks if the token has expired
- Queries the Anthropic API endpoint:
https://api.anthropic.com/api/oauth/usage - Parses and displays usage information
Run claude setup-token to authenticate Claude Code.
Run claude setup-token again to renew your authentication.
Verify the module is in your PowerShell module path:
$env:PSModulePath -split ';'Open an issue with:
- Your PowerShell version:
$PSVersionTable - Error message (if any)
- Steps to reproduce
The API returns:
{
"five_hour": {
"resets_at": "2025-10-15T00:00:00.034642+00:00",
"utilization": 54
},
"seven_day": null,
"seven_day_oauth_apps": null,
"seven_day_opus": null
}Note: seven_day, seven_day_oauth_apps, and seven_day_opus are only available for Claude Max subscribers or enterprise accounts, not my case!
Contributions are welcome! Please read CONTRIBUTING.md for details.
Areas we especially need help with:
- Claude Max features testing (7-day limits, Opus limits)
- Cross-platform testing (macOS, Linux)
- Documentation and examples
MIT License - see LICENSE for details.
- Built with reverse engineering of Anthropic's API
- Inspired by the need for programmatic usage monitoring
- Community-driven development
This is an unofficial module and is not affiliated with or endorsed by Anthropic. Use at your own risk.
Star ⭐ this repo if you find it useful!
