cctrack

command module
v0.0.0-...-3789308 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 3 Imported by: 0

README

cctrack

A cost tracker for Claude Code. Parses your local JSONL logs, calculates spend per session/project/model, and serves a real-time dashboard — all from a single binary.

Features

  • Cost tracking — today, this week, this month, and projected monthly spend
  • Session explorer — browse every Claude Code session with token and cost breakdowns
  • Project breakdown — see spend grouped by project, with monthly trends
  • Model breakdown — usage and cost per model (Opus, Sonnet, Haiku)
  • Activity heatmap — visualize when you're using Claude Code most
  • Request timeline — per-request token usage within each session
  • Real-time updates — file watcher + WebSocket push when new activity is detected
  • Budget tracking — set a monthly budget and see progress against it
  • Single binary — Go CLI with an embedded Vue 3 SPA, no separate frontend server needed

Installation

From source
git clone https://github.com/ksred/cctrack.git
cd cctrack
cd web && npm install && npm run build && cd ..
go build -o cctrack .
Go install
# Requires the web/dist directory to be pre-built
go install github.com/ksred/cctrack@latest

Usage

Start the dashboard
cctrack serve

Opens a web dashboard on http://localhost:8877 with real-time cost tracking. Parses logs on startup and watches for new activity.

Parse logs manually
cctrack parse

Scans ~/.claude/projects/ for JSONL log files and updates the SQLite database.

Quick status
cctrack status

Prints today/week/month spend and your most expensive session to stdout.

View configuration
cctrack config

How it works

  1. Claude Code writes JSONL logs to ~/.claude/projects/<project>/<session>.jsonl
  2. cctrack scans these files, extracts token usage from assistant messages, and deduplicates by requestId
  3. Costs are calculated using Anthropic's published per-token rates for each model
  4. Data is stored in a local SQLite database (~/.config/cctrack/cctrack.db)
  5. The serve command starts an HTTP server with a REST API and embedded Vue SPA
  6. A file watcher detects new log activity and pushes updates via WebSocket

Configuration

Config is stored at ~/.config/cctrack/config.json:

{
  "log_dir": "~/.claude/projects",
  "db_path": "~/.config/cctrack/cctrack.db",
  "port": 8877,
  "monthly_budget_usd": 200,
  "open_browser_on_serve": true
}

All settings can also be changed from the dashboard's settings page.

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
api
hub

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL