Skip to content

[FEATURE] Automatic Cost Tracking and Reporting #18550

@oktN

Description

@oktN

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

Currently, users have no visibility into the cost of their Claude Code operations without manually asking Claude to estimate costs or checking external billing dashboards. This makes it difficult to:

  • Understand the cost impact of different commands (e.g., /init, code generation, file operations)
  • Budget and manage AI usage within teams/organizations
  • Make informed decisions about when to use Claude Code vs. other tools
  • Track costs in real-time during development sessions

Proposed Solution

1. Per-Command Cost Display

After each command or significant operation, display estimated costs:

✓ /init completed successfully

Tokens used: 38,315 (30,000 input + 8,315 output)
Estimated cost: $0.21 (based on Claude 3.5 Sonnet pricing)

2. Session Summary

When exiting Claude Code or on-demand via a command like /costs, show:

=== Session Cost Summary ===
Duration: 45 minutes
Total tokens: 156,432 (120,000 input + 36,432 output)
Estimated cost: $0.91

Breakdown by operation:
  /init command:        $0.21 (38,315 tokens)
  Code generation:      $0.45 (85,120 tokens)
  File operations:      $0.15 (22,450 tokens)
  Conversation:         $0.10 (10,547 tokens)

3. Running Cost Counter

Display current session costs in the status bar or header:

Claude Code | Session: $0.45 | Tokens: 67.2K

Alternative Solutions

  1. External monitoring only - Requires users to check AWS/Anthropic dashboards separately (poor UX)
  2. Post-session analysis - Users can't make real-time decisions about usage
  3. Third-party wrappers - Adds complexity and maintenance burden

Priority

Medium - Would be very helpful

Feature Category

CLI commands and flags

Use Case Example

As a developer, I want to see the cost of each command so I can understand which operations are most expensive.

As a team lead, I want a session summary showing total costs so I can track and budget for Claude Code usage across my team.

As a finance manager, I want users to see cost warnings when sessions become expensive so we can control AI spending.

As an enterprise user, I want to configure custom pricing that matches my negotiated rates so cost estimates are accurate.

Additional Context

Token usage warnings are already displayed (e.g., "Token usage: 38315/200000"), which shows the infrastructure for tracking is in place. This feature would add cost calculation and better presentation of that existing data.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions