Skip to content
Back to skills

Cost Tracking

ASecurity

Tracks and analyzes AI coding assistant token usage, model spending, and session costs from local logs without remote dependencies.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 17, 2026
ai-agentsjavascriptgojavabashnode

Works with

  • claude code
  • terminal
  • cli

Security analysis

A100/100

Scanned October 17, 2026

npx -y skills add airshell/ai-optimizer --skill cost-tracking --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cost Tracking?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cost Tracking
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/airshell-cost-tracking/badge)](https://www.skillsdirectory.com/skills/airshell-cost-tracking)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cost-tracking
description: >-
  Tracks and analyzes AI coding assistant token usage, model spending, and
  session costs from local logs without remote dependencies.
metadata:
  origin: AI Optimizer
  license: MIT
---

# Local Cost Tracking & Model Accounting

Analyze AI coding assistant token usage history, session spending, and per-model costs from your machine local logs.

## When to Use

- "How much have I spent on AI coding sessions today?"
- "What did this session cost in tokens and dollars?"
- "Show me a cost breakdown by model across recent sessions"
- Budgeting, usage audits, or verifying savings

## Where the Data Lives

AI Optimizer reads local session transcripts and logs directly from your machine:
- Google Antigravity transcripts: `~/.gemini/antigravity/`
- OpenAI Codex sessions: `~/.codex/sessions/`
- Claude Code session logs: `~/.claude/metrics/costs.jsonl` or session transcripts

All data is parsed locally with zero network queries and zero external transmission.

## Instant CLI Reporting

Use the built-in AI Optimizer CLI for instant summaries:

```bash
# Today token and dollar spend breakdown by model
ai-opt --today

# Daily breakdown table across the last 30 days
ai-opt --daily

# Inspect RTK Proxy terminal compression and Ponytail savings
ai-opt --savings

# Start the local dashboard
ai-opt --serve
```

## Local Log Parsing Pattern (Node.js)

```javascript
import fs from "node:fs";
import path from "node:path";
import os from "node:os";

// Read local session metric records
const logPath = path.join(os.homedir(), ".claude", "metrics", "costs.jsonl");
if (fs.existsSync(logPath)) {
  const lines = fs.readFileSync(logPath, "utf8").trim().split("\n");
  const sessions = new Map();
  for (const line of lines) {
    try {
      const rec = JSON.parse(line);
      sessions.set(rec.session_id || rec.timestamp, rec);
    } catch {}
  }
  const totalUSD = [...sessions.values()].reduce((sum, s) => sum + (Number(s.estimated_cost_usd) || 0), 0);
  console.log(`Total spend across ${sessions.size} sessions: $${totalUSD.toFixed(2)}`);
}
```

## Anti-Patterns

- **Never double-count**: Session records are often cumulative snapshots; always take the latest snapshot per session identifier.
- **Differentiate prompt cache reads**: Cache read tokens are priced at ~10% of standard input token rates. Never bill cache reads at full prompt rates.
- **Zero remote telemetry**: Never send local session tokens or costs to external analytics beacons.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.