cctrackr 0.1.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/LICENSE +21 -0
- package/README.md +465 -0
- package/dist/index.js +582 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -0
- package/pricing/models.json +155 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 azharuddinkhan3005
|
|
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,465 @@
|
|
|
1
|
+
# cctrack
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/cctrackr)
|
|
4
|
+
[](https://github.com/azharuddinkhan3005/cctrack/blob/main/LICENSE)
|
|
5
|
+
[](https://nodejs.org)
|
|
6
|
+
|
|
7
|
+
Know exactly what Claude Code costs you. Accurate token tracking, cost breakdowns, and a beautiful interactive dashboard -- all from your local JSONL logs.
|
|
8
|
+
|
|
9
|
+
## What It Does
|
|
10
|
+
|
|
11
|
+
cctrack reads Claude Code's local usage logs and turns them into actionable analytics. It deduplicates requests, applies Anthropic's tiered pricing, and gives you cost breakdowns by day, session, project, and model -- in the terminal or as an interactive HTML dashboard.
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<img src="assets/dashboard-hero.png" alt="cctrack dashboard overview" width="100%">
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **Accurate cost calculation** -- 3-tier deduplication (requestId > messageId > content hash) eliminates double-counting. Tiered pricing applies Anthropic's rate change at the 200K token threshold.
|
|
20
|
+
- **14 Anthropic models, 24 aliases** -- Covers every Claude model. Dynamic pricing fetches current rates from Anthropic's public page, with bundled fallback if offline.
|
|
21
|
+
- **Interactive HTML dashboard** -- 9 chart panels, project/date filters, dark/light mode. Self-contained HTML file you can share or archive.
|
|
22
|
+
- **Per-project breakdown** -- Automatically resolves project names from the filesystem directory structure, including subagent paths that point back to parent projects.
|
|
23
|
+
- **Budget alerts** -- 4-level system (safe / warning / critical / exceeded) with configurable daily and monthly budgets.
|
|
24
|
+
- **Burn rate projections** -- Hourly, daily, and monthly burn rates with projected month-end spend, suppressed when data is insufficient (< 1 hour).
|
|
25
|
+
- **5-hour window tracking** -- Usage grouped into time windows to help you see consumption patterns across the day.
|
|
26
|
+
- **ROI calculator** -- Compares your API-equivalent cost against Pro ($20/mo), Max 5x ($100/mo), and Max 20x ($200/mo) plans with fuzzy plan name matching.
|
|
27
|
+
- **Real-time monitor** -- Live terminal display that refreshes every few seconds with current session cost and burn rate.
|
|
28
|
+
- **Rate limit intelligence** -- Tracks billable tokens (input + cache_creation only, NOT cache_read) and includes an EMA-based predictive model.
|
|
29
|
+
- **Multiple output formats** -- `--json` on all commands, `--csv` on daily/monthly/session for spreadsheet export.
|
|
30
|
+
- **Statusline integration** -- One-line output designed for tmux status bars and editor integrations, with optional stdin rate limit data from Claude Code.
|
|
31
|
+
- **Zero data collection** -- All processing is local. No telemetry, no server, no account required.
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx cctrackr@latest
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
That's it. Your dashboard opens in the browser with your full usage history.
|
|
40
|
+
|
|
41
|
+
To install globally:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install -g cctrackr
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Dashboard Panels
|
|
48
|
+
|
|
49
|
+
The dashboard is a self-contained HTML file with 9 interactive panels. No server needed -- open it locally or share the file.
|
|
50
|
+
|
|
51
|
+
- **Dark / light mode** -- Toggle with the button in the top-right corner. Charts rebuild with correct theme colors.
|
|
52
|
+
- **Live filtering** -- Date range and project filters auto-apply on change (no need to click Apply). All panels update together.
|
|
53
|
+
- **Responsive** -- Adapts to desktop, tablet, and mobile viewports with proper breakpoints at 1024px, 768px, and 480px.
|
|
54
|
+
- **Print-ready** -- Charts convert to static images before printing so they render correctly on paper.
|
|
55
|
+
- **Accessible** -- ARIA labels on all chart containers, screen-reader-friendly data tables.
|
|
56
|
+
|
|
57
|
+
### Cost Over Time
|
|
58
|
+
|
|
59
|
+
<img src="assets/panel-cost.png" alt="Cost Over Time" width="700">
|
|
60
|
+
|
|
61
|
+
Daily spend as bars with a cumulative cost trendline. Spot spending spikes and trends at a glance.
|
|
62
|
+
|
|
63
|
+
### Input / Output Tokens
|
|
64
|
+
|
|
65
|
+
<img src="assets/panel-io.png" alt="I/O Tokens" width="700">
|
|
66
|
+
|
|
67
|
+
Input vs. output token volume per day. See how much you're sending versus receiving.
|
|
68
|
+
|
|
69
|
+
### Cache Tokens
|
|
70
|
+
|
|
71
|
+
<img src="assets/panel-cache.png" alt="Cache Tokens" width="700">
|
|
72
|
+
|
|
73
|
+
Cache write vs. cache read volume over time. High cache reads relative to writes means you're getting good prompt caching value.
|
|
74
|
+
|
|
75
|
+
### Project Breakdown
|
|
76
|
+
|
|
77
|
+
<img src="assets/panel-project.png" alt="Project Breakdown" width="700">
|
|
78
|
+
|
|
79
|
+
Cost per project as a horizontal bar chart. Instantly see which projects consume the most.
|
|
80
|
+
|
|
81
|
+
### Model Distribution
|
|
82
|
+
|
|
83
|
+
<img src="assets/panel-model.png" alt="Model Distribution" width="700">
|
|
84
|
+
|
|
85
|
+
Spend split by model. Understand how your costs divide across Opus, Sonnet, Haiku, and others.
|
|
86
|
+
|
|
87
|
+
### Cache Reuse Efficiency
|
|
88
|
+
|
|
89
|
+
<img src="assets/panel-cache-eff.png" alt="Cache Efficiency" width="700">
|
|
90
|
+
|
|
91
|
+
Cache hit rate over time. Track whether your workflows are effectively reusing cached prompts.
|
|
92
|
+
|
|
93
|
+
### Usage Heatmap
|
|
94
|
+
|
|
95
|
+
<img src="assets/panel-heatmap.png" alt="Usage Heatmap" width="700">
|
|
96
|
+
|
|
97
|
+
Hour-of-day by day-of-week activity map. See when you use Claude Code the most.
|
|
98
|
+
|
|
99
|
+
### Sessions
|
|
100
|
+
|
|
101
|
+
<img src="assets/panel-sessions.png" alt="Sessions table" width="700">
|
|
102
|
+
|
|
103
|
+
Sortable table of every session with project, model, duration, request count, tokens, and cost.
|
|
104
|
+
|
|
105
|
+
### ROI Analysis
|
|
106
|
+
|
|
107
|
+
<img src="assets/panel-roi.png" alt="ROI Analysis" width="700">
|
|
108
|
+
|
|
109
|
+
Compares your projected monthly cost against Pro, Max 5x, and Max 20x subscription plans so you can see which plan gives you the best value.
|
|
110
|
+
|
|
111
|
+
## CLI Commands
|
|
112
|
+
|
|
113
|
+
| Command | Description |
|
|
114
|
+
|---|---|
|
|
115
|
+
| `cctrack` | Open interactive HTML dashboard (default) |
|
|
116
|
+
| `cctrack daily` | Daily usage breakdown with cost sparklines |
|
|
117
|
+
| `cctrack monthly` | Monthly aggregated view |
|
|
118
|
+
| `cctrack session` | Per-session breakdown with project and model |
|
|
119
|
+
| `cctrack blocks` | Usage grouped by 5-hour windows |
|
|
120
|
+
| `cctrack roi` | ROI analysis vs subscription plans |
|
|
121
|
+
| `cctrack live` | Real-time terminal monitor with burn rate |
|
|
122
|
+
| `cctrack statusline` | Compact one-line output for tmux/editors |
|
|
123
|
+
| `cctrack limits` | Rate limit analysis (billable token tracking) |
|
|
124
|
+
| `cctrack export csv` | Export per-request data as CSV |
|
|
125
|
+
| `cctrack export json` | Export structured JSON |
|
|
126
|
+
| `cctrack pricing list` | View all model prices |
|
|
127
|
+
| `cctrack config` | Manage budgets and settings |
|
|
128
|
+
|
|
129
|
+
## Command Details
|
|
130
|
+
|
|
131
|
+
### `cctrack dashboard`
|
|
132
|
+
|
|
133
|
+
Opens an interactive HTML dashboard in your browser. The HTML file is self-contained -- no server needed. You can save it, share it, or archive it.
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
cctrack dashboard # Open in browser
|
|
137
|
+
cctrack dashboard --save report.html # Save to file without opening
|
|
138
|
+
cctrack dashboard --json # Output raw dashboard data as JSON
|
|
139
|
+
cctrack dashboard --project my-app # Pre-filter to a specific project
|
|
140
|
+
cctrack dashboard --since 2026-03-01 # Filter from a date
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### `cctrack roi`
|
|
144
|
+
|
|
145
|
+
Compares your actual API-equivalent cost against subscription plans. Supports fuzzy plan names:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
cctrack roi # Default: compare against all plans
|
|
149
|
+
cctrack roi --plan pro # Compare against Pro ($20/mo)
|
|
150
|
+
cctrack roi --plan max5 # Compare against Max 5x ($100/mo)
|
|
151
|
+
cctrack roi --plan 200 # Fuzzy: "200" resolves to Max 20x
|
|
152
|
+
cctrack roi --plan max # Fuzzy: "max" resolves to Max 5x
|
|
153
|
+
cctrack roi --json # Machine-readable output
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### `cctrack live`
|
|
157
|
+
|
|
158
|
+
Real-time terminal monitor that refreshes every few seconds. Shows today's cost, burn rate, and budget status. Press Ctrl+C to exit.
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
cctrack live # Default refresh every 5 seconds
|
|
162
|
+
cctrack live --interval 10 # Refresh every 10 seconds
|
|
163
|
+
cctrack live --project my-app # Monitor a specific project
|
|
164
|
+
cctrack live --mode display # Use Claude Code's cost estimates
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### `cctrack blocks`
|
|
168
|
+
|
|
169
|
+
Groups usage into 5-hour time windows to reveal consumption patterns. Also displays weekly rate limit windows and extra usage credit data when available (from statusline hook).
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
cctrack blocks # Current window and recent history
|
|
173
|
+
cctrack blocks --json # Machine-readable output
|
|
174
|
+
cctrack blocks --live # Auto-refresh every 5 seconds
|
|
175
|
+
cctrack blocks --since 2026-03-25 # Filter by date range
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### `cctrack limits`
|
|
179
|
+
|
|
180
|
+
Analyzes rate limit consumption using billable tokens only (input + cache_creation, excluding cache_read).
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
cctrack limits # Terminal summary
|
|
184
|
+
cctrack limits --json # Detailed JSON with prediction model
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### `cctrack statusline`
|
|
188
|
+
|
|
189
|
+
Designed to be piped into tmux or editor status bars. Ultra-fast with a 30-second cache for repeated calls.
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
cctrack statusline # One-line summary
|
|
193
|
+
cctrack statusline --json # Structured JSON for scripts
|
|
194
|
+
cctrack statusline --format '{cost} | {model}' # Custom format
|
|
195
|
+
cctrack statusline --no-cache # Force fresh parse
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Custom format placeholders:** `{cost}`, `{model}`, `{tokens}`, `{block_pct}`, `{block_remaining}`
|
|
199
|
+
|
|
200
|
+
To use as a Claude Code statusline hook (receives real rate limit data from stdin), add to `.claude/settings.json`:
|
|
201
|
+
|
|
202
|
+
```json
|
|
203
|
+
{
|
|
204
|
+
"statusline": "cctrack statusline"
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
When configured as a hook, cctrack receives rate limit data (`used_percentage`, `resets_at`, weekly windows, extra usage credits) directly from Claude Code's stdin. This data is persisted to `~/.cctrack/ratelimits.json` and shared with `blocks` and `live` commands.
|
|
209
|
+
|
|
210
|
+
### `cctrack export`
|
|
211
|
+
|
|
212
|
+
Export raw per-request data for external analysis:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
cctrack export csv # CSV to stdout
|
|
216
|
+
cctrack export csv > usage.csv # Save to file
|
|
217
|
+
cctrack export json # Full dashboard JSON
|
|
218
|
+
cctrack export csv --since 2026-03-01 # Date-filtered export
|
|
219
|
+
cctrack export csv --project my-app # Project-filtered export
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Cost Modes
|
|
223
|
+
|
|
224
|
+
The `--mode` flag controls how costs are calculated:
|
|
225
|
+
|
|
226
|
+
| Mode | Description |
|
|
227
|
+
|---|---|
|
|
228
|
+
| `calculate` | Default. Computes cost from tokens using Anthropic's pricing |
|
|
229
|
+
| `display` | Uses the `costUSD` field from JSONL entries (Claude Code's own estimate) |
|
|
230
|
+
| `compare` | Shows both calculated and display costs side by side |
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
cctrack daily --mode display # Use Claude Code's cost estimates
|
|
234
|
+
cctrack daily --mode compare # Compare both methods
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Terminal Output Examples
|
|
238
|
+
|
|
239
|
+
**Daily breakdown:**
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
$ cctrack daily
|
|
243
|
+
|
|
244
|
+
┌────────────┬────────┬────────┬─────────────┬────────────┬────────┬──────────────────┐
|
|
245
|
+
│ Date │ Input │ Output │ Cache Write │ Cache Read │ Total │ Cost │
|
|
246
|
+
├────────────┼────────┼────────┼─────────────┼────────────┼────────┼──────────────────┤
|
|
247
|
+
│ 2026-03-25 │ 12.3K │ 45.6K │ 1.8M │ 156.2M │ 158.1M │ $92.45 ████████ │
|
|
248
|
+
│ 2026-03-26 │ 8.1K │ 32.4K │ 1.2M │ 98.7M │ 99.9M │ $58.30 █████░░░ │
|
|
249
|
+
└────────────┴────────┴────────┴─────────────┴────────────┴────────┴──────────────────┘
|
|
250
|
+
Daily Budget: ████████████░░░░░░░░ 58% ($58.30 / $100.00)
|
|
251
|
+
────────────────────────────────────────────────────────────
|
|
252
|
+
Total: 258.0M tokens, $150.75
|
|
253
|
+
Burn rate: $3.14/hr, $75.38/day → projected $2261.25/month
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
**Session view:**
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
$ cctrack session
|
|
260
|
+
|
|
261
|
+
┌─────────────────┬─────────────┬─────────────┬──────────┬──────────┬────────┬─────────┐
|
|
262
|
+
│ Session ID │ Project │ Model │ Duration │ Requests │ Tokens │ Cost │
|
|
263
|
+
├─────────────────┼─────────────┼─────────────┼──────────┼──────────┼────────┼─────────┤
|
|
264
|
+
│ a1b2c3d4-e5f... │ my-app │ opus-4.6 │ 18h 30m │ 620 │ 210.5M │ $122.40 │
|
|
265
|
+
│ f6e5d4c3-b2a... │ my-api │ sonnet-4.6 │ 8h 15m │ 195 │ 47.5M │ $28.35 │
|
|
266
|
+
└─────────────────┴─────────────┴─────────────┴──────────┴──────────┴────────┴─────────┘
|
|
267
|
+
2 sessions, 815 requests, 258.0M tokens, $150.75
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Statusline (for tmux or editor status bars):**
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
$ cctrack statusline
|
|
274
|
+
$58.30 today │ opus-4.6 │ 99.9M tok │ █████░░░ 52% 5h (2h 15m)
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**ROI analysis:**
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
$ cctrack roi --plan max5
|
|
281
|
+
|
|
282
|
+
ROI Analysis (max5 plan)
|
|
283
|
+
────────────────────────
|
|
284
|
+
Total tokens: 258.0M
|
|
285
|
+
API equivalent: $150.75
|
|
286
|
+
Subscription: $100.00/mo
|
|
287
|
+
Savings: $50.75 (33.7%)
|
|
288
|
+
Projected monthly: $2261.25
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**Blocks view:**
|
|
292
|
+
|
|
293
|
+
```
|
|
294
|
+
$ cctrack blocks
|
|
295
|
+
|
|
296
|
+
┌───────────────────┬──────────┬──────────┬────────┐
|
|
297
|
+
│ Window │ Requests │ Tokens │ Cost │
|
|
298
|
+
├───────────────────┼──────────┼──────────┼────────┤
|
|
299
|
+
│ 10:00 — 15:00 │ 142 │ 48.2M │ $28.10 │
|
|
300
|
+
│ 15:00 — 20:00 │ 98 │ 31.5M │ $18.40 │
|
|
301
|
+
└───────────────────┴──────────┴──────────┴────────┘
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Options
|
|
305
|
+
|
|
306
|
+
**Global flags** (supported by most commands):
|
|
307
|
+
|
|
308
|
+
| Flag | Description | Available on |
|
|
309
|
+
|---|---|---|
|
|
310
|
+
| `--since YYYY-MM-DD` | Filter from date | daily, monthly, session, blocks, dashboard, export, roi, live |
|
|
311
|
+
| `--until YYYY-MM-DD` | Filter to date | daily, monthly, session, blocks, dashboard, export, roi, live |
|
|
312
|
+
| `--project <name>` | Filter by project | daily, monthly, session, dashboard, export, live |
|
|
313
|
+
| `--mode <mode>` | Cost mode: `calculate` (default), `display`, `compare` | daily, monthly, session, blocks, dashboard, export, roi, live, statusline, limits |
|
|
314
|
+
| `--timezone <tz>` | Timezone for date grouping (e.g. `America/New_York`) | daily, monthly, session, dashboard, export, roi, live |
|
|
315
|
+
| `--json` | Output as JSON | daily, monthly, session, blocks, dashboard, roi, live, statusline, limits, pricing, export |
|
|
316
|
+
| `--csv` | Output as CSV | daily, monthly, session |
|
|
317
|
+
| `--breakdown` | Show per-model breakdown | daily, monthly |
|
|
318
|
+
|
|
319
|
+
**Command-specific flags:**
|
|
320
|
+
|
|
321
|
+
| Flag | Command | Description |
|
|
322
|
+
|---|---|---|
|
|
323
|
+
| `--save <path>` | dashboard | Save HTML to file without opening browser |
|
|
324
|
+
| `--interval <sec>` | live | Refresh interval in seconds (default: 5) |
|
|
325
|
+
| `--live` | blocks | Auto-refresh every 5 seconds |
|
|
326
|
+
| `--full` | session | Show full session IDs and project names (no truncation) |
|
|
327
|
+
| `--format <tpl>` | statusline | Custom format: `{cost}`, `{model}`, `{tokens}`, `{block_pct}`, `{block_remaining}` |
|
|
328
|
+
| `--no-cache` | statusline | Force fresh parse, skip 30-second cache |
|
|
329
|
+
| `--plan <name>` | roi | Plan to compare: `pro`, `max5`, `max20` (fuzzy: `20`, `100`, `200`, `max`) |
|
|
330
|
+
|
|
331
|
+
## Budget Alerts
|
|
332
|
+
|
|
333
|
+
Set daily or monthly spending budgets:
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
cctrack config set budget.daily 100
|
|
337
|
+
cctrack config set budget.monthly 2000
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
The `daily` and `live` commands show a color-coded progress bar:
|
|
341
|
+
|
|
342
|
+
```
|
|
343
|
+
Daily Budget: ████████████░░░░░░░░ 62% ($62.00 / $100.00)
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
| Level | Threshold | Color |
|
|
347
|
+
|---|---|---|
|
|
348
|
+
| Safe | < 50% | Green |
|
|
349
|
+
| Warning | 50 -- 80% | Yellow |
|
|
350
|
+
| Critical | 80 -- 100% | Red |
|
|
351
|
+
| Exceeded | > 100% | Red (flashing) |
|
|
352
|
+
|
|
353
|
+
## Pricing
|
|
354
|
+
|
|
355
|
+
cctrack maintains accurate per-token pricing for all 14 Anthropic models:
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
cctrack pricing list # View all model prices
|
|
359
|
+
cctrack pricing status # Check pricing source and freshness
|
|
360
|
+
cctrack pricing update # Force-fetch latest prices from Anthropic
|
|
361
|
+
cctrack pricing list --json # Machine-readable pricing data
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
Pricing works in two tiers:
|
|
365
|
+
|
|
366
|
+
- **Standard rate** -- Applied to the first 200K input tokens per request
|
|
367
|
+
- **Tiered rate** -- Applied to input tokens beyond 200K (typically discounted)
|
|
368
|
+
|
|
369
|
+
Prices are fetched from Anthropic's public pricing page and cached locally at `~/.cctrack/pricing.json` (refreshed every 24 hours). If the fetch fails, cctrack falls back to bundled pricing data shipped with the package.
|
|
370
|
+
|
|
371
|
+
## How It Works
|
|
372
|
+
|
|
373
|
+
cctrack reads Claude Code's JSONL usage logs from `~/.claude/projects/` and processes them in five steps:
|
|
374
|
+
|
|
375
|
+
1. **Parse** -- Validates each JSONL entry against a Zod schema, skips non-usage entries
|
|
376
|
+
2. **Deduplicate** -- Removes duplicates using requestId > messageId > content hash (3-tier)
|
|
377
|
+
3. **Resolve projects** -- Maps filesystem paths to project names, handles subagent paths
|
|
378
|
+
4. **Calculate costs** -- Applies Anthropic's per-token pricing with tiered rates at the 200K threshold
|
|
379
|
+
5. **Aggregate** -- Builds daily, monthly, session, and project views in a single pass
|
|
380
|
+
|
|
381
|
+
## Known Limitations
|
|
382
|
+
|
|
383
|
+
cctrack is built on Claude Code's local JSONL logs and has inherent accuracy boundaries. We want to be upfront about what it can and cannot tell you.
|
|
384
|
+
|
|
385
|
+
### Billable tokens vs. total tokens
|
|
386
|
+
|
|
387
|
+
Anthropic does not count `cache_read` tokens toward rate limits -- only `input` and `cache_creation` tokens are billable. cctrack's `limits` command reports billable tokens using this formula. This matters because cache-heavy sessions can show 200M+ total tokens while only 2M are actually billable. **Cost calculations use all token types at their correct per-type rates, but rate limit analysis intentionally excludes cache_read.**
|
|
388
|
+
|
|
389
|
+
### Statusline data depends on your setup
|
|
390
|
+
|
|
391
|
+
`cctrack statusline` is designed to be used as a Claude Code statusline hook (configured via `.claude/settings.json`). When configured this way, it receives real rate limit data (`used_percentage`, `resets_at`) directly from Claude Code's stdin on every assistant message. **If you run `cctrack statusline` manually from a terminal, this real-time rate limit data is not available** -- you will only see cost and token data derived from JSONL logs.
|
|
392
|
+
|
|
393
|
+
### Blocks are approximations, not Anthropic's actual windows
|
|
394
|
+
|
|
395
|
+
`cctrack blocks` groups your usage into 5-hour windows to help you see usage patterns. These windows are based on your local timestamps and do not correspond to Anthropic's internal rate limit windows. Anthropic's rate limiting involves multiple overlapping systems that are not publicly documented and cannot be reconstructed from JSONL data alone.
|
|
396
|
+
|
|
397
|
+
### Rate limit prediction is uncalibrated
|
|
398
|
+
|
|
399
|
+
cctrack includes an EMA-based predictive model for rate limit estimation, but it requires calibration data (actual rate limit events) to be accurate. Most users -- especially those on Max plans -- rarely hit rate limits, so the model will have little or no calibration data. Treat its predictions as rough estimates, not precise forecasts.
|
|
400
|
+
|
|
401
|
+
### JSONL logs don't capture everything
|
|
402
|
+
|
|
403
|
+
- **Web usage** (claude.ai) shares the same rate limit pool but is not recorded in local JSONL files
|
|
404
|
+
- **Output token counts** in JSONL may undercount actual consumption in some cases
|
|
405
|
+
- **Plan changes** (e.g., switching from Pro to Max 5x) invalidate historical rate limit estimates
|
|
406
|
+
- **Extra usage credits** extend the effective limit dynamically and are not visible in logs
|
|
407
|
+
|
|
408
|
+
### Cost estimates vs. actual billing
|
|
409
|
+
|
|
410
|
+
cctrack uses Anthropic's publicly listed per-token prices. Your actual bill may differ due to volume discounts, enterprise agreements, or pricing changes not yet reflected in cctrack's bundled price table. Always verify against your Anthropic billing dashboard.
|
|
411
|
+
|
|
412
|
+
## Configuration
|
|
413
|
+
|
|
414
|
+
Config is stored at `~/.cctrack/config.json`:
|
|
415
|
+
|
|
416
|
+
```bash
|
|
417
|
+
cctrack config set budget.daily 100 # Daily budget in $
|
|
418
|
+
cctrack config set budget.monthly 2000 # Monthly budget in $
|
|
419
|
+
cctrack config set budget.block 50 # Per 5-hour block budget in $
|
|
420
|
+
cctrack config get # View current config
|
|
421
|
+
cctrack config reset # Reset to defaults
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
**Environment variables:**
|
|
425
|
+
|
|
426
|
+
| Variable | Description | Default |
|
|
427
|
+
|---|---|---|
|
|
428
|
+
| `CLAUDE_CONFIG_DIR` | Custom Claude config directory | `~/.claude` |
|
|
429
|
+
|
|
430
|
+
## Requirements
|
|
431
|
+
|
|
432
|
+
- Node.js >= 20
|
|
433
|
+
- Claude Code installed (with usage data in `~/.claude/projects/`)
|
|
434
|
+
|
|
435
|
+
## Privacy
|
|
436
|
+
|
|
437
|
+
cctrack processes all data locally on your machine. No usage data is ever transmitted to any server. The only network request is an optional fetch of Anthropic's public pricing page to keep model prices current -- no user data is sent.
|
|
438
|
+
|
|
439
|
+
## Disclaimer
|
|
440
|
+
|
|
441
|
+
cctrack is an independent open-source project and is not affiliated with, endorsed by, or sponsored by Anthropic, PBC. "Claude" and "Claude Code" are trademarks of Anthropic, PBC.
|
|
442
|
+
|
|
443
|
+
Pricing data is sourced from Anthropic's publicly available pricing page and may not reflect the most current rates. Always verify costs against your actual Anthropic billing.
|
|
444
|
+
|
|
445
|
+
## Development
|
|
446
|
+
|
|
447
|
+
```bash
|
|
448
|
+
git clone https://github.com/azharuddinkhan3005/cctrack.git
|
|
449
|
+
cd cctrack
|
|
450
|
+
pnpm install
|
|
451
|
+
pnpm build
|
|
452
|
+
pnpm test # 280 unit tests
|
|
453
|
+
pnpm test:e2e # 14 browser tests
|
|
454
|
+
node dist/index.js daily
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the full development guide.
|
|
458
|
+
|
|
459
|
+
## License
|
|
460
|
+
|
|
461
|
+
[MIT](LICENSE)
|
|
462
|
+
|
|
463
|
+
## Contributing
|
|
464
|
+
|
|
465
|
+
Issues and PRs welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) and our [Code of Conduct](CODE_OF_CONDUCT.md) before contributing.
|