quota-gate
Skill4 starsChanged 5 months agoMITView on GitHub
Use before expensive, long-running, automated, or quota-sensitive AI coding agent work to check subscription quota and fail closed when quota is low or unknown.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- ryanmaclean/skillstheir own version, first seen Sep 23, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- ryanmaclean/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 6 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 19
Default provider is claude, because this skill is currently installed into Claude Code.
- Distinctive: line 25
Before doing the expensive work, run:
- Distinctive: line 81
Never estimate provider quota from conversation context.
- Distinctive: line 82
Never continue if the quota check fails.
- Very specific: line 83
Never ask for manual token input unless quota-gate explicitly reports a missing credential/API-key reason for the selected provider.
- Distinctive: line 84
Treat any non-zero exit as a hard stop for the expensive routine.
- Distinctive: line 85
Do not use MCP for this skill.
- Distinctive: line 86
Do not print or request access tokens or refresh tokens.
- Very specific: line 102
If exit 0, continue. If exit 2, return only:
- Very specific: line 108
If exit 1, return only:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Quota Gate
Overview
Use this skill before expensive, long-running, automated, or quota-sensitive AI coding agent routines. It runs a bundled Node.js gate that checks subscription quota and returns a machine-readable allow/skip decision. It supports direct Claude Code and Codex usage checks using local CLI credentials; no resident OpenUsage app is required.
Default provider is claude, because this skill is currently installed into Claude Code. For Codex quota checks, pass --provider=codex explicitly.
The gate fails closed. If quota is low, unknown, credentials are missing, the endpoint errors, or the response shape is invalid, do not continue with the requested work.
Required Check
Before doing the expensive work, run:
scripts/quota-gate --weekly-min=<N> --five-hour-min=<M>For automatic Claude Code enforcement, install/enable the bundled plugin. Claude Code reads hooks/hooks.json from the plugin and runs the UserPromptSubmit hook automatically. The hook command is:
${CLAUDE_PLUGIN_ROOT}/skills/quota-gate/scripts/claude-quota-hookThe hook runs this gate only when the prompt looks quota-sensitive, and blocks the prompt if quota is below its hard floor or unknown. It conforms to Claude Code's expected format: exit 0, no stdout to allow, and stdout containing only {"decision":"block","reason":"..."} to block.
The plugin hook uses conservative default hard floors (10% weekly and 10% five-hour remaining) so it only stops expensive prompts near exhaustion. The standalone quota-gate command keeps a stricter weekly default for explicit/manual checks.
Optional environment controls:
QUOTA_GATE_WEEKLY_MIN=<0..100>to override the hook's weekly hard floor. Default:10.QUOTA_GATE_FIVE_HOUR_MIN=<0..100>to override the hook's five-hour hard floor. Default:10.QUOTA_GATE_CACHE_TTL_SECONDS=<n>to set the usage cache freshness window.QUOTA_GATE_NO_CACHE=1to bypass the usage cache.QUOTA_GATE_DEBUG=1to print token-redacted diagnostics to stderr.QUOTA_GATE_HOOK_PATTERN=<javascript-regex>to override the trigger heuristic.QUOTA_GATE_HOOK_ALWAYS=1to check every prompt.
For Codex quota checks, select the Codex provider explicitly:
scripts/quota-gate --provider=codex --weekly-min=<N> --session-min=<M>Thresholds are minimum remaining percentages.
Default thresholds:
--weekly-min=50--five-hour-min=0
Exit Code Contract
- Exit
0: quota is sufficient; continue with the requested work. - Exit
2: quota is below threshold; stop and return only:
{"status":"skipped","reason":"low_ai_quota"}- Exit
1: quota is unknown because of missing credentials, auth failure, endpoint error, invalid response, or internal error; stop and return only:
{"status":"skipped","reason":"unknown_ai_quota"}Rules
- Never estimate provider quota from conversation context.
- Never continue if the quota check fails.
- Never ask for manual token input unless
quota-gateexplicitly reports a missing credential/API-key reason for the selected provider. - Treat any non-zero exit as a hard stop for the expensive routine.
- Do not use MCP for this skill.
- Do not print or request access tokens or refresh tokens.
Examples
Example 1
User prompt:
Use quota-gate. Execute this only if weekly quota remaining is above 50%; otherwise do nothing.
Expected action:
scripts/quota-gate --weekly-min=50If exit 0, continue. If exit 2, return only:
{"status":"skipped","reason":"low_ai_quota"}If exit 1, return only:
{"status":"skipped","reason":"unknown_ai_quota"}Example 2
User prompt:
Run this refactor only if I have at least 30% of five-hour quota and 60% weekly quota left.
Expected action:
scripts/quota-gate --weekly-min=60 --five-hour-min=30Example 3
User prompt:
Use Codex only if weekly quota remaining is at least 50%.
Expected action:
scripts/quota-gate --provider=codex --weekly-min=50Output Shape
The script always prints JSON. resets_at is preserved when the endpoint provides it. When reset time is known, each usage window can include advisory pacing metadata showing whether usage is faster than a linear budget for that window.
Allowed:
{
"allowed": true,
"reason": "ok",
"thresholds": {
"weekly_min_remaining_pct": 50,
"five_hour_min_remaining_pct": 20
},
"usage": {
"five_hour": {
"used_pct": 10,
"remaining_pct": 90,
"resets_at": "..."
},
"weekly": {
"used_pct": 40,
"remaining_pct": 60,
"resets_at": "..."
}
}
}Skipped due to low quota:
{
"allowed": false,
"reason": "below_threshold",
"thresholds": {
"weekly_min_remaining_pct": 50,
"five_hour_min_remaining_pct": 20
},
"usage": {
"five_hour": {
"used_pct": 85,
"remaining_pct": 15,
"resets_at": "..."
},
"weekly": {
"used_pct": 55,
"remaining_pct": 45,
"resets_at": "..."
}
}
}Unknown quota:
{"allowed":false,"reason":"missing_claude_code_credentials"}or:
{"allowed":false,"reason":"usage_endpoint_429"}Verification Checklist
- Ran
scripts/quota-gatebefore expensive work, or verified the Claude Code hook ran it. - Continued only on exit
0. - Returned the exact low-quota JSON on exit
2. - Returned the exact unknown-quota JSON on exit
1. - If using the hook, it blocks quota-sensitive prompts on low/unknown quota and stays silent when quota is sufficient.
- Did not ask for or print OAuth tokens, API keys, or credential files.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

