costclaw 0.12.2 → 0.12.4
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 +327 -326
- package/dist/index.js +770 -270
- package/package.json +47 -47
package/README.md
CHANGED
|
@@ -1,326 +1,327 @@
|
|
|
1
|
-
# costclaw
|
|
2
|
-
|
|
3
|
-
A local cost and setup audit for [Claude Code](https://claude.com/claude-code).
|
|
4
|
-
Point it at your session logs and it shows where token spend leaks, scores your
|
|
5
|
-
setup across six pillars, and ranks
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
- `--
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
`
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
`
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
page
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
-
|
|
250
|
-
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
|
268
|
-
|
|
|
269
|
-
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
`
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
1
|
+
# costclaw
|
|
2
|
+
|
|
3
|
+
A local cost and setup audit for [Claude Code](https://claude.com/claude-code).
|
|
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.
|
|
7
|
+
|
|
8
|
+
Your prompts are analyzed locally and never uploaded. The audit parses the logs
|
|
9
|
+
already on your disk and prints a report.
|
|
10
|
+
|
|
11
|
+
## Use it
|
|
12
|
+
|
|
13
|
+
Requires Node 20+.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx costclaw audit
|
|
17
|
+
```
|
|
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:
|
|
21
|
+
|
|
22
|
+
```
|
|
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.
|
|
43
|
+
```
|
|
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.
|
|
48
|
+
|
|
49
|
+
## On a subscription? Declare your plan
|
|
50
|
+
|
|
51
|
+
Every dollar the audit prints is an API-equivalent price: what those tokens
|
|
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.
|
|
56
|
+
|
|
57
|
+
The first interactive run asks which one you are on and remembers the answer, so
|
|
58
|
+
usually there is nothing to do. To set it directly, or to change it later:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npx costclaw audit --plan max20x # or pro, max5x; --plan api switches back
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Piped runs, `--json` and CI are never asked and assume API rates, so a scripted
|
|
65
|
+
audit never blocks waiting for an answer.
|
|
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:
|
|
70
|
+
|
|
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.
|
|
77
|
+
```
|
|
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.
|
|
82
|
+
|
|
83
|
+
The value is saved to `~/.costclaw/config.json`, so later runs (and `optimize`)
|
|
84
|
+
remember it. The findings and their ranking are identical either way; only the
|
|
85
|
+
unit is framed to match how you actually pay.
|
|
86
|
+
|
|
87
|
+
## Options
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
costclaw audit [--path <dir>] [--claude-md <file>] [--plan <plan>] [--json] [--html [file]] [--no-html] [--card [file]]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- `--path <dir>` audit a specific projects directory (default `~/.claude/projects`).
|
|
94
|
+
- `--claude-md <file>` score a specific CLAUDE.md file's quality (by default the
|
|
95
|
+
audit scores `~/.claude/CLAUDE.md` when it exists).
|
|
96
|
+
- `--plan <api|pro|max5x|max20x>` declare how you pay for Claude (see above);
|
|
97
|
+
persisted for later runs.
|
|
98
|
+
- `--json` print the raw, derived `AuditRecord` instead of the human report.
|
|
99
|
+
- The HTML report is written and opened in your browser **by default**
|
|
100
|
+
(`costclaw-report.html` in the current directory). The file inlines
|
|
101
|
+
everything, so nothing is fetched and nothing is uploaded; the terminal
|
|
102
|
+
report still prints (in color on interactive terminals; set `NO_COLOR` to
|
|
103
|
+
disable). `--html <file>` picks the path; `--no-html` skips the file;
|
|
104
|
+
`--json` runs stay file-free unless `--html` is passed explicitly. Set
|
|
105
|
+
`COSTCLAW_NO_OPEN=1` to write reports without launching a browser (CI and
|
|
106
|
+
test runners are detected and never open one). The report ends with a
|
|
107
|
+
"What to do next" ramp: the commands to run next, how the optimize license
|
|
108
|
+
works, and a command reference.
|
|
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
|
|
111
|
+
strongest pillar. A static file, no fonts or network calls.
|
|
112
|
+
|
|
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`.
|
|
128
|
+
|
|
129
|
+
## Diff
|
|
130
|
+
|
|
131
|
+
Every audit run saves a snapshot of the derived record to `~/.costclaw/history`
|
|
132
|
+
(local, nothing uploaded). Run the audit again after you have made changes, then:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npx costclaw diff
|
|
136
|
+
```
|
|
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:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
CostClaw diff
|
|
143
|
+
Baseline: 2026-06-09 Current: 2026-07-09 (30 days)
|
|
144
|
+
|
|
145
|
+
Since the baseline:
|
|
146
|
+
New spend $842.10 across 210 new sessions
|
|
147
|
+
Marginal cache hit 97.1% (lifetime 96.2%)
|
|
148
|
+
Cache-miss exposure (estimate) +$96.40 (now $1131.61)
|
|
149
|
+
|
|
150
|
+
Rule-based setup score: 83 -> 86 (+3, Tight)
|
|
151
|
+
CLAUDE.md quality 69 -> 78 (+9)
|
|
152
|
+
...
|
|
153
|
+
|
|
154
|
+
Fixes resolved since the baseline:
|
|
155
|
+
- [$52.40] Review model fit for 61 small sessions
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
The marginal cache hit rate covers only the period between the two audits, which
|
|
159
|
+
a lifetime average hides. You can also diff two explicit records saved with
|
|
160
|
+
`costclaw audit --json`: `costclaw diff baseline.json current.json`. Add `--json`
|
|
161
|
+
for the machine-readable diff. Free, like the audit. The history keeps the newest
|
|
162
|
+
50 snapshots and prunes older ones automatically.
|
|
163
|
+
|
|
164
|
+
## Badge
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
npx costclaw badge
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Runs a fresh audit and writes a shields.io-style badge SVG (default
|
|
171
|
+
`costclaw-badge.svg`): a "costclaw" segment and your overall score, colored by
|
|
172
|
+
its band. Drop it in a README with a plain image tag:
|
|
173
|
+
|
|
174
|
+
```markdown
|
|
175
|
+

|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
costclaw badge [--path <dir>] [--claude-md <file>] [--out <file>]
|
|
180
|
+
```
|
|
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.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
npx costclaw optimize
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Generates, for every project your audit saw, five artifacts: an optimized
|
|
192
|
+
`CLAUDE.md` scaffold, a prioritized fix playbook, a conservative,
|
|
193
|
+
project-derived `settings.suggested.json` permission allowlist, a
|
|
194
|
+
`HARNESS-UPGRADE.md` work order for your own Claude Code, and `costclaw.md`
|
|
195
|
+
(the generated sections as a standalone include). It never writes inside a
|
|
196
|
+
project; only `costclaw apply` does that, and only on an explicit command.
|
|
197
|
+
|
|
198
|
+
It also reviews the files themselves. The dashboard shows your global
|
|
199
|
+
`~/.claude/CLAUDE.md`, plus every file it imports with an `@path` line, and each
|
|
200
|
+
project's `CLAUDE.md` annotated line by line: what to remove (the generated
|
|
201
|
+
include now carries it, or the global file already says it), what to move out
|
|
202
|
+
(dated and status text, a paragraph that names only one project), and what to
|
|
203
|
+
add (a short, evidence-backed block, never a placeholder). Above that sits one
|
|
204
|
+
prompt, `UPGRADE-ALL.md`, covering the global file and every project at once:
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
claude "Follow ~/.costclaw/optimize/UPGRADE-ALL.md"
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
It states each file's per-turn token total before and after the proposed
|
|
211
|
+
changes, and no target line count anywhere. A project with no `CLAUDE.md` of its
|
|
212
|
+
own now reports no "before" instead of comparing against your global file, which
|
|
213
|
+
was never that project's text.
|
|
214
|
+
|
|
215
|
+
By default it runs globally: it ranks your audited projects by spend,
|
|
216
|
+
generates for the top ones (cap 10; override with `--limit N`) into
|
|
217
|
+
`~/.costclaw/optimize/<project>/`, writes `UPGRADE-ALL.md` and one
|
|
218
|
+
`DASHBOARD.html` index at the root
|
|
219
|
+
listing every project with its receipt and apply line, plus a local
|
|
220
|
+
click-to-apply page you can use instead of the command line (Ctrl+C, the
|
|
221
|
+
page's Done button, or `--no-serve` to skip it). `--project <dir>` keeps the
|
|
222
|
+
single-project behavior, writing into `./costclaw-out` (or `--out <dir>`)
|
|
223
|
+
instead. `--no-dashboard` skips the HTML.
|
|
224
|
+
|
|
225
|
+
And it tells you what it actually did to the file that rides on every turn:
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
Your CLAUDE.md: an estimated 5,266 tokens to 2,479 (52.9% smaller), paid on every turn.
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
costclaw never calls a model, so it does not rewrite your prose: your own sections
|
|
232
|
+
are carried through exactly as written. When that carried prose is most of what is
|
|
233
|
+
left, the receipt says so rather than presenting a small percentage as a win:
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
About 1,714 of those tokens are your own prose, carried through as written.
|
|
237
|
+
costclaw does not rewrite prose, so trimming it is judgment work: HARNESS-UPGRADE.md
|
|
238
|
+
ranks your heaviest sections and flags the dated lines to move into docs/.
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
`HARNESS-UPGRADE.md` is the fourth artifact: a work order you hand to your own
|
|
242
|
+
Claude Code (`claude "Follow costclaw-out/HARNESS-UPGRADE.md"`). It carries the
|
|
243
|
+
merge and permission tasks plus evidence-conditional ones, and when your carried
|
|
244
|
+
prose is heavy it ranks it so the trimming is a worklist instead of a guess:
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
Heaviest carried sections, largest first:
|
|
248
|
+
|
|
249
|
+
- Core Philosophy: est. 1,382 tokens.
|
|
250
|
+
- How to Work: est. 1,267 tokens, 2 dated lines.
|
|
251
|
+
- Communication and Output: est. 550 tokens, 3 dated lines.
|
|
252
|
+
|
|
253
|
+
The remaining 6 carried sections account for the other 1,880 tokens.
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Those rows plus the remainder line add up to the stated total, the same way the
|
|
257
|
+
playbook's per-project table reconciles. costclaw sets no target line count
|
|
258
|
+
anywhere: it measures what your sections cost and which lines carry dates, and
|
|
259
|
+
leaves the keep-or-move judgment to you.
|
|
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:
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
### Where that money is
|
|
266
|
+
|
|
267
|
+
| Project | Cache-miss exposure (estimate) | Cache hit | Main sessions |
|
|
268
|
+
| --- | --- | --- | --- |
|
|
269
|
+
| some-app | $490.43 | 98% | 229 |
|
|
270
|
+
| another-app | $312.43 | 99% | 131 |
|
|
271
|
+
|
|
272
|
+
39 smaller projects account for the remaining $172.06.
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
The rows plus that remainder line always add up to the headline figure above
|
|
276
|
+
them, so the breakdown reconciles rather than approximating.
|
|
277
|
+
|
|
278
|
+
```
|
|
279
|
+
costclaw optimize [--path <dir>] [--claude-md <file>] [--project <dir>] [--out <dir>] [--limit <n>] [--no-dashboard] [--no-serve] [--force]
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Apply
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
npx costclaw apply
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
The only command that writes inside a project, and only additively. Run it
|
|
289
|
+
from inside the project, or pass a directory:
|
|
290
|
+
|
|
291
|
+
```
|
|
292
|
+
costclaw apply [<dir>] [--remove] [--replace] [--apply-settings [file]] [--from <dir>] [--force]
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
- Default mode writes the generated sections to `.claude/costclaw.md` and adds
|
|
296
|
+
one `@.claude/costclaw.md` import line (Claude Code's memory import syntax)
|
|
297
|
+
to your `CLAUDE.md`. Every line you wrote stays exactly as it was. Idempotent:
|
|
298
|
+
running it again rewrites the include and leaves the import line alone.
|
|
299
|
+
- `--remove` undoes it: deletes `.claude/costclaw.md` and `.claude/costclaw/`,
|
|
300
|
+
and strips the import line (only that exact generated line).
|
|
301
|
+
- `--replace` is the old wholesale rewrite. It requires a git repository (a
|
|
302
|
+
`.git` directory in the project), so the undo is `git checkout -- CLAUDE.md`;
|
|
303
|
+
outside git it refuses. It still keeps a `.bak` as a second net, refusing to
|
|
304
|
+
overwrite an existing one without `--force`.
|
|
305
|
+
- `--apply-settings [file]` additively merges the derived permission allowlist
|
|
306
|
+
into your Claude Code settings. Opt-in: it only touches
|
|
307
|
+
`permissions.allow` and `permissions.deny` (a deduped union that keeps your
|
|
308
|
+
existing entries and orders them first) and never removes or changes any other
|
|
309
|
+
key. The default target is the project's `.claude/settings.json`; pass
|
|
310
|
+
`[file]` to target another. It backs up the previous file to `<target>.bak`,
|
|
311
|
+
prints a diff, then writes pretty JSON. A missing target is created; a file it
|
|
312
|
+
cannot `JSON.parse` (for example JSONC with comments) is refused and left
|
|
313
|
+
untouched.
|
|
314
|
+
- `--from <dir>` points at a specific artifacts folder instead of looking one
|
|
315
|
+
up by project. Without it, `apply` finds artifacts from the last `optimize`
|
|
316
|
+
run, or generates them cold (into `./costclaw-out`) if none exist yet.
|
|
317
|
+
- `--force` allows overwriting an existing `.bak` backup for `--replace` and
|
|
318
|
+
`--apply-settings`.
|
|
319
|
+
|
|
320
|
+
`optimize` and `apply` need a one-time license (`costclaw activate <key>`);
|
|
321
|
+
`audit` is free.
|
|
322
|
+
|
|
323
|
+
## Privacy
|
|
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.
|