costclaw 0.12.4 → 0.13.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/README.md +72 -72
- package/dist/index.js +745 -189
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
A local cost and setup audit for [Claude Code](https://claude.com/claude-code).
|
|
4
4
|
Point it at your session logs and it shows where token spend leaks, scores your
|
|
5
|
-
setup across six pillars, and ranks counterfactual opportunities by estimated
|
|
6
|
-
token value.
|
|
5
|
+
setup across six pillars, and ranks counterfactual opportunities by estimated
|
|
6
|
+
token value.
|
|
7
7
|
|
|
8
|
-
Your prompts are analyzed locally and never uploaded. The audit parses the logs
|
|
9
|
-
already on your disk and prints a report.
|
|
8
|
+
Your prompts are analyzed locally and never uploaded. The audit parses the logs
|
|
9
|
+
already on your disk and prints a report.
|
|
10
10
|
|
|
11
11
|
## Use it
|
|
12
12
|
|
|
@@ -16,43 +16,43 @@ Requires Node 20+.
|
|
|
16
16
|
npx costclaw audit
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
That reads `~/.claude/projects` (override with `--path <dir>`) and prints a
|
|
20
|
-
local report. This concise example is synthetic, generated from synthetic inputs:
|
|
19
|
+
That reads `~/.claude/projects` (override with `--path <dir>`) and prints a
|
|
20
|
+
local report. This concise example is synthetic, generated from synthetic inputs:
|
|
21
21
|
|
|
22
22
|
```
|
|
23
23
|
CostClaw audit
|
|
24
|
-
Source: synthetic example (1 session across 1 project)
|
|
25
|
-
CLAUDE.md: synthetic input
|
|
26
|
-
|
|
27
|
-
Cache-miss exposure (estimate): $90.01
|
|
28
|
-
|
|
29
|
-
Estimated current API-equivalent valuation: $100.01 Cache hit: 0.0% Session hours (timestamp union): 1.0
|
|
30
|
-
Model spend: opus 0.01% / haiku 99.99%
|
|
31
|
-
|
|
32
|
-
Rule-based setup score: 74 / 100 (Solid)
|
|
33
|
-
CLAUDE.md quality 72
|
|
34
|
-
Context hygiene 50
|
|
35
|
-
Prompting patterns 75
|
|
36
|
-
Session management 100
|
|
37
|
-
Tool and MCP config 88
|
|
38
|
-
Cost discipline 67
|
|
39
|
-
|
|
40
|
-
Top opportunities by estimated exposure:
|
|
41
|
-
- [$90.01] Reduce cache-miss exposure
|
|
42
|
-
Synthetic cache-read counterfactual; cold and unique inputs may not be cacheable.
|
|
24
|
+
Source: synthetic example (1 session across 1 project)
|
|
25
|
+
CLAUDE.md: synthetic input
|
|
26
|
+
|
|
27
|
+
Cache-miss exposure (estimate): $90.01
|
|
28
|
+
|
|
29
|
+
Estimated current API-equivalent valuation: $100.01 Cache hit: 0.0% Session hours (timestamp union): 1.0
|
|
30
|
+
Model spend: opus 0.01% / haiku 99.99%
|
|
31
|
+
|
|
32
|
+
Rule-based setup score: 74 / 100 (Solid)
|
|
33
|
+
CLAUDE.md quality 72
|
|
34
|
+
Context hygiene 50
|
|
35
|
+
Prompting patterns 75
|
|
36
|
+
Session management 100
|
|
37
|
+
Tool and MCP config 88
|
|
38
|
+
Cost discipline 67
|
|
39
|
+
|
|
40
|
+
Top opportunities by estimated exposure:
|
|
41
|
+
- [$90.01] Reduce cache-miss exposure
|
|
42
|
+
Synthetic cache-read counterfactual; cold and unique inputs may not be cacheable.
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
The audit applies rules to observed cache and setup patterns. Its suggested causes
|
|
46
|
-
and actions are hypotheses to inspect, not diagnoses or proof that a change will save
|
|
47
|
-
money. Burn Clock needs at least 7 active days of logs; below that it is left out.
|
|
45
|
+
The audit applies rules to observed cache and setup patterns. Its suggested causes
|
|
46
|
+
and actions are hypotheses to inspect, not diagnoses or proof that a change will save
|
|
47
|
+
money. Burn Clock needs at least 7 active days of logs; below that it is left out.
|
|
48
48
|
|
|
49
49
|
## On a subscription? Declare your plan
|
|
50
50
|
|
|
51
51
|
Every dollar the audit prints is an API-equivalent price: what those tokens
|
|
52
52
|
would cost at pay-as-you-go rates. On a Claude subscription (Pro or Max) your
|
|
53
|
-
usage within an included allowance may have no marginal token charge. Extra Usage
|
|
54
|
-
can be billed, so API-equivalent figures are neither money back nor a statement of
|
|
55
|
-
your actual subscription charges.
|
|
53
|
+
usage within an included allowance may have no marginal token charge. Extra Usage
|
|
54
|
+
can be billed, so API-equivalent figures are neither money back nor a statement of
|
|
55
|
+
your actual subscription charges.
|
|
56
56
|
|
|
57
57
|
The first interactive run asks which one you are on and remembers the answer, so
|
|
58
58
|
usually there is nothing to do. To set it directly, or to change it later:
|
|
@@ -64,21 +64,21 @@ npx costclaw audit --plan max20x # or pro, max5x; --plan api switches back
|
|
|
64
64
|
Piped runs, `--json` and CI are never asked and assume API rates, so a scripted
|
|
65
65
|
audit never blocks waiting for an answer.
|
|
66
66
|
|
|
67
|
-
The headline becomes cache-miss exposure - a counterfactual comparison of logged
|
|
68
|
-
token use with a cache-read scenario - with dollars as API-equivalent context. The
|
|
69
|
-
following uses the same synthetic example:
|
|
67
|
+
The headline becomes cache-miss exposure - a counterfactual comparison of logged
|
|
68
|
+
token use with a cache-read scenario - with dollars as API-equivalent context. The
|
|
69
|
+
following uses the same synthetic example:
|
|
70
70
|
|
|
71
71
|
```
|
|
72
|
-
Cache-miss exposure (counterfactual): 90.0% of analyzed usage ($90.01 at API rates)
|
|
73
|
-
|
|
74
|
-
Estimated current API-equivalent valuation: $100.01 Cache hit: 0.0% Session hours (timestamp union): 1.0
|
|
75
|
-
Plan: max20x. This synthetic example does not measure quota, billing, or promise
|
|
76
|
-
more work. Activity windows are omitted when there is insufficient history.
|
|
72
|
+
Cache-miss exposure (counterfactual): 90.0% of analyzed usage ($90.01 at API rates)
|
|
73
|
+
|
|
74
|
+
Estimated current API-equivalent valuation: $100.01 Cache hit: 0.0% Session hours (timestamp union): 1.0
|
|
75
|
+
Plan: max20x. This synthetic example does not measure quota, billing, or promise
|
|
76
|
+
more work. Activity windows are omitted when there is insufficient history.
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
Usage windows are fixed activity bins based on local timestamps. They summarize
|
|
80
|
-
observed activity only: CostClaw does not know Anthropic's actual quota, rate-limit
|
|
81
|
-
windows, subscription inclusion, or billing adjustments.
|
|
79
|
+
Usage windows are fixed activity bins based on local timestamps. They summarize
|
|
80
|
+
observed activity only: CostClaw does not know Anthropic's actual quota, rate-limit
|
|
81
|
+
windows, subscription inclusion, or billing adjustments.
|
|
82
82
|
|
|
83
83
|
The value is saved to `~/.costclaw/config.json`, so later runs (and `optimize`)
|
|
84
84
|
remember it. The findings and their ranking are identical either way; only the
|
|
@@ -107,24 +107,24 @@ costclaw audit [--path <dir>] [--claude-md <file>] [--plan <plan>] [--json] [--h
|
|
|
107
107
|
"What to do next" ramp: the commands to run next, how the optimize license
|
|
108
108
|
works, and a command reference.
|
|
109
109
|
- `--card [file]` also write a shareable score card SVG (default
|
|
110
|
-
`costclaw-card.svg`): your score, band, cache-miss exposure estimate, cache hit rate, and
|
|
110
|
+
`costclaw-card.svg`): your score, band, cache-miss exposure estimate, cache hit rate, and
|
|
111
111
|
strongest pillar. A static file, no fonts or network calls.
|
|
112
112
|
|
|
113
113
|
Run `costclaw --version` (or `-v` / `costclaw version`) to print the installed
|
|
114
|
-
CLI version.
|
|
115
|
-
|
|
116
|
-
## Accuracy boundary
|
|
117
|
-
|
|
118
|
-
The report estimates current API-equivalent list-price value from logged usage and a
|
|
119
|
-
dated rate table. It is not billing proof. Unknown model IDs, unavailable pricing
|
|
120
|
-
modifiers, and incomplete logs add uncertainty. Repeated cumulative request updates
|
|
121
|
-
are counted once using the highest coherent observed total; logged cache TTL splits are priced
|
|
122
|
-
when available. A top-level/split conflict retains the valid top-level count at the
|
|
123
|
-
conservative one-hour rate with a warning; legacy writes without a split use five-minute
|
|
124
|
-
pricing with a warning. Cache-miss exposure is a counterfactual, and the setup score uses
|
|
125
|
-
rules rather than a provider quality grade. The release retests these boundaries with
|
|
126
|
-
`npm test --workspace @costclaw/engine -- accuracy-regression` and
|
|
127
|
-
`npm test --workspace costclaw -- accuracy-report`.
|
|
114
|
+
CLI version.
|
|
115
|
+
|
|
116
|
+
## Accuracy boundary
|
|
117
|
+
|
|
118
|
+
The report estimates current API-equivalent list-price value from logged usage and a
|
|
119
|
+
dated rate table. It is not billing proof. Unknown model IDs, unavailable pricing
|
|
120
|
+
modifiers, and incomplete logs add uncertainty. Repeated cumulative request updates
|
|
121
|
+
are counted once using the highest coherent observed total; logged cache TTL splits are priced
|
|
122
|
+
when available. A top-level/split conflict retains the valid top-level count at the
|
|
123
|
+
conservative one-hour rate with a warning; legacy writes without a split use five-minute
|
|
124
|
+
pricing with a warning. Cache-miss exposure is a counterfactual, and the setup score uses
|
|
125
|
+
rules rather than a provider quality grade. The release retests these boundaries with
|
|
126
|
+
`npm test --workspace @costclaw/engine -- accuracy-regression` and
|
|
127
|
+
`npm test --workspace costclaw -- accuracy-report`.
|
|
128
128
|
|
|
129
129
|
## Diff
|
|
130
130
|
|
|
@@ -135,8 +135,8 @@ Every audit run saves a snapshot of the derived record to `~/.costclaw/history`
|
|
|
135
135
|
npx costclaw diff
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
-
That compares your latest two audits and shows movement in the estimates. It does not
|
|
139
|
-
verify money recovered. The numeric example below is illustrative:
|
|
138
|
+
That compares your latest two audits and shows movement in the estimates. It does not
|
|
139
|
+
verify money recovered. The numeric example below is illustrative:
|
|
140
140
|
|
|
141
141
|
```
|
|
142
142
|
CostClaw diff
|
|
@@ -145,14 +145,14 @@ Baseline: 2026-06-09 Current: 2026-07-09 (30 days)
|
|
|
145
145
|
Since the baseline:
|
|
146
146
|
New spend $842.10 across 210 new sessions
|
|
147
147
|
Marginal cache hit 97.1% (lifetime 96.2%)
|
|
148
|
-
Cache-miss exposure (estimate) +$96.40 (now $1131.61)
|
|
148
|
+
Cache-miss exposure (estimate) +$96.40 (now $1131.61)
|
|
149
149
|
|
|
150
|
-
Rule-based setup score: 83 -> 86 (+3, Tight)
|
|
150
|
+
Rule-based setup score: 83 -> 86 (+3, Tight)
|
|
151
151
|
CLAUDE.md quality 69 -> 78 (+9)
|
|
152
152
|
...
|
|
153
153
|
|
|
154
154
|
Fixes resolved since the baseline:
|
|
155
|
-
- [$52.40] Review model fit for 61 small sessions
|
|
155
|
+
- [$52.40] Review model fit for 61 small sessions
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
The marginal cache hit rate covers only the period between the two audits, which
|
|
@@ -179,10 +179,10 @@ its band. Drop it in a README with a plain image tag:
|
|
|
179
179
|
costclaw badge [--path <dir>] [--claude-md <file>] [--out <file>]
|
|
180
180
|
```
|
|
181
181
|
|
|
182
|
-
## Optimize
|
|
183
|
-
|
|
184
|
-
The numeric examples in this section are illustrative placeholders, not output from
|
|
185
|
-
an account or a promise of savings.
|
|
182
|
+
## Optimize
|
|
183
|
+
|
|
184
|
+
The numeric examples in this section are illustrative placeholders, not output from
|
|
185
|
+
an account or a promise of savings.
|
|
186
186
|
|
|
187
187
|
```bash
|
|
188
188
|
npx costclaw optimize
|
|
@@ -258,13 +258,13 @@ playbook's per-project table reconciles. costclaw sets no target line count
|
|
|
258
258
|
anywhere: it measures what your sections cost and which lines carry dates, and
|
|
259
259
|
leaves the keep-or-move judgment to you.
|
|
260
260
|
|
|
261
|
-
The playbook breaks the cache-miss exposure estimate down by project, so you can see
|
|
262
|
-
which repository has modeled exposure and at what cache hit rate:
|
|
261
|
+
The playbook breaks the cache-miss exposure estimate down by project, so you can see
|
|
262
|
+
which repository has modeled exposure and at what cache hit rate:
|
|
263
263
|
|
|
264
264
|
```
|
|
265
265
|
### Where that money is
|
|
266
266
|
|
|
267
|
-
| Project | Cache-miss exposure (estimate) | Cache hit | Main sessions |
|
|
267
|
+
| Project | Cache-miss exposure (estimate) | Cache hit | Main sessions |
|
|
268
268
|
| --- | --- | --- | --- |
|
|
269
269
|
| some-app | $490.43 | 98% | 229 |
|
|
270
270
|
| another-app | $312.43 | 99% | 131 |
|
|
@@ -322,6 +322,6 @@ costclaw apply [<dir>] [--remove] [--replace] [--apply-settings [file]] [--from
|
|
|
322
322
|
|
|
323
323
|
## Privacy
|
|
324
324
|
|
|
325
|
-
The audit saves a derived `AuditRecord`: totals and generated prose, with no raw
|
|
326
|
-
prompt text, file paths, or secrets. A hosted dashboard is on the roadmap and would
|
|
327
|
-
receive only that derived record, never your logs.
|
|
325
|
+
The audit saves a derived `AuditRecord`: totals and generated prose, with no raw
|
|
326
|
+
prompt text, file paths, or secrets. A hosted dashboard is on the roadmap and would
|
|
327
|
+
receive only that derived record, never your logs.
|