Auto-discovered marketplace from rhom6us/claude-token-tracker
npx claudepluginhub fnclaude/token-trackerTracks token usage and automatically adjusts Claude's efficiency behavior based on weekly and session limits
A session-start hook for Claude Code that fetches your real usage data from Anthropic's API and automatically adjusts Claude's efficiency behavior based on how close you are to your limits.
Claude Code (Max plan) has rolling 5-hour and weekly usage limits, but there's no built-in way to automatically throttle behavior as you approach them. You either burn through your quota fast or manually check /usage and tell Claude to be more careful.
A Node.js script that runs as a Claude Code SessionStart hook:
~/.claude/.credentials.jsonNORMAL, CONSERVATIVE, or SURVIVAL) into the session contextNo token counting, no approximations — it uses the same data that powers the /usage dialog.
git clone https://github.com/rhom6us/claude-token-tracker
Add to ~/.claude/settings.json:
{
"hooks": {
"SessionStart": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "node /path/to/claude-token-tracker/token-tracker.js",
"timeout": 30
}
]
}
]
}
}
The hook injects sensible default behaviors for each tier. To override them, define your own in ~/.claude/CLAUDE.md:
### Token Budget Tiers
- **NORMAL** — [your custom behavior]
- **CONSERVATIVE** — [your custom behavior]
- **SURVIVAL** — [your custom behavior]
CLAUDE.md instructions take precedence over the hook's defaults, so you only need to add this if you want different behavior.
config.json:
| Field | Description | Default |
|---|---|---|
tiers.normal.maxBurnRatio | Max burn ratio for NORMAL tier | 1.2 |
tiers.normal.effortLevel | Recommended effort level for NORMAL | "high" |
tiers.conservative.maxBurnRatio | Max burn ratio for CONSERVATIVE | 1.8 |
tiers.conservative.effortLevel | Recommended effort level for CONSERVATIVE | "medium" |
tiers.survival.effortLevel | Recommended effort level for SURVIVAL | "low" |
fiveHourThresholds.conservative | 5-hour % that triggers CONSERVATIVE | 75 |
fiveHourThresholds.survival | 5-hour % that triggers SURVIVAL | 90 |
Claude Code stores an OAuth token in ~/.claude/.credentials.json. The script uses this token to call GET https://api.anthropic.com/api/oauth/usage, which returns real utilization percentages — the same data that powers the /usage dialog:
{
"five_hour": { "utilization": 64, "resets_at": "2026-04-01T09:00:00Z" },
"seven_day": { "utilization": 2, "resets_at": "2026-04-08T07:00:00Z" },
"seven_day_sonnet": { "utilization": 0, "resets_at": "2026-04-02T02:00:00Z" }
}
The tier is determined by comparing your token consumption rate to time passage rate using a burn ratio:
burn ratio = weekly usage % / week progress %
| Burn Ratio | Tier | Meaning |
|---|---|---|
| ≤ 1.2 | NORMAL | On pace or under budget |
| 1.2 – 1.8 | CONSERVATIVE | Ahead of pace |
| > 1.8 | SURVIVAL | Significantly ahead of pace |
The 5-hour session window acts as a burst protection override — if your 5-hour utilization hits 75% you'll get CONSERVATIVE, and at 90% you'll get SURVIVAL, regardless of weekly pacing.
Each session start appends a row to ~/.claude/token-tracker/usage-log.csv:
timestamp,five_hour_pct,weekly_pct,weekly_sonnet_pct,weekly_opus_pct,week_progress_pct,tier
Use the /burndown skill to visualize usage history as a line graph comparing actual usage against ideal pace.
MIT