costclaw 0.1.1 → 0.2.1

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 +114 -54
  2. package/dist/index.js +673 -171
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,54 +1,114 @@
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
+
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] [--html [file]] [--card [file]]
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
+ - `--html [file]` also write a self-contained HTML report (default
50
+ `costclaw-report.html` in the current directory) and open it in your browser.
51
+ The file inlines everything, so nothing is fetched and nothing is uploaded; the
52
+ terminal report still prints.
53
+ - `--card [file]` also write a shareable score card SVG (default
54
+ `costclaw-card.svg`): your score, band, recoverable spend, cache hit rate, and
55
+ strongest pillar. A static file, no fonts or network calls.
56
+
57
+ Run `costclaw --version` (or `-v` / `costclaw version`) to print the installed
58
+ CLI version.
59
+
60
+ ## Badge
61
+
62
+ ```bash
63
+ npx costclaw badge
64
+ ```
65
+
66
+ Runs a fresh audit and writes a shields.io-style badge SVG (default
67
+ `costclaw-badge.svg`): a "costclaw" segment and your overall score, colored by
68
+ its band. Drop it in a README with a plain image tag:
69
+
70
+ ```markdown
71
+ ![costclaw score](./costclaw-badge.svg)
72
+ ```
73
+
74
+ ```
75
+ costclaw badge [--path <dir>] [--claude-md <file>] [--out <file>]
76
+ ```
77
+
78
+ ## Optimize
79
+
80
+ ```bash
81
+ npx costclaw optimize
82
+ ```
83
+
84
+ Turns the same audit into done-for-you artifacts: an optimized `CLAUDE.md`
85
+ scaffold, a prioritized fix playbook, and a conservative, project-derived
86
+ `settings.suggested.json` permission allowlist. It scans `--project <dir>`
87
+ (default: the current directory) to auto-fill the scaffold from your real files.
88
+ By default it dry-runs into `./costclaw-out` and touches none of your files.
89
+
90
+ ```
91
+ costclaw optimize [--path <dir>] [--claude-md <file>] [--project <dir>] [--out <dir>] [--write <file>] [--apply-settings [file]] [--force]
92
+ ```
93
+
94
+ - `--write <file>` applies the optimized `CLAUDE.md` in place, after backing up
95
+ the original to `<file>.bak` and printing a diff.
96
+ - `--apply-settings [file]` merges the derived permission allowlist into your
97
+ Claude Code settings. Opt-in and additive: it only touches
98
+ `permissions.allow` and `permissions.deny` (a deduped union that keeps your
99
+ existing entries and orders them first) and never removes or changes any other
100
+ key. The default target is the scanned project's `.claude/settings.json`; pass
101
+ `[file]` to target another. It backs up the previous file to `<target>.bak`,
102
+ prints a diff, then writes pretty JSON. A missing target is created; a file it
103
+ cannot `JSON.parse` (for example JSONC with comments) is refused and left
104
+ untouched.
105
+ - `--force` allows overwriting an existing `.bak` backup for `--write` and
106
+ `--apply-settings`.
107
+
108
+ `optimize` needs a one-time license (`costclaw activate <key>`); `audit` is free.
109
+
110
+ ## Privacy
111
+
112
+ The only thing the tool produces is a derived `AuditRecord`: totals and generated
113
+ prose, no prompt text, no file paths, no secrets. A hosted dashboard is on the
114
+ roadmap and would receive only that derived record, never your logs.