skills$openclaw/claude-code-usage
azaidi948.1kā˜…

by azaidi94

claude-code-usage – OpenClaw Skill

claude-code-usage is an OpenClaw Skills integration for security workflows. 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. Includes automated session refresh reminders and reset detection monitoring.

8.1k stars2.6k forksSecurity L1
Updated Feb 7, 2026Created Feb 7, 2026security

Skill Snapshot

nameclaude-code-usage
descriptionCheck 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. Includes automated session refresh reminders and reset detection monitoring. OpenClaw Skills integration.
ownerazaidi94
repositoryazaidi94/claude-code-usage
languageMarkdown
licenseMIT
topics
securityL1
installopenclaw add @azaidi94/claude-code-usage
last updatedFeb 7, 2026

Maintainer

azaidi94

azaidi94

Maintains claude-code-usage in the OpenClaw Skills directory.

View GitHub profile
File Explorer
10 files
.
scripts
claude-usage.sh
7.1 KB
monitor-and-notify.sh
707 B
monitor-usage.sh
3.5 KB
session-reminder.sh
3.3 KB
setup-monitoring.sh
1.6 KB
_meta.json
466 B
CRON_SETUP.md
1.5 KB
README.md
2.0 KB
SKILL.md
6.1 KB
SKILL.md

name: claude-code-usage description: 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. Includes automated session refresh reminders and reset detection monitoring. metadata: clawdbot: emoji: "šŸ“Š" os: - darwin - linux requires: bins: - curl

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'

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:

  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:

šŸ”„ 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:

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

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

# Debian/Ubuntu
sudo apt install libsecret-tools

# Fedora/RHEL
sudo dnf install libsecret
README.md

Claude Code Usage Skill

Check your Claude Code OAuth API usage limits directly from Clawdbot.

Features

  • šŸ“Š Session (5-hour) and Weekly (7-day) utilization tracking
  • šŸŽØ Beautiful progress bars with color-coded status indicators
  • ⚔ Smart caching (60s default) to avoid API spam
  • šŸ“¤ JSON output for scripting
  • šŸ¦ž Telegram-friendly formatting
  • šŸ”” NEW v1.1.0: Automated monitoring with reset notifications

Quick Test

cd /Users/ali/clawd/skills/claude-code-usage
./scripts/claude-usage.sh

Example Output

šŸ¦ž Claude Code Usage

ā±ļø  Session (5h): 🟢 ā–ˆā–‘ā–‘ā–‘ā–‘ā–‘ā–‘ā–‘ā–‘ā–‘ 18%
   Resets in: 2h 48m

šŸ“… Weekly (7d): 🟢 ā–‘ā–‘ā–‘ā–‘ā–‘ā–‘ā–‘ā–‘ā–‘ā–‘ 2%
   Resets in: 6d 21h

Usage in Clawdbot

Just ask:

  • "How much Claude usage do I have left?"
  • "Check my Claude Code limits"
  • "What's my Claude quota?"

The skill automatically triggers and provides a formatted response.

Automated Monitoring (v1.2.0+)

Session Refresh Reminders (Recommended)

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

One-command setup:

cd /Users/ali/clawd/skills/claude-code-usage
./scripts/session-reminder.sh

This creates a self-scheduling chain that:

  • Checks when your session refreshes
  • Schedules the next reminder for that exact time
  • Notifies you automatically every 5 hours
  • Runs forever with zero maintenance

Reset Detection (Alternative)

Alternatively, monitor for quota resets by polling:

./scripts/monitor-usage.sh  # Test once
./scripts/setup-monitoring.sh  # Setup automated polling

See SKILL.md for detailed comparison and configuration options.

Publishing to ClawdHub

To share with the community:

cd /Users/ali/clawd/skills
clawdhub publish claude-code-usage \
  --slug claude-code-usage \
  --name "Claude Code Usage" \
  --version 1.0.0 \
  --changelog "Initial release: Session & weekly usage tracking with beautiful formatting"

Author

Created for Clawdbot by RZA šŸ¦ž

Permissions & Security

Security level L1: Low-risk skills with minimal permissions. Review inputs and outputs before running in production.

Requirements

- **macOS**: Uses Keychain to access Claude Code credentials - **Linux**: Uses `secret-tool` for credential storage - **Credentials**: Must have Claude Code CLI authenticated

FAQ

How do I install claude-code-usage?

Run openclaw add @azaidi94/claude-code-usage in your terminal. This installs claude-code-usage into your OpenClaw Skills catalog.

Does this skill run locally or in the cloud?

OpenClaw Skills execute locally by default. Review the SKILL.md and permissions before running any skill.

Where can I verify the source code?

The source repository is available at https://github.com/openclaw/skills/tree/main/skills/azaidi94/claude-code-usage. Review commits and README documentation before installing.