[STUDY] Cost tracking — learn from Claude Code's usage pricing system #158

Open
opened 2026-03-31 16:30:10 +00:00 by ezra · 0 comments
Member

Parent Epic: #154

Maps to: #97 (cost tracking and budget enforcement)

Source Files

  • src/cost-tracker.ts (10,706 bytes)
  • src/services/claudeAiLimits.ts — rate limit handling
  • src/services/rateLimitMessages.ts — user-facing rate limit messages
  • src/services/policyLimits/ — policy-based limits

Key Patterns to Study

  1. Per-model tracking — tracks input/output/cache tokens per model
  2. USD cost calculationcalculateUSDCost() with model-specific pricing
  3. Cache-aware — tracks cache read and cache write tokens separately
  4. Duration tracking — API duration with and without retries
  5. Session cost state — cost state that can be saved/restored across sessions

Acceptance Criteria

  • Read cost-tracker.ts and limits files
  • Document the pricing model
  • Document how cache tokens are tracked
  • Write adaptation plan for multi-backend cost tracking
  • Post findings as comment on #97
## Parent Epic: #154 ## Maps to: #97 (cost tracking and budget enforcement) ### Source Files - `src/cost-tracker.ts` (10,706 bytes) - `src/services/claudeAiLimits.ts` — rate limit handling - `src/services/rateLimitMessages.ts` — user-facing rate limit messages - `src/services/policyLimits/` — policy-based limits ### Key Patterns to Study 1. **Per-model tracking** — tracks input/output/cache tokens per model 2. **USD cost calculation** — `calculateUSDCost()` with model-specific pricing 3. **Cache-aware** — tracks cache read and cache write tokens separately 4. **Duration tracking** — API duration with and without retries 5. **Session cost state** — cost state that can be saved/restored across sessions ### Acceptance Criteria - [ ] Read cost-tracker.ts and limits files - [ ] Document the pricing model - [ ] Document how cache tokens are tracked - [ ] Write adaptation plan for multi-backend cost tracking - [ ] Post findings as comment on #97
Timmy was assigned by ezra 2026-03-31 16:30:10 +00:00
Timmy added this to the Claude Code Study milestone 2026-03-31 16:58:32 +00:00
Timmy added the study label 2026-03-31 16:58:33 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Timmy_Foundation/timmy-home#158