Goccc
Fast, zero-dependency cost calculator and customizable statusline for Claude Code. Breakdowns by model, day, project, and branch. Lightweight, single binary, no runtime needed.
Install / Use
/learn @backstabslash/GocccQuality Score
Category
Development & EngineeringSupported Platforms
README
A fast, zero-dependency CLI cost calculator and customizable statusline for Claude Code. Breakdowns by model, day, project, and branch. Single binary, no runtime needed.
Table of Contents
- Installation
- Usage
- Claude Code Statusline
- Session Exit Hook
- Configuration
- Flags
- Preserving Log History
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
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.
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) |
| -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.
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
347.2kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
