quota-management

athola's avatarfrom athola

Quota tracking, threshold monitoring, and graceful degradation for rate-limited API services.Triggers: quota, rate limiting, usage limits, thresholdsUse when: integrating rate-limited services or tracking API usage

⭐83stars🔀11forks📁View on GitHub🕐Updated Jan 3, 2026

When & Why to Use This Skill

This Claude skill provides a robust infrastructure for tracking API quotas, monitoring usage thresholds, and implementing graceful degradation. It is designed to help developers manage rate-limited services effectively by providing real-time usage estimation, cost tracking, and proactive alerting to prevent service interruptions and optimize resource consumption.

Use Cases

  • API Rate Limit Management: Automatically monitor and enforce request limits for third-party integrations to prevent service blocks and ensure continuous operation.
  • Cost Optimization and Tracking: Track token consumption and API usage across different sessions and modules to manage operational expenses and prevent budget overruns.
  • Resilient System Design: Implement multi-tier threshold actions, such as request batching or deferring non-urgent tasks when quotas reach critical levels (e.g., >95% usage).
  • Pre-execution Resource Estimation: Predict resource requirements and check quota availability before executing complex tasks to avoid mid-process failures.
namequota-management
description|
Triggersquota, rate limiting, usage limits, thresholds
Use whenintegrating rate-limited services or tracking API usage
categoryinfrastructure
tags[quota, rate-limiting, resource-management, cost-tracking, thresholds]
dependencies[]
tools[quota-tracker]
infrastructure[quota-tracking, threshold-monitoring, usage-estimation]
patterns[graceful-degradation, quota-enforcement, cost-optimization]
complexityintermediate
estimated_tokens500
progressive_loadingtrue

Table of Contents

Quota Management

Overview

Patterns for tracking and enforcing resource quotas across rate-limited services. This skill provides the infrastructure that other plugins use for consistent quota handling.

When to Use

  • Building integrations with rate-limited APIs
  • Need to track usage across sessions
  • Want graceful degradation when limits approached
  • Require cost estimation before operations

Core Concepts

Quota Thresholds

Three-tier threshold system for proactive management:

Level Usage Action
Healthy <80% Proceed normally
Warning 80-95% Alert, consider batching
Critical >95% Defer non-urgent, use secondary services

Quota Types

@dataclass
class QuotaConfig:
    requests_per_minute: int = 60
    requests_per_day: int = 1000
    tokens_per_minute: int = 100000
    tokens_per_day: int = 1000000

Quick Start

Check Quota Status

from leyline.quota_tracker import QuotaTracker

tracker = QuotaTracker(service="my-service")
status, warnings = tracker.get_quota_status()

if status == "CRITICAL":
    # Defer or use secondary service
    pass

Record Usage

tracker.record_request(
    tokens=estimated_tokens,
    success=True,
    duration=elapsed_seconds
)

Estimate Before Execution

can_proceed, issues = tracker.can_handle_task(estimated_tokens)
if not can_proceed:
    print(f"Quota issues: {issues}")

Integration Pattern

Other plugins reference this skill:

# In your skill's frontmatter
dependencies: [leyline:quota-management]

Then use the shared patterns:

  1. Initialize tracker for your service
  2. Check quota before operations
  3. Record usage after operations
  4. Handle threshold warnings gracefully

Detailed Resources

  • Threshold Strategies: See modules/threshold-strategies.md for degradation patterns
  • Estimation Patterns: See modules/estimation-patterns.md for token/cost estimation

Exit Criteria

  • Quota status checked before operation
  • Usage recorded after operation
  • Threshold warnings handled appropriately

Troubleshooting

Common Issues

Command not found Ensure all dependencies are installed and in PATH

Permission errors Check file permissions and run with appropriate privileges

Unexpected behavior Enable verbose logging with --verbose flag