goccc
Goccc is a fast, zero-dependency CLI tool designed to function as both a cost calculator and a live statusline provider for Claude Code. It breaks down your API costs by model, day, project, and month — more precise and lightweight than ccusage, with additional features like MCP server tracking and local currency support.
A fast, zero-dependency CLI cost calculator and statusline provider for Claude Code — single binary, no runtime needed.
Parses JSONL conversation logs and subagent sessions from ~/.claude/projects/, deduplicates streaming responses, and breaks down spending by model, day, project, and branch — with accurate cache-tier and web search pricing.
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
Local Currency
To display costs in your local currency, create ~/.goccc.json:
{
"currency": "ZAR"
}
goccc will auto-fetch the exchange rate from USD and cache it for 24 hours. If the API is unreachable, the last cached rate is used. Set currency to any ISO 4217 code (e.g., EUR, GBP, ZAR, JPY).
For one-off overrides without a config file, use both flags together:
goccc -currency-symbol "€" -currency-rate 0.92
JSON output always reports costs in USD for backward compatibility, with a currency metadata object when a non-USD currency is active.
See also: Configuration for threshold customization.
Claude Code Statusline
goccc can serve as a Claude Code statusline provider — a 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 window — remaining percentage of the 5-hour usage window with elapsed time (subscription users only; hidden for API billing). Emoji switches to 🪫 below 25%
- 🤖 Model — current model
Cost and context values are color-coded yellow → red as they increase. The 5h window is color-coded in reverse — yellow below 50%, red below 25%.
Setup
Add to ~/.claude/settings.json:
Using Homebrew (recommended — fast, no runtime needed):
{
"statusLine": {
"type": "command",
"command": "goccc -statusline"
}
}
Using Go (requires Go installed; binary is cached after first download):
{
"statusLine": {
"type": "command",
"command": "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", "mcp", "5h", "model"],
"separator": " · ",
"segment_options": {
"session_cost": { "emoji": "🤑" },
"ctx": { "emoji": "🧠", "label": "context" }
}
}
}
segments — ordered list of segments to display. Only listed segments are shown. Use "|" to force a line break (as shown above).
Available segments:
| Segment | Default | Auto-hides when |
|---|---|---|
session_cost |
💸 $X.XX session |
cost is $0 |
today_cost |
💰 $X.XX today |
cost is $0 |
ctx |
💭 XX% ctx |
— |
model |
🤖 Model Name |
— |
mcp |
🔌 N MCPs (...) |
no MCPs detected |
5h |
🔋 XX% (X/5h) |
absent (API billing) |
7d |
🔋 XX% (X/7d) |
absent (API billing) |
tokens |
📊 XK in / XK out |
both zero |
lines |
📝 +N -N |
both zero |
duration |
⏱️ Xm |
zero |
cwd |
📁 dirname |
empty |
version |
🏷️ X.Y.Z |
empty |
separator — string between segments (default: " · ").
segment_options — per-segment overrides for emoji and label. Only specified fields are overridden.
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
goccc reads its config from ~/.goccc.json.
Cost Thresholds
Cost values are color-coded yellow (warning) and red (alert) when they exceed thresholds. The defaults are $25 and $50 per day. To customize:
{
"warn_threshold": 30,
"alert_threshold": 75
}
Thresholds are in USD (before currency conversion). They apply to the terminal output, statusline, and session exit hook.
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.
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi