A developer has identified a cost-tracking issue with Anthropic's Claude Code when using its headless mode with session resumption. The `total_cost_usd` metric reported by Claude Code is cumulative across sessions, leading to inaccurate per-turn cost calculations if not handled carefully. The author implemented a fix by storing the previous session's total cost and calculating the delta for each new turn, ensuring that only the cost incurred in that specific turn is displayed. AI
IMPACT Highlights a potential cost-management challenge for developers using headless LLM APIs, requiring careful implementation for accurate billing.
RANK_REASON Developer identifies and proposes a fix for a specific product behavior related to cost tracking.
Read on dev.to — Claude Code tag →
AI-generated summary · Google Gemini · from 1 sources. How we write summaries →