claude-code-cost 0.9.0 → 0.10.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 +23 -74
- package/package.json +1 -1
- package/server.js +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
[](LICENSE)
|
|
5
5
|
[](https://www.npmjs.com/package/claude-code-cost)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**[Live Demo & Docs](https://nikiforovall.blog/claude-code-cost/)**
|
|
8
|
+
|
|
9
|
+
> Know what [Claude Code](https://docs.anthropic.com/en/docs/claude-code) costs you — per day, per project, per session.
|
|
10
|
+
|
|
11
|
+

|
|
8
12
|
|
|
9
13
|
## Getting Started
|
|
10
14
|
|
|
@@ -12,90 +16,35 @@
|
|
|
12
16
|
npx claude-code-cost --open
|
|
13
17
|
```
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
That's it. No hooks, no config — the dashboard reads your existing Claude Code session files.
|
|
18
|
-
|
|
19
|
-
### Overview
|
|
20
|
-
|
|
21
|
-

|
|
22
|
-

|
|
23
|
-
|
|
24
|
-
### Projects
|
|
19
|
+
That's it — no hooks, no config. The dashboard reads the JSONL session logs Claude Code already writes to `~/.claude/projects/` and aggregates them server-side. Completely read-only; nothing leaves your machine.
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-

|
|
21
|
+
## Features
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
- **Top-down drill-down** — total → project → session → message; every number is one click from its breakdown
|
|
24
|
+
- **Dynamic pricing** — live model prices from [LiteLLM](https://github.com/BerriAI/litellm) with tiered pricing (200K threshold), cache token costs, and fast mode multipliers; offline fallback included
|
|
25
|
+
- **Daily cost chart** — configurable range from 1 day to 1 year
|
|
26
|
+
- **Cost by model** — see how spend splits across Opus, Sonnet, and Haiku
|
|
27
|
+
- **Cache efficiency** — cache reads vs. fresh input tokens across sessions
|
|
28
|
+
- **Session detail** — cumulative cost curve, stacked token bars, per-message table with model, tools, and running total
|
|
29
|
+
- **Accurate accounting** — same pricing logic as [ccusage](https://github.com/ryoppippi/ccusage): pre-calculated `costUSD` when present, deduplication by `messageId + requestId`
|
|
30
|
+
- **17 color themes** — Ember, Gruvbox, Catppuccin, Tokyo Night, Dracula, Nord, and more — each in light and dark, PWA installable
|
|
31
|
+
- **Hub integration** — runs standalone or as a tab in [Claude Code Hub](https://github.com/NikiforovAll/claude-code-hub) alongside Kanban, Marketplace, and Memory
|
|
30
32
|
|
|
31
|
-

|
|
33
|
+

|
|
33
34
|
|
|
34
|
-
|
|
35
|
+

|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
- **Dynamic pricing** — Fetches live model prices from [LiteLLM](https://github.com/BerriAI/litellm), supports tiered pricing (200K threshold), cache token costs, and fast mode multipliers
|
|
38
|
-
- **Daily cost chart** — Bar chart with cumulative line, configurable date range (1d / 3d / 7d / 30d / 90d / 1y)
|
|
39
|
-
- **Model distribution** — Donut chart showing cost breakdown by model
|
|
40
|
-
- **Cache efficiency** — Track how well prompt caching is working across your sessions
|
|
41
|
-
- **Project breakdown** — See which projects cost the most, sortable by cost, sessions, or activity
|
|
42
|
-
- **Session detail** — Message-level cost breakdown with cumulative cost and token stacked bar charts
|
|
43
|
-
- **Dark & light theme** — Matches the Claude Code Hub design system
|
|
44
|
-
- **Hub integration** — Works as a tab in Claude Code Hub alongside Kanban and Marketplace
|
|
45
|
-
- **Instant reload** — API responses cached in browser; Refresh button for fresh data
|
|
37
|
+

|
|
46
38
|
|
|
47
39
|
## Configuration
|
|
48
40
|
|
|
49
|
-
```bash
|
|
50
|
-
PORT=8080 npx claude-code-cost # Custom port
|
|
51
|
-
npx claude-code-cost --open # Auto-open browser
|
|
52
|
-
npx claude-code-cost --dir=~/.claude-work # Custom Claude config dir
|
|
53
41
|
```
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
### Global install
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
npm install -g claude-code-cost
|
|
61
|
-
claude-code-cost --open
|
|
42
|
+
--port <number> Custom port (default: 3543, falls back if busy)
|
|
43
|
+
--dir <path> Custom Claude config dir (default: ~/.claude)
|
|
44
|
+
--open Open browser on start
|
|
62
45
|
```
|
|
63
46
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Claude Code writes conversation logs to `~/.claude/projects/` as JSONL files. Each assistant response includes token counts (`input_tokens`, `output_tokens`, `cache_creation_input_tokens`, `cache_read_input_tokens`) and model info.
|
|
67
|
-
|
|
68
|
-
The dashboard:
|
|
69
|
-
1. **Reads** JSONL session files (streamed line-by-line for large files)
|
|
70
|
-
2. **Fetches** live model pricing from LiteLLM (cached 6h, offline fallback included)
|
|
71
|
-
3. **Calculates** cost per message using tiered pricing with 200K token threshold
|
|
72
|
-
4. **Aggregates** by day, project, and session — all server-side
|
|
73
|
-
5. **Renders** with Chart.js — no build step, vanilla JS
|
|
74
|
-
|
|
75
|
-
Nothing is modified — the dashboard is read-only.
|
|
76
|
-
|
|
77
|
-
### Cost Calculation
|
|
78
|
-
|
|
79
|
-
Uses the same pricing logic as [ccusage](https://github.com/ryoppippi/ccusage):
|
|
80
|
-
|
|
81
|
-
- **Auto mode** — Uses pre-calculated `costUSD` from JSONL when available, otherwise calculates from tokens
|
|
82
|
-
- **Tiered pricing** — Tokens above 200K threshold charged at higher rate (Claude 1M context models)
|
|
83
|
-
- **Fast mode** — Applies provider-specific multiplier for fast/streaming responses
|
|
84
|
-
- **Deduplication** — Skips duplicate messages by `messageId + requestId` hash
|
|
85
|
-
|
|
86
|
-
## FAQ
|
|
87
|
-
|
|
88
|
-
**Where does pricing data come from?**
|
|
89
|
-
Live from [LiteLLM's pricing dataset](https://github.com/BerriAI/litellm) (2000+ models). Cached for 6 hours. If the fetch fails, a bundled offline snapshot of Claude model prices is used.
|
|
90
|
-
|
|
91
|
-
**Does it work offline?**
|
|
92
|
-
Yes. The offline pricing fallback covers all current Claude models. PWA support included.
|
|
93
|
-
|
|
94
|
-
**Does it modify any files?**
|
|
95
|
-
No. Completely read-only — only reads JSONL files from `~/.claude/projects/`.
|
|
96
|
-
|
|
97
|
-
**Does it work with Claude Code Hub?**
|
|
98
|
-
Yes. Exposes `/hub-config` endpoint and forwards keyboard shortcuts (Ctrl+Alt+Arrow, Alt+1-9) to the hub parent frame.
|
|
47
|
+
The config dir can also be set via the `CLAUDE_CONFIG_DIR` environment variable.
|
|
99
48
|
|
|
100
49
|
## License
|
|
101
50
|
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -19,7 +19,7 @@ function getArg(name) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const PORT = getArg('port') || process.env.PORT || 3543;
|
|
22
|
-
const claudeDirArg = getArg('dir');
|
|
22
|
+
const claudeDirArg = getArg('dir') || process.env.CLAUDE_CONFIG_DIR || process.env.CLAUDE_DIR;
|
|
23
23
|
const CLAUDE_DIR = claudeDirArg
|
|
24
24
|
? claudeDirArg.replace(/^~/, os.homedir())
|
|
25
25
|
: path.join(os.homedir(), '.claude');
|