Skip to main content

Claude Code usage-per-project status line and tracker

Project description

claude-code-usage-per-project (ccupp)

A Claude Code status line and usage tracker that shows per-project efficiency metrics — messages, tokens, cost, and API time — across all sessions for the current working directory.

pip install ccupp && ccupp install

(Requirements: Python 3.6+)

What it does

1. Status line (piped from Claude Code)

status-line

  • Line 1: Model name — effort level — context-window bar (green/yellow/red at 70%/90%)
  • Line 2: Project name — [N msg] user messages sent — [Nk tok] tokens used — [$N.NN] cost — [XhYm] total API response time (all cumulative for the session)

2. Usage report (run directly in terminal)

$ ccupp

Prints a boxed per-session table for the project in the current directory:

myproject — Claude Code usage (per project)

╭──────────────┬─────────────────┬──────────┬────────┬───────┬─────────╮
│ SESSION      │ DATE            │ USER_MSG │ TOKENS │  COST │    TIME │
├──────────────┼─────────────────┼──────────┼────────┼───────┼─────────┤
│ 9beb422a     │ 2026-05-30 12:00│       12 │  84.2k │ $1.83 │  6m12s  │
│ 0ec212f4~    │ 2026-05-29 09:15│        8 │  51.0k │ $0.94 │  4m30s  │
├──────────────┼─────────────────┼──────────┼────────┼───────┼─────────┤
│ TOTAL        │                 │       20 │ 135.2k │ $2.77 │ 10m42s  │
╰──────────────┴─────────────────┴──────────┴────────┴───────┴─────────╯
  ~ = backfill estimate (cost·time approximate)

3. Daily breakdown (run directly in terminal)

$ ccupp --daily

Same current-project scope as the usage report, but grouped by local calendar day instead of by session — recomputed from the raw transcripts so each request's tokens, cost, and time land on the day it happened:

myproject — Claude Code usage by day

╭────────────┬──────────┬────────┬───────┬─────────╮
│ DATE       │ USER_MSG │ TOKENS │  COST │    TIME │
├────────────┼──────────┼────────┼───────┼─────────┤
│ 2026-05-29 │        8 │  51.0k │ $0.94 │  4m30s  │
│ 2026-05-30 │       12 │  84.2k │ $1.83 │  6m12s  │
├────────────┼──────────┼────────┼───────┼─────────┤
│ TOTAL      │       20 │ 135.2k │ $2.77 │ 10m42s  │
╰────────────┴──────────┴────────┴───────┴─────────╯

4. Model breakdown (run directly in terminal)

$ ccupp --model

The current project's usage split per model, sorted by cost (highest first) — useful for seeing where spend concentrates between Opus, Sonnet, and Haiku:

myproject — Claude Code usage by model

╭───────────────────┬──────┬────────┬───────╮
│ MODEL             │ REQS │ TOKENS │  COST │
├───────────────────┼──────┼────────┼───────┤
│ claude-opus-4-7   │   38 │  96.1k │ $2.41 │
│ claude-sonnet-4-6 │   21 │  39.1k │ $0.36 │
├───────────────────┼──────┼────────┼───────┤
│ TOTAL             │   59 │ 135.2k │ $2.77 │
╰───────────────────┴──────┴────────┴───────╯

5. All-projects comparison (run directly in terminal)

$ ccupp --all

Prints a boxed comparison table with one row per project across every project ccupp has tracked, sorted by cost (highest first). Projects spread across renamed folders are merged into a single row via their git identity:

Claude Code usage — all projects

╭───────────┬──────────┬──────────┬────────┬─────────┬───────╮
│ PROJECT   │ SESSIONS │ USER_MSG │ TOKENS │    COST │  TIME │
├───────────┼──────────┼──────────┼────────┼─────────┼───────┤
│ myproject │       20 │      548 │ 101.7M │  $59.97 │ 2h58m │
│ ccupp     │        4 │      109 │ 148.1M │  $48.46 │ 4h15m │
│ blog      │       13 │      123 │  66.2M │  $24.36 │ 1h29m │
├───────────┼──────────┼──────────┼────────┼─────────┼───────┤
│ TOTAL     │       37 │      780 │ 316.0M │ $132.79 │ 8h42m │
╰───────────┴──────────┴──────────┴────────┴─────────┴───────╯

6. Prompt export (run directly in terminal)

$ ccupp --export

Exports every human prompt you typed (filtering out tool results, system messages, UI slash commands like /usage or /model, interrupt markers) to PROMPTS.md as a chronological Markdown document.

✅ ./PROMPTS.md
   3 sessions · 47 prompts
# myproject — Prompts

Generated 2026-05-30 12:00 · 2 sessions · 3 prompts

## Session 1 · 2026-05-29 09:15 · `0ec212f4`

2 prompts

**1.**

> refactor the auth module to use JWT

**2.**

> add unit tests for the new token validation logic

---

## Session 2 · 2026-05-30 12:00 · `9beb422a`

1 prompt

**1.**

> how does the session snapshot work?

7. Help and version (run directly in terminal)

$ ccupp --help      # or -h
$ ccupp --version   # or -v

--help lists every mode (the bare ccupp default report, --daily, --model, --all, --export, and install). --version prints the installed version:

$ ccupp --version
ccupp 0.2.2

How it works

Cumulative totals and project identity

Each session writes a snapshot file to .ccupp/sessions/<session_id>.json inside the Claude transcript directory. The current session's snapshot is overwritten on every render (idempotent). Past sessions without a snapshot are backfill-estimated from the raw .jsonl transcript — these are marked with ~ in the report, and their cost and time are approximate.

A backfill snapshot is a cache, not a write-once file: it records the byte size of the transcript it was computed from (src_size), and is recomputed whenever the transcript grows past that size. This keeps backfill totals consistent with the --daily/--model recompute even if a session's snapshot was first written mid-session. Live snapshots (exact cost/time from Claude Code's stdin) are never invalidated.

To accumulate totals across sessions, ccupp resolves a stable project identity from git:

  1. Remote URL — normalized and SHA-1 hashed (remote:<hash>)
  2. First commit SHA — used when there's no remote (commit:<sha>)
  3. Current directory only — fallback when there's no git history

The identity → list of transcript directories mapping is stored in ~/.ccupp/registry.json. This means totals are preserved across folder renames as long as the git identity is stable.

How each metric is calculated

Modeled on ccusage's approach:

  • Messages — user-type entries, excluding tool results, meta/sidechain messages, and short UI commands (e.g. /usage, /model)
  • Tokens — sum of input, cache_creation_input, cache_read_input, and output tokens across deduplicated assistant messages. Deduplication is by (message.id, requestId); when keys collide, non-sidechain wins, then larger token total wins.
  • Cost — live sessions use total_cost_usd from Claude Code's stdin directly. Backfill uses ccusage Auto mode: costUSD field per entry if present, otherwise computed from tokens × per-model rates from LiteLLM's pricing file, cached at ~/.ccupp/litellm-pricing.json for 24h.
  • Time — live sessions use total_api_ms from stdin. Backfill estimates by measuring the gap between each user message timestamp and the last assistant message timestamp for the same requestId.

The per-session report and all-projects comparison read these cached snapshots. The --daily and --model breakdowns instead recompute from the raw transcripts every time (snapshots only carry session totals, not per-day or per-model splits), reusing the same deduplication and Auto-mode cost model — so their totals reconcile with the per-session report. Dates in --daily are bucketed by your local timezone, matching the report's local-time dates.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ccupp-0.2.4.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ccupp-0.2.4-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file ccupp-0.2.4.tar.gz.

File metadata

  • Download URL: ccupp-0.2.4.tar.gz
  • Upload date:
  • Size: 35.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for ccupp-0.2.4.tar.gz
Algorithm Hash digest
SHA256 a4c58c7a9c69dd28644743bf18b3c56585ed98e6e7bc3055ad5b8fc3cf13d9c3
MD5 b1714a425b57445ee0803100c59c5e4f
BLAKE2b-256 3b2a749a5538c8468be369ad08f13b05b9be566663751d0599ad6023cb4640ce

See more details on using hashes here.

File details

Details for the file ccupp-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: ccupp-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for ccupp-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 533417912a993a928544837b87469708690988d6773ed9b6c625908fa4709647
MD5 ae5fbdd30cca8d04e1af93dac3ef7a12
BLAKE2b-256 e1c191130f874237c6c12cdd753804cbad32b61f4fa8519b5ed2fc0934274dde

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page