Sign inSign up

vikas9dev/ccusage

By vikas9dev

โ€ขUpdated 5 months ago

Local dashboard to visualize Claude Code token usage, costs, and activity from ~/.claude data.

Image
Developer tools
0

507

vikas9dev/ccusage repository overview

โ ๐Ÿ“Š ccusage

Your Claude Code usage, beautifully visualized โ€” right on your machine.

Track every token, every cost, every project. Fully offline. No API key. No cloud. Just your data.

Stack License Docker Platform

๐Ÿ”— GitHubโ  ยท ๐Ÿณ Docker Hubโ 


โ ๐Ÿ–ผ๏ธ Screenshot

Claude Usage Dashboard


โ โœจ Features

FeatureDetails
๐Ÿ—‚๏ธPer-project breakdownInput / Output / Cache Write / Cache Read tokens
๐Ÿ’ฐCost estimationAPI-equivalent cost across Opus, Sonnet & Haiku
๐Ÿ•Period filters12H ยท 1D ยท 7D ยท 15D ยท 30D ยท 3M ยท All-time
โšกCache hit rateSee exactly how much you save via prompt caching
๐Ÿ“ˆActivity chartsDaily & hourly views with cost-per-day toggle
๐Ÿง Conversation depthAvg message depth per project
๐Ÿท๏ธModel mix badgesOpus / Sonnet / Haiku usage per project
๐Ÿ”Project searchInstantly filter across all your projects
๐Ÿ“ฅCSV exportDownload your full usage data
๐Ÿ”„Auto-refreshLive updates every 30 seconds

โ ๐Ÿง Linux / ๐ŸŽ macOS
docker run -d \
  --name ccusage \
  -p 9001:9001 \
  -v ~/.claude:/claude-data:ro \
  -e CLAUDE_DATA_DIR=/claude-data \
  vikas9dev/ccusage:latest
โ ๐ŸชŸ Windows โ€” PowerShell
docker run -d `
  --name ccusage `
  -p 9001:9001 `
  -v "$env:USERPROFILE\.claude:/claude-data:ro" `
  -e CLAUDE_DATA_DIR=/claude-data `
  vikas9dev/ccusage:latest
โ ๐ŸชŸ Windows โ€” CMD
docker run -d ^
  --name ccusage ^
  -p 9001:9001 ^
  -v "%USERPROFILE%\.claude:/claude-data:ro" ^
  -e CLAUDE_DATA_DIR=/claude-data ^
  vikas9dev/ccusage:latest

Then open ๐Ÿ‘‰ http://localhost:9001โ 


โ ๐Ÿ™ Docker Compose

Create a docker-compose.yml anywhere and run docker compose up -d:

services:
  ccusage:
    image: vikas9dev/ccusage:latest
    ports:
      - "9001:9001"
    volumes:
      - "${CLAUDE_DATA_DIR:-~/.claude}:/claude-data:ro"
    environment:
      - CLAUDE_DATA_DIR=/claude-data
    restart: unless-stopped

๐Ÿ’ก Windows users: replace ~/.claude with C:\Users\<YourName>\.claude in the volumes line, or set CLAUDE_DATA_DIR as an environment variable before running.

docker stop ccusage && docker rm ccusage   # ๐Ÿ›‘ stop & remove

โ ๐Ÿ› ๏ธ Local Development (without Docker)

โ Prerequisites
  • ๐Ÿ Python 3.11+
  • ๐ŸŸข Node.js 18+
โ Setup & Run
git clone https://github.com/vikas9dev/ccusage
cd ccusage
cd frontend && npm install && cd ..
bash start.sh      # ๐Ÿš€ starts backend + frontend
ServiceURL
๐Ÿ”ง Backend APIhttp://localhost:9001โ 
๐ŸŽจ Frontend UIhttp://localhost:5173โ 
bash stop.sh       # ๐Ÿ›‘ stop both
bash restart.sh    # ๐Ÿ” restart both
โ โš™๏ธ Configuration

Copy and edit .env (optional โ€” defaults work out of the box):

BACKEND_PORT=9001
FRONTEND_PORT=5173
CLAUDE_DATA_DIR=~/.claude

โ ๐Ÿ—๏ธ Build Your Own Docker Image

# ๐Ÿ”จ Build
docker build -t ccusage .

# โ–ถ๏ธ Run locally
docker run -d \
  --name ccusage \
  -p 9001:9001 \
  -v ~/.claude:/claude-data:ro \
  -e CLAUDE_DATA_DIR=/claude-data \
  ccusage
โ ๐Ÿ“ค Push to Docker Hub
docker login
docker tag ccusage vikas9dev/ccusage:latest
docker tag ccusage vikas9dev/ccusage:1.0.0
docker push vikas9dev/ccusage:latest
docker push vikas9dev/ccusage:1.0.0
โ ๐ŸŒ Multi-platform Build (Intel + Apple Silicon)
# One-time setup
docker buildx create --use --name multiarch

# Build & push amd64 + arm64 simultaneously
docker buildx build \
  --platform linux/amd64,linux/arm64 \
  -t vikas9dev/ccusage:latest \
  -t vikas9dev/ccusage:1.0.0 \
  --push .

โ ๐Ÿ” How It Works

ccusage reads three local files written by Claude Code โ€” nothing leaves your machine:

๐Ÿ“„ FileWhat it provides
~/.claude/history.jsonlPer-message project + session timestamps
~/.claude/projects/<dir>/*.jsonlToken usage per session (deduplicated by message ID)
~/.claude/stats-cache.jsonAll-time global aggregates (sessions, messages, model totals)

๐Ÿ’ก Cost shown is API equivalent cost โ€” what your usage would cost on pay-per-token billing. If you're on a flat subscription, your actual charge is your monthly plan fee.


โ ๐Ÿ’ต Pricing Reference

ModelInputOutputCache WriteCache Read
๐ŸŸฃ Claude Opus 4$15/M$75/M$18.75/M$1.50/M
๐Ÿ”ต Claude Sonnet 4.6$3/M$15/M$3.75/M$0.30/M
๐ŸŸข Claude Haiku 4.5$0.80/M$4/M$1.00/M$0.08/M

Prices per million tokens. Source: Anthropic pricingโ 


โ ๐Ÿ”ง Environment Variables

VariableDefaultDescription
CLAUDE_DATA_DIR~/.claude๐Ÿ“ Path to your Claude Code data directory
BACKEND_PORT9001๐Ÿ”Œ Port for the backend API and frontend
FRONTEND_PORT5173๐ŸŽจ Frontend dev server port (local dev only)

โ ๐Ÿ“œ License

MIT ยฉ vikas9devโ 

Tag summary

Content type

Image

Digest

sha256:cf6d4063aโ€ฆ

Size

43.5 MB

Last updated

5 months ago

docker pull vikas9dev/ccusage