@statforge/claudestat 1.3.0 → 1.5.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 +140 -547
- package/dist/config.d.ts +1 -0
- package/dist/config.js +6 -0
- package/dist/cost-projector.d.ts +24 -0
- package/dist/cost-projector.js +133 -0
- package/dist/daemon.js +1 -1
- package/dist/db.d.ts +4 -0
- package/dist/db.js +14 -6
- package/dist/enricher.d.ts +18 -26
- package/dist/enricher.js +113 -333
- package/dist/index.js +48 -7
- package/dist/insights.js +0 -2
- package/dist/meta-stats.js +1 -1
- package/dist/middleware/rate-limiter.js +1 -1
- package/dist/paths.d.ts +17 -0
- package/dist/paths.js +44 -0
- package/dist/quota-tracker.js +0 -1
- package/dist/roast.js +0 -2
- package/dist/routes/events.js +29 -5
- package/dist/routes/misc.js +4 -22
- package/dist/routes/stream.d.ts +1 -1
- package/dist/routes/stream.js +3 -3
- package/dist/service.js +11 -7
- package/dist/watchers/adapter.d.ts +37 -0
- package/dist/watchers/adapter.js +31 -0
- package/dist/watchers/amp.d.ts +8 -0
- package/dist/watchers/amp.js +42 -0
- package/dist/watchers/claude-code.d.ts +17 -0
- package/dist/watchers/claude-code.js +300 -0
- package/dist/watchers/codebuff.d.ts +8 -0
- package/dist/watchers/codebuff.js +42 -0
- package/dist/watchers/codex.d.ts +9 -0
- package/dist/watchers/codex.js +43 -0
- package/dist/watchers/droid.d.ts +8 -0
- package/dist/watchers/droid.js +42 -0
- package/dist/watchers/opencode.d.ts +9 -0
- package/dist/watchers/opencode.js +43 -0
- package/hooks/event.js +4 -9
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -14,15 +14,19 @@ Works with Claude Pro, Max 5, and Max 20. Zero cloud dependencies. Pure Node.js.
|
|
|
14
14
|
[](LICENSE)
|
|
15
15
|
[](https://nodejs.org)
|
|
16
16
|
[]()
|
|
17
|
-
[](https://github.com/DeibyGS/claudestat/actions/workflows/ci.yml)
|
|
18
|
+
[](https://github.com/DeibyGS/claudestat/releases/latest)
|
|
18
19
|
[](CONTRIBUTING.md)
|
|
19
20
|
|
|
20
|
-
[Installation](#installation) •
|
|
21
|
+
[Installation](#installation) •
|
|
22
|
+
[Quick Start](#quick-start) •
|
|
23
|
+
[Commands](#commands) •
|
|
24
|
+
[Dashboard](#dashboard) •
|
|
25
|
+
[FAQ](#faq) •
|
|
26
|
+
[Contributing](#contributing)
|
|
21
27
|
|
|
22
28
|

|
|
23
29
|
|
|
24
|
-
---
|
|
25
|
-
|
|
26
30
|
### See it in action
|
|
27
31
|
|
|
28
32
|
*Live dashboard · terminal trace · quota guard — all running in real time*
|
|
@@ -33,9 +37,29 @@ Works with Claude Pro, Max 5, and Max 20. Zero cloud dependencies. Pure Node.js.
|
|
|
33
37
|
|
|
34
38
|
---
|
|
35
39
|
|
|
40
|
+
## Table of Contents
|
|
41
|
+
|
|
42
|
+
- [Why claudestat?](#why-claudestat)
|
|
43
|
+
- [Ask Claude about itself](#ask-claude-about-itself)
|
|
44
|
+
- [Features](#features)
|
|
45
|
+
- [Quick Start](#quick-start)
|
|
46
|
+
- [Requirements](#requirements)
|
|
47
|
+
- [Installation](#installation)
|
|
48
|
+
- [Commands](#commands)
|
|
49
|
+
- [Dashboard](#dashboard)
|
|
50
|
+
- [MCP Server](#mcp-server)
|
|
51
|
+
- [Configuration](#configuration)
|
|
52
|
+
- [Troubleshooting](#troubleshooting)
|
|
53
|
+
- [FAQ](#faq)
|
|
54
|
+
- [Uninstall](#uninstall)
|
|
55
|
+
- [Contributing](#contributing)
|
|
56
|
+
- [License](#license)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
36
60
|
## Why claudestat?
|
|
37
61
|
|
|
38
|
-
Tools like ccusage are great for reviewing history. claudestat is for while you're coding
|
|
62
|
+
Tools like ccusage are great for reviewing history. claudestat is for *while you're coding*.
|
|
39
63
|
|
|
40
64
|
It taps into Claude Code's hook system to capture every event the moment it fires, stores everything locally in SQLite, and gives you a live dashboard, quota alerts, and an MCP server — not just a report.
|
|
41
65
|
|
|
@@ -48,16 +72,7 @@ It taps into Claude Code's hook system to capture every event the moment it fire
|
|
|
48
72
|
| Loop detector | ✅ | ❌ |
|
|
49
73
|
| MCP server (ask Claude about itself) | ✅ | ❌ |
|
|
50
74
|
| Historical usage analysis | ✅ | ✅ |
|
|
51
|
-
|
|
52
|
-
**What you get:**
|
|
53
|
-
|
|
54
|
-
- Live tool trace — every call with duration and token cost as it runs
|
|
55
|
-
- Quota guard — alerts at 70%, 85%, 95%; optional kill switch blocks new sessions at X%
|
|
56
|
-
- Loop detector — flags context thrashing with estimated waste cost
|
|
57
|
-
- Top tools — know which tools eat most of your budget
|
|
58
|
-
- Web dashboard — session history, analytics, model breakdown, charts
|
|
59
|
-
- MCP server — 7 tools so Claude can answer questions about its own usage
|
|
60
|
-
- Weekly insights — pattern analysis with actionable tips
|
|
75
|
+
| Multi-CLI support (Codex, OpenCode, Amp, etc.) | ✅ | ✅ |
|
|
61
76
|
|
|
62
77
|
> If claudestat is useful, give it a ⭐ — it helps other developers find it.
|
|
63
78
|
|
|
@@ -74,37 +89,38 @@ claude mcp add claudestat -s user -- claudestat-mcp
|
|
|
74
89
|
Then just ask:
|
|
75
90
|
|
|
76
91
|
```
|
|
77
|
-
> What's my current quota status?
|
|
78
92
|
> How much did I spend this week?
|
|
79
93
|
> What are my top 5 tools by cost?
|
|
80
94
|
> Break down my usage by model
|
|
95
|
+
> What's my cost projection for next month?
|
|
81
96
|
```
|
|
82
97
|
|
|
83
|
-
|
|
98
|
+
[Full MCP reference →](docs/MCP.md)
|
|
84
99
|
|
|
85
100
|
---
|
|
86
101
|
|
|
87
|
-
##
|
|
102
|
+
## Features
|
|
88
103
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
- **Live tool trace** — every call with duration and token cost as it runs
|
|
105
|
+
- **Quota guard** — alerts at 70%, 85%, 95%; optional kill switch blocks new sessions at X%
|
|
106
|
+
- **Loop detector** — flags context thrashing with estimated waste cost
|
|
107
|
+
- **Top tools** — know which tools eat most of your budget
|
|
108
|
+
- **Cost projection** — linear regression with trend, confidence intervals, R²
|
|
109
|
+
- **Web dashboard** — 6 tabs: Live, History, Projects, Analytics, Top, System
|
|
110
|
+
- **MCP server** — 7 tools so Claude can answer questions about its own usage
|
|
111
|
+
- **Weekly insights** — pattern analysis with actionable tips
|
|
112
|
+
- **Multi-CLI support** — works with Claude Code, Codex, OpenCode, and more
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Quick Start
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm install -g @statforge/claudestat && claudestat setup
|
|
120
|
+
open http://localhost:7337
|
|
105
121
|
```
|
|
106
122
|
|
|
107
|
-
|
|
123
|
+
Start a Claude Code session and watch the events flow in. That's it.
|
|
108
124
|
|
|
109
125
|
---
|
|
110
126
|
|
|
@@ -118,484 +134,122 @@ Claude Code event
|
|
|
118
134
|
## Installation
|
|
119
135
|
|
|
120
136
|
```bash
|
|
121
|
-
npm install -g @statforge/claudestat
|
|
137
|
+
npm install -g @statforge/claudestat && claudestat setup
|
|
122
138
|
```
|
|
123
139
|
|
|
124
|
-
|
|
140
|
+
`claudestat setup` installs the Claude Code hooks and registers the daemon as a system service (launchd on macOS, systemd on Linux) — no sudo required. The daemon starts automatically whenever you log in.
|
|
141
|
+
|
|
142
|
+
> **Using NVM?** Make sure you're on your default Node version:
|
|
125
143
|
> ```bash
|
|
126
|
-
> nvm use default && npm install -g @statforge/claudestat
|
|
144
|
+
> nvm use default && npm install -g @statforge/claudestat && claudestat setup
|
|
127
145
|
> ```
|
|
128
|
-
>
|
|
146
|
+
>
|
|
147
|
+
> Restart Claude Code after setup so the hooks take effect.
|
|
129
148
|
|
|
130
|
-
|
|
149
|
+
### Manual setup
|
|
131
150
|
|
|
132
151
|
```bash
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
This modifies `~/.claude/settings.json` to add `SessionStart`, `PreToolUse`, `PostToolUse`, and `Stop` hooks. A backup is created before any change.
|
|
137
|
-
|
|
138
|
-
> Restart Claude Code after installing so the hooks take effect.
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
## Quick Start
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
# 1. Start the background daemon
|
|
146
|
-
claudestat start
|
|
147
|
-
|
|
148
|
-
# 2. Open the dashboard in your browser
|
|
149
|
-
# macOS:
|
|
150
|
-
open http://localhost:7337
|
|
151
|
-
# Windows:
|
|
152
|
-
start http://localhost:7337
|
|
153
|
-
# Linux:
|
|
154
|
-
xdg-open http://localhost:7337
|
|
155
|
-
|
|
156
|
-
# 3. Or watch a live terminal trace
|
|
157
|
-
claudestat watch
|
|
152
|
+
npm install -g @statforge/claudestat
|
|
153
|
+
claudestat install # installs hooks into Claude Code
|
|
154
|
+
claudestat start # start the daemon manually
|
|
158
155
|
```
|
|
159
156
|
|
|
160
|
-
That's it. Start a Claude Code session and watch the events flow in.
|
|
161
|
-
|
|
162
157
|
---
|
|
163
158
|
|
|
164
159
|
## Commands
|
|
165
160
|
|
|
166
161
|
| Command | Description |
|
|
167
|
-
|
|
168
|
-
| `claudestat
|
|
169
|
-
| `claudestat
|
|
170
|
-
| `claudestat restart` |
|
|
171
|
-
| `claudestat install` | Install
|
|
172
|
-
| `claudestat uninstall` | Remove hooks from Claude Code |
|
|
162
|
+
|---------|-------------|
|
|
163
|
+
| `claudestat setup` | One-command setup: install hooks + register daemon as system service |
|
|
164
|
+
| `claudestat setup --uninstall` | Remove hooks and system service |
|
|
165
|
+
| `claudestat start` / `stop` / `restart` | Manage the background daemon |
|
|
166
|
+
| `claudestat install` / `uninstall` | Install or remove Claude Code hooks |
|
|
173
167
|
| `claudestat watch` | Live terminal trace view |
|
|
174
168
|
| `claudestat status` | Show quota, cost, and burn rate |
|
|
175
|
-
| `claudestat config` | View or edit configuration |
|
|
176
169
|
| `claudestat top` | Rank tools by cost, call count, or duration |
|
|
177
|
-
| `claudestat weekly` | Weekly usage summary
|
|
178
|
-
| `claudestat insights` | Deep usage insights: cost
|
|
179
|
-
| `claudestat
|
|
180
|
-
| `claudestat
|
|
181
|
-
| `claudestat version` | Show version and check for npm updates |
|
|
182
|
-
| `claudestat export [format]` | Export session data to JSON or CSV |
|
|
170
|
+
| `claudestat weekly` | Weekly usage summary |
|
|
171
|
+
| `claudestat insights` | Deep usage insights: cost, cache, efficiency, models |
|
|
172
|
+
| `claudestat project` | Cost projection with linear regression |
|
|
173
|
+
| `claudestat config` | View or edit configuration |
|
|
183
174
|
| `claudestat doctor` | Check installation health and diagnose issues |
|
|
175
|
+
| `claudestat export [format]` | Export session data to JSON or CSV |
|
|
176
|
+
| `claudestat roast` | Sarcastic usage analysis |
|
|
177
|
+
| `claudestat version` | Show version and check for updates |
|
|
184
178
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
Live terminal trace — every tool call as it happens, with duration and token cost.
|
|
188
|
-
|
|
189
|
-
```
|
|
190
|
-
claudestat watch
|
|
191
|
-
|
|
192
|
-
● Session a3f1bc · my-project · claude-sonnet-4-5
|
|
193
|
-
|
|
194
|
-
16:42:01 Bash 342ms 1,240 tok $0.0018
|
|
195
|
-
16:42:03 Read 89ms 420 tok $0.0006
|
|
196
|
-
16:42:05 Edit 124ms 890 tok $0.0013
|
|
197
|
-
16:42:08 Agent (haiku) 2.1s 3,200 tok $0.0024
|
|
198
|
-
16:42:11 Write 67ms 310 tok $0.0004
|
|
199
|
-
|
|
200
|
-
Context: 42,800 / 200,000 (21%) │ Session cost: $0.0065 │ 🟢 healthy
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
### `claudestat top`
|
|
204
|
-
|
|
205
|
-
Ranks your most-used tools by estimated cost, call count, or duration across all sessions.
|
|
206
|
-
|
|
207
|
-
```
|
|
208
|
-
claudestat top
|
|
209
|
-
|
|
210
|
-
🏆 claudestat top by est. cost (last 30 days)
|
|
211
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
212
|
-
|
|
213
|
-
1 Edit ████████████████░░░░ $146.47 21%
|
|
214
|
-
2479 calls · 38.5m
|
|
215
|
-
2 Bash ███████████████░░░░░ $140.66 20%
|
|
216
|
-
2651 calls · 153.6m
|
|
217
|
-
3 Read ██████████████░░░░░░ $126.08 18%
|
|
218
|
-
2315 calls · 34.0m
|
|
219
|
-
4 Grep ████░░░░░░░░░░░░░░░░ $39.93 6%
|
|
220
|
-
699 calls · 9.3m
|
|
221
|
-
5 ToolSearch ██░░░░░░░░░░░░░░░░░░ $21.83 3%
|
|
222
|
-
469 calls · 7.4m
|
|
223
|
-
6 Glob ██░░░░░░░░░░░░░░░░░░ $13.96 2%
|
|
224
|
-
269 calls · 5.7m
|
|
225
|
-
7 Write █░░░░░░░░░░░░░░░░░░░ $12.93 2%
|
|
226
|
-
237 calls · 87.1m
|
|
227
|
-
8 mcp__plugin_engr… █░░░░░░░░░░░░░░░░░░░ $8.10 1%
|
|
228
|
-
149 calls · 2.6m
|
|
229
|
-
9 Agent █░░░░░░░░░░░░░░░░░░░ $8.09 1%
|
|
230
|
-
168 calls · 95.7m
|
|
231
|
-
10 WebFetch █░░░░░░░░░░░░░░░░░░░ $5.86 1%
|
|
232
|
-
106 calls · 9.9m
|
|
233
|
-
Other — $184.79 26%
|
|
234
|
-
|
|
235
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
Options: `--by cost|count|duration` · `--days 7|30|90` · `--limit N`
|
|
239
|
-
|
|
240
|
-
### `claudestat weekly`
|
|
241
|
-
|
|
242
|
-
Weekly usage summary with an actionable tip. Detects patterns like Bash overuse, low efficiency, high session count, and loop frequency.
|
|
243
|
-
|
|
244
|
-
```
|
|
245
|
-
claudestat weekly
|
|
246
|
-
|
|
247
|
-
📊 claudestat weekly May 8 – May 13
|
|
248
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
249
|
-
|
|
250
|
-
💰 $198.38 total · 40 sessions · 114 loops
|
|
251
|
-
|
|
252
|
-
🔧 Top tool Bash 22% of cost
|
|
253
|
-
|
|
254
|
-
📈 Efficiency ██████████████████░░ 91/100
|
|
255
|
-
|
|
256
|
-
💾 Cache hit ████████████████████ 100%
|
|
257
|
-
|
|
258
|
-
📦 Tokens 73K in + 1.2M out
|
|
259
|
-
|
|
260
|
-
⚡ Tip: 114 loops detected — consider using /compact earlier to prevent context thrashing
|
|
261
|
-
|
|
262
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
Options: `--json` for machine-readable output.
|
|
266
|
-
|
|
267
|
-
### `claudestat status`
|
|
268
|
-
|
|
269
|
-
Shows your current quota usage with visual progress bars, plan detection, and burn rate.
|
|
270
|
-
|
|
271
|
-
```
|
|
272
|
-
claudestat status
|
|
273
|
-
|
|
274
|
-
📊 claudestat PRO plan
|
|
275
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
276
|
-
|
|
277
|
-
5h ████████████████████ 100% resets 4:10 AM
|
|
278
|
-
|
|
279
|
-
Week ██████░░░░░░░░░░░░░░ 31% resets May 18
|
|
280
|
-
|
|
281
|
-
🔥 490 tok/min · 101 prompts used
|
|
282
|
-
|
|
283
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
Options: `--json` for machine-readable output.
|
|
287
|
-
|
|
288
|
-
### `claudestat insights`
|
|
289
|
-
|
|
290
|
-
Deep usage insights: cost breakdown by project, cache savings, output/input ratio, efficiency trend, peak activity hours, and model breakdown.
|
|
291
|
-
|
|
292
|
-
```
|
|
293
|
-
claudestat insights
|
|
294
|
-
|
|
295
|
-
💡 claudestat insights last 7 days
|
|
296
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
297
|
-
|
|
298
|
-
💰 $4.96/session · 40 sessions · $198.38 total
|
|
299
|
-
|
|
300
|
-
🗂 Top projects
|
|
301
|
-
no project █████████░░░░░░░░░░░ $93.69 47%
|
|
302
|
-
|
|
303
|
-
claudestat ████████░░░░░░░░░░░░ $74.60 38%
|
|
304
|
-
|
|
305
|
-
wodrival ███░░░░░░░░░░░░░░░░░ $24.95 13%
|
|
306
|
-
|
|
307
|
-
aprendiendo-in ░░░░░░░░░░░░░░░░░░░░ $3.32 2%
|
|
308
|
-
|
|
309
|
-
other ░░░░░░░░░░░░░░░░░░░░ $1.81 1%
|
|
310
|
-
|
|
311
|
-
⚡ Cache ~$1029.43 saved · 100% hit rate
|
|
312
|
-
|
|
313
|
-
📊 16× output/input · cache-heavy workload
|
|
314
|
-
|
|
315
|
-
📈 Efficiency 91/100 ↓ -2 vs prev period · 114 loops
|
|
316
|
-
|
|
317
|
-
⏰ Activity by time of day
|
|
318
|
-
🌙 00:00–05:59 ████████████████████ 18 sessions
|
|
319
|
-
|
|
320
|
-
🌅 06:00–11:59 ███████░░░░░░░░░░░░░ 6 sessions
|
|
321
|
-
|
|
322
|
-
☀️ 12:00–17:59 ███░░░░░░░░░░░░░░░░░ 3 sessions
|
|
323
|
-
|
|
324
|
-
🌆 18:00–23:59 ██████████████░░░░░░ 13 sessions
|
|
325
|
-
|
|
326
|
-
🤖 Models
|
|
327
|
-
claude-sonnet-4-6 ████████████████████ $197.11 99% · 23 sessions
|
|
328
|
-
|
|
329
|
-
claude-haiku-4-5-20251001 ░░░░░░░░░░░░░░░░░░░░ $1.26 1% · 15 sessions
|
|
330
|
-
|
|
331
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
Options: `--days 7|14|30|90` · `--json` for machine-readable output.
|
|
335
|
-
|
|
336
|
-
### `claudestat config`
|
|
337
|
-
|
|
338
|
-
```
|
|
339
|
-
claudestat config
|
|
340
|
-
|
|
341
|
-
⚙️ claudestat config
|
|
342
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
343
|
-
|
|
344
|
-
Plan PRO
|
|
345
|
-
Alerts enabled
|
|
346
|
-
|
|
347
|
-
Kill switch OFF
|
|
348
|
-
████████████████████
|
|
349
|
-
|
|
350
|
-
Cycle thresholds 70%, 85%, 95%
|
|
351
|
-
yellow ████████░░ orange █████████░ red ██████████
|
|
352
|
-
|
|
353
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
```bash
|
|
357
|
-
# Enable kill switch at 90% quota
|
|
358
|
-
claudestat config --kill-switch true --threshold 90
|
|
359
|
-
|
|
360
|
-
# Force plan detection
|
|
361
|
-
claudestat config --plan max5 # pro | max5 | max20 | auto
|
|
362
|
-
|
|
363
|
-
# Toggle daemon rate limit alerts
|
|
364
|
-
claudestat config --alerts false
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
Config is stored at `~/.claudestat/config.json` (macOS/Linux) or `%USERPROFILE%\.claudestat\config.json` (Windows).
|
|
368
|
-
|
|
369
|
-
### `claudestat roast`
|
|
370
|
-
|
|
371
|
-
Get a sarcastic analysis of your Claude Code usage — humor with insights.
|
|
372
|
-
|
|
373
|
-
```bash
|
|
374
|
-
claudestat roast
|
|
375
|
-
|
|
376
|
-
🔥 Your Claude Code Roast (30 days)
|
|
377
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
378
|
-
|
|
379
|
-
Score ██████████████████░░ 92/100 ★★★★★
|
|
380
|
-
|
|
381
|
-
Scorecard
|
|
382
|
-
┌─────────────────┬──────────────┬──────────────┐
|
|
383
|
-
│ Metric │ Value │ Rating │
|
|
384
|
-
├─────────────────┼──────────────┼──────────────┤
|
|
385
|
-
│ Sessions │ 47 │ normal │
|
|
386
|
-
│ Total cost │ $12.40 │ frugal │
|
|
387
|
-
│ Avg/session │ $0.26/session│ efficient │
|
|
388
|
-
│ Bash calls │ 1240 │ 🔨 overload │
|
|
389
|
-
│ Loops │ 8 │ clean │
|
|
390
|
-
│ Efficiency │ 92/100 │ 🏆 elite │
|
|
391
|
-
│ Tokens │ 4.2M │ — │
|
|
392
|
-
│ Top tool │ Bash 38% │ — │
|
|
393
|
-
└─────────────────┴──────────────┴──────────────┘
|
|
394
|
-
|
|
395
|
-
Roast Cards
|
|
396
|
-
|
|
397
|
-
┌──────────────────────────────────────────────────┐
|
|
398
|
-
│ 🖥️ BASH OVERLOAD │
|
|
399
|
-
│ 1240 calls in 30d — once every 2.3 min │
|
|
400
|
-
│ Are you okay? │
|
|
401
|
-
└──────────────────────────────────────────────────┘
|
|
402
|
-
|
|
403
|
-
┌──────────────────────────────────────────────────┐
|
|
404
|
-
│ 🔄 LOOP MONEY PIT │
|
|
405
|
-
│ $4.20 wasted on loops — that's 14 coffees │
|
|
406
|
-
│ Just saying. │
|
|
407
|
-
└──────────────────────────────────────────────────┘
|
|
408
|
-
|
|
409
|
-
Verdict
|
|
410
|
-
You're a machine. Or maybe you're just not using Claude enough.
|
|
411
|
-
|
|
412
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
413
|
-
github.com/DeibyGS/claudestat
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
Options: `--stats` for raw stats with visual bars · `--months N` to look back N months.
|
|
417
|
-
|
|
418
|
-
### `claudestat doctor`
|
|
419
|
-
|
|
420
|
-
Diagnoses common installation problems — useful if `claudestat start` fails or hooks are not firing.
|
|
421
|
-
|
|
422
|
-
```
|
|
423
|
-
claudestat doctor
|
|
424
|
-
|
|
425
|
-
🩺 claudestat doctor
|
|
426
|
-
──────────────────────────────────────────────
|
|
427
|
-
✓ Node.js version (22.17.0)
|
|
428
|
-
✓ Claude Code installed
|
|
429
|
-
✓ Hooks installed in Claude Code
|
|
430
|
-
✓ ~/.claudestat/ data directory exists
|
|
431
|
-
✓ Hook script deployed (~/.claudestat/hooks/event.js)
|
|
432
|
-
✓ Daemon running (localhost:7337)
|
|
433
|
-
✓ Global CLI symlink valid
|
|
434
|
-
✓ No duplicate claudestat binaries in PATH
|
|
435
|
-
✓ Version match (installed: v1.2.2)
|
|
436
|
-
✓ NVM prefix matches active binary
|
|
437
|
-
──────────────────────────────────────────────
|
|
438
|
-
All checks passed — claudestat is healthy!
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
If a check fails, `doctor` prints the exact fix command to run.
|
|
179
|
+
[Full command reference with output examples →](docs/COMMANDS.md)
|
|
442
180
|
|
|
443
181
|
---
|
|
444
182
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
Shows the current version and checks npm for updates.
|
|
448
|
-
|
|
449
|
-
```bash
|
|
450
|
-
claudestat version
|
|
451
|
-
|
|
452
|
-
1.2.2
|
|
453
|
-
latest ✓
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
If a newer version is available, it shows: `latest: 1.3.0 — run npm update`.
|
|
183
|
+
## Dashboard
|
|
457
184
|
|
|
458
|
-
|
|
185
|
+
The dashboard lives at `http://localhost:7337` and has six tabs: **Live** (real-time trace), **History** (sessions by date), **Projects** (grid with stats), **Analytics** (KPIs + charts), **Top** (tool rankings), and **System** (daemon health).
|
|
459
186
|
|
|
460
|
-
|
|
187
|
+

|
|
461
188
|
|
|
462
|
-
|
|
463
|
-
# Export all sessions as JSON to stdout
|
|
464
|
-
claudestat export
|
|
189
|
+

|
|
465
190
|
|
|
466
|
-
|
|
467
|
-
claudestat export csv --output ~/sessions.csv
|
|
191
|
+

|
|
468
192
|
|
|
469
|
-
|
|
470
|
-
claudestat export json --from 2025-05-01 --to 2025-05-31
|
|
193
|
+

|
|
471
194
|
|
|
472
|
-
|
|
473
|
-
claudestat export csv --project myapp --output myapp-sessions.csv
|
|
195
|
+

|
|
474
196
|
|
|
475
|
-
|
|
476
|
-
claudestat export json --from 2025-05-01 --project claudestat --output may-claudestat.json
|
|
477
|
-
```
|
|
197
|
+

|
|
478
198
|
|
|
479
|
-
|
|
199
|
+

|
|
480
200
|
|
|
481
|
-
|
|
201
|
+
[Dashboard details →](docs/DASHBOARD.md)
|
|
482
202
|
|
|
483
203
|
---
|
|
484
204
|
|
|
485
205
|
## MCP Server
|
|
486
206
|
|
|
487
|
-
claudestat includes an MCP
|
|
488
|
-
|
|
489
|
-
### Tools exposed
|
|
490
|
-
|
|
491
|
-
| Tool | Description |
|
|
492
|
-
|------|------------|
|
|
493
|
-
| `get_quota_status` | 5h cycle usage %, plan, weekly hours, burn rate (with on-demand API refresh + disk cache) |
|
|
494
|
-
| `get_current_session` | Latest session: cost, tokens, efficiency, loops |
|
|
495
|
-
| `get_session_stats` | Aggregated stats for N days |
|
|
496
|
-
| `get_top_tools` | Top 10 tools by cost/count/duration (default 30 days) |
|
|
497
|
-
| `get_usage_insights` | Deep insights: cost per project, cache savings, efficiency trend, peak hours, model breakdown |
|
|
498
|
-
| `get_model_breakdown` | Cost and session count broken down by Claude model (Sonnet, Haiku, Opus) |
|
|
499
|
-
| `get_weekly_insight` | Weekly summary with actionable tip |
|
|
500
|
-
|
|
501
|
-
### Register with Claude Code
|
|
207
|
+
claudestat includes an MCP server with 7 tools for querying usage stats. Register once:
|
|
502
208
|
|
|
503
209
|
```bash
|
|
504
210
|
claude mcp add claudestat -s user -- claudestat-mcp
|
|
505
211
|
```
|
|
506
212
|
|
|
507
|
-
|
|
508
|
-
- *"What's my current quota status?"*
|
|
509
|
-
- *"Show me my latest session cost"*
|
|
510
|
-
- *"What are my top 5 tools by cost this week?"*
|
|
511
|
-
- *"Give me usage insights for the last 14 days"*
|
|
512
|
-
- *"Break down my usage by model"*
|
|
213
|
+
Then ask Claude: *"What's my quota status?"*, *"Show me my latest session"*, *"Top 5 tools by cost"*.
|
|
513
214
|
|
|
514
215
|

|
|
515
216
|
|
|
516
|
-
|
|
217
|
+
[MCP tools reference →](docs/MCP.md)
|
|
517
218
|
|
|
518
219
|
---
|
|
519
220
|
|
|
520
|
-
##
|
|
521
|
-
|
|
522
|
-
The dashboard lives at `http://localhost:7337` and has six tabs:
|
|
221
|
+
## Configuration
|
|
523
222
|
|
|
524
|
-
|
|
525
|
-
Real-time stream of every tool call in the active session. Shows tool name, duration, and token cost. Agent sub-calls expand into nested traces; Skill invocations collapse into labeled containers.
|
|
223
|
+
Config is stored at `~/.claudestat/config.json`. View it with `claudestat config` or edit the file directly.
|
|
526
224
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-

|
|
533
|
-
|
|
534
|
-
### Projects
|
|
535
|
-
Grid of every project you've worked on. Shows last active date, total sessions, cost, model usage breakdown (Sonnet / Haiku), and an efficiency progress bar.
|
|
536
|
-
|
|
537
|
-

|
|
538
|
-
|
|
539
|
-
### Analytics
|
|
540
|
-
- 6 KPIs: total cost, tokens, cache savings, hidden loop waste, avg efficiency, session count
|
|
541
|
-
- Token/cost trend charts (7 / 30 / 90 days)
|
|
542
|
-
- Hours by project
|
|
543
|
-
- AI-generated weekly reports (auto-scheduled or on demand)
|
|
544
|
-
|
|
545
|
-

|
|
546
|
-
|
|
547
|
-

|
|
548
|
-
|
|
549
|
-
### Top
|
|
550
|
-
Tool rankings across all your sessions. Sortable by estimated cost, call count, or duration — with a time filter (7 / 30 / 90 days). Also shows projected weekly and monthly spend based on your recent burn rate.
|
|
551
|
-
|
|
552
|
-

|
|
553
|
-
|
|
554
|
-
### System
|
|
555
|
-
Daemon health, DB size, Node version, config file paths, and memory context.
|
|
556
|
-
|
|
557
|
-

|
|
558
|
-
|
|
559
|
-
---
|
|
560
|
-
|
|
561
|
-
## Configuration reference
|
|
562
|
-
|
|
563
|
-
Config is stored at `~/.claudestat/config.json` (macOS/Linux) or `%USERPROFILE%\.claudestat\config.json` (Windows) and created automatically on first run.
|
|
564
|
-
|
|
565
|
-
```json
|
|
566
|
-
{
|
|
567
|
-
"killSwitchEnabled": false,
|
|
568
|
-
"killSwitchThreshold": 95,
|
|
569
|
-
"warnThresholds": [70, 85, 95],
|
|
570
|
-
"plan": null,
|
|
571
|
-
"alertsEnabled": true,
|
|
572
|
-
"reportsEnabled": false,
|
|
573
|
-
"reportFrequency": "weekly",
|
|
574
|
-
"reportDay": 1,
|
|
575
|
-
"reportTime": "09:00"
|
|
576
|
-
}
|
|
225
|
+
```bash
|
|
226
|
+
claudestat config --kill-switch true --threshold 90
|
|
227
|
+
claudestat config --plan max5
|
|
228
|
+
claudestat config --alerts false
|
|
577
229
|
```
|
|
578
230
|
|
|
579
|
-
|
|
580
|
-
|---|---|---|
|
|
581
|
-
| `killSwitchEnabled` | `false` | Enable the quota kill switch. When `true`, new Claude Code sessions are blocked once your quota reaches the threshold. |
|
|
582
|
-
| `killSwitchThreshold` | `95` | Quota percentage (0–100) at which the kill switch activates. Only relevant when `killSwitchEnabled` is `true`. |
|
|
583
|
-
| `warnThresholds` | `[70, 85, 95]` | Three quota percentages for yellow, orange, and red warnings in the dashboard and daemon alerts. |
|
|
584
|
-
| `plan` | `null` | Force plan detection. Valid values: `"pro"`, `"max5"`, `"max20"`. Leave `null` to auto-detect. |
|
|
585
|
-
| `alertsEnabled` | `true` | Enable daemon rate limit alerts — polls quota every 60s and logs a warning (with optional desktop notification) when thresholds are crossed. |
|
|
586
|
-
| `reportsEnabled` | `false` | Enable automatic AI-generated usage reports on a schedule. |
|
|
587
|
-
| `reportFrequency` | `"weekly"` | How often to generate reports. Valid values: `"weekly"`, `"biweekly"`, `"monthly"`. |
|
|
588
|
-
| `reportDay` | `1` | Day of week for reports (0=Sun, 1=Mon … 6=Sat). |
|
|
589
|
-
| `reportTime` | `"09:00"` | Time of day (HH:MM) when the report is generated. |
|
|
231
|
+
[Full configuration reference →](docs/CONFIG.md)
|
|
590
232
|
|
|
591
|
-
|
|
233
|
+
---
|
|
592
234
|
|
|
593
|
-
|
|
594
|
-
# Enable kill switch at 90% quota
|
|
595
|
-
claudestat config --kill-switch true --threshold 90
|
|
235
|
+
## How it works
|
|
596
236
|
|
|
597
|
-
|
|
598
|
-
|
|
237
|
+
```
|
|
238
|
+
Claude Code event
|
|
239
|
+
│
|
|
240
|
+
▼
|
|
241
|
+
Hook script (~/.claudestat/hooks/event.js)
|
|
242
|
+
│ POST JSON to daemon
|
|
243
|
+
▼
|
|
244
|
+
Daemon (localhost:7337)
|
|
245
|
+
│ stores events in SQLite
|
|
246
|
+
│ enriches with JSONL token data
|
|
247
|
+
│ runs pattern analyzer
|
|
248
|
+
▼
|
|
249
|
+
Dashboard (React + Vite, auto-refreshes)
|
|
250
|
+
│
|
|
251
|
+
▼
|
|
252
|
+
You see everything — live
|
|
599
253
|
```
|
|
600
254
|
|
|
601
255
|
---
|
|
@@ -603,132 +257,71 @@ claudestat config --plan max5
|
|
|
603
257
|
## Troubleshooting
|
|
604
258
|
|
|
605
259
|
**`claudestat start` hangs for ~5 seconds**
|
|
606
|
-
Normal — `require('express')` takes a few seconds on first load.
|
|
260
|
+
Normal — `require('express')` takes a few seconds on first load.
|
|
607
261
|
|
|
608
262
|
**Hooks are not firing / dashboard shows no events**
|
|
609
263
|
Run `claudestat doctor` — it checks every component and prints the exact fix command.
|
|
610
|
-
If hooks were installed before upgrading, run `claudestat uninstall && claudestat install` to refresh.
|
|
611
264
|
|
|
612
265
|
**`claudestat` command not found after install**
|
|
613
266
|
If using NVM, the binary may point to the wrong Node version:
|
|
614
267
|
```bash
|
|
615
|
-
nvm use default && npm install -g @statforge/claudestat
|
|
616
|
-
hash -r claudestat # macOS/Linux — refresh shell binary cache
|
|
268
|
+
nvm use default && npm install -g @statforge/claudestat && hash -r claudestat
|
|
617
269
|
```
|
|
618
270
|
|
|
619
|
-
**
|
|
620
|
-
|
|
271
|
+
**Kill switch is blocking new sessions**
|
|
272
|
+
Disable with `claudestat config --kill-switch false`, or wait for the 5h quota window to reset.
|
|
621
273
|
|
|
622
274
|
**Approaching rate limit**
|
|
623
|
-
|
|
624
|
-
To see current quota at any time: `claudestat status`
|
|
625
|
-
|
|
626
|
-
**Kill switch is blocking new sessions**
|
|
627
|
-
The kill switch only activates when `killSwitchEnabled: true` AND `cyclePct >= killSwitchThreshold`.
|
|
628
|
-
To disable: `claudestat config --kill-switch false`
|
|
629
|
-
Or wait for the 5h quota window to reset (check time remaining with `claudestat status`).
|
|
275
|
+
The daemon polls quota every 60s and logs warnings at 70%, 85%, and 95%. Check anytime with `claudestat status`.
|
|
630
276
|
|
|
631
|
-
|
|
632
|
-
|
|
277
|
+
**Working with multiple projects**
|
|
278
|
+
claudestat tracks every project automatically. The Projects tab groups sessions by working directory.
|
|
633
279
|
|
|
634
280
|
---
|
|
635
281
|
|
|
636
|
-
##
|
|
282
|
+
## FAQ
|
|
283
|
+
|
|
284
|
+
**What is claudestat? How is it different from ccusage?**
|
|
285
|
+
claudestat is a real-time monitor for Claude Code — not a log reader. It hooks into every tool call as it fires, tracks token usage and cost live, guards your quota with configurable alerts, and exposes an MCP server. ccusage reads JSONL history after sessions end; claudestat runs while you code.
|
|
286
|
+
|
|
287
|
+
**How do I track Claude Code costs?**
|
|
288
|
+
Install with `npm install -g @statforge/claudestat && claudestat setup`, then open `http://localhost:7337` for the live dashboard. Use `claudestat status` for a quick summary or `claudestat export` for full data export.
|
|
637
289
|
|
|
638
|
-
|
|
290
|
+
**Does claudestat work with Claude Pro, Max 5, and Max 20?**
|
|
291
|
+
Yes. claudestat auto-detects your plan. You can also force it with `claudestat config --plan max5`.
|
|
639
292
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
- **VS Code extension** — sidebar panel with live stats inside the editor
|
|
293
|
+
**Is my data sent to any server?**
|
|
294
|
+
No. All data is stored locally in SQLite at `~/.claudestat/`. Zero cloud dependencies.
|
|
643
295
|
|
|
644
|
-
|
|
296
|
+
**Does claudestat work on Windows?**
|
|
297
|
+
Yes — macOS, Linux, and Windows are all supported.
|
|
645
298
|
|
|
646
299
|
---
|
|
647
300
|
|
|
648
301
|
## Uninstall
|
|
649
302
|
|
|
650
303
|
```bash
|
|
651
|
-
claudestat uninstall
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
rm -rf ~/.claudestat # removes DB, config, and PID file
|
|
655
|
-
|
|
656
|
-
# Windows (PowerShell):
|
|
657
|
-
Remove-Item -Recurse -Force "$env:USERPROFILE\.claudestat"
|
|
304
|
+
claudestat setup --uninstall # remove hooks + system service
|
|
305
|
+
rm -rf ~/.claudestat # macOS / Linux
|
|
306
|
+
Remove-Item -Recurse -Force "$env:USERPROFILE\.claudestat" # Windows (PowerShell)
|
|
658
307
|
```
|
|
659
308
|
|
|
309
|
+
> If you installed manually, use `claudestat uninstall` to remove only the hooks.
|
|
310
|
+
|
|
660
311
|
---
|
|
661
312
|
|
|
662
313
|
## Contributing
|
|
663
314
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
Whether you want to fix a bug, improve a dashboard view, add a new pattern to the analyzer, or support a new provider — contributions are encouraged.
|
|
667
|
-
|
|
668
|
-
### How to contribute
|
|
669
|
-
|
|
670
|
-
1. Fork the repository
|
|
671
|
-
2. Create a branch: `git checkout -b feat/your-feature`
|
|
672
|
-
3. Make your changes
|
|
673
|
-
4. Run the test suite: `node --require tsx/cjs tests/index.ts` (243 tests)
|
|
674
|
-
5. Open a PR with a clear description of what you changed and why
|
|
675
|
-
|
|
676
|
-
### Good first areas
|
|
677
|
-
|
|
678
|
-
- **Pattern analyzer** (`src/pattern-analyzer.ts`) — add new usage patterns or improve thresholds
|
|
679
|
-
- **Dashboard components** (`dashboard/src/components/`) — UI improvements, new charts, accessibility
|
|
680
|
-
- **New commands** — ideas like `claudestat compare`
|
|
681
|
-
- **Bug reports** — open an issue with steps to reproduce and your Node/OS version
|
|
682
|
-
|
|
683
|
-
### Running locally
|
|
315
|
+
PRs are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for full guidelines.
|
|
684
316
|
|
|
685
317
|
```bash
|
|
686
318
|
git clone https://github.com/YOUR_USERNAME/claudestat
|
|
687
319
|
cd claudestat
|
|
688
320
|
npm install
|
|
689
|
-
npm run dev:full # starts daemon + dashboard hot-reload together
|
|
690
321
|
node --require tsx/cjs tests/index.ts # run all tests
|
|
691
322
|
```
|
|
692
323
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
This project follows the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
|
|
696
|
-
|
|
697
|
-
---
|
|
698
|
-
|
|
699
|
-
## Contributors
|
|
700
|
-
|
|
701
|
-
Thanks to everyone who has contributed to claudestat:
|
|
702
|
-
|
|
703
|
-
[Deiby Gorrin](https://github.com/DeibyGS) — creator and maintainer
|
|
704
|
-
|
|
705
|
-
Want to appear here? Pick a [good-first-issue](https://github.com/DeibyGS/claudestat/labels/good-first-issue) and open a PR.
|
|
706
|
-
|
|
707
|
-
---
|
|
708
|
-
|
|
709
|
-
## FAQ
|
|
710
|
-
|
|
711
|
-
**What is claudestat? How is it different from ccusage?**
|
|
712
|
-
claudestat is a real-time monitor for Claude Code — not a log reader. It hooks into every tool call as it fires, tracks token usage and cost live, guards your quota with configurable alerts, and exposes an MCP server so Claude can answer questions about its own usage. ccusage reads JSONL history after sessions end; claudestat runs while you code.
|
|
713
|
-
|
|
714
|
-
**How do I monitor Claude Code token usage?**
|
|
715
|
-
Install with `npm install -g @statforge/claudestat`, run `claudestat start`, and open `http://localhost:7337` for the live dashboard.
|
|
716
|
-
|
|
717
|
-
**How do I track Claude Code costs?**
|
|
718
|
-
claudestat records every session's token usage and estimates API cost per tool call.
|
|
719
|
-
Use `claudestat status` for a quick summary or `claudestat export` for full data export.
|
|
720
|
-
|
|
721
|
-
**How do I get alerted when Claude Code hits the rate limit?**
|
|
722
|
-
claudestat polls your quota every 60 seconds and sends desktop notifications when you cross 70%, 85%, or 95%. Configure with `claudestat config --alerts true`.
|
|
723
|
-
|
|
724
|
-
**Does claudestat work with Claude Pro, Max 5, and Max 20?**
|
|
725
|
-
Yes. claudestat auto-detects your plan. You can also force it with `claudestat config --plan max5`.
|
|
726
|
-
|
|
727
|
-
**Is my data sent to any server?**
|
|
728
|
-
No. All data is stored locally in SQLite at `~/.claudestat/`. Zero cloud dependencies.
|
|
729
|
-
|
|
730
|
-
**Does claudestat work on Windows?**
|
|
731
|
-
Yes — macOS, Linux, and Windows are all supported.
|
|
324
|
+
Good first areas: pattern analyzer (`src/pattern-analyzer.ts`), dashboard components (`dashboard/src/components/`), new commands.
|
|
732
325
|
|
|
733
326
|
---
|
|
734
327
|
|