cctrack-ai 0.1.0__tar.gz

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.
@@ -0,0 +1,40 @@
1
+ # planning and local dev helpers — not for the public repo
2
+ PLAN.md
3
+ examples.sh
4
+
5
+ # python
6
+ __pycache__/
7
+ *.py[cod]
8
+ *.pyo
9
+ .venv/
10
+ venv/
11
+ env/
12
+
13
+ # build and packaging
14
+ dist/
15
+ build/
16
+ *.egg-info/
17
+ *.egg
18
+
19
+ # database (generated at runtime)
20
+ *.db
21
+ *.sqlite
22
+ *.sqlite3
23
+
24
+ # test cache
25
+ .pytest_cache/
26
+ .coverage
27
+ htmlcov/
28
+
29
+ # editor
30
+ .vscode/
31
+ .idea/
32
+ *.swp
33
+ *.swo
34
+
35
+ # os
36
+ .DS_Store
37
+ Thumbs.db
38
+
39
+ # user price overrides stay local
40
+ # (~/.config/cctrack/prices.json is outside the repo anyway)
@@ -0,0 +1,272 @@
1
+ Metadata-Version: 2.4
2
+ Name: cctrack-ai
3
+ Version: 0.1.0
4
+ Summary: Track and analyze AI token usage from Claude Code and other CLI agents
5
+ Project-URL: Homepage, https://github.com/Sk786/cctrack
6
+ Project-URL: Bug Tracker, https://github.com/Sk786/cctrack/issues
7
+ License: MIT
8
+ Keywords: ai,claude,cli,terminal,token,usage
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Utilities
18
+ Requires-Python: >=3.10
19
+ Requires-Dist: plotext>=5.2
20
+ Requires-Dist: pydantic>=2.0
21
+ Requires-Dist: rich>=13.0
22
+ Requires-Dist: typer>=0.12
23
+ Provides-Extra: dev
24
+ Requires-Dist: build>=1.0; extra == 'dev'
25
+ Requires-Dist: pytest>=8.0; extra == 'dev'
26
+ Requires-Dist: twine>=5.0; extra == 'dev'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # cctrack
30
+
31
+ Track and analyze your AI token usage from Claude Code and other CLI agents — directly in the terminal.
32
+
33
+ No API key needed. Reads local session files, stores in SQLite, shows cost breakdowns with charts.
34
+
35
+ ```
36
+ $ cctrack today
37
+
38
+ Today's Usage — Monday, June 29 2026
39
+ ╭────────────────────┬───────┬────────┬─────────────┬────────────┬──────────────┬────────────╮
40
+ │ Model │ Input │ Output │ Cache Write │ Cache Read │ Total Tokens │ Cost (USD) │
41
+ ├────────────────────┼───────┼────────┼─────────────┼────────────┼──────────────┼────────────┤
42
+ │ claude-sonnet-4-6 │ 12.4k │ 89.1k │ 640k │ 8.2M │ 9.0M │ $5.31 │
43
+ ├────────────────────┼───────┼────────┼─────────────┼────────────┼──────────────┼────────────┤
44
+ │ TOTAL │ │ │ │ │ 9.0M │ $5.31 │
45
+ ╰────────────────────┴───────┴────────┴─────────────┴────────────┴──────────────┴────────────╯
46
+ ```
47
+
48
+ ## Install
49
+
50
+ ```bash
51
+ pip install cctrack-ai
52
+ ```
53
+
54
+ Or from source:
55
+
56
+ ```bash
57
+ git clone https://github.com/yourusername/cctrack
58
+ cd cctrack
59
+ pip install -e .
60
+ ```
61
+
62
+ ## Commands
63
+
64
+ ### `cctrack today`
65
+ Token usage and cost for the current day, broken down by model. Includes a stacked token-type chart.
66
+
67
+ ```
68
+ $ cctrack today
69
+
70
+ Today's Usage — Monday, June 29 2026
71
+ ╭────────────────────┬───────┬────────┬─────────────┬────────────┬──────────────┬────────────╮
72
+ │ Model │ Input │ Output │ Cache Write │ Cache Read │ Total Tokens │ Cost (USD) │
73
+ ├────────────────────┼───────┼────────┼─────────────┼────────────┼──────────────┼────────────┤
74
+ │ claude-sonnet-4-6 │ 12.4k │ 89.1k │ 640k │ 8.2M │ 9.0M │ $5.31 │
75
+ │ claude-haiku-4-5 │ 3.1k │ 14.2k │ 120k │ 1.1M │ 1.2M │ $0.12 │
76
+ ├────────────────────┼───────┼────────┼─────────────┼────────────┼──────────────┼────────────┤
77
+ │ TOTAL │ │ │ │ │ 10.2M │ $5.43 │
78
+ ╰────────────────────┴───────┴────────┴─────────────┴────────────┴──────────────┴────────────╯
79
+
80
+ Token Breakdown by Type
81
+ ┌──────────────────────────────────────────────────────────────────────┐
82
+ │ ██ Input ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ Cache Read │
83
+ │ ██ Output │
84
+ │ ██ Cache Write │
85
+ │ ██ Cache Read │
86
+ └──────────────────────────────────────────────────────────────────────┘
87
+ ```
88
+
89
+ ### `cctrack weekly`
90
+ Last 7 days with a proportional spend bar per day and a daily cost line chart.
91
+
92
+ ```
93
+ $ cctrack weekly
94
+
95
+ Weekly Usage — Jun 23 to Jun 29, 2026
96
+ ╭────────────┬─────┬────────┬────────────┬──────────────────────────────╮
97
+ │ Date │ Day │ Tokens │ Cost (USD) │ Spend │
98
+ ├────────────┼─────┼────────┼────────────┼──────────────────────────────┤
99
+ │ 2026-06-23 │ Mon │ — │ — │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
100
+ │ 2026-06-24 │ Tue │ 3.1M │ $2.14 │ ████░░░░░░░░░░░░░░░░░░░░░░░░ │
101
+ │ 2026-06-25 │ Wed │ 820.4k │ $0.61 │ █░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
102
+ │ 2026-06-26 │ Thu │ 14.7M │ $9.88 │ ████████████████░░░░░░░░░░░░ │
103
+ │ 2026-06-27 │ Fri │ 22.3M │ $14.92 │ ████████████████████████░░░░ │
104
+ │ 2026-06-28 │ Sat │ — │ — │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
105
+ │ 2026-06-29 │ Sun │ 10.2M │ $5.43 │ █████████░░░░░░░░░░░░░░░░░░░ │
106
+ ├────────────┼─────┼────────┼────────────┼──────────────────────────────┤
107
+ │ TOTAL │ │ 51.1M │ $32.98 │ │
108
+ ╰────────────┴─────┴────────┴────────────┴──────────────────────────────╯
109
+
110
+ By Model
111
+ ─────────────────────────────────────────────────────
112
+ claude-sonnet-4-6
113
+ tokens : 47.8M
114
+ cost : $31.44
115
+ claude-haiku-4-5
116
+ tokens : 3.3M
117
+ cost : $1.54
118
+
119
+ Daily Spend (USD) — line chart
120
+ 14.9 ┤ ⢀⠔⠣⡀
121
+ │ ⡠⠊ ⠑⡄
122
+ 9.9 ┤ ⡔⠁ ⠑⢄
123
+ │ ⢠⠊ ⠈⢢
124
+ 5.0 ┤ ⢀⠔⠣⡀ ⡔⠁ ⠑⢄ ⢀⠔
125
+ │ ⡠⠊ ⠑⡄ ⡠⠊ ⠈⢢ ⡠⠊
126
+ 0.0 ┤⣀⣀⣀⡠⠤⠴⠁ ⠊ ⠑⠁ ⠑⠁
127
+ └┬───────────┬──────────┬───────────┬───────────┬
128
+ Mon/23 Tue/24 Wed/25 Thu/26 Fri/27 …
129
+ ```
130
+
131
+ ### `cctrack stats`
132
+ All-time summary across every session, sorted by cost. Includes a model cost bar chart.
133
+
134
+ ```
135
+ $ cctrack stats
136
+
137
+ All-Time Usage [2026-06-01 → 2026-06-29]
138
+ ╭────────────────────────┬────────┬────────┬─────────────┬────────────┬──────────────┬────────────╮
139
+ │ Model │ Input │ Output │ Cache Write │ Cache Read │ Total Tokens │ Cost (USD) │
140
+ ├────────────────────────┼────────┼────────┼─────────────┼────────────┼──────────────┼────────────┤
141
+ │ claude-sonnet-4-6 │ 84.3k │ 1.1M │ 8.4M │ 98.7M │ 108.3M │ $74.20 │
142
+ │ claude-haiku-4-5 │ 12.1k │ 44.2k │ 900k │ 16.3M │ 17.3M │ $2.41 │
143
+ ├────────────────────────┼────────┼────────┼─────────────┼────────────┼──────────────┼────────────┤
144
+ │ TOTAL │ │ │ │ │ 125.6M │ $76.61 │
145
+ ╰────────────────────────┴────────┴────────┴─────────────┴────────────┴──────────────┴────────────╯
146
+
147
+ Cost by Model (USD)
148
+ ────────────────────────────────────────────────────────
149
+ sonnet-4-6 ┤████████████████████████████████ $74.20
150
+ haiku-4-5 ┤██ $2.41
151
+ └─────────────────────────────────────
152
+ 0 20 40 60 80
153
+ ```
154
+
155
+ ### `cctrack projects`
156
+ Usage ranked by project, showing which directories are spending the most.
157
+
158
+ ```
159
+ $ cctrack projects
160
+
161
+ Usage by Project
162
+ ╭────────────────────────┬────────┬────────────┬─────────────┬───────────────╮
163
+ │ Project │ Tokens │ Cost (USD) │ Last Active │ Models │
164
+ ├────────────────────────┼────────┼────────────┼─────────────┼───────────────┤
165
+ │ home/user/projects/api │ 58.2M │ $38.91 │ 2026-06-29 │ sonnet │
166
+ │ home/user/projects/web │ 31.4M │ $21.07 │ 2026-06-28 │ sonnet │
167
+ │ home/user/projects/cli │ 22.1M │ $11.22 │ 2026-06-27 │ haiku, sonnet │
168
+ │ home/user/scratch │ 8.6M │ $4.19 │ 2026-06-25 │ haiku │
169
+ │ home/user/dotfiles │ 213.4k │ $0.18 │ 2026-06-22 │ sonnet │
170
+ ├────────────────────────┼────────┼────────────┼─────────────┼───────────────┤
171
+ │ TOTAL │ 120.5M │ $75.57 │ │ │
172
+ ╰────────────────────────┴────────┴────────────┴─────────────┴───────────────╯
173
+ ```
174
+
175
+ ### `cctrack prices`
176
+ Show the model pricing table and where it's loaded from.
177
+
178
+ ```
179
+ $ cctrack prices
180
+
181
+ Model Pricing (USD per 1M tokens)
182
+ ┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
183
+ ┃ Model ┃ Input ┃ Output ┃ Cache Write ┃ Cache Read ┃
184
+ ┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
185
+ │ claude-sonnet-4-6 │ $3.00 │ $15.00 │ $3.75 │ $0.30 │
186
+ │ claude-opus-4-8 │ $15.00 │ $75.00 │ $18.75 │ $1.50 │
187
+ │ claude-haiku-4-5 │ $0.80 │ $4.00 │ $1.00 │ $0.08 │
188
+ │ default (fallback) │ $3.00 │ $15.00 │ $3.75 │ $0.30 │
189
+ └────────────────────┴────────┴────────┴─────────────┴────────────┘
190
+
191
+ Loaded from: ~/.local/lib/python/site-packages/cctrack/data/prices.json
192
+ To override, copy to: ~/.config/cctrack/prices.json
193
+ ```
194
+
195
+ ### `cctrack setup`
196
+ Show all config paths and a getting-started guide.
197
+
198
+ ## Shell Prompt Integration
199
+
200
+ See today's spend on every new terminal prompt — same pattern as a git branch indicator.
201
+
202
+ **bash / zsh** — add to `~/.bashrc` or `~/.zshrc`:
203
+ ```bash
204
+ export PS1="$(cctrack-prompt) $PS1"
205
+ ```
206
+
207
+ **fish** — add to `~/.config/fish/config.fish`:
208
+ ```fish
209
+ function fish_prompt; echo (cctrack-prompt) (fish_prompt); end
210
+ ```
211
+
212
+ **Starship** — add to `~/.config/starship.toml`:
213
+ ```toml
214
+ [custom.cctrack]
215
+ command = "cctrack-prompt"
216
+ when = "true"
217
+ ```
218
+
219
+ Output looks like:
220
+ ```
221
+ [CC 10.2M · $5.43] user@host ~/projects $
222
+ ```
223
+
224
+ Format options:
225
+ ```bash
226
+ cctrack-prompt # [CC 10.2M · $5.43] (default)
227
+ cctrack-prompt --format tokens # [CC 10.2M]
228
+ cctrack-prompt --format cost # [CC $5.43]
229
+ ```
230
+
231
+ `cctrack-prompt` reads SQLite only — no JSONL parsing — and completes in ~40ms.
232
+
233
+ ## How It Works
234
+
235
+ 1. Claude Code stores full session transcripts at `~/.claude/projects/**/*.jsonl`
236
+ 2. `cctrack` parses these files and stores token counts in `~/.config/cctrack/usage.db`
237
+ 3. All commands query SQLite — fast and offline
238
+
239
+ No API key needed. Everything is local.
240
+
241
+ ## Customizing Prices
242
+
243
+ Prices are bundled at `cctrack/data/prices.json`. To override:
244
+
245
+ ```bash
246
+ mkdir -p ~/.config/cctrack
247
+ cp $(python -c "import cctrack; print(cctrack.__file__.replace('__init__.py','data/prices.json'))") \
248
+ ~/.config/cctrack/prices.json
249
+ # edit ~/.config/cctrack/prices.json
250
+ ```
251
+
252
+ cctrack always prefers your copy if it exists.
253
+
254
+ ## Cost Color Coding
255
+
256
+ All cost values are color coded consistently across every command:
257
+
258
+ | Color | Threshold |
259
+ |--------|---------------|
260
+ | Green | < $0.25 |
261
+ | Yellow | $0.25 – $1.00 |
262
+ | Red | > $1.00 |
263
+
264
+ ## Roadmap
265
+
266
+ - **v0.2** — Codex / OpenAI support via the Usage API
267
+ - **v0.3** — Gemini CLI support
268
+ - **v0.4** — Budget alerts and weekly digest
269
+
270
+ ## License
271
+
272
+ MIT
@@ -0,0 +1,244 @@
1
+ # cctrack
2
+
3
+ Track and analyze your AI token usage from Claude Code and other CLI agents — directly in the terminal.
4
+
5
+ No API key needed. Reads local session files, stores in SQLite, shows cost breakdowns with charts.
6
+
7
+ ```
8
+ $ cctrack today
9
+
10
+ Today's Usage — Monday, June 29 2026
11
+ ╭────────────────────┬───────┬────────┬─────────────┬────────────┬──────────────┬────────────╮
12
+ │ Model │ Input │ Output │ Cache Write │ Cache Read │ Total Tokens │ Cost (USD) │
13
+ ├────────────────────┼───────┼────────┼─────────────┼────────────┼──────────────┼────────────┤
14
+ │ claude-sonnet-4-6 │ 12.4k │ 89.1k │ 640k │ 8.2M │ 9.0M │ $5.31 │
15
+ ├────────────────────┼───────┼────────┼─────────────┼────────────┼──────────────┼────────────┤
16
+ │ TOTAL │ │ │ │ │ 9.0M │ $5.31 │
17
+ ╰────────────────────┴───────┴────────┴─────────────┴────────────┴──────────────┴────────────╯
18
+ ```
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ pip install cctrack-ai
24
+ ```
25
+
26
+ Or from source:
27
+
28
+ ```bash
29
+ git clone https://github.com/yourusername/cctrack
30
+ cd cctrack
31
+ pip install -e .
32
+ ```
33
+
34
+ ## Commands
35
+
36
+ ### `cctrack today`
37
+ Token usage and cost for the current day, broken down by model. Includes a stacked token-type chart.
38
+
39
+ ```
40
+ $ cctrack today
41
+
42
+ Today's Usage — Monday, June 29 2026
43
+ ╭────────────────────┬───────┬────────┬─────────────┬────────────┬──────────────┬────────────╮
44
+ │ Model │ Input │ Output │ Cache Write │ Cache Read │ Total Tokens │ Cost (USD) │
45
+ ├────────────────────┼───────┼────────┼─────────────┼────────────┼──────────────┼────────────┤
46
+ │ claude-sonnet-4-6 │ 12.4k │ 89.1k │ 640k │ 8.2M │ 9.0M │ $5.31 │
47
+ │ claude-haiku-4-5 │ 3.1k │ 14.2k │ 120k │ 1.1M │ 1.2M │ $0.12 │
48
+ ├────────────────────┼───────┼────────┼─────────────┼────────────┼──────────────┼────────────┤
49
+ │ TOTAL │ │ │ │ │ 10.2M │ $5.43 │
50
+ ╰────────────────────┴───────┴────────┴─────────────┴────────────┴──────────────┴────────────╯
51
+
52
+ Token Breakdown by Type
53
+ ┌──────────────────────────────────────────────────────────────────────┐
54
+ │ ██ Input ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ Cache Read │
55
+ │ ██ Output │
56
+ │ ██ Cache Write │
57
+ │ ██ Cache Read │
58
+ └──────────────────────────────────────────────────────────────────────┘
59
+ ```
60
+
61
+ ### `cctrack weekly`
62
+ Last 7 days with a proportional spend bar per day and a daily cost line chart.
63
+
64
+ ```
65
+ $ cctrack weekly
66
+
67
+ Weekly Usage — Jun 23 to Jun 29, 2026
68
+ ╭────────────┬─────┬────────┬────────────┬──────────────────────────────╮
69
+ │ Date │ Day │ Tokens │ Cost (USD) │ Spend │
70
+ ├────────────┼─────┼────────┼────────────┼──────────────────────────────┤
71
+ │ 2026-06-23 │ Mon │ — │ — │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
72
+ │ 2026-06-24 │ Tue │ 3.1M │ $2.14 │ ████░░░░░░░░░░░░░░░░░░░░░░░░ │
73
+ │ 2026-06-25 │ Wed │ 820.4k │ $0.61 │ █░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
74
+ │ 2026-06-26 │ Thu │ 14.7M │ $9.88 │ ████████████████░░░░░░░░░░░░ │
75
+ │ 2026-06-27 │ Fri │ 22.3M │ $14.92 │ ████████████████████████░░░░ │
76
+ │ 2026-06-28 │ Sat │ — │ — │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
77
+ │ 2026-06-29 │ Sun │ 10.2M │ $5.43 │ █████████░░░░░░░░░░░░░░░░░░░ │
78
+ ├────────────┼─────┼────────┼────────────┼──────────────────────────────┤
79
+ │ TOTAL │ │ 51.1M │ $32.98 │ │
80
+ ╰────────────┴─────┴────────┴────────────┴──────────────────────────────╯
81
+
82
+ By Model
83
+ ─────────────────────────────────────────────────────
84
+ claude-sonnet-4-6
85
+ tokens : 47.8M
86
+ cost : $31.44
87
+ claude-haiku-4-5
88
+ tokens : 3.3M
89
+ cost : $1.54
90
+
91
+ Daily Spend (USD) — line chart
92
+ 14.9 ┤ ⢀⠔⠣⡀
93
+ │ ⡠⠊ ⠑⡄
94
+ 9.9 ┤ ⡔⠁ ⠑⢄
95
+ │ ⢠⠊ ⠈⢢
96
+ 5.0 ┤ ⢀⠔⠣⡀ ⡔⠁ ⠑⢄ ⢀⠔
97
+ │ ⡠⠊ ⠑⡄ ⡠⠊ ⠈⢢ ⡠⠊
98
+ 0.0 ┤⣀⣀⣀⡠⠤⠴⠁ ⠊ ⠑⠁ ⠑⠁
99
+ └┬───────────┬──────────┬───────────┬───────────┬
100
+ Mon/23 Tue/24 Wed/25 Thu/26 Fri/27 …
101
+ ```
102
+
103
+ ### `cctrack stats`
104
+ All-time summary across every session, sorted by cost. Includes a model cost bar chart.
105
+
106
+ ```
107
+ $ cctrack stats
108
+
109
+ All-Time Usage [2026-06-01 → 2026-06-29]
110
+ ╭────────────────────────┬────────┬────────┬─────────────┬────────────┬──────────────┬────────────╮
111
+ │ Model │ Input │ Output │ Cache Write │ Cache Read │ Total Tokens │ Cost (USD) │
112
+ ├────────────────────────┼────────┼────────┼─────────────┼────────────┼──────────────┼────────────┤
113
+ │ claude-sonnet-4-6 │ 84.3k │ 1.1M │ 8.4M │ 98.7M │ 108.3M │ $74.20 │
114
+ │ claude-haiku-4-5 │ 12.1k │ 44.2k │ 900k │ 16.3M │ 17.3M │ $2.41 │
115
+ ├────────────────────────┼────────┼────────┼─────────────┼────────────┼──────────────┼────────────┤
116
+ │ TOTAL │ │ │ │ │ 125.6M │ $76.61 │
117
+ ╰────────────────────────┴────────┴────────┴─────────────┴────────────┴──────────────┴────────────╯
118
+
119
+ Cost by Model (USD)
120
+ ────────────────────────────────────────────────────────
121
+ sonnet-4-6 ┤████████████████████████████████ $74.20
122
+ haiku-4-5 ┤██ $2.41
123
+ └─────────────────────────────────────
124
+ 0 20 40 60 80
125
+ ```
126
+
127
+ ### `cctrack projects`
128
+ Usage ranked by project, showing which directories are spending the most.
129
+
130
+ ```
131
+ $ cctrack projects
132
+
133
+ Usage by Project
134
+ ╭────────────────────────┬────────┬────────────┬─────────────┬───────────────╮
135
+ │ Project │ Tokens │ Cost (USD) │ Last Active │ Models │
136
+ ├────────────────────────┼────────┼────────────┼─────────────┼───────────────┤
137
+ │ home/user/projects/api │ 58.2M │ $38.91 │ 2026-06-29 │ sonnet │
138
+ │ home/user/projects/web │ 31.4M │ $21.07 │ 2026-06-28 │ sonnet │
139
+ │ home/user/projects/cli │ 22.1M │ $11.22 │ 2026-06-27 │ haiku, sonnet │
140
+ │ home/user/scratch │ 8.6M │ $4.19 │ 2026-06-25 │ haiku │
141
+ │ home/user/dotfiles │ 213.4k │ $0.18 │ 2026-06-22 │ sonnet │
142
+ ├────────────────────────┼────────┼────────────┼─────────────┼───────────────┤
143
+ │ TOTAL │ 120.5M │ $75.57 │ │ │
144
+ ╰────────────────────────┴────────┴────────────┴─────────────┴───────────────╯
145
+ ```
146
+
147
+ ### `cctrack prices`
148
+ Show the model pricing table and where it's loaded from.
149
+
150
+ ```
151
+ $ cctrack prices
152
+
153
+ Model Pricing (USD per 1M tokens)
154
+ ┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
155
+ ┃ Model ┃ Input ┃ Output ┃ Cache Write ┃ Cache Read ┃
156
+ ┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
157
+ │ claude-sonnet-4-6 │ $3.00 │ $15.00 │ $3.75 │ $0.30 │
158
+ │ claude-opus-4-8 │ $15.00 │ $75.00 │ $18.75 │ $1.50 │
159
+ │ claude-haiku-4-5 │ $0.80 │ $4.00 │ $1.00 │ $0.08 │
160
+ │ default (fallback) │ $3.00 │ $15.00 │ $3.75 │ $0.30 │
161
+ └────────────────────┴────────┴────────┴─────────────┴────────────┘
162
+
163
+ Loaded from: ~/.local/lib/python/site-packages/cctrack/data/prices.json
164
+ To override, copy to: ~/.config/cctrack/prices.json
165
+ ```
166
+
167
+ ### `cctrack setup`
168
+ Show all config paths and a getting-started guide.
169
+
170
+ ## Shell Prompt Integration
171
+
172
+ See today's spend on every new terminal prompt — same pattern as a git branch indicator.
173
+
174
+ **bash / zsh** — add to `~/.bashrc` or `~/.zshrc`:
175
+ ```bash
176
+ export PS1="$(cctrack-prompt) $PS1"
177
+ ```
178
+
179
+ **fish** — add to `~/.config/fish/config.fish`:
180
+ ```fish
181
+ function fish_prompt; echo (cctrack-prompt) (fish_prompt); end
182
+ ```
183
+
184
+ **Starship** — add to `~/.config/starship.toml`:
185
+ ```toml
186
+ [custom.cctrack]
187
+ command = "cctrack-prompt"
188
+ when = "true"
189
+ ```
190
+
191
+ Output looks like:
192
+ ```
193
+ [CC 10.2M · $5.43] user@host ~/projects $
194
+ ```
195
+
196
+ Format options:
197
+ ```bash
198
+ cctrack-prompt # [CC 10.2M · $5.43] (default)
199
+ cctrack-prompt --format tokens # [CC 10.2M]
200
+ cctrack-prompt --format cost # [CC $5.43]
201
+ ```
202
+
203
+ `cctrack-prompt` reads SQLite only — no JSONL parsing — and completes in ~40ms.
204
+
205
+ ## How It Works
206
+
207
+ 1. Claude Code stores full session transcripts at `~/.claude/projects/**/*.jsonl`
208
+ 2. `cctrack` parses these files and stores token counts in `~/.config/cctrack/usage.db`
209
+ 3. All commands query SQLite — fast and offline
210
+
211
+ No API key needed. Everything is local.
212
+
213
+ ## Customizing Prices
214
+
215
+ Prices are bundled at `cctrack/data/prices.json`. To override:
216
+
217
+ ```bash
218
+ mkdir -p ~/.config/cctrack
219
+ cp $(python -c "import cctrack; print(cctrack.__file__.replace('__init__.py','data/prices.json'))") \
220
+ ~/.config/cctrack/prices.json
221
+ # edit ~/.config/cctrack/prices.json
222
+ ```
223
+
224
+ cctrack always prefers your copy if it exists.
225
+
226
+ ## Cost Color Coding
227
+
228
+ All cost values are color coded consistently across every command:
229
+
230
+ | Color | Threshold |
231
+ |--------|---------------|
232
+ | Green | < $0.25 |
233
+ | Yellow | $0.25 – $1.00 |
234
+ | Red | > $1.00 |
235
+
236
+ ## Roadmap
237
+
238
+ - **v0.2** — Codex / OpenAI support via the Usage API
239
+ - **v0.3** — Gemini CLI support
240
+ - **v0.4** — Budget alerts and weekly digest
241
+
242
+ ## License
243
+
244
+ MIT
File without changes
@@ -0,0 +1,38 @@
1
+ import json
2
+ import platform
3
+ from pathlib import Path
4
+
5
+ _BUNDLED_PRICES = Path(__file__).parent / "data" / "prices.json"
6
+ _USER_PRICES = Path.home() / ".config" / "cctrack" / "prices.json"
7
+
8
+
9
+ def load_prices() -> dict:
10
+ path = _USER_PRICES if _USER_PRICES.exists() else _BUNDLED_PRICES
11
+ with open(path) as f:
12
+ data = json.load(f)
13
+ data["_source"] = str(path)
14
+ return data
15
+
16
+
17
+ def get_pricing(model: str) -> tuple[dict[str, float], str]:
18
+ """Return (price_dict, source_path) for a model name."""
19
+ data = load_prices()
20
+ models: dict = data.get("models", {})
21
+ for key, prices in models.items():
22
+ if model.startswith(key):
23
+ return prices, data["_source"]
24
+ return data["default"], data["_source"]
25
+
26
+
27
+ def get_claude_projects_dir() -> Path:
28
+ if platform.system() == "Windows":
29
+ return Path.home() / "AppData" / "Roaming" / "Claude" / "projects"
30
+ return Path.home() / ".claude" / "projects"
31
+
32
+
33
+ def get_user_prices_path() -> Path:
34
+ return _USER_PRICES
35
+
36
+
37
+ def get_bundled_prices_path() -> Path:
38
+ return _BUNDLED_PRICES
@@ -0,0 +1,30 @@
1
+ {
2
+ "_comment": "Prices in USD per 1,000,000 tokens. Source: https://anthropic.com/pricing",
3
+ "_updated": "2026-06-24",
4
+ "models": {
5
+ "claude-sonnet-4-6": {
6
+ "input": 3.00,
7
+ "output": 15.00,
8
+ "cache_write": 3.75,
9
+ "cache_read": 0.30
10
+ },
11
+ "claude-opus-4-8": {
12
+ "input": 15.00,
13
+ "output": 75.00,
14
+ "cache_write": 18.75,
15
+ "cache_read": 1.50
16
+ },
17
+ "claude-haiku-4-5": {
18
+ "input": 0.80,
19
+ "output": 4.00,
20
+ "cache_write": 1.00,
21
+ "cache_read": 0.08
22
+ }
23
+ },
24
+ "default": {
25
+ "input": 3.00,
26
+ "output": 15.00,
27
+ "cache_write": 3.75,
28
+ "cache_read": 0.30
29
+ }
30
+ }