ccusage 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccusage-0.4.0/.gitignore +4 -0
- {ccusage-0.3.0 → ccusage-0.4.0}/LICENSE +1 -1
- ccusage-0.4.0/PKG-INFO +25 -0
- ccusage-0.4.0/README.md +12 -0
- ccusage-0.4.0/ccusage/__init__.py +7 -0
- ccusage-0.4.0/ccusage/__main__.py +3 -0
- ccusage-0.4.0/pyproject.toml +24 -0
- ccusage-0.3.0/.github/workflows/publish.yml +0 -29
- ccusage-0.3.0/.github/workflows/release-eligibility.yml +0 -12
- ccusage-0.3.0/.gitignore +0 -10
- ccusage-0.3.0/.python-version +0 -1
- ccusage-0.3.0/PKG-INFO +0 -196
- ccusage-0.3.0/README.md +0 -185
- ccusage-0.3.0/pyproject.toml +0 -23
- ccusage-0.3.0/release-notes/v0.2.0.md +0 -20
- ccusage-0.3.0/release-notes/v0.3.0.md +0 -11
- ccusage-0.3.0/src/ccusage/__init__.py +0 -852
- ccusage-0.3.0/src/ccusage/__main__.py +0 -2
- ccusage-0.3.0/tests/test_ccusage.py +0 -607
- ccusage-0.3.0/uv.lock +0 -8
ccusage-0.4.0/.gitignore
ADDED
ccusage-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ccusage
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Claude Code usage limit monitor
|
|
5
|
+
Project-URL: Homepage, https://github.com/wakamex/clanker-usage
|
|
6
|
+
Project-URL: Source, https://github.com/wakamex/clanker-usage
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: anthropic,claude,claude-code,cli,rate-limits,statusline,usage
|
|
10
|
+
Requires-Python: >=3.12
|
|
11
|
+
Requires-Dist: clanker-usage==0.4.0
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# ccusage
|
|
15
|
+
|
|
16
|
+
Monitor your Claude Code quota from the terminal: current usage, a one-line statusline, and a daemon that keeps a cache fresh.
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
uv tool install ccusage
|
|
20
|
+
ccusage # current quotas
|
|
21
|
+
ccusage statusline # one line, from a cache less than five minutes old
|
|
22
|
+
ccusage json # the usage-v1 document
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`ccusage` is the Claude Code command of [clanker-usage](https://github.com/wakamex/clanker-usage), so it installs clanker-usage at the same version. The documentation lives there.
|
ccusage-0.4.0/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# ccusage
|
|
2
|
+
|
|
3
|
+
Monitor your Claude Code quota from the terminal: current usage, a one-line statusline, and a daemon that keeps a cache fresh.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
uv tool install ccusage
|
|
7
|
+
ccusage # current quotas
|
|
8
|
+
ccusage statusline # one line, from a cache less than five minutes old
|
|
9
|
+
ccusage json # the usage-v1 document
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`ccusage` is the Claude Code command of [clanker-usage](https://github.com/wakamex/clanker-usage), so it installs clanker-usage at the same version. The documentation lives there.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling==1.32.4"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ccusage"
|
|
7
|
+
version = "0.4.0"
|
|
8
|
+
description = "Claude Code usage limit monitor"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
keywords = ["claude", "claude-code", "anthropic", "usage", "rate-limits", "statusline", "cli"]
|
|
11
|
+
requires-python = ">=3.12"
|
|
12
|
+
license = "MIT"
|
|
13
|
+
license-files = ["LICENSE"]
|
|
14
|
+
dependencies = ["clanker-usage==0.4.0"]
|
|
15
|
+
|
|
16
|
+
[project.urls]
|
|
17
|
+
Homepage = "https://github.com/wakamex/clanker-usage"
|
|
18
|
+
Source = "https://github.com/wakamex/clanker-usage"
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
ccusage = "ccusage:main"
|
|
22
|
+
|
|
23
|
+
[tool.hatch.build.targets.wheel]
|
|
24
|
+
packages = ["ccusage"]
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
name: Publish to PyPI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
tags: ["v*"]
|
|
6
|
-
|
|
7
|
-
permissions:
|
|
8
|
-
contents: read
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
validate:
|
|
12
|
-
uses: wakamex/release-actions/.github/workflows/python-validation.yml@stable
|
|
13
|
-
|
|
14
|
-
publish:
|
|
15
|
-
needs: validate
|
|
16
|
-
runs-on: ubuntu-24.04
|
|
17
|
-
environment: pypi
|
|
18
|
-
permissions:
|
|
19
|
-
contents: read
|
|
20
|
-
id-token: write
|
|
21
|
-
steps:
|
|
22
|
-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
23
|
-
- uses: wakamex/release-actions/pypi-publish@stable
|
|
24
|
-
|
|
25
|
-
github-release:
|
|
26
|
-
needs: publish
|
|
27
|
-
permissions:
|
|
28
|
-
contents: write
|
|
29
|
-
uses: wakamex/release-actions/.github/workflows/github-release.yml@stable
|
ccusage-0.3.0/.gitignore
DELETED
ccusage-0.3.0/.python-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.13
|
ccusage-0.3.0/PKG-INFO
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.5
|
|
2
|
-
Name: ccusage
|
|
3
|
-
Version: 0.3.0
|
|
4
|
-
Summary: Claude Code usage monitor — fetches rate limits from Anthropic's API
|
|
5
|
-
Project-URL: Homepage, https://github.com/wakamex/ccusage
|
|
6
|
-
Project-URL: Source, https://github.com/wakamex/ccusage
|
|
7
|
-
License-Expression: MIT
|
|
8
|
-
License-File: LICENSE
|
|
9
|
-
Requires-Python: >=3.12
|
|
10
|
-
Description-Content-Type: text/markdown
|
|
11
|
-
|
|
12
|
-
# ccusage
|
|
13
|
-
|
|
14
|
-
Claude Code usage monitor. Fetches your real rate limit data from Anthropic's API and displays it in the Claude Code statusline.
|
|
15
|
-
|
|
16
|
-
## Example output
|
|
17
|
-
|
|
18
|
-
`ccusage` command:
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
Plan: max_5x
|
|
22
|
-
Session 39% resets 1h26m
|
|
23
|
-
Week (all) 15% resets 143h26m
|
|
24
|
-
Week (Sonnet) 39% resets 65h26m
|
|
25
|
-
Extra usage $0.00 / $1000.00
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Claude Code statusline (self-caching — refreshes from API when stale, no daemon needed):
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
~/projects/myapp [Opus 4.6] sess:39% 7d:15% son:39% | $1.37 | max_5x | reset:1h26m
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Install
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
uv tool install ccusage
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Then run:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
# Check usage once
|
|
44
|
-
ccusage
|
|
45
|
-
|
|
46
|
-
# Run the daemon (keeps usage-limits.json updated)
|
|
47
|
-
ccusage daemon
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Configure the statusline in `~/.claude/settings.json`:
|
|
51
|
-
|
|
52
|
-
```json
|
|
53
|
-
{
|
|
54
|
-
"statusLine": {
|
|
55
|
-
"type": "command",
|
|
56
|
-
"command": "ccusage statusline"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
If Claude Code uses `CLAUDE_CONFIG_DIR`, ccusage reads credentials and writes
|
|
62
|
-
`usage-limits.json` in that directory instead.
|
|
63
|
-
|
|
64
|
-
Each refresh also saves a copy under `usage-limits/<account uuid>.json`, tagged with the logged-in account's UUID and email from Claude Code's `.claude.json`. If you switch between Claude accounts with `/login`, the account you logged out of keeps its last usage there. An idle account cannot use quota, so that snapshot stays accurate until its windows reset.
|
|
65
|
-
|
|
66
|
-
To keep a second account current while you are logged into another, give it its own config directory with a permanent login, run a second daemon there with `CLAUDE_CONFIG_DIR` set, and symlink that directory's `usage-limits` folder to the main one so both daemons share their snapshots. Start that daemon with `--defer`: it then skips a refresh whenever another daemon saved the same account's snapshot within the last one and a half intervals, so an account logged in under two config directories is polled once.
|
|
67
|
-
|
|
68
|
-
## Commands
|
|
69
|
-
|
|
70
|
-
| Command | Description |
|
|
71
|
-
|---------|-------------|
|
|
72
|
-
| `ccusage` | Show current usage (colored terminal output) |
|
|
73
|
-
| `ccusage json` | Print raw JSON |
|
|
74
|
-
| `ccusage daemon [-i SECS] [--defer]` | Run in foreground, refresh every 5 min (customizable) |
|
|
75
|
-
| `ccusage statusline` | Claude Code statusline (self-caching, no daemon needed) |
|
|
76
|
-
| `ccusage install` | Print setup instructions |
|
|
77
|
-
|
|
78
|
-
## How Claude Code rate limiting works
|
|
79
|
-
|
|
80
|
-
Discovered by inspecting Claude Code's bundled `cli.js` (v2.1.32).
|
|
81
|
-
|
|
82
|
-
### Data sources
|
|
83
|
-
|
|
84
|
-
Claude Code gets rate limit data from two places:
|
|
85
|
-
|
|
86
|
-
1. **`/api/oauth/usage` endpoint** — Called by the `/status` slash command. Returns utilization percentages and reset times for each rate limit bucket. Requires the `anthropic-beta: oauth-2025-04-20` header.
|
|
87
|
-
|
|
88
|
-
2. **Response headers on every API call** — Every message response includes headers like:
|
|
89
|
-
- `anthropic-ratelimit-unified-{claim}-utilization` (0-100 float)
|
|
90
|
-
- `anthropic-ratelimit-unified-{claim}-reset` (unix timestamp)
|
|
91
|
-
- `anthropic-ratelimit-unified-status` (`allowed` / `allowed_warning` / `rejected`)
|
|
92
|
-
- `anthropic-ratelimit-unified-fallback` (`available` when fallback models are available)
|
|
93
|
-
- `anthropic-ratelimit-unified-overage-status` / `overage-reset`
|
|
94
|
-
- `anthropic-ratelimit-unified-representative-claim`
|
|
95
|
-
|
|
96
|
-
### Rate limit types
|
|
97
|
-
|
|
98
|
-
| Type | Key in API response | Description |
|
|
99
|
-
|------|-------------------|-------------|
|
|
100
|
-
| `five_hour` | `five_hour` | Rolling 5-hour session window |
|
|
101
|
-
| `seven_day` | `seven_day` | Rolling 7-day all-models window |
|
|
102
|
-
| `seven_day_sonnet` | `seven_day_sonnet` | Rolling 7-day Sonnet-specific window |
|
|
103
|
-
| `seven_day_opus` | `seven_day_opus` | Rolling 7-day Opus-specific window |
|
|
104
|
-
| `overage` | `extra_usage` | Extra/overage usage (if enabled) |
|
|
105
|
-
|
|
106
|
-
The flat `seven_day_*` keys above are all `null` now — the live quota data
|
|
107
|
-
lives in a structured `limits` array, which ccusage reads. Each entry is
|
|
108
|
-
self-describing: `kind` (`session` / `weekly_all` / `weekly_scoped`),
|
|
109
|
-
`percent`, `resets_at`, and for scoped limits a `scope.model.display_name`.
|
|
110
|
-
Because the structured response does not include a session duration, ccusage
|
|
111
|
-
labels that limit `Session` and caches it under `session` rather than assuming
|
|
112
|
-
it is always five hours. Existing `5h` cache files remain readable.
|
|
113
|
-
Model-scoped weekly windows (Opus, Sonnet, and a newly added **Fable**) are
|
|
114
|
-
keyed by their model name, so any new one is auto-detected and displayed with
|
|
115
|
-
no code change (e.g. `scope.model.display_name: "Fable"` → "Week (Fable)",
|
|
116
|
-
statusline `fab:`).
|
|
117
|
-
|
|
118
|
-
### API response format
|
|
119
|
-
|
|
120
|
-
```
|
|
121
|
-
GET https://api.anthropic.com/api/oauth/usage
|
|
122
|
-
Authorization: Bearer <oauth_access_token>
|
|
123
|
-
anthropic-beta: oauth-2025-04-20
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
```json
|
|
127
|
-
{
|
|
128
|
-
"five_hour": {
|
|
129
|
-
"utilization": 35.0,
|
|
130
|
-
"resets_at": "2026-02-06T22:00:00+00:00"
|
|
131
|
-
},
|
|
132
|
-
"seven_day": {
|
|
133
|
-
"utilization": 14.0,
|
|
134
|
-
"resets_at": "2026-02-12T20:00:00+00:00"
|
|
135
|
-
},
|
|
136
|
-
"seven_day_sonnet": {
|
|
137
|
-
"utilization": 39.0,
|
|
138
|
-
"resets_at": "2026-02-09T14:00:00+00:00"
|
|
139
|
-
},
|
|
140
|
-
"seven_day_opus": null,
|
|
141
|
-
"seven_day_oauth_apps": null,
|
|
142
|
-
"seven_day_cowork": null,
|
|
143
|
-
"iguana_necktie": null,
|
|
144
|
-
"extra_usage": {
|
|
145
|
-
"is_enabled": true,
|
|
146
|
-
"monthly_limit": 100000,
|
|
147
|
-
"used_credits": 0.0,
|
|
148
|
-
"utilization": null
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Authentication
|
|
154
|
-
|
|
155
|
-
The OAuth token normally lives at `~/.claude/.credentials.json`, or under
|
|
156
|
-
`CLAUDE_CONFIG_DIR` when that environment variable is set:
|
|
157
|
-
|
|
158
|
-
```json
|
|
159
|
-
{
|
|
160
|
-
"claudeAiOauth": {
|
|
161
|
-
"accessToken": "sk-ant-oat01-...",
|
|
162
|
-
"refreshToken": "sk-ant-ort01-...",
|
|
163
|
-
"expiresAt": 1770412938485,
|
|
164
|
-
"subscriptionType": "team",
|
|
165
|
-
"rateLimitTier": "default_claude_max_5x"
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
The access token expires roughly hourly. When it's expired (or rejected with a 401/403), ccusage refreshes it itself using the `refreshToken` and writes the rotated credentials back to `.credentials.json` — the same flow Claude Code uses, so the two stay in sync and no active Claude Code session is needed.
|
|
171
|
-
|
|
172
|
-
### Warning thresholds (from cli.js)
|
|
173
|
-
|
|
174
|
-
Claude Code shows inline warnings based on these thresholds:
|
|
175
|
-
|
|
176
|
-
```
|
|
177
|
-
five_hour: 90% utilization when 72% of window has passed
|
|
178
|
-
seven_day: 75% at 60%, 50% at 35%, 25% at 15%
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Other endpoints found in cli.js
|
|
182
|
-
|
|
183
|
-
- `/api/oauth/profile` — User profile
|
|
184
|
-
- `/api/oauth/account/settings` — Account settings
|
|
185
|
-
- `/api/claude_code/policy_limits` — Org policy limits (needs `organizationUuid`)
|
|
186
|
-
- `/api/organization/claude_code_first_token_date` — Org onboarding date
|
|
187
|
-
|
|
188
|
-
### Local files Claude Code uses
|
|
189
|
-
|
|
190
|
-
| File | Written by | Contains |
|
|
191
|
-
|------|-----------|----------|
|
|
192
|
-
| `~/.claude/.credentials.json` | Claude Code | OAuth tokens, plan tier |
|
|
193
|
-
| `~/.claude/stats-cache.json` | Claude Code | Local usage stats (message counts, token counts per model) |
|
|
194
|
-
| `~/.claude/usage-limits.json` | ccusage daemon | Cached API usage data (this tool) |
|
|
195
|
-
| `~/.claude/usage-limits/<account uuid>.json` | ccusage daemon | Last usage seen for each Claude account (this tool) |
|
|
196
|
-
| `~/.claude/statsig/` | Claude Code | Feature flags, experiment assignments |
|
ccusage-0.3.0/README.md
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
# ccusage
|
|
2
|
-
|
|
3
|
-
Claude Code usage monitor. Fetches your real rate limit data from Anthropic's API and displays it in the Claude Code statusline.
|
|
4
|
-
|
|
5
|
-
## Example output
|
|
6
|
-
|
|
7
|
-
`ccusage` command:
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
Plan: max_5x
|
|
11
|
-
Session 39% resets 1h26m
|
|
12
|
-
Week (all) 15% resets 143h26m
|
|
13
|
-
Week (Sonnet) 39% resets 65h26m
|
|
14
|
-
Extra usage $0.00 / $1000.00
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Claude Code statusline (self-caching — refreshes from API when stale, no daemon needed):
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
~/projects/myapp [Opus 4.6] sess:39% 7d:15% son:39% | $1.37 | max_5x | reset:1h26m
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Install
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
uv tool install ccusage
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Then run:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
# Check usage once
|
|
33
|
-
ccusage
|
|
34
|
-
|
|
35
|
-
# Run the daemon (keeps usage-limits.json updated)
|
|
36
|
-
ccusage daemon
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
Configure the statusline in `~/.claude/settings.json`:
|
|
40
|
-
|
|
41
|
-
```json
|
|
42
|
-
{
|
|
43
|
-
"statusLine": {
|
|
44
|
-
"type": "command",
|
|
45
|
-
"command": "ccusage statusline"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
If Claude Code uses `CLAUDE_CONFIG_DIR`, ccusage reads credentials and writes
|
|
51
|
-
`usage-limits.json` in that directory instead.
|
|
52
|
-
|
|
53
|
-
Each refresh also saves a copy under `usage-limits/<account uuid>.json`, tagged with the logged-in account's UUID and email from Claude Code's `.claude.json`. If you switch between Claude accounts with `/login`, the account you logged out of keeps its last usage there. An idle account cannot use quota, so that snapshot stays accurate until its windows reset.
|
|
54
|
-
|
|
55
|
-
To keep a second account current while you are logged into another, give it its own config directory with a permanent login, run a second daemon there with `CLAUDE_CONFIG_DIR` set, and symlink that directory's `usage-limits` folder to the main one so both daemons share their snapshots. Start that daemon with `--defer`: it then skips a refresh whenever another daemon saved the same account's snapshot within the last one and a half intervals, so an account logged in under two config directories is polled once.
|
|
56
|
-
|
|
57
|
-
## Commands
|
|
58
|
-
|
|
59
|
-
| Command | Description |
|
|
60
|
-
|---------|-------------|
|
|
61
|
-
| `ccusage` | Show current usage (colored terminal output) |
|
|
62
|
-
| `ccusage json` | Print raw JSON |
|
|
63
|
-
| `ccusage daemon [-i SECS] [--defer]` | Run in foreground, refresh every 5 min (customizable) |
|
|
64
|
-
| `ccusage statusline` | Claude Code statusline (self-caching, no daemon needed) |
|
|
65
|
-
| `ccusage install` | Print setup instructions |
|
|
66
|
-
|
|
67
|
-
## How Claude Code rate limiting works
|
|
68
|
-
|
|
69
|
-
Discovered by inspecting Claude Code's bundled `cli.js` (v2.1.32).
|
|
70
|
-
|
|
71
|
-
### Data sources
|
|
72
|
-
|
|
73
|
-
Claude Code gets rate limit data from two places:
|
|
74
|
-
|
|
75
|
-
1. **`/api/oauth/usage` endpoint** — Called by the `/status` slash command. Returns utilization percentages and reset times for each rate limit bucket. Requires the `anthropic-beta: oauth-2025-04-20` header.
|
|
76
|
-
|
|
77
|
-
2. **Response headers on every API call** — Every message response includes headers like:
|
|
78
|
-
- `anthropic-ratelimit-unified-{claim}-utilization` (0-100 float)
|
|
79
|
-
- `anthropic-ratelimit-unified-{claim}-reset` (unix timestamp)
|
|
80
|
-
- `anthropic-ratelimit-unified-status` (`allowed` / `allowed_warning` / `rejected`)
|
|
81
|
-
- `anthropic-ratelimit-unified-fallback` (`available` when fallback models are available)
|
|
82
|
-
- `anthropic-ratelimit-unified-overage-status` / `overage-reset`
|
|
83
|
-
- `anthropic-ratelimit-unified-representative-claim`
|
|
84
|
-
|
|
85
|
-
### Rate limit types
|
|
86
|
-
|
|
87
|
-
| Type | Key in API response | Description |
|
|
88
|
-
|------|-------------------|-------------|
|
|
89
|
-
| `five_hour` | `five_hour` | Rolling 5-hour session window |
|
|
90
|
-
| `seven_day` | `seven_day` | Rolling 7-day all-models window |
|
|
91
|
-
| `seven_day_sonnet` | `seven_day_sonnet` | Rolling 7-day Sonnet-specific window |
|
|
92
|
-
| `seven_day_opus` | `seven_day_opus` | Rolling 7-day Opus-specific window |
|
|
93
|
-
| `overage` | `extra_usage` | Extra/overage usage (if enabled) |
|
|
94
|
-
|
|
95
|
-
The flat `seven_day_*` keys above are all `null` now — the live quota data
|
|
96
|
-
lives in a structured `limits` array, which ccusage reads. Each entry is
|
|
97
|
-
self-describing: `kind` (`session` / `weekly_all` / `weekly_scoped`),
|
|
98
|
-
`percent`, `resets_at`, and for scoped limits a `scope.model.display_name`.
|
|
99
|
-
Because the structured response does not include a session duration, ccusage
|
|
100
|
-
labels that limit `Session` and caches it under `session` rather than assuming
|
|
101
|
-
it is always five hours. Existing `5h` cache files remain readable.
|
|
102
|
-
Model-scoped weekly windows (Opus, Sonnet, and a newly added **Fable**) are
|
|
103
|
-
keyed by their model name, so any new one is auto-detected and displayed with
|
|
104
|
-
no code change (e.g. `scope.model.display_name: "Fable"` → "Week (Fable)",
|
|
105
|
-
statusline `fab:`).
|
|
106
|
-
|
|
107
|
-
### API response format
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
GET https://api.anthropic.com/api/oauth/usage
|
|
111
|
-
Authorization: Bearer <oauth_access_token>
|
|
112
|
-
anthropic-beta: oauth-2025-04-20
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
```json
|
|
116
|
-
{
|
|
117
|
-
"five_hour": {
|
|
118
|
-
"utilization": 35.0,
|
|
119
|
-
"resets_at": "2026-02-06T22:00:00+00:00"
|
|
120
|
-
},
|
|
121
|
-
"seven_day": {
|
|
122
|
-
"utilization": 14.0,
|
|
123
|
-
"resets_at": "2026-02-12T20:00:00+00:00"
|
|
124
|
-
},
|
|
125
|
-
"seven_day_sonnet": {
|
|
126
|
-
"utilization": 39.0,
|
|
127
|
-
"resets_at": "2026-02-09T14:00:00+00:00"
|
|
128
|
-
},
|
|
129
|
-
"seven_day_opus": null,
|
|
130
|
-
"seven_day_oauth_apps": null,
|
|
131
|
-
"seven_day_cowork": null,
|
|
132
|
-
"iguana_necktie": null,
|
|
133
|
-
"extra_usage": {
|
|
134
|
-
"is_enabled": true,
|
|
135
|
-
"monthly_limit": 100000,
|
|
136
|
-
"used_credits": 0.0,
|
|
137
|
-
"utilization": null
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Authentication
|
|
143
|
-
|
|
144
|
-
The OAuth token normally lives at `~/.claude/.credentials.json`, or under
|
|
145
|
-
`CLAUDE_CONFIG_DIR` when that environment variable is set:
|
|
146
|
-
|
|
147
|
-
```json
|
|
148
|
-
{
|
|
149
|
-
"claudeAiOauth": {
|
|
150
|
-
"accessToken": "sk-ant-oat01-...",
|
|
151
|
-
"refreshToken": "sk-ant-ort01-...",
|
|
152
|
-
"expiresAt": 1770412938485,
|
|
153
|
-
"subscriptionType": "team",
|
|
154
|
-
"rateLimitTier": "default_claude_max_5x"
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
The access token expires roughly hourly. When it's expired (or rejected with a 401/403), ccusage refreshes it itself using the `refreshToken` and writes the rotated credentials back to `.credentials.json` — the same flow Claude Code uses, so the two stay in sync and no active Claude Code session is needed.
|
|
160
|
-
|
|
161
|
-
### Warning thresholds (from cli.js)
|
|
162
|
-
|
|
163
|
-
Claude Code shows inline warnings based on these thresholds:
|
|
164
|
-
|
|
165
|
-
```
|
|
166
|
-
five_hour: 90% utilization when 72% of window has passed
|
|
167
|
-
seven_day: 75% at 60%, 50% at 35%, 25% at 15%
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### Other endpoints found in cli.js
|
|
171
|
-
|
|
172
|
-
- `/api/oauth/profile` — User profile
|
|
173
|
-
- `/api/oauth/account/settings` — Account settings
|
|
174
|
-
- `/api/claude_code/policy_limits` — Org policy limits (needs `organizationUuid`)
|
|
175
|
-
- `/api/organization/claude_code_first_token_date` — Org onboarding date
|
|
176
|
-
|
|
177
|
-
### Local files Claude Code uses
|
|
178
|
-
|
|
179
|
-
| File | Written by | Contains |
|
|
180
|
-
|------|-----------|----------|
|
|
181
|
-
| `~/.claude/.credentials.json` | Claude Code | OAuth tokens, plan tier |
|
|
182
|
-
| `~/.claude/stats-cache.json` | Claude Code | Local usage stats (message counts, token counts per model) |
|
|
183
|
-
| `~/.claude/usage-limits.json` | ccusage daemon | Cached API usage data (this tool) |
|
|
184
|
-
| `~/.claude/usage-limits/<account uuid>.json` | ccusage daemon | Last usage seen for each Claude account (this tool) |
|
|
185
|
-
| `~/.claude/statsig/` | Claude Code | Feature flags, experiment assignments |
|
ccusage-0.3.0/pyproject.toml
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
[project]
|
|
2
|
-
name = "ccusage"
|
|
3
|
-
version = "0.3.0"
|
|
4
|
-
description = "Claude Code usage monitor — fetches rate limits from Anthropic's API"
|
|
5
|
-
readme = "README.md"
|
|
6
|
-
requires-python = ">=3.12"
|
|
7
|
-
license = "MIT"
|
|
8
|
-
license-files = ["LICENSE"]
|
|
9
|
-
dependencies = []
|
|
10
|
-
|
|
11
|
-
[tool.uv]
|
|
12
|
-
package = true
|
|
13
|
-
|
|
14
|
-
[build-system]
|
|
15
|
-
requires = ["hatchling"]
|
|
16
|
-
build-backend = "hatchling.build"
|
|
17
|
-
|
|
18
|
-
[project.urls]
|
|
19
|
-
Homepage = "https://github.com/wakamex/ccusage"
|
|
20
|
-
Source = "https://github.com/wakamex/ccusage"
|
|
21
|
-
|
|
22
|
-
[project.scripts]
|
|
23
|
-
ccusage = "ccusage:main"
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
ccusage now remembers the usage of every Claude account you log into, so switching accounts with `/login` no longer loses the other account's numbers. The package is also licensed under MIT.
|
|
2
|
-
|
|
3
|
-
## Highlights
|
|
4
|
-
|
|
5
|
-
- Each refresh also saves a copy of the usage to `~/.claude/usage-limits/<account uuid>.json`, tagged with the logged-in account's UUID and email. The account you switched away from keeps its last usage there, and since an idle account can't use quota, that copy stays accurate until its windows reset. `usage-limits.json` also gains an `account` field and is otherwise unchanged. ([`e2ed247`](https://github.com/wakamex/ccusage/commit/e2ed247b0b677c7e36220cb5b83f916022e0d14b))
|
|
6
|
-
- If you switch accounts in the middle of a refresh, ccusage skips the per-account copy for that refresh, so usage is never saved under the wrong account. Both cache files are now written atomically, so readers never see a half-written file. ([`e2ed247`](https://github.com/wakamex/ccusage/commit/e2ed247b0b677c7e36220cb5b83f916022e0d14b))
|
|
7
|
-
- The wheel and sdist now include a LICENSE file and declare `License-Expression: MIT`. ([`adbcbdb`](https://github.com/wakamex/ccusage/commit/adbcbdb40450f0e231a46026ad00848b0d188ac1))
|
|
8
|
-
|
|
9
|
-
## Changes
|
|
10
|
-
|
|
11
|
-
- Create the GitHub Release from committed release notes ([`146bf16`](https://github.com/wakamex/ccusage/commit/146bf165297bdd16c7300bd0dfdac3240d568fbf))
|
|
12
|
-
- Use the shared release actions ([`e623b1d`](https://github.com/wakamex/ccusage/commit/e623b1d0f5189e71b561f1fbb5fda1c92b788069))
|
|
13
|
-
- Remove the Markdown fence from the release workflows ([`614db37`](https://github.com/wakamex/ccusage/commit/614db372050760ba84f34469acd2ade6e03b0206))
|
|
14
|
-
- Pin runners and actions, and follow release-actions stable ([`1ef57c9`](https://github.com/wakamex/ccusage/commit/1ef57c9009a6604b2bd0804ba654f84064a5b090))
|
|
15
|
-
- Keep the last usage of each Claude account ([`e2ed247`](https://github.com/wakamex/ccusage/commit/e2ed247b0b677c7e36220cb5b83f916022e0d14b))
|
|
16
|
-
- License ccusage under MIT ([`adbcbdb`](https://github.com/wakamex/ccusage/commit/adbcbdb40450f0e231a46026ad00848b0d188ac1))
|
|
17
|
-
|
|
18
|
-
## History
|
|
19
|
-
|
|
20
|
-
[v0.1.12...v0.2.0](https://github.com/wakamex/ccusage/compare/v0.1.12...v0.2.0)
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
`ccusage daemon --defer` lets you keep several Claude accounts current without polling any of them twice.
|
|
2
|
-
|
|
3
|
-
To track an account you are not logged into, give it its own config directory with a permanent login, run a second daemon there with `CLAUDE_CONFIG_DIR` set, and symlink that directory's `usage-limits` folder to the main one. If you then log your main directory into the same account, both daemons would poll it. A daemon started with `--defer` skips a refresh whenever another daemon saved the same account's snapshot within the last one and a half refresh intervals, and starts refreshing again once that other daemon moves to a different account. Daemons without the flag behave as before.
|
|
4
|
-
|
|
5
|
-
## Changes
|
|
6
|
-
|
|
7
|
-
- Add daemon --defer to poll an account once across config directories ([`97d96a2`](https://github.com/wakamex/ccusage/commit/97d96a2b70e3424cece8f32bc8cac440df93c68c))
|
|
8
|
-
|
|
9
|
-
## History
|
|
10
|
-
|
|
11
|
-
[v0.2.0...v0.3.0](https://github.com/wakamex/ccusage/compare/v0.2.0...v0.3.0)
|