[FEATURE] Expose /cost and /usage data programmatically to hooks and plugins

Open 💬 4 comments Opened Apr 19, 2026 by jerrythomas

Summary

Claude Code /cost and /usage commands already display token counts, session cost, and quota information interactively. This data is not available to hooks, plugins, or external tools programmatically — blocking cost dashboards, burn rate projections, and quota-aware tooling.

The data already exists

  • /cost shows session and total cost
  • /usage shows quota consumption

The ask is narrow: expose what these commands already know in a machine-readable format.

Proposed Solutions (any would work)

Option A: --json flag on existing commands

claude /cost --json
# {"session_cost_usd": 0.35, "total_cost_usd": 4.20, "tokens_in": 142000, "tokens_out": 38000}

Option B: Hook payload enrichment

Include cost/usage in SessionStart or SessionEnd hook payload:

{"quota_remaining_pct": 58, "session_cost_usd": 0.35}

Option C: Well-known file

Write to ~/.claude/session-stats.json that plugins can read.

Use Case

Building a session analytics desktop companion that shows AI-driven developers their efficiency metrics. Token/cost data is the missing piece — everything else (FTR, turns, rework rate, tool usage) we can already capture via hooks.

Related

  • #11008 — Expose token usage and cost data in hook inputs
  • #49588 — Expose session token usage to MCP servers and hooks

Impact

Quota anxiety is real — developers self-censor usage because they cannot see burn rate. Table-stakes for any metered service.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗