@jeganwrites/claudash 1.0.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/CONTRIBUTING.md +35 -0
- package/LICENSE +21 -0
- package/README.md +261 -0
- package/analyzer.py +890 -0
- package/bin/claudash.js +121 -0
- package/claude_ai_tracker.py +358 -0
- package/cli.py +1034 -0
- package/config.py +100 -0
- package/db.py +1156 -0
- package/fix_tracker.py +539 -0
- package/insights.py +359 -0
- package/mcp_server.py +414 -0
- package/package.json +39 -0
- package/scanner.py +385 -0
- package/server.py +762 -0
- package/templates/accounts.html +936 -0
- package/templates/dashboard.html +1742 -0
- package/tools/get-derived-keys.py +112 -0
- package/tools/mac-sync.py +386 -0
- package/tools/oauth_sync.py +308 -0
- package/tools/setup-pm2.sh +53 -0
- package/waste_patterns.py +334 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Contributing to Claudash
|
|
2
|
+
|
|
3
|
+
## Reporting bugs
|
|
4
|
+
|
|
5
|
+
Open an issue with:
|
|
6
|
+
- Your OS and Python version
|
|
7
|
+
- Steps to reproduce
|
|
8
|
+
- Expected vs actual behavior
|
|
9
|
+
|
|
10
|
+
## Known limitations (v1.0)
|
|
11
|
+
|
|
12
|
+
- Browser tracking: macOS cookie sync only (oauth_sync.py works on all platforms)
|
|
13
|
+
- Single-user: no multi-user auth
|
|
14
|
+
- Performance: designed for <50K sessions
|
|
15
|
+
|
|
16
|
+
## Roadmap (v1.1)
|
|
17
|
+
|
|
18
|
+
- Linux browser tracking
|
|
19
|
+
- Performance caching layer
|
|
20
|
+
- MCP server — verified working
|
|
21
|
+
- Interactive session drilldown
|
|
22
|
+
|
|
23
|
+
## Development setup
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git clone https://github.com/pnjegan/claudash
|
|
27
|
+
cd claudash
|
|
28
|
+
python3 cli.py dashboard # zero deps, just run it
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Code style
|
|
32
|
+
|
|
33
|
+
- Python 3.8+ stdlib only — no pip dependencies
|
|
34
|
+
- Type hints encouraged but not required
|
|
35
|
+
- Debug logs prefixed with `[module_name]`
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jegan Nagarajan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# Claudash
|
|
2
|
+
|
|
3
|
+
Personal Claude usage dashboard. Tracks token consumption, cost, cache ROI,
|
|
4
|
+
5-hour window burn, per-project attribution, sub-agent cost, waste patterns,
|
|
5
|
+
and claude.ai browser usage — for Max, Pro, and API plans.
|
|
6
|
+
|
|
7
|
+
Zero pip dependencies. Single SQLite file. Single HTML page.
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## What you get
|
|
14
|
+
|
|
15
|
+
- **Efficiency Score** — single 0-100 score across 5 dimensions: cache, model right-sizing, window discipline, floundering rate, compaction. Honest, actionable, comparable over time.
|
|
16
|
+
- **Subscription ROI math** — see your API-equivalent cost vs. what you pay Anthropic
|
|
17
|
+
- **Per-project attribution** — cost, sessions, cache hit rate, model efficiency, week-over-week change
|
|
18
|
+
- **5-hour window intelligence** — burn rate, predicted exhaust, safe-to-start check, best autonomous-run hour
|
|
19
|
+
- **Sub-agent cost tracking** — see how much your agentic orchestration costs
|
|
20
|
+
- **Waste-pattern detection** — floundering loops, repeated reads, cost outliers, context rot
|
|
21
|
+
- **Daily budget alerts** — configurable per-account cost ceiling with warning and exceeded insights
|
|
22
|
+
- **claude.ai browser tracking** — unified view across Claude Code + web chat (combined window burn)
|
|
23
|
+
- **MCP server** — expose Claudash data to Claude Code itself via Model Context Protocol
|
|
24
|
+
- **Insights engine** — 14 rules that fire actionable notifications (cache spikes, compaction gaps, window risk, ROI milestones, etc.)
|
|
25
|
+
|
|
26
|
+
## Platform Support
|
|
27
|
+
|
|
28
|
+
| Platform | Core Dashboard | Browser Tracking | Notes |
|
|
29
|
+
|---|---|---|---|
|
|
30
|
+
| macOS + Claude Code | Full | via mac-sync.py or oauth_sync.py | Best experience |
|
|
31
|
+
| Linux + Claude Code | Full | via oauth_sync.py | Recommended for VPS |
|
|
32
|
+
| Windows + Claude Code | Core | Not supported | Path auto-detection added |
|
|
33
|
+
| EC2/VPS | Full | Headless | Use SSH tunnel to view |
|
|
34
|
+
| claude.ai browser only | Partial | Window tracking only | No project intelligence |
|
|
35
|
+
|
|
36
|
+
## Getting Started
|
|
37
|
+
|
|
38
|
+
### Requirements
|
|
39
|
+
- Python 3.8+
|
|
40
|
+
- Claude Code installed and at least one session run
|
|
41
|
+
- macOS or Linux (Windows: core features work, browser tracking not supported)
|
|
42
|
+
|
|
43
|
+
### Fastest (via npx — no install needed)
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx claudash
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Requires Node.js 16+ and Python 3.8+.
|
|
50
|
+
Auto-installs, opens browser, detects your Claude Code data.
|
|
51
|
+
|
|
52
|
+
### Manual install (local Mac/Linux)
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git clone https://github.com/pnjegan/claudash
|
|
56
|
+
cd claudash
|
|
57
|
+
python3 cli.py dashboard
|
|
58
|
+
# Browser opens at http://localhost:8080
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Quick start (VPS/EC2)
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# On your server:
|
|
65
|
+
git clone https://github.com/pnjegan/claudash
|
|
66
|
+
cd claudash
|
|
67
|
+
nohup python3 cli.py dashboard > claudash.log 2>&1 &
|
|
68
|
+
|
|
69
|
+
# On your local machine:
|
|
70
|
+
ssh -L 8080:localhost:8080 your-server
|
|
71
|
+
# Open: http://localhost:8080
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### First run
|
|
75
|
+
|
|
76
|
+
Claudash auto-detects `~/.claude/projects/` on startup.
|
|
77
|
+
If it finds JSONL files, data appears immediately.
|
|
78
|
+
If not, check that Claude Code has been used at least once.
|
|
79
|
+
|
|
80
|
+
### Browser window tracking (optional)
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Claude Code users (any OS) — recommended:
|
|
84
|
+
python3 tools/oauth_sync.py
|
|
85
|
+
|
|
86
|
+
# macOS browser-only users:
|
|
87
|
+
python3 tools/mac-sync.py
|
|
88
|
+
|
|
89
|
+
# Automate via cron:
|
|
90
|
+
# */5 * * * * python3 /path/to/oauth_sync.py
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Full setup walkthrough in [SETUP.md](SETUP.md).
|
|
94
|
+
|
|
95
|
+
## Keeping it running
|
|
96
|
+
|
|
97
|
+
### Simple (background process)
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
nohup python3 cli.py dashboard > claudash.log 2>&1 &
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Recommended (PM2 — auto-restarts on crash)
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
bash tools/setup-pm2.sh
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Check if running
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
curl http://localhost:8080/health
|
|
113
|
+
# or with PM2:
|
|
114
|
+
pm2 status
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### View logs
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
tail -f /tmp/claudash.log
|
|
121
|
+
# or with PM2:
|
|
122
|
+
pm2 logs claudash
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Two sync methods for claude.ai browser data
|
|
126
|
+
|
|
127
|
+
Claudash supports two ways to push your claude.ai session usage to the server.
|
|
128
|
+
Pick one based on how you use Claude.
|
|
129
|
+
|
|
130
|
+
- **`tools/oauth_sync.py`** — **recommended for Claude Code users**. Reuses the
|
|
131
|
+
OAuth access token that `claude` already stores in `~/.claude/.credentials.json`.
|
|
132
|
+
No cookies, no keychain, works on Linux / macOS / Windows. Run via cron.
|
|
133
|
+
|
|
134
|
+
- **`tools/mac-sync.py`** — for **claude.ai browser-only** users (no Claude Code
|
|
135
|
+
install). Extracts the `sessionKey` cookie from Chrome / Vivaldi via the macOS
|
|
136
|
+
keychain. macOS only.
|
|
137
|
+
|
|
138
|
+
Both scripts POST to the same `/api/claude-ai/sync` endpoint gated by the
|
|
139
|
+
`sync_token` from `python3 cli.py keys`.
|
|
140
|
+
|
|
141
|
+
## Account configuration
|
|
142
|
+
|
|
143
|
+
`config.py` sets the initial account configuration on first run.
|
|
144
|
+
After first run, accounts are managed in the dashboard UI (Accounts page).
|
|
145
|
+
Changes to `config.py` after first run have no effect — use the Accounts
|
|
146
|
+
page to modify accounts.
|
|
147
|
+
|
|
148
|
+
## Commands
|
|
149
|
+
|
|
150
|
+
| Command | Description |
|
|
151
|
+
|---|---|
|
|
152
|
+
| `python3 cli.py dashboard` | Start the server on :8080 (127.0.0.1) |
|
|
153
|
+
| `python3 cli.py scan` | Incremental scan of all tracked JSONL files + waste detection |
|
|
154
|
+
| `python3 cli.py scan --reprocess` | Re-tag every existing session using the current `PROJECT_MAP` |
|
|
155
|
+
| `python3 cli.py show-other` | List source paths of sessions tagged `Other` |
|
|
156
|
+
| `python3 cli.py stats` | Per-account stats table (CLI) |
|
|
157
|
+
| `python3 cli.py insights` | Print active insights |
|
|
158
|
+
| `python3 cli.py window` | Show 5-hour window status per account |
|
|
159
|
+
| `python3 cli.py export` | Export last 30 days of sessions to `usage_export.csv` |
|
|
160
|
+
| `python3 cli.py waste` | Run waste-pattern detection and print a summary |
|
|
161
|
+
| `python3 cli.py mcp` | Print the MCP settings.json snippet + smoke-test the server |
|
|
162
|
+
| `python3 cli.py keys` | Print `dashboard_key` and `sync_token` (sensitive) |
|
|
163
|
+
| `python3 cli.py claude-ai` | Show claude.ai browser tracking status |
|
|
164
|
+
|
|
165
|
+
## How Claudash differs from similar tools
|
|
166
|
+
|
|
167
|
+
Claudash is not a clone of any existing tool. It focuses on the parts other
|
|
168
|
+
trackers skip: persistence, per-project attribution, and the intelligence
|
|
169
|
+
layer that turns raw numbers into action.
|
|
170
|
+
|
|
171
|
+
| Feature | Claudash | ccusage | claude-usage | claude-monitor |
|
|
172
|
+
|---|---|---|---|---|
|
|
173
|
+
| Web dashboard | ✓ | ✗ | ✓ | ✗ |
|
|
174
|
+
| Per-project attribution | ✓ | partial | ✗ | ✗ |
|
|
175
|
+
| claude.ai browser tracking | ✓ | ✗ | ✗ | ✗ |
|
|
176
|
+
| Subscription ROI math | ✓ | ✗ | ✗ | ✗ |
|
|
177
|
+
| Account manager UI | ✓ | ✗ | ✗ | ✗ |
|
|
178
|
+
| Sub-agent cost tracking | ✓ | ✗ | ✗ | ✗ |
|
|
179
|
+
| MCP server | ✓ | ✓ | ✗ | ✗ |
|
|
180
|
+
| Waste pattern detection | ✓ | ✗ | ✗ | ✗ |
|
|
181
|
+
| Multi-machine collector | ✓ | ✗ | ✗ | ✗ |
|
|
182
|
+
| Zero pip dependencies | ✓ | ✗ | ✓ | ✗ |
|
|
183
|
+
|
|
184
|
+
We recommend using `ccusage` alongside Claudash — `ccusage` for quick terminal
|
|
185
|
+
reports, Claudash for deep project intelligence, persistence, and actionable
|
|
186
|
+
insights.
|
|
187
|
+
|
|
188
|
+
## Insight rules
|
|
189
|
+
|
|
190
|
+
14 rules fire after every scan:
|
|
191
|
+
|
|
192
|
+
| Type | Severity | When it triggers |
|
|
193
|
+
|---|---|---|
|
|
194
|
+
| `model_waste` | amber | Project uses Opus but avg output <800 tokens — Sonnet is sufficient |
|
|
195
|
+
| `cache_spike` | red | Cache creation >3× the 7-day average |
|
|
196
|
+
| `compaction_gap` | amber | Sessions hit 70% of window limit without `/compact` |
|
|
197
|
+
| `cost_target` | green | Project hit its cost-per-session target |
|
|
198
|
+
| `window_risk` | red | Current burn rate will exhaust the 5-hour window in <60 min |
|
|
199
|
+
| `roi_milestone` | green | Subscription ROI crossed 2×, 5×, or 10× this month |
|
|
200
|
+
| `heavy_day` | blue | Consistent heavy usage on same day of week |
|
|
201
|
+
| `best_window` | blue | Identifies quietest 5-hour block for autonomous runs |
|
|
202
|
+
| `window_combined_risk` | red | Claude Code + claude.ai browser combined >80% of window |
|
|
203
|
+
| `session_expiry` | red | claude.ai session cookie expired |
|
|
204
|
+
| `pro_messages_low` | amber | Pro plan at >70% of message budget |
|
|
205
|
+
| `subagent_cost_spike` | amber | Sub-agents consume >30% of project cost |
|
|
206
|
+
| `floundering_detected` | red | Session stuck in retry loops (same tool >=4 times) |
|
|
207
|
+
| `budget_warning` / `budget_exceeded` | amber / red | Daily budget threshold crossed |
|
|
208
|
+
|
|
209
|
+
## API endpoints
|
|
210
|
+
|
|
211
|
+
| Method | Path | Auth | Description |
|
|
212
|
+
|---|---|---|---|
|
|
213
|
+
| GET | `/api/data?account=X` | — | Full analysis (metrics, projects, windows, insights, sub-agents, waste, budget) |
|
|
214
|
+
| GET | `/api/projects?account=X` | — | Per-project breakdown |
|
|
215
|
+
| GET | `/api/insights?account=X&dismissed=0` | — | Active insights |
|
|
216
|
+
| GET | `/api/window?account=X` | — | 5-hour window status + history |
|
|
217
|
+
| GET | `/api/trends?account=X&days=7` | — | Daily snapshots for charts |
|
|
218
|
+
| GET | `/api/health` | — | DB size, total records, last scan |
|
|
219
|
+
| GET | `/api/accounts` | — | Accounts with `data_paths`, projects, budget |
|
|
220
|
+
| GET | `/api/claude-ai/accounts` | — | claude.ai browser tracking config (session keys scrubbed) |
|
|
221
|
+
| POST | `/api/scan` | X-Dashboard-Key | Trigger a rescan |
|
|
222
|
+
| POST | `/api/insights/{id}/dismiss` | X-Dashboard-Key | Dismiss an insight |
|
|
223
|
+
| POST / PUT / DELETE | `/api/accounts*` | X-Dashboard-Key | Account CRUD |
|
|
224
|
+
| POST | `/api/claude-ai/sync` | X-Sync-Token | Push browser / OAuth usage from a collector |
|
|
225
|
+
|
|
226
|
+
GET endpoints are unauthenticated because the server only binds `127.0.0.1`.
|
|
227
|
+
Every mutating endpoint requires `X-Dashboard-Key` (from `python3 cli.py keys`).
|
|
228
|
+
|
|
229
|
+
## Tech stack
|
|
230
|
+
|
|
231
|
+
- Python 3.8+ stdlib only — zero pip dependencies
|
|
232
|
+
- SQLite with WAL mode (`data/usage.db`)
|
|
233
|
+
- Vanilla JS dashboard with DM Serif Display + DM Mono + DM Sans (Google Fonts `@import`)
|
|
234
|
+
- No build step, no bundler, no Node, no Docker
|
|
235
|
+
|
|
236
|
+
## Documentation
|
|
237
|
+
|
|
238
|
+
- [SETUP.md](SETUP.md) — first-time setup guide
|
|
239
|
+
- [CHANGELOG.md](CHANGELOG.md) — version history
|
|
240
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md) — how to contribute
|
|
241
|
+
|
|
242
|
+
## Security
|
|
243
|
+
|
|
244
|
+
Your data never leaves your machine.
|
|
245
|
+
|
|
246
|
+
- Dashboard reads JSONL files Claude Code writes to `~/.claude/projects/`
|
|
247
|
+
- All data stored in local SQLite (`data/usage.db`)
|
|
248
|
+
- Dashboard served on localhost only — not accessible from internet
|
|
249
|
+
- mac-sync.py reads browser cookies locally and pushes only your
|
|
250
|
+
window usage percentage to your dashboard server
|
|
251
|
+
- No telemetry, no analytics, no external API calls
|
|
252
|
+
- No data sent to Anthropic, GitHub, or any third party
|
|
253
|
+
|
|
254
|
+
The dashboard key is stored in `data/usage.db` (SQLite).
|
|
255
|
+
The DB file has 0600 permissions (owner read/write only).
|
|
256
|
+
If you have filesystem access to the VPS, you have access
|
|
257
|
+
to the key — this is by design for a single-user tool.
|
|
258
|
+
|
|
259
|
+
## License
|
|
260
|
+
|
|
261
|
+
MIT. See [LICENSE](LICENSE).
|