ailimits
v0.3.0
Published
Show your current Claude Code subscription usage limits
Readme
ailimits
A small TypeScript CLI that reports your current Claude Code subscription
usage limits — the same 5-hour and 7-day rate-limit windows shown by Claude
Code's built-in /usage command.
How it works
- Reads your Claude Code OAuth token from the OS credential store —
macOS Keychain or Windows Credential Manager (target
Claude Code-credentials) — and falls back to~/.claude/.credentials.json(also%APPDATA%\.claude\.credentials.jsonon Windows) when no OS store entry is present. - Calls
GET https://api.anthropic.com/api/oauth/usage— the endpoint Claude Code itself uses — and prints the utilization of each window.
No credentials are stored or transmitted anywhere except to Anthropic's API.
Requirements
- Node.js 20+ (uses the built-in
fetch) - Claude Code installed and logged in (run
claudeonce)
Use as a CLI
npx ailimits # one-off, no install
npx ailimits --json # raw JSON from the API
npm install -g ailimits # or install the `ailimits` command
ailimits
ailimits --jsonUse as a dependency
npm install ailimitsimport { getUsage } from 'ailimits';
// Convenience: read local credentials and return the raw usage payload.
const usage = await getUsage();
console.log(usage.five_hour?.utilization);// Or compose the building blocks yourself (e.g. a custom renderer).
import {
UsageApp,
KeychainCredentialsProvider,
AnthropicUsageProvider,
PrettyRenderer,
} from 'ailimits';
await new UsageApp(
new KeychainCredentialsProvider(),
new AnthropicUsageProvider(),
new PrettyRenderer(),
).run();Importing the package is side-effect-free — nothing runs until you call it,
and the library throws on error instead of calling process.exit. The tool
only works where Claude Code credentials exist locally (e.g. a dev machine).
Local development
npm install # install dev dependencies (TypeScript)
npm run build # compile src/ → dist/
npm start # pretty output
npm run dev # build + run in one stepArchitecture
The project follows a hexagonal layout under src/:
core/— domain types, ports (interfaces) and theUsageAppuse case. Contains no I/O.adapters/— driven adapters that implement the ports: reading credentials from the Keychain/file and fetching usage from the API.presentation/— driving adapters that render output (PrettyRenderer,JsonRenderer).index.ts— the library entry point: side-effect-free re-exports plus thegetUsage()convenience function.cli.ts— the CLI entry point (bin): the composition root that wires adapters intoUsageApp. Consumes the public API fromindex.ts.
Example output:
Claude Code usage limits
5-hour window [██░░░░░░░░░░░░░░░░░░] 8% (resets 5/18/2026, 8:20:00 PM)
7-day window [██░░░░░░░░░░░░░░░░░░] 12% (resets 5/22/2026, 8:00:00 PM)