Claude Code Usage
Check Claude Code OAuth usage limits (session & weekly quotas). Use when user asks about Claude Code usage, remaining limits, rate limits, or how much Claude usage they have left. โฆ
azaidi94
@azaidi94
What This Skill Does
Shell script that checks Claude Code OAuth usage limits for session (5-hour) and weekly (7-day) windows, displaying utilization percentages, reset times, and color-coded status indicators. Supports caching, JSON output, and automated refresh reminders.
Replaces manually checking Claude Code rate limits through the Anthropic API or guessing remaining quota by providing real-time usage stats with automated reset notifications.
When to Use It
- Check remaining Claude Code session quota before starting a long coding session
- Monitor weekly usage limits to avoid hitting rate caps during heavy development
- Integrate Claude Code usage stats into a status bar or monitoring dashboard
- Get notified automatically when your 5-hour session quota refreshes
- Export usage data in JSON format for custom analytics or alerting scripts
- Verify OAuth token is still valid by checking usage endpoint returns data
Install
$ openclaw skills install @azaidi94/claude-code-usageClaude Code Usage
Check your Claude Code OAuth API usage limits for both session (5-hour) and weekly (7-day) windows.
Quick Start
cd {baseDir}
./scripts/claude-usage.sh
Usage
# Default: show cached usage (if fresh)
./scripts/claude-usage.sh
# Force refresh from API
./scripts/claude-usage.sh --fresh
# JSON output
./scripts/claude-usage.sh --json
# Custom cache TTL
./scripts/claude-usage.sh --cache-ttl 300
Output
Text format (default):
๐ฆ Claude Code Usage
โฑ๏ธ Session (5h): ๐ข โโโโโโโโโโ 40%
Resets in: 2h 15m
๐
Weekly (7d): ๐ก โโโโโโโโโโ 60%
Resets in: 3d 8h
JSON format (--json):
{
"session": {
"utilization": 40,
"resets_in": "2h 15m",
"resets_at": "2026-01-19T22:15:00Z"
},
"weekly": {
"utilization": 60,
"resets_in": "3d 8h",
"resets_at": "2026-01-22T04:00:00Z"
},
"cached_at": "2026-01-19T20:00:00Z"
}
Features
- ๐ Session limit (5-hour window) - Short-term rate limit
- ๐ Weekly limit (7-day window) - Long-term rate limit
- โก Smart caching - 60-second cache to avoid API spam
- ๐จ Beautiful output - Progress bars, emojis, color-coded status
- ๐ Force refresh -
--freshflag to bypass cache - ๐ค JSON output - Machine-readable format
- ๐ Automated monitoring - Get notified when quotas reset
Status Indicators
- ๐ข Green - 0-50% usage (healthy)
- ๐ก Yellow - 51-80% usage (moderate)
- ๐ด Red - 81-100% usage (high/critical)
Requirements
- macOS: Uses Keychain to access Claude Code credentials
- Linux: Uses
secret-toolfor credential storage - Credentials: Must have Claude Code CLI authenticated
How It Works
- Retrieves OAuth token from system keychain
- Queries
api.anthropic.com/api/oauth/usagewith OAuth bearer token - Parses
five_hourandseven_dayutilization metrics - Calculates time remaining until reset
- Formats output with progress bars and status indicators
- Caches result for 60 seconds (configurable)
Cache
Default cache: /tmp/claude-usage-cache (60s TTL)
Override:
CACHE_FILE=/tmp/my-cache CACHE_TTL=300 ./scripts/claude-usage.sh
Examples
Check usage before starting work:
./scripts/claude-usage.sh --fresh
Integrate with statusline:
usage=$(./scripts/claude-usage.sh | grep "Session" | awk '{print $NF}')
echo "Session: $usage"
Get JSON for monitoring:
./scripts/claude-usage.sh --json | jq '.session.utilization'
Automated Monitoring
Session Refresh Reminders (Recommended)
Get notified exactly when your 5-hour session quota refreshes!
Quick Setup:
./scripts/session-reminder.sh
This creates a self-scheduling chain of cron jobs that:
- Checks your current session expiry time
- Schedules the next reminder for when your session refreshes
- Notifies you with current usage stats
- Auto-removes itself (the new cron takes over)
What You'll Get:
๐ Claude Code Session Status
โฑ๏ธ Current usage: 44%
โฐ Next refresh: 2h 15m
Your 5-hour quota will reset soon! ๐ฆ
โ
Next reminder scheduled for: Jan 22 at 01:22 AM
How It Works:
- Each reminder runs
claude-usage.shto find the exact session reset time - Schedules a one-time cron for that exact moment
- Repeats every 5 hours automatically
- Self-correcting if session times ever drift
Benefits:
- โ Accurate to the minute
- โ No manual scheduling needed
- โ Adapts to your actual usage patterns
- โ Minimal API calls (only when needed)
Reset Detection Monitor (Alternative)
Get automatic notifications when your Claude Code quotas reset by polling usage.
Quick Setup:
# Test once
./scripts/monitor-usage.sh
# Setup automated monitoring (runs every 30 minutes)
./scripts/setup-monitoring.sh
Or add via Clawdbot directly:
# Check every 30 minutes
clawdbot cron add --cron "*/30 * * * *" \
--message "cd /Users/ali/clawd/skills/claude-code-usage && ./scripts/monitor-usage.sh" \
--name "Claude Code Usage Monitor" \
--session isolated --deliver --channel telegram
What You'll Get:
๐ Claude Code Session Reset!
โฑ๏ธ Your 5-hour quota has reset
๐ Usage: 2%
โฐ Next reset: 4h 58m
Fresh usage available! ๐ฆ
How It Works:
- Monitors usage every 30 minutes (configurable)
- Detects resets when usage drops significantly (>10% or <5%)
- Sends notifications via Telegram when resets occur
- Tracks state in
/tmp/claude-usage-state.json
Customization:
# Change check interval
clawdbot cron add --cron "*/15 * * * *" ... # Every 15 minutes
clawdbot cron add --cron "0 * * * *" ... # Every hour
# Custom state file location
STATE_FILE=/path/to/state.json ./scripts/monitor-usage.sh
Which Monitoring Method?
| Feature | Session Reminder | Reset Detection |
|---|---|---|
| Accuracy | โ Exact minute | ~30min window |
| API calls | Minimal | Every check |
| Notification timing | Right on reset | Up to 30min delay |
| Setup | One command | One command |
| Maintenance | Self-scheduling | Cron runs forever |
Recommendation: Use Session Reminder for precise, real-time notifications.
Troubleshooting
No credentials found:
- Ensure Claude Code CLI is installed and authenticated
- Run
claudeonce to trigger OAuth flow
API request failed:
- Check internet connection
- Verify OAuth token hasn't expired
- Try
--freshto force new request
Linux users:
Install libsecret for credential storage:
# Debian/Ubuntu
sudo apt install libsecret-tools
# Fedora/RHEL
sudo dnf install libsecret
Related skills
OpenClaw Optimised
@hexnickkGuide for writing and optimizing CLAUDE.md files for maximum Claude Code performance. Use when creating new CLAUDE.md, reviewing existing ones, or when user asks about CLAUDE.md best practices. Covers structure, content, pruning, and common mistakes.
Clawdbot Logs
@satriapamudjiAnalyze Clawdbot logs and diagnostics. Use when the user asks about bot performance, response times, errors, session stats, token usage, API costs, or wants to debug slow responses.
UI/UX Pro Max
@xobi667UI/UX design intelligence and implementation guidance for building polished interfaces. Use when the user asks for UI design, UX flows, information architecture, visual style direction, design systems/tokens, component specs, copy/microcopy, accessibility, or to generate/critique/refine frontend UI (HTML/CSS/JS, React, Next.js, Vue, Svelte, Tailwind). Includes workflows for (1) generating new UI layouts and styling, (2) improving existing UI/UX, (3) producing design-system tokens and component guidelines, and (4) turning UX recommendations into concrete code changes.
Clawdbot Security Check
@thesethrosePerform a comprehensive read-only security audit of Clawdbot's own configuration. This is a knowledge-based skill that teaches Clawdbot to identify hardening opportunities across the system. Use when user asks to "run security check", "audit clawdbot", "check security hardening", or "what vulnerabilities does my Clawdbot have". This skill uses Clawdbot's internal capabilities and file system access to inspect configuration, detect misconfigurations, and recommend remediations. It is designed to be extensible - new checks can be added by updating this skill's knowledge.
X Api
@lobstergeneralintelligencePost to X (Twitter) using the official API with OAuth 1.0a. Use when you need to tweet, post updates, or publish content. Bypasses rate limits and bot detection that affect cookie-based approaches like bird CLI.
Smart Model Switching
@millibusAuto-route tasks to the cheapest Claude model that works correctly. Three-tier progression: Haiku โ Sonnet โ Opus. Classify before responding. HAIKU (default): factual Q&A, greetings, reminders, status checks, lookups, simple file ops, heartbeats, casual chat, 1-2 sentence tasks. ESCALATE TO SONNET: code >10 lines, analysis, comparisons, planning, reports, multi-step reasoning, tables, long writing >3 paragraphs, summarization, research synthesis, most user conversations. ESCALATE TO OPUS: architecture decisions, complex debugging, multi-file refactoring, strategic planning, nuanced judgment, deep research, critical production decisions. Rule: If a human needs >30 seconds of focused thinking, escalate. If Sonnet struggles with complexity, go to Opus. Save 50-90% on API costs by starting cheap and escalating only when needed.