
Model Usage
Pull per-model Codex or Claude spend from local CodexBar logs so you can see what your agent coding sessions actually cost.
Overview
Model usage is an agent skill for the Operate phase that summarizes CodexBar local cost logs into per-model spend for Codex or Claude.
Install
npx skills add https://github.com/steipete/clawdis --skill model-usageWhat is this skill?
- Summarize CodexBar local cost logs by model for Codex or Claude providers
- Current-model mode picks the highest-cost model on the latest daily row with modelBreakdowns
- All-models mode returns a full breakdown across entries
- Bundled Python summarizer supports portable --input JSON on any OS with Python
- Live CLI fetch path documented for macOS via codexbar with brew cask install
- Supports two providers: Codex and Claude
- Two summary modes: current model and all models
Adoption & trust: 2k installs on skills.sh; 378k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are burning tokens across Codex and Claude but only see vague totals, not which model drove yesterday’s bill.
Who is it for?
Solo builders on macOS with CodexBar installed who want quick local model-cost snapshots during agent-heavy sprints.
Skip if: Teams that need centralized cloud billing, invoice reconciliation, or spend data when no CodexBar logs or export JSON exists.
When should I use this skill?
You need per-model usage cost from CodexBar local logs for Codex or Claude, including current or full breakdowns.
What do I get? / Deliverables
You get a current-model or all-models cost breakdown you can paste into budgets, retros, or agent runbooks.
- Per-model cost summary for current or all-models mode
- Optional JSON formatted breakdown via --format json --pretty
Recommended Skills
Journey fit
Cost visibility belongs in Operate because it tracks ongoing AI usage after you are already shipping and iterating with agents. Monitoring is the right shelf for spend summaries derived from daily cost logs rather than one-off build tasks.
How it compares
Local CodexBar log summarizer, not a cloud cost-management MCP or generic finance dashboard.
Common Questions / FAQ
Who is model-usage for?
Indie and solo builders who use CodexBar to track Claude or Codex sessions and want the agent to read those logs into a clear per-model summary.
When should I use model-usage?
Use it during Operate when reviewing weekly AI spend, before switching default models, or after a heavy ship cycle when you need to see which model dominated the latest daily entry.
Is model-usage safe to install?
It reads local cost data and shells out to codexbar or Python on your machine; review the Security Audits panel on this Prism page before installing in a sensitive environment.
SKILL.md
READMESKILL.md - Model Usage
# Model usage ## Overview Get per-model usage cost from CodexBar's local cost logs. Supports "current model" (most recent daily entry) or "all models" summaries for Codex or Claude. Live CodexBar CLI invocation is currently documented for macOS only. The bundled Python summarizer is portable: if you already have exported CodexBar JSON, `--input` mode works anywhere Python is available. ## Quick start 1. Fetch cost JSON via CodexBar CLI or pass a JSON file. 2. Use the bundled script to summarize by model. ```bash python {baseDir}/scripts/model_usage.py --provider codex --mode current python {baseDir}/scripts/model_usage.py --provider codex --mode all python {baseDir}/scripts/model_usage.py --provider claude --mode all --format json --pretty ``` ## Current model logic - Uses the most recent daily row with `modelBreakdowns`. - Picks the model with the highest cost in that row. - Falls back to the last entry in `modelsUsed` when breakdowns are missing. - Override with `--model <name>` when you need a specific model. ## Inputs - Default: runs `codexbar cost --format json --provider <codex|claude>`. - macOS: use the bundled CodexBar CLI install path above for live local usage reads. - Linux/other platforms: use `--input` with exported CodexBar JSON until this skill documents a supported local CodexBar install path for that platform. - File or stdin: ```bash codexbar cost --provider codex --format json > /tmp/cost.json python {baseDir}/scripts/model_usage.py --input /tmp/cost.json --mode all cat /tmp/cost.json | python {baseDir}/scripts/model_usage.py --input - --mode current ``` ## Output - Text (default) or JSON (`--format json --pretty`). - Values are cost-only per model; tokens are not split by model in CodexBar output. ## References - Read `references/codexbar-cli.md` for CLI flags and cost JSON fields. # CodexBar CLI quick ref (usage + cost) ## Install - App: Preferences -> Advanced -> Install CLI - Repo: ./bin/install-codexbar-cli.sh ## Commands - Usage snapshot (web/cli sources): - codexbar usage --format json --pretty - codexbar --provider all --format json - Local cost usage (Codex + Claude only): - codexbar cost --format json --pretty - codexbar cost --provider codex|claude --format json ## Cost JSON fields The payload is an array (one per provider). - provider, source, updatedAt - sessionTokens, sessionCostUSD - last30DaysTokens, last30DaysCostUSD - daily[]: date, inputTokens, outputTokens, cacheReadTokens, cacheCreationTokens, totalTokens, totalCost, modelsUsed, modelBreakdowns[] - modelBreakdowns[]: modelName, cost - totals: totalInputTokens, totalOutputTokens, cacheReadTokens, cacheCreationTokens, totalTokens, totalCost ## Notes - Cost usage is local-only. It reads JSONL logs under: - Codex: ~/.codex/sessions/\*_/_.jsonl - Claude: ~/.config/claude/projects/**/\*.jsonl or ~/.claude/projects/**/\*.jsonl - If web usage is required (non-local), use codexbar usage (not cost). #!/usr/bin/env python3 """ Summarize CodexBar local cost usage by model. Defaults to current model (most recent daily entry), or list all models. """ from __future__ import annotations import argparse import json import subprocess import sys from dataclasses import dataclass from datetime import date, datetime, timedelta from typing import Any, Dict, Iterable, List, Optional, Tuple def positive_int(value: str) -> int: try: parsed = int(val