/cost-tracking

Compute inference-only token costs from Claude Code JSONL logs.

8|1|Updated Jan 21, 2024
One-click install
npx skills add https://github.com/azigler/dotfiles --skill cost-tracking-azigler
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: /cost-tracking
Source: https://github.com/azigler/dotfiles/tree/main/agents/skills/cost-tracking
Command: npx skills add https://github.com/azigler/dotfiles --skill cost-tracking-azigler

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill turns Claude Code session JSONL logs into a clear, project-level ledger of inference costs so you can understand where your token budget goes.

Core Features & Use Cases

  • Orchestrator-only cost ledger per session: Sums input/output tokens while filtering out subagent sidechains so the totals reflect orchestrator work.
  • Inference-only pricing (cache excluded): Computes cost as input + output at standard model rates, while tracking cache tokens only as reference counters (not in the canonical cost).
  • Automatic updates via /offboard: Appends a new row to .claude/plans/cost-tracking.md when the ledger file exists, using the most recent session JSONL (or a provided session path).

Quick Start

Set up cost tracking by copying the ledger template into .claude/plans/cost-tracking.md and then letting /offboard append new session rows automatically.

Frequently Asked Questions about /cost-tracking

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I track Claude Code token usage costs per session?

You can track Claude Code token usage costs by parsing session JSONL logs to compute an inference-only cost ledger. This sums orchestrator input and output tokens while filtering out subagent sidechain contributions to reflect main session work.

What is the best way to calculate Anthropic API billing transparency for Claude Code projects?

Anthropic API billing transparency is achieved by applying model-specific public pricing to filtered JSONL session logs, generating a per-project markdown ledger showing exact inference costs separated from cache token counters.

Does the cost ledger include cache token expenses from Claude Code sessions?

The cost ledger excludes cache token expenses from the headline cost. Cache tokens are tracked only as reference counters, while canonical cost is computed strictly from standard input and output token rates.

How do I set up automatic budgeting updates for Claude Code token spend?

Automatic budgeting updates require copying the ledger template into .claude/plans/cost-tracking.md. Once the ledger exists, the /offboard command appends new session rows using the most recent JSONL log or a provided path.

Why are my subagent sidechain token costs excluded from the project billing ledger?

Subagent sidechain token costs are excluded from the billing ledger to ensure totals reflect orchestrator work only. Filtering by type and isSidechain prevents sidechain contributions from inflating headline inference cost.

Can I export Claude Code session cost tracking data as JSON instead of markdown?

You can export Claude Code session cost tracking data as JSON. The ledger append logic supports emitting markdown rows, JSON, verbose output, or commit-lines for flexible integration with downstream budgeting and token-allocation analysis workflows.