โœ“ Verified ๐Ÿ’ป Development โœ“ Enhanced Data

Claude Code Usage

Check Claude Code OAuth usage limits.

Rating
4.4 (443 reviews)
Downloads
32,985 downloads
Version
1.0.0

Overview

Check Claude Code OAuth usage limits.

โœจKey Features

1

๐Ÿ“Š Session limit (5-hour window) - Short-term rate limit

2

๐Ÿ“… Weekly limit (7-day window) - Long-term rate limit

3

โšก Smart caching - 60-second cache to avoid API spam

4

๐ŸŽจ Beautiful output - Progress bars, emojis, color-coded status

5

๐Ÿ”„ Force refresh - --fresh flag to bypass cache

6

๐Ÿ“ค JSON output - Machine-readable format

7

๐Ÿ”” Automated monitoring - Get notified when quotas reset

Complete Documentation

View Source โ†’

Claude Code Usage

Check your Claude Code OAuth API usage limits for both session (5-hour) and weekly (7-day) windows.

Quick Start

bash
cd {baseDir}
./scripts/claude-usage.sh

Usage

bash
# 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):

text
๐Ÿฆž Claude Code Usage

โฑ๏ธ  Session (5h): ๐ŸŸข โ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 40%
   Resets in: 2h 15m

๐Ÿ“… Weekly (7d): ๐ŸŸก โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘ 60%
   Resets in: 3d 8h

JSON format (--json):

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

  • Retrieves OAuth token from system keychain
  • Queries api.anthropic.com/api/oauth/usage with OAuth bearer token
  • Parses five_hour and seven_day utilization 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:

bash
CACHE_FILE=/tmp/my-cache CACHE_TTL=300 ./scripts/claude-usage.sh

Examples

Check usage before starting work:

bash
./scripts/claude-usage.sh --fresh

Integrate with statusline:

bash
usage=$(./scripts/claude-usage.sh | grep "Session" | awk '{print $NF}')
echo "Session: $usage"

Get JSON for monitoring:

bash
./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:

bash
./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:
text
๐Ÿ”„ 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.sh to 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:

bash
# Test once
./scripts/monitor-usage.sh

# Setup automated monitoring (runs every 30 minutes)
./scripts/setup-monitoring.sh

Or add via Clawdbot directly:

bash
# 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:

text
๐ŸŽ‰ 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:
bash
# 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?

FeatureSession ReminderReset Detection
Accuracyโœ… Exact minute~30min window
API callsMinimalEvery check
Notification timingRight on resetUp to 30min delay
SetupOne commandOne command
MaintenanceSelf-schedulingCron runs forever
Recommendation: Use Session Reminder for precise, real-time notifications.

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:
bash
# Debian/Ubuntu
sudo apt install libsecret-tools

# Fedora/RHEL
sudo dnf install libsecret

Installation

Terminal bash

openclaw install claude-code-usage
    
Copied!

๐Ÿ’ปCode Examples

./scripts/claude-usage.sh --cache-ttl 300

scriptsclaude-usagesh---cache-ttl-300.txt
## Output

**Text format** (default):

}

.txt
## 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

cachefiletmpmy-cache-cachettl300-scriptsclaude-usagesh.txt
## Examples

**Check usage before starting work:**

./scripts/claude-usage.sh --json | jq '.session.utilization'

scriptsclaude-usagesh---json--jq-sessionutilization.txt
## Automated Monitoring

### Session Refresh Reminders (Recommended)

Get notified exactly when your 5-hour session quota refreshes!

**Quick Setup:**

./scripts/session-reminder.sh

scriptssession-remindersh.txt
This creates a **self-scheduling chain** of cron jobs that:
1. Checks your current session expiry time
2. Schedules the next reminder for when your session refreshes
3. Notifies you with current usage stats
4. Auto-removes itself (the new cron takes over)

**What You'll Get:**

โœ… Next reminder scheduled for: Jan 22 at 01:22 AM

-next-reminder-scheduled-for-jan-22-at-0122-am.txt
**How It Works:**
- Each reminder runs `claude-usage.sh` to 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:**

Fresh usage available! ๐Ÿฆž

fresh-usage-available-.txt
**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:**

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

statefilepathtostatejson-scriptsmonitor-usagesh.txt
### 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 `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:
example.sh
# 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
example.txt
๐Ÿฆž Claude Code Usage

โฑ๏ธ  Session (5h): ๐ŸŸข โ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 40%
   Resets in: 2h 15m

๐Ÿ“… Weekly (7d): ๐ŸŸก โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘ 60%
   Resets in: 3d 8h

Tags

#clawdbot_tools #code

Quick Info

Category Development
Model Claude 3.5
Complexity One-Click
Author azaidi94
Last Updated 3/10/2026
๐Ÿš€
Optimized for
Claude 3.5
๐Ÿง 

Ready to Install?

Get started with this skill in seconds

openclaw install claude-code-usage