costclaw 0.2.0 → 0.2.2

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.
Files changed (3) hide show
  1. package/README.md +122 -54
  2. package/dist/index.js +681 -129
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,54 +1,122 @@
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 fixes by the dollars they recover.
6
-
7
- Your prompts never leave your machine. The audit parses the logs already on your
8
- disk and prints a report. It uploads nothing.
9
-
10
- ## Use it
11
-
12
- Requires Node 20+.
13
-
14
- ```bash
15
- npx costclaw audit
16
- ```
17
-
18
- That reads `~/.claude/projects` (override with `--path <dir>`) and prints:
19
-
20
- ```
21
- CostClaw audit
22
- Source: ~/.claude/projects (N sessions across M projects)
23
-
24
- Recoverable spend (cache-miss exposure): $XXX.XX
25
-
26
- Spend analyzed: $X,XXX.XX Cache hit: 96.3% Active hours: XXX.X
27
- Overall setup score: 91 / 100 (Dialed in)
28
- CLAUDE.md quality n/a
29
- Context hygiene [###################.] 95
30
- Prompting patterns [##################..] 92
31
- Session management [####################] 100
32
- Tool and MCP config [####################] 100
33
- Cost discipline [##############......] 70
34
-
35
- Top fixes by recoverable spend:
36
- - [$XXX.XX] Recover spend lost to cache misses
37
- Keep the start of each session stable so the prompt cache is reused.
38
- ```
39
-
40
- ## Options
41
-
42
- ```
43
- costclaw audit [--path <dir>] [--claude-md <file>] [--json]
44
- ```
45
-
46
- - `--path <dir>` audit a specific projects directory (default `~/.claude/projects`).
47
- - `--claude-md <file>` score a CLAUDE.md file's quality.
48
- - `--json` print the raw, derived `AuditRecord` instead of the human report.
49
-
50
- ## Privacy
51
-
52
- The only thing the tool produces is a derived `AuditRecord`: totals and generated
53
- prose, no prompt text, no file paths, no secrets. A hosted dashboard is on the
54
- roadmap and would receive only that derived record, never your logs.
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 fixes by the dollars they recover.
6
+
7
+ Your prompts never leave your machine. The audit parses the logs already on your
8
+ disk and prints a report. It uploads nothing.
9
+
10
+ ## Use it
11
+
12
+ Requires Node 20+.
13
+
14
+ ```bash
15
+ npx costclaw audit
16
+ ```
17
+
18
+ That reads `~/.claude/projects` (override with `--path <dir>`) and prints:
19
+
20
+ ```
21
+ CostClaw audit
22
+ Source: ~/.claude/projects (N sessions across M projects)
23
+ CLAUDE.md: ~/.claude/CLAUDE.md
24
+
25
+ Recoverable spend (cache-miss exposure): $XXX.XX
26
+
27
+ Spend analyzed: $X,XXX.XX Cache hit: 96.3% Active hours: XXX.X
28
+ Model spend: opus 71% / sonnet 24% / haiku 5%
29
+
30
+ Top projects by spend:
31
+ C--Projects-demo $XXX.XX 312 sessions cache 96.4% opus
32
+
33
+ Overall setup score: 91 / 100 (Dialed in)
34
+ CLAUDE.md quality [#################...] 85
35
+ Context hygiene [###################.] 95
36
+ Prompting patterns [##################..] 92
37
+ Session management [####################] 100
38
+ Tool and MCP config [####################] 100
39
+ Cost discipline [##############......] 70
40
+
41
+ Top fixes by recoverable spend:
42
+ - [$XXX.XX] Recover spend lost to cache misses
43
+ Keep the start of each session stable so the prompt cache is reused.
44
+ Evidence: XX% of input tokens missed the cache across N sessions.
45
+ ```
46
+
47
+ ## Options
48
+
49
+ ```
50
+ costclaw audit [--path <dir>] [--claude-md <file>] [--json] [--html [file]] [--card [file]]
51
+ ```
52
+
53
+ - `--path <dir>` audit a specific projects directory (default `~/.claude/projects`).
54
+ - `--claude-md <file>` score a specific CLAUDE.md file's quality (by default the
55
+ audit scores `~/.claude/CLAUDE.md` when it exists).
56
+ - `--json` print the raw, derived `AuditRecord` instead of the human report.
57
+ - `--html [file]` also write a self-contained HTML report (default
58
+ `costclaw-report.html` in the current directory) and open it in your browser.
59
+ The file inlines everything, so nothing is fetched and nothing is uploaded; the
60
+ terminal report still prints.
61
+ - `--card [file]` also write a shareable score card SVG (default
62
+ `costclaw-card.svg`): your score, band, recoverable spend, cache hit rate, and
63
+ strongest pillar. A static file, no fonts or network calls.
64
+
65
+ Run `costclaw --version` (or `-v` / `costclaw version`) to print the installed
66
+ CLI version.
67
+
68
+ ## Badge
69
+
70
+ ```bash
71
+ npx costclaw badge
72
+ ```
73
+
74
+ Runs a fresh audit and writes a shields.io-style badge SVG (default
75
+ `costclaw-badge.svg`): a "costclaw" segment and your overall score, colored by
76
+ its band. Drop it in a README with a plain image tag:
77
+
78
+ ```markdown
79
+ ![costclaw score](./costclaw-badge.svg)
80
+ ```
81
+
82
+ ```
83
+ costclaw badge [--path <dir>] [--claude-md <file>] [--out <file>]
84
+ ```
85
+
86
+ ## Optimize
87
+
88
+ ```bash
89
+ npx costclaw optimize
90
+ ```
91
+
92
+ Turns the same audit into done-for-you artifacts: an optimized `CLAUDE.md`
93
+ scaffold, a prioritized fix playbook, and a conservative, project-derived
94
+ `settings.suggested.json` permission allowlist. It scans `--project <dir>`
95
+ (default: the current directory) to auto-fill the scaffold from your real files.
96
+ By default it dry-runs into `./costclaw-out` and touches none of your files.
97
+
98
+ ```
99
+ costclaw optimize [--path <dir>] [--claude-md <file>] [--project <dir>] [--out <dir>] [--write <file>] [--apply-settings [file]] [--force]
100
+ ```
101
+
102
+ - `--write <file>` applies the optimized `CLAUDE.md` in place, after backing up
103
+ the original to `<file>.bak` and printing a diff.
104
+ - `--apply-settings [file]` merges the derived permission allowlist into your
105
+ Claude Code settings. Opt-in and additive: it only touches
106
+ `permissions.allow` and `permissions.deny` (a deduped union that keeps your
107
+ existing entries and orders them first) and never removes or changes any other
108
+ key. The default target is the scanned project's `.claude/settings.json`; pass
109
+ `[file]` to target another. It backs up the previous file to `<target>.bak`,
110
+ prints a diff, then writes pretty JSON. A missing target is created; a file it
111
+ cannot `JSON.parse` (for example JSONC with comments) is refused and left
112
+ untouched.
113
+ - `--force` allows overwriting an existing `.bak` backup for `--write` and
114
+ `--apply-settings`.
115
+
116
+ `optimize` needs a one-time license (`costclaw activate <key>`); `audit` is free.
117
+
118
+ ## Privacy
119
+
120
+ The only thing the tool produces is a derived `AuditRecord`: totals and generated
121
+ prose, no prompt text, no file paths, no secrets. A hosted dashboard is on the
122
+ roadmap and would receive only that derived record, never your logs.