Skip to content

backstabslash/goccc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

34 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CI Zero Dependencies Go Report Card Latest Release License: MIT

A fast, zero-dependency CLI cost calculator, tool analytics, and customizable statusline for Claude Code. Breakdowns by model, day, project, and branch. Single binary, no runtime needed.

demo

Table of Contents

Installation

Homebrew (macOS / Linux)

brew install backstabslash/tap/goccc

Go install

go install github.com/backstabslash/goccc@latest

Pre-built binaries

Available on the releases page for macOS, Linux, and Windows (amd64 / arm64).

From source

git clone https://github.com/backstabslash/goccc.git && cd goccc
go build -o goccc .     # macOS / Linux
go build -o goccc.exe . # Windows

Usage

goccc                              # Summary of all-time usage
goccc -days 7 -all                 # Last 7 days with daily and project breakdowns
goccc -daily                       # Daily breakdown only
goccc -monthly                     # Monthly breakdown
goccc -projects                    # Project breakdown only
goccc -project webapp -daily       # Filter by project name (substring match)
goccc -days 1                      # Today's usage
goccc -projects -top 5             # Top 5 most expensive projects
goccc -days 30 -all -json          # JSON output for scripting
goccc -json | jq '.summary.total_cost'  # Pipe to jq for custom analysis
goccc -currency-symbol "€" -currency-rate 0.92  # One-off currency override
goccc -tools -days 30             # Tool & skill usage analytics
goccc -tools -project myapp -json # Tool analytics filtered by project, as JSON

Claude Code Statusline

goccc can serve as a Claude Code statusline β€” a fully customizable, live cost dashboard right in your terminal prompt.

πŸ’Έ $1.23 session Β· πŸ’° $5.67 today Β· πŸ’­ 45% ctx Β· πŸ”Œ 2 MCPs (confluence, jira) Β· πŸ”‹ 94% (1.5/5h) Β· πŸ€– Opus 4.6
  • πŸ’Έ Session cost β€” parsed from the current session's JSONL files using goccc's pricing table
  • πŸ’° Today's total β€” aggregated across all sessions today (shown only when higher than session cost)
  • πŸ’­ Context % β€” context window usage percentage
  • πŸ”Œ MCPs β€” active MCP servers (from settings, marketplace plugins, and project config; respects per-project disables)
  • πŸ”‹ 5h / 7d window β€” remaining percentage of the usage window with elapsed time (subscription users only; hidden for API billing). Emoji switches to πŸͺ« below 25%
  • πŸ€– Model β€” current model

Values are color-coded: cost and context turn yellow β†’ red as they increase; rate limit windows are inverted β€” yellow below 50%, red below 25% remaining.

Setup

Add to ~/.claude/settings.json:

{
  "statusLine": {
    "type": "command",
    "command": "goccc -statusline"
  }
}

Works with any install method. To run without installing: go run github.com/backstabslash/goccc@latest -statusline.

Customization

The statusline is fully customizable via ~/.goccc.json. With no config, you get the default layout shown above.

{
  "statusline": {
    "segments": ["session_cost", "today_cost", "ctx", "model", "|", "5h", "cwd", "branch"],
    "separator": " Β· ",
    "segment_options": {
      "session_cost": { "emoji": "πŸ€‘", "label": "sess" },
      "today_cost": { "label": "day" },
      "ctx": { "emoji": "🧠", "label": "context" },
      "5h": { "emoji": "⏳" },
      "branch": { "emoji": "πŸ”€" }
    }
  }
}

segments β€” ordered list of segments to display. Only listed segments are shown; segments with no data auto-hide. "|" forces a line break.

The config above produces:

πŸ€‘ $1.23 sess Β· πŸ’° $5.67 day Β· 🧠 45% context Β· πŸ€– Opus 4.6
⏳ 94% (1.5/5h) Β· πŸ“ my-project Β· πŸ”€ feature/auth

Available segments:

Segment Default Auto-hides when Overrides
session_cost πŸ’Έ $X.XX session cost is $0 emoji, label
today_cost πŸ’° $X.XX today cost is $0 emoji, label
ctx πŸ’­ XX% ctx β€” emoji, label
model πŸ€– Model Name β€” emoji
mcp πŸ”Œ N MCPs (...) no MCPs detected emoji, label
branch 🌿 branch-name no branch emoji
5h πŸ”‹ XX% (X/5h) absent (API billing) emoji
7d πŸ”‹ XX% (X/7d) absent (API billing) emoji
tokens πŸ“Š XK in / XK out both zero emoji
lines πŸ“ +N -N both zero emoji
duration ⏱️ Xm zero emoji
cwd πŸ“ dirname empty emoji
version 🏷️ X.Y.Z empty emoji

separator β€” string between segments (default: " Β· ").

segment_options β€” per-segment overrides. emoji replaces the default icon (for 5h/7d, replaces the dynamic πŸ”‹/πŸͺ«). label replaces trailing text (only on segments marked above).

Session Exit Hook

goccc can show a cost summary when a Claude Code session ends β€” the feature users miss most since Anthropic removed it.

πŸ’Έ $1.87 session (14 reqs, 23m) Β· πŸ’° $12.34 today Β· πŸ€– Opus 4.6, Haiku 4.5

Add to ~/.claude/settings.json:

{
  "hooks": {
    "SessionEnd": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "goccc -session-end"
          }
        ]
      }
    ]
  }
}

The hook runs within Claude Code's 1.5-second timeout. If anything fails, it exits silently β€” it will never break session teardown.

Tool & Skill Analytics

The -tools flag shows how often each tool and skill was invoked across your sessions β€” useful for understanding your workflow patterns, auditing MCP tool usage, and spotting unused skills.

goccc -tools                    # All-time tool usage
goccc -tools -days 7            # Last 7 days
goccc -tools -project myapp     # Filter by project
goccc -tools -top 5             # Top 5 in each breakdown
goccc -tools -json              # JSON output for scripting
────────────────────────────────────────────────────────────────────────────────
  TOOL BREAKDOWN (3,960 total, 24 unique, 82 sessions)
────────────────────────────────────────────────────────────────────────────────
  Tool                                     Invocations     Errors     Projects
  ────────────────────────────────────────────────────────────────────────────
  Bash                                           1,373       5.1%           12
  Read                                           1,231       4.3%           13
  Edit                                             459       2.4%            9
  ...

────────────────────────────────────────────────────────────────────────────────
  AGENT BREAKDOWN (83 spawned, 5 unique, 33 sessions)
────────────────────────────────────────────────────────────────────────────────
  Agent Type                     Invocations    Avg Time     Total    Projects
  ────────────────────────────────────────────────────────────────────────────
  Explore                                 46      2m 39s     2h 2m           8
  general-purpose                         29       4m 8s        2h           6
  ...

────────────────────────────────────────────────────────────────────────────────
  SKILL BREAKDOWN (32 invocations, 13 unique, 24 sessions, 46 available)
────────────────────────────────────────────────────────────────────────────────
  Skill                                              Invocations      Projects
  ────────────────────────────────────────────────────────────────────────────
  superpowers:brainstorming                                   14             7
  review-diff                                                  1             1
  ...

  ⚠ 37 unused skills (0 invocations):
    update-config, create-prd, ...

Supports all the same filtering flags (-days, -project) and output modes (-json) as the cost report.

Configuration

All configuration lives in ~/.goccc.json. Every field is optional.

Key Description
currency ISO 4217 currency code (e.g. EUR, GBP, JPY). Rate auto-fetched and cached 24h
warn_threshold Yellow color-coding threshold (default: $25, auto-scales with currency; custom values used as-is)
alert_threshold Red color-coding threshold (default: $50, auto-scales with currency; custom values used as-is)
statusline Statusline customization β€” segments, separator, per-segment overrides

Local Currency

Set "currency": "EUR" (or any ISO 4217 code) in ~/.goccc.json. goccc auto-fetches the exchange rate from USD and caches it for 24 hours. If the API is unreachable, the last cached rate is used. For one-off overrides without a config file, use -currency-symbol "€" -currency-rate 0.92 together.

JSON output always reports costs in USD, with a currency metadata object when a non-USD currency is active.

Flags

Flag Short Default Description
-days -d 0 Only show the last N calendar days (0 = all time)
-project -p β€” Filter by project name (substring, case-insensitive)
-daily β€” false Show daily breakdown
-monthly -m false Show monthly breakdown (mutually exclusive with -daily)
-projects β€” false Show per-project breakdown
-all β€” false Show all breakdowns (daily + projects)
-top -n 0 Max entries in breakdowns (0 = all)
-tools β€” false Show tool and skill usage analytics
-json β€” false Output as JSON
-no-color β€” false Disable colored output (also respects NO_COLOR env)
-base-dir β€” ~/.claude Base directory for Claude Code data
-session-end β€” false Session exit hook mode (reads SessionEnd JSON from stdin)
-statusline β€” false Statusline mode for Claude Code (reads session JSON from stdin)
-currency-symbol β€” β€” Override currency symbol (requires -currency-rate)
-currency-rate β€” 0 Override exchange rate from USD (requires -currency-symbol)
-version -V β€” Print version and exit

Preserving Log History

Claude Code periodically deletes old log files. To keep more history for cost tracking, increase the cleanup period in ~/.claude/settings.json:

{
  "cleanupPeriodDays": 365
}

The default is 30 days. Set it higher to retain more data for goccc to analyze.

About

Fast, zero-dependency cost calculator and customizable statusline for Claude Code. Breakdowns by model, day, project, and branch. Lightweight, single binary, no runtime needed.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors