Documentation
¶
Overview ¶
Package economics provides Claude Code spending vs savings analysis.
Combines ccusage (tokens spent) with tokman tracking (tokens saved) to provide dual-metric economic impact reporting with weighted cost-per-token calculations.
Index ¶
Constants ¶
View Source
const ( WeightOutput = 5.0 // Output = 5x input WeightCacheCreate = 1.25 // Cache write = 1.25x input WeightCacheRead = 0.1 // Cache read = 0.1x input )
API pricing ratios (verified Feb 2026, consistent across Claude models <=200K context) Source: https://docs.anthropic.com/en/docs/about-claude/models
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MonthStats ¶
MonthStats represents monthly tracking stats
type PeriodEconomics ¶
type PeriodEconomics struct {
Label string
// ccusage metrics (Option for graceful degradation)
CCCost *float64
CCTotalTokens *uint64
CCActiveTokens *uint64 // input + output only (excluding cache)
// Per-type token breakdown
CCInputTokens *uint64
CCOutputTokens *uint64
CCCacheCreateTokens *uint64
CCCacheReadTokens *uint64
// tokman metrics
TMCommands *int
TMSavedTokens *int
TMSavingsPct *float64
// Primary metric (weighted input CPT)
WeightedInputCPT *float64 // Derived input CPT using API ratios
SavingsWeighted *float64 // saved * weighted_input_cpt (PRIMARY)
// Legacy metrics (verbose mode only)
BlendedCPT *float64 // cost / total_tokens (diluted by cache)
ActiveCPT *float64 // cost / active_tokens (OVERESTIMATES)
SavingsBlended *float64 // saved * blended_cpt (UNDERESTIMATES)
SavingsActive *float64 // saved * active_cpt (OVERESTIMATES)
}
PeriodEconomics represents economics data for a single time period
type RunOptions ¶
type RunOptions struct {
Daily bool
Weekly bool
Monthly bool
All bool
Format string // "text", "json", "csv"
Verbose bool
}
RunOptions configures the economics report
type Totals ¶
type Totals struct {
CCCost float64
CCTotalTokens uint64
CCActiveTokens uint64
CCInputTokens uint64
CCOutputTokens uint64
CCCacheCreate uint64
CCCacheRead uint64
TMCommands int
TMSavedTokens int
TMAvgSavingsPct float64
WeightedInputCPT *float64
SavingsWeighted *float64
BlendedCPT *float64
ActiveCPT *float64
SavingsBlended *float64
SavingsActive *float64
}
Totals represents aggregated economics across all periods
Click to show internal directories.
Click to hide internal directories.