claude-usage-limits 1.0.0
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.
- package/.claude-plugin/marketplace.json +18 -0
- package/.claude-plugin/plugin.json +22 -0
- package/LICENSE +21 -0
- package/README.md +291 -0
- package/bin/cli.js +62 -0
- package/commands/check.md +14 -0
- package/package.json +43 -0
- package/skills/usage-limits/SKILL.md +163 -0
- package/skills/usage-limits/references/how-it-works.md +136 -0
- package/skills/usage-limits/references/tactics.md +170 -0
- package/skills/usage-limits/scripts/lowpower.js +230 -0
- package/skills/usage-limits/scripts/usage.js +918 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "usage-limits",
|
|
3
|
+
"owner": {
|
|
4
|
+
"name": "Ridelink",
|
|
5
|
+
"url": "https://github.com/ridelink0"
|
|
6
|
+
},
|
|
7
|
+
"description": "Usage limit aware planning for Claude Code.",
|
|
8
|
+
"plugins": [
|
|
9
|
+
{
|
|
10
|
+
"name": "usage-limits",
|
|
11
|
+
"source": "./",
|
|
12
|
+
"description": "Reads how much of your Claude Code usage limit is left, converts it into turns of headroom, and plans the work to fit inside it.",
|
|
13
|
+
"category": "productivity",
|
|
14
|
+
"tags": ["usage", "limits", "cost", "planning"],
|
|
15
|
+
"license": "MIT"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "usage-limits",
|
|
3
|
+
"displayName": "Usage Limits",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Reads how much of your Claude Code usage limit is left, converts it into turns of headroom, and plans the work to fit inside it. Includes a low power switch that keeps spending down even at high effort.",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Ridelink",
|
|
8
|
+
"url": "https://github.com/ridelink0"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/ridelink0/claude-code-usage-limits",
|
|
11
|
+
"repository": "https://github.com/ridelink0/claude-code-usage-limits",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"usage",
|
|
15
|
+
"limits",
|
|
16
|
+
"budget",
|
|
17
|
+
"cost",
|
|
18
|
+
"tokens",
|
|
19
|
+
"planning",
|
|
20
|
+
"effort"
|
|
21
|
+
]
|
|
22
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ridelink
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# usage-limits
|
|
2
|
+
|
|
3
|
+
A Claude Code plugin that reads how much of your usage limit is left and plans
|
|
4
|
+
the work to fit inside it.
|
|
5
|
+
|
|
6
|
+
Claude Code already knows how much of your 5-hour and weekly limit you have
|
|
7
|
+
spent. It caches the numbers locally and shows them when you ask. What it does
|
|
8
|
+
not do on its own is notice that the job in front of it is bigger than the
|
|
9
|
+
budget behind it, and adjust. This adds that: a report you can act on, and a
|
|
10
|
+
set of rules for what to do when the answer is "not enough".
|
|
11
|
+
|
|
12
|
+
## What it prints
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
Claude Code usage
|
|
16
|
+
|
|
17
|
+
Plan Claude Pro
|
|
18
|
+
Snapshot 3m old
|
|
19
|
+
Settings model=opus effort=xhigh
|
|
20
|
+
Overage off, work stops at the limit
|
|
21
|
+
|
|
22
|
+
Window Used Resets in Left Turns left
|
|
23
|
+
5-hour 62% 1h 40m $46.00 ~88 <- binding
|
|
24
|
+
weekly 75% 2d 4h $124 ~240
|
|
25
|
+
|
|
26
|
+
Recent pace 15 turns in the last hour, $0.164 per turn, effort xhigh
|
|
27
|
+
Measured 1,284 turns of local transcript
|
|
28
|
+
|
|
29
|
+
The 5-hour limit is the binding one. At the current pace it runs out in about
|
|
30
|
+
1h 12m, which is 28m short of the reset. Size the work to fit, or slow the burn.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`Turns left` is the column that matters. It divides the remaining headroom by
|
|
34
|
+
what a turn has actually been costing over the last hour, on your account, at
|
|
35
|
+
your effort level, so it moves when your working style does. Fifteen turns of
|
|
36
|
+
headroom means something you can plan against; 75 percent does not.
|
|
37
|
+
|
|
38
|
+
It also breaks the window down by model, with the token split behind it:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
Models in the 5-hour window
|
|
42
|
+
Model Turns Tokens Output Share
|
|
43
|
+
claude-opus-5 159 27.0M 212k 100%
|
|
44
|
+
Tokens input 318, cache write 631k, cache read 26.2M, output 212k
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
When more than one project has run inside the window it breaks that down too,
|
|
48
|
+
so you can see which working directory actually spent the week:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
Projects in the weekly window
|
|
52
|
+
Project Turns Tokens Share
|
|
53
|
+
...ideLink-Stuff-app 930 45.2M 78%
|
|
54
|
+
C--Users-OWNER 240 12.1M 22%
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
That split is usually the surprise. Almost all of it is cache reads, billed at
|
|
58
|
+
a tenth of the input rate but paid again on every turn, which is why context
|
|
59
|
+
length matters more than any single expensive message.
|
|
60
|
+
|
|
61
|
+
The percentages and reset times come from Claude Code's own cache. The pace
|
|
62
|
+
comes from your local session transcripts. Neither requires a network call.
|
|
63
|
+
|
|
64
|
+
## Install
|
|
65
|
+
|
|
66
|
+
Nothing to install, if you just want the numbers:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
npx claude-usage-limits
|
|
70
|
+
npx claude-usage-limits --status
|
|
71
|
+
npx claude-usage-limits lowpower on
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
That runs the same code as the plugin. Node 18 or newer.
|
|
75
|
+
|
|
76
|
+
To have Claude read the numbers and plan against them, install it properly.
|
|
77
|
+
|
|
78
|
+
As a plugin:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
/plugin marketplace add ridelink0/claude-code-usage-limits
|
|
82
|
+
/plugin install usage-limits@usage-limits
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
As a plain skill, if you would rather not use the plugin system:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
git clone https://github.com/ridelink0/claude-code-usage-limits
|
|
89
|
+
cp -r claude-code-usage-limits/skills/usage-limits ~/.claude/skills/usage-limits
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
On Windows, in PowerShell:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
git clone https://github.com/ridelink0/claude-code-usage-limits
|
|
96
|
+
Copy-Item -Recurse claude-code-usage-limits\skills\usage-limits "$env:USERPROFILE\.claude\skills\usage-limits"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Either way, ask something like "how much usage do I have left" or "can we
|
|
100
|
+
finish this before the limit hits" and Claude will load it. Installed as a
|
|
101
|
+
plugin it also gives you `/usage-limits:check`, which prints the report and
|
|
102
|
+
sizes whatever you just asked for against it.
|
|
103
|
+
|
|
104
|
+
The scripts also run on their own, with or without any of the above:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
node skills/usage-limits/scripts/usage.js
|
|
108
|
+
node skills/usage-limits/scripts/usage.js --json
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Credits, and what happens at the wall
|
|
112
|
+
|
|
113
|
+
The report says which of two things happens when the plan allowance runs out,
|
|
114
|
+
because they need opposite handling.
|
|
115
|
+
|
|
116
|
+
If paid credits are off, work stops dead and there is no buying through it,
|
|
117
|
+
so the report says so and plans around it. If they are on, the limit is a cost
|
|
118
|
+
boundary instead of a wall. It deliberately does not warn you about that
|
|
119
|
+
crossover, because Claude Code already announces it and asks before drawing on
|
|
120
|
+
credits, and a second warning saying the same thing is just noise.
|
|
121
|
+
|
|
122
|
+
When the binding window will run out before it resets, the report stops
|
|
123
|
+
describing and starts instructing:
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
The 5-hour limit is the binding one. At the current pace it runs out in about
|
|
127
|
+
20m, which is 3h 40m short of the reset. Size the work to fit, or slow the burn.
|
|
128
|
+
Work stops when it does. Nothing carries on into paid credits.
|
|
129
|
+
Land what exists, write the handoff, and resume after 03:00.
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The clock time matters more than the countdown. "Resume after 03:00" is a
|
|
133
|
+
plan; "4h 12m" is a number you still have to do arithmetic on.
|
|
134
|
+
|
|
135
|
+
The skill also requires Claude to say up front when a job will not fit in what
|
|
136
|
+
is left, name what it is doing now, what it is leaving, and when the rest can
|
|
137
|
+
happen, rather than starting and stopping halfway through an edit.
|
|
138
|
+
|
|
139
|
+
## Status line
|
|
140
|
+
|
|
141
|
+
For a permanent readout instead of asking, point Claude Code's status line at
|
|
142
|
+
the same script. In `settings.json`:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"statusLine": {
|
|
147
|
+
"type": "command",
|
|
148
|
+
"command": "node ~/.claude/skills/usage-limits/scripts/usage.js --status"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
It prints one line and prefixes `LOW` once a window passes 90 percent:
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
5h 62% 1h 40m wk 75% 2d 4h
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`--status` reads only the cached percentages and never opens a transcript, so
|
|
160
|
+
it runs in about a tenth of a second and is safe on every redraw. Use the full
|
|
161
|
+
path rather than `~` if your shell does not expand it, and point it at the
|
|
162
|
+
plugin copy instead if that is how you installed it.
|
|
163
|
+
|
|
164
|
+
## Plans
|
|
165
|
+
|
|
166
|
+
It reads which plan you are on and adjusts what it tells you, because the
|
|
167
|
+
advice differs even though the arithmetic does not:
|
|
168
|
+
|
|
169
|
+
| Plan | Read from | What changes |
|
|
170
|
+
| --- | --- | --- |
|
|
171
|
+
| Pro | `claude_pro` | Smallest budget. The 5-hour window usually binds first. |
|
|
172
|
+
| Max 5x | `claude_max` plus `default_claude_max_5x` | Room for Opus on most work. The weekly window is the one that bites. |
|
|
173
|
+
| Max 20x | `claude_max` plus `default_claude_max_20x` | Rarely binds. No reason to slow down unless the weekly is already high. |
|
|
174
|
+
| Team, Enterprise | `claude_team`, `claude_enterprise` | Seats are pooled and overage is an org setting. |
|
|
175
|
+
|
|
176
|
+
The window maths never needs to know the plan. It calibrates against what your
|
|
177
|
+
own account reports, so it is right on any tier, including ones that did not
|
|
178
|
+
exist when this was written. The plan only decides which line of advice you
|
|
179
|
+
get at the bottom of the report.
|
|
180
|
+
|
|
181
|
+
## Where it works
|
|
182
|
+
|
|
183
|
+
Every surface of Claude Code on a machine shares one config directory, so
|
|
184
|
+
this reads all of them and does not care which one you are in:
|
|
185
|
+
|
|
186
|
+
| Surface | Works | Notes |
|
|
187
|
+
| --- | --- | --- |
|
|
188
|
+
| Terminal (`claude`) | yes | |
|
|
189
|
+
| VS Code extension | yes | |
|
|
190
|
+
| JetBrains extension | yes | |
|
|
191
|
+
| Desktop app | yes | |
|
|
192
|
+
| Headless (`claude -p`) | yes | Scripts run fine, but there are no slash commands, so `lowpower.js` is the only way to change effort. |
|
|
193
|
+
| Cloud and web sessions | partly | Those run on a remote machine with their own config directory. Percentages are per-account and stay correct; the pace is measured from whatever transcripts are local to wherever you run the script. |
|
|
194
|
+
|
|
195
|
+
Sessions from different surfaces land in the same `~/.claude/projects` tree
|
|
196
|
+
and are counted together. On this machine the transcripts carry both `cli` and
|
|
197
|
+
`claude-vscode` entrypoints, and the report totals both.
|
|
198
|
+
|
|
199
|
+
Windows, macOS, and Linux all work. `CLAUDE_CONFIG_DIR` is honoured if you have
|
|
200
|
+
moved the config directory.
|
|
201
|
+
|
|
202
|
+
## Working cheaply on purpose
|
|
203
|
+
|
|
204
|
+
Half the problem is measurement. The other half is that a high effort setting
|
|
205
|
+
keeps spending at the same rate whether or not there is room left.
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
node skills/usage-limits/scripts/lowpower.js status
|
|
209
|
+
node skills/usage-limits/scripts/lowpower.js on # effortLevel -> low
|
|
210
|
+
node skills/usage-limits/scripts/lowpower.js on --effort medium --model sonnet
|
|
211
|
+
node skills/usage-limits/scripts/lowpower.js off # puts back what was there
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
It edits `effortLevel` in `settings.json` through a temporary file, saves the
|
|
215
|
+
previous values alongside, and keeps a `.usage-limits-backup` copy of the original.
|
|
216
|
+
Keys it does not manage are left untouched. Running `on` twice does not
|
|
217
|
+
overwrite the saved originals.
|
|
218
|
+
|
|
219
|
+
The file change applies to new sessions. For a session already running,
|
|
220
|
+
`/effort low` does the same thing immediately.
|
|
221
|
+
|
|
222
|
+
That covers the setting. The larger saving is behavioural, and the skill file
|
|
223
|
+
spells it out: batch tool calls, read line ranges instead of whole files, skip
|
|
224
|
+
subagents when the context already exists, stop retrying a fix that is not
|
|
225
|
+
working. Effort level does not control any of that, which is why those rules
|
|
226
|
+
apply even at `xhigh` or `max`. The reasoning behind each one is in
|
|
227
|
+
[tactics.md](skills/usage-limits/references/tactics.md).
|
|
228
|
+
|
|
229
|
+
## Requirements
|
|
230
|
+
|
|
231
|
+
Node 18 or newer, and a Claude Code recent enough to write
|
|
232
|
+
`cachedUsageUtilization` into `~/.claude.json`. If the report says it found no
|
|
233
|
+
snapshot, run `/usage` once inside Claude Code and it will be there.
|
|
234
|
+
|
|
235
|
+
Nothing is uploaded. No API key, token, or credential is read. Everything comes
|
|
236
|
+
from files already on the machine.
|
|
237
|
+
|
|
238
|
+
## How accurate is it
|
|
239
|
+
|
|
240
|
+
Good enough to plan with, not a bill. The honest caveats:
|
|
241
|
+
|
|
242
|
+
- The meter reports whole percent, so a reading of 2 percent is really
|
|
243
|
+
somewhere between 1.5 and 2.5. Low readings project badly, and the report
|
|
244
|
+
says so when it is in that range.
|
|
245
|
+
- Transcripts are local. Usage from another machine or from claude.ai counts
|
|
246
|
+
against the same limit but leaves no local record, which makes the estimate
|
|
247
|
+
read low.
|
|
248
|
+
- The dollar figures are an internal unit used to convert your token mix into
|
|
249
|
+
a percentage of the limit. On a subscription plan you are not billed them.
|
|
250
|
+
- Turns left assumes the next turns look like the last hour's. A debugging
|
|
251
|
+
spiral breaks that assumption immediately.
|
|
252
|
+
- The cache only refreshes when Claude Code talks to the API, so after an idle
|
|
253
|
+
spell a window can sit past its own reset time. When that happens the report
|
|
254
|
+
says `stale` and the status line says `rolling` rather than reporting a
|
|
255
|
+
percentage for a window that has already turned over.
|
|
256
|
+
|
|
257
|
+
[how-it-works.md](skills/usage-limits/references/how-it-works.md) has the field
|
|
258
|
+
names, the formulas, and the rest of it.
|
|
259
|
+
|
|
260
|
+
## Layout
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
.claude-plugin/plugin.json plugin manifest
|
|
264
|
+
.claude-plugin/marketplace.json lets the repo serve itself
|
|
265
|
+
skills/usage-limits/SKILL.md what Claude reads
|
|
266
|
+
skills/usage-limits/scripts/ the two scripts
|
|
267
|
+
skills/usage-limits/references/ the longer notes
|
|
268
|
+
test/ node --test, no dependencies
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## Tests
|
|
272
|
+
|
|
273
|
+
```
|
|
274
|
+
node --test
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
72 tests over the pricing, the window arithmetic, plan and credit detection,
|
|
278
|
+
the status line, per-project attribution, the CLI, and the settings
|
|
279
|
+
save/restore.
|
|
280
|
+
|
|
281
|
+
## Status
|
|
282
|
+
|
|
283
|
+
It works and I use it daily.
|
|
284
|
+
|
|
285
|
+
What I am not doing is fielding feature requests or support questions. If you
|
|
286
|
+
want it to behave differently, fork it and change it, which is what the MIT
|
|
287
|
+
licence is there for. Do not wait on me to add something for you.
|
|
288
|
+
|
|
289
|
+
## License
|
|
290
|
+
|
|
291
|
+
MIT. See [LICENSE](LICENSE).
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// One entry point for the npm package. The plugin and skill call the scripts
|
|
5
|
+
// under skills/usage-limits/scripts directly; this just gives npx users a
|
|
6
|
+
// single command that reaches the same code.
|
|
7
|
+
|
|
8
|
+
const HELP = `claude-usage-limits - how much Claude Code usage is left, and whether the job fits
|
|
9
|
+
|
|
10
|
+
claude-usage-limits the report
|
|
11
|
+
claude-usage-limits --json the same numbers, machine readable
|
|
12
|
+
claude-usage-limits --status one short line, for a status line
|
|
13
|
+
|
|
14
|
+
claude-usage-limits lowpower status show the current effort setting
|
|
15
|
+
claude-usage-limits lowpower on lower effortLevel, remembering the old value
|
|
16
|
+
claude-usage-limits lowpower on --effort medium --model sonnet
|
|
17
|
+
claude-usage-limits lowpower off put back exactly what was there
|
|
18
|
+
|
|
19
|
+
Reads the usage figures Claude Code already caches locally, plus your session
|
|
20
|
+
transcripts, to report the remaining headroom as turns of work. Nothing is
|
|
21
|
+
uploaded and no credentials are read.
|
|
22
|
+
|
|
23
|
+
https://github.com/ridelink0/claude-code-usage-limits
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
function run(argv) {
|
|
27
|
+
const args = argv || [];
|
|
28
|
+
|
|
29
|
+
if (args.indexOf('--help') !== -1 || args.indexOf('-h') !== -1) {
|
|
30
|
+
process.stdout.write(HELP);
|
|
31
|
+
return Promise.resolve(0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (args.indexOf('--version') !== -1 || args.indexOf('-v') !== -1) {
|
|
35
|
+
process.stdout.write(require('../package.json').version + '\n');
|
|
36
|
+
return Promise.resolve(0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (args[0] === 'lowpower') {
|
|
40
|
+
const lowpower = require('../skills/usage-limits/scripts/lowpower.js');
|
|
41
|
+
return Promise.resolve(lowpower.main(args.slice(1)));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const usage = require('../skills/usage-limits/scripts/usage.js');
|
|
45
|
+
return Promise.resolve(usage.main(args));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (require.main === module) {
|
|
49
|
+
run(process.argv.slice(2)).then(
|
|
50
|
+
(code) => {
|
|
51
|
+
process.exitCode = code || 0;
|
|
52
|
+
},
|
|
53
|
+
(err) => {
|
|
54
|
+
process.stderr.write(
|
|
55
|
+
'claude-usage-limits: ' + (err && err.message ? err.message : String(err)) + '\n'
|
|
56
|
+
);
|
|
57
|
+
process.exitCode = 1;
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = { run, HELP };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Report how much Claude Code usage limit is left and how many turns of work it buys
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Run the usage report and read it back to me.
|
|
6
|
+
|
|
7
|
+
1. Run `node "${CLAUDE_PLUGIN_ROOT}/skills/usage-limits/scripts/usage.js"`.
|
|
8
|
+
2. Tell me which window is binding, how many turns of headroom is left, and
|
|
9
|
+
whether that window resets before the budget runs out.
|
|
10
|
+
3. If I have already said what I want built, size it against the turns left
|
|
11
|
+
and say whether it fits. If it does not fit, say what to cut rather than
|
|
12
|
+
starting and hoping.
|
|
13
|
+
|
|
14
|
+
Report the numbers and stop. Do not start other work as part of this command.
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claude-usage-limits",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "See how much of your Claude Code usage limit is left as turns of work rather than a percentage, and plan the job to fit inside it.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"claude",
|
|
7
|
+
"claude-code",
|
|
8
|
+
"usage",
|
|
9
|
+
"limits",
|
|
10
|
+
"rate-limit",
|
|
11
|
+
"tokens",
|
|
12
|
+
"cost",
|
|
13
|
+
"budget",
|
|
14
|
+
"statusline",
|
|
15
|
+
"cli"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://github.com/ridelink0/claude-code-usage-limits",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/ridelink0/claude-code-usage-limits.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/ridelink0/claude-code-usage-limits/issues"
|
|
24
|
+
},
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"author": "Ridelink (https://github.com/ridelink0)",
|
|
27
|
+
"bin": {
|
|
28
|
+
"claude-usage-limits": "bin/cli.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"bin/",
|
|
32
|
+
"skills/",
|
|
33
|
+
"commands/",
|
|
34
|
+
".claude-plugin/"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"test": "node --test",
|
|
41
|
+
"usage": "node bin/cli.js"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: usage-limits
|
|
3
|
+
description: Check how much of the Claude Code usage limit is left and plan the work to fit inside it. Use before starting anything long, when the 5-hour or weekly limit is getting close, when asked how much usage is left or whether there is enough left to finish, and when asked to work cheaply, burn fewer credits, or stretch the rest of the limit.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# usage-limits
|
|
7
|
+
|
|
8
|
+
Running out of limit halfway through a job is a scheduling failure, not bad
|
|
9
|
+
luck. The numbers are on disk before the work starts. Read them, size the job
|
|
10
|
+
against them, and either commit to finishing or cut the job down until it fits.
|
|
11
|
+
|
|
12
|
+
## 1. Measure
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
node scripts/usage.js
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Paths here are relative to this skill's own directory, not the project you are
|
|
19
|
+
working in. Run them from there, or prefix them with the skill's path.
|
|
20
|
+
|
|
21
|
+
It prints the real percentages and reset times from the CLI's own cache, plus
|
|
22
|
+
a pace measured from the local session transcripts:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Window Used Resets in Left Turns left
|
|
26
|
+
5-hour 62% 1h 40m $46.0 ~88
|
|
27
|
+
weekly 75% 2d 4h $124 ~240 <- binding
|
|
28
|
+
|
|
29
|
+
Recent pace 15 turns in the last hour, $0.164 per turn, effort xhigh
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`Turns left` is the number that matters. It is the remaining headroom divided
|
|
33
|
+
by what a turn has actually been costing over the last hour, on this account,
|
|
34
|
+
at this effort level. Add `--json` when you want the raw fields.
|
|
35
|
+
|
|
36
|
+
If it says no snapshot was found, run `/usage` once in Claude Code and try
|
|
37
|
+
again. That populates the cache the script reads.
|
|
38
|
+
|
|
39
|
+
The last line names the plan (Pro, Max 5x, Max 20x, Team, Enterprise) and what
|
|
40
|
+
it means for spending. Pro has the least room and the 5-hour window usually
|
|
41
|
+
binds first; Max 20x rarely binds at all. Take that line into account before
|
|
42
|
+
deciding how careful to be.
|
|
43
|
+
|
|
44
|
+
## 2. Size the job before starting it
|
|
45
|
+
|
|
46
|
+
Count the work in turns, not in tasks. A rough scale that holds up in practice:
|
|
47
|
+
|
|
48
|
+
| Work | Turns |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| Read and answer a question about existing code | 1 to 2 |
|
|
51
|
+
| One edit plus the check that it worked | 2 to 4 |
|
|
52
|
+
| A feature touching three or four files | 10 to 20 |
|
|
53
|
+
| Debugging something with an unknown cause | 15 or more, and unpredictable |
|
|
54
|
+
|
|
55
|
+
Then compare against `Turns left` and hold back a reserve. Reserve about a
|
|
56
|
+
fifth of the budget for landing the work: the test run, the commit, and the
|
|
57
|
+
handoff note. Work that gets cut off just before the commit is worth nothing,
|
|
58
|
+
so the reserve is not optional.
|
|
59
|
+
|
|
60
|
+
## 3. Decide, out loud
|
|
61
|
+
|
|
62
|
+
Tell the user which of these applies before doing anything expensive.
|
|
63
|
+
|
|
64
|
+
**It fits.** Say so with the number, then work normally. Do not slow down out
|
|
65
|
+
of caution when there is room. Cheapness is not a virtue when the budget is
|
|
66
|
+
not tight.
|
|
67
|
+
|
|
68
|
+
**It fits only if nothing goes wrong.** Say so, switch to low power for the
|
|
69
|
+
run, and reorder the work so the valuable part lands first.
|
|
70
|
+
|
|
71
|
+
**It does not fit.** Say so before starting, in plain words. State that not
|
|
72
|
+
all of it can be done in what is left, list what you are doing now and what
|
|
73
|
+
you are leaving, and name the wall-clock time the window resets so the user
|
|
74
|
+
knows when the rest can happen. Then do the part that fits, properly. Do not
|
|
75
|
+
start and hope: half a feature, committed and working, beats a whole one
|
|
76
|
+
abandoned mid-edit.
|
|
77
|
+
|
|
78
|
+
**The window resets first.** If the reset lands before the budget runs out,
|
|
79
|
+
the limit is not the constraint. Say that and stop optimising for it.
|
|
80
|
+
|
|
81
|
+
## Credits
|
|
82
|
+
|
|
83
|
+
The `Credits` line in the report says what actually happens at the limit, and
|
|
84
|
+
the two cases need opposite handling.
|
|
85
|
+
|
|
86
|
+
**Off.** Work stops dead at the limit. Nothing spills over. This is the case
|
|
87
|
+
to plan hardest around, because there is no way to buy your way through it.
|
|
88
|
+
|
|
89
|
+
**On.** The limit is a cost boundary rather than a hard stop, so a job that
|
|
90
|
+
does not fit can still be finished, for money. Do not warn about the crossover
|
|
91
|
+
yourself: Claude Code announces it and asks before drawing on credits, and
|
|
92
|
+
repeating that only adds noise. Just factor it into the plan, and take the
|
|
93
|
+
user's answer to that prompt as the decision.
|
|
94
|
+
|
|
95
|
+
## 4. Low power
|
|
96
|
+
|
|
97
|
+
Two halves, and the second one is the half that actually binds.
|
|
98
|
+
|
|
99
|
+
The setting:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
node scripts/lowpower.js on # effortLevel -> low, old value saved
|
|
103
|
+
node scripts/lowpower.js on --effort medium --model sonnet
|
|
104
|
+
node scripts/lowpower.js off # restores exactly what was there
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
In a headless run (`claude -p`) there are no slash commands, so the script is
|
|
108
|
+
the only lever there.
|
|
109
|
+
|
|
110
|
+
`effortLevel` is what the `/effort` picker writes. Reasoning is billed as
|
|
111
|
+
output tokens, the most expensive tokens in the request, so dropping `xhigh`
|
|
112
|
+
to `low` is the largest per-turn saving available without changing model or
|
|
113
|
+
scope. The file change applies to new sessions; for the session already
|
|
114
|
+
running, `/effort low` takes effect immediately.
|
|
115
|
+
|
|
116
|
+
The behaviour, which applies **even at xhigh or max effort**, because the
|
|
117
|
+
effort setting does not control any of it:
|
|
118
|
+
|
|
119
|
+
- Think briefly on routine steps. Save the long reasoning for decisions that
|
|
120
|
+
are actually hard to reverse.
|
|
121
|
+
- Send independent tool calls together in one message. Three calls in one turn
|
|
122
|
+
cost one context resend; three separate turns cost three.
|
|
123
|
+
- Read line ranges, not whole files. Grep with a head limit. A 40k-token file
|
|
124
|
+
read is not paid once, it is paid again on every later turn in the session.
|
|
125
|
+
- Never re-read a file to confirm an edit landed. The edit tool already failed
|
|
126
|
+
if it did not.
|
|
127
|
+
- No subagents. A subagent starts cold and re-derives context that is already
|
|
128
|
+
in this session.
|
|
129
|
+
- Nothing that was not asked for. No speculative refactor, no extra test, no
|
|
130
|
+
drive-by cleanup.
|
|
131
|
+
- Fewer, denser turns. Narration between tool calls is output tokens spent on
|
|
132
|
+
nothing.
|
|
133
|
+
|
|
134
|
+
`references/tactics.md` has the full list and the billing reasons behind each
|
|
135
|
+
one.
|
|
136
|
+
|
|
137
|
+
## 5. Checkpoint before the wall
|
|
138
|
+
|
|
139
|
+
When the binding window is under roughly 15 percent, or under about ten turns
|
|
140
|
+
of headroom, stop adding work and land what exists:
|
|
141
|
+
|
|
142
|
+
1. Commit or otherwise save the working state.
|
|
143
|
+
2. Write `HANDOFF.md`: what is done, what is next, which files are mid-change,
|
|
144
|
+
what the next session should read first.
|
|
145
|
+
3. Say when the window resets, as a clock time and not just a duration, plus
|
|
146
|
+
what to run on the way back in.
|
|
147
|
+
|
|
148
|
+
A handoff written with ten turns left is worth more than the tenth turn.
|
|
149
|
+
|
|
150
|
+
## When to skip this skill
|
|
151
|
+
|
|
152
|
+
Do not run the report on every prompt. Once at the start of a long piece of
|
|
153
|
+
work, and again if the job grows or something starts looping. The report costs
|
|
154
|
+
a turn, which is the thing it is trying to save.
|
|
155
|
+
|
|
156
|
+
## Files
|
|
157
|
+
|
|
158
|
+
| Path | What it is |
|
|
159
|
+
| --- | --- |
|
|
160
|
+
| `scripts/usage.js` | The report. `--json` for raw fields, `--status` for a one-line status line readout that skips the transcript scan. |
|
|
161
|
+
| `scripts/lowpower.js` | `status`, `on`, `off`. Restores what it replaced. |
|
|
162
|
+
| `references/tactics.md` | Every lever that lowers cost, and why it works. |
|
|
163
|
+
| `references/how-it-works.md` | Where the numbers come from and where they are soft. |
|