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-usage

Claude 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 - --fresh flag 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-tool for credential storage
  • Credentials: Must have Claude Code CLI authenticated

How It Works

  1. Retrieves OAuth token from system keychain
  2. Queries api.anthropic.com/api/oauth/usage with OAuth bearer token
  3. Parses five_hour and seven_day utilization metrics
  4. Calculates time remaining until reset
  5. Formats output with progress bars and status indicators
  6. 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 (New in v1.1.0)

Get automatic notifications when your Claude Code quotas reset!

Quick Setup

Test the monitor 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 --schedule "*/30 * * * *" \
  --command "/Users/ali/clawd/skills/claude-code-usage/scripts/monitor-usage.sh" \
  --label "Claude Code Usage Monitor"

What You'll Get

When your quotas reset, you'll receive notifications like:

๐ŸŽ‰ Claude Code Session Reset!

โฑ๏ธ  Your 5-hour quota has reset
๐Ÿ“Š Usage: 2%
โฐ Next reset: 4h 58m

Fresh usage available! ๐Ÿฆž

How It Works

  1. Monitors usage every 30 minutes (configurable)
  2. Detects resets when usage drops significantly (>10% or <5%)
  3. Sends notifications via Telegram when resets occur
  4. Tracks state in /tmp/claude-usage-state.json

Customization

Change check interval:

# Every 15 minutes
clawdbot cron add --schedule "*/15 * * * *" ...

# Every hour
clawdbot cron add --schedule "0 * * * *" ...

Custom state file location:

STATE_FILE=/path/to/state.json ./scripts/monitor-usage.sh

Troubleshooting

No credentials found:

  • Ensure Claude Code CLI is installed and authenticated
  • Run claude once to trigger OAuth flow

API request failed:

  • Check internet connection
  • Verify OAuth token hasn't expired
  • Try --fresh to force new request

Linux users: Install libsecret for credential storage:

# Debian/Ubuntu
sudo apt install libsecret-tools

# Fedora/RHEL
sudo dnf install libsecret

Top skills in this category

Skill Vetter

@spclaudehome

Security-first skill vetting for AI agents. Use before installing any skill from ClawdHub, GitHub, or other sources. Checks for red flags, permission scope, and suspicious patterns.

1.3k278k

Free Ride - Unlimited free AI

@shaivpidadi

Manages free AI models from OpenRouter for OpenClaw. Automatically ranks models by quality, configures fallbacks for rate-limit handling, and updates opencla...

49172k

Playwright (Automation + MCP + Scraper)

@ivangdavila

Automates, tests, and debugs browsers with Playwright: locators, auto-waiting, traces, CI runs, and MCP browser control. Use when a test is flaky, times out, or fails only in CI or headless; when a locator matches multiple elements or the wrong one (strict mode violation); when clicks need force, waits become sleeps, or networkidle never settles; for storageState and login setup, request mocking and HAR replay, uploads and downloads, iframes and shadow DOM, popups and dialogs, screenshot diffs that change per machine, trace and report artifacts, sharding a slow suite, device and permission emulation, accessibility checks, driving a real browser through Playwright MCP, extracting data from JS-rendered pages, or porting a Cypress, Puppeteer, or Selenium suite to Playwright. Not for maintaining an existing Cypress or Puppeteer suite (cypress, puppeteer) or for work a plain HTTP request answers (http).

13043k

n8n

@thomasansems

Manage n8n workflows and automations via API. Use when working with n8n workflows, executions, or automation tasks - listing workflows, activating/deactivating, checking execution status, manually triggering workflows, or debugging automation issues.

6121k

Skill Vetter - Pre-Install Security Review

@donovanpankratz-del

Security vetting protocol before installing any AI agent skill. Red flag detection for credential theft, obfuscated code, exfiltration. Risk classification L...

2726k