model-usage — Claude skill: per-model cost breakdowns
Reads CodexBar local cost logs and breaks spending down by model for Codex or Claude. Useful when you want to see where the money goes.
npx skills add openclaw/openclaw --skill model-usage -a claude-codeWhat model-usage does
The skill pulls per-model cost from CodexBar's local logs. Two modes: current, which uses the most recent daily entry, and all, which covers every model. Both Codex and Claude are supported.
The work happens in scripts/model_usage.py. By default it runs codexbar cost --format json --provider , but you can hand it an exported JSON file through --input or stdin instead. For current, it takes the latest daily row with modelBreakdowns and picks the model with the highest cost there; if breakdowns are missing it falls back to the last entry in modelsUsed. Pass --model to target one model.
Live reads need codexbar on PATH, and CLI builds ship for macOS and Linux. Everywhere else, use --input with exported JSON — Python is enough. One caveat: CodexBar reports cost only, tokens are not split by model. If you don't track per-model spend, skip this one.
What it helps with
- see which model cost the most in the latest daily entry
- compare cost across all models for a period
- export the breakdown as JSON for a report
- check spending for one model with --model
- read CodexBar logs on a machine without the live CLI
Example prompts for the agent
- Show today's per-model cost: python {baseDir}/scripts/model_usage.py --provider codex --mode current
- Give me the full Claude breakdown as JSON: python {baseDir}/scripts/model_usage.py --provider claude --mode all --format json --pretty
- Summarize this log file: python {baseDir}/scripts/model_usage.py --input /tmp/cost.json --mode all
How to install model-usage
1Skills CLI (Vercel)
npx skills add openclaw/openclaw --skill model-usage -a claude-code2Manually: put the files in place
~/.claude/skills/model-usage/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/model-usage/
1Skills CLI (Vercel)
npx skills add openclaw/openclaw --skill model-usage -a codex2Manually: put the files in place
.agents/skills/model-usage/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add openclaw/openclaw --skill model-usage -a cursor2Manually: put the files in place
.cursor/skills/model-usage/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install openclaw/openclaw model-usage2Manually: put the files in place
.github/skills/model-usage/SKILL.md1Skills CLI (Vercel)
npx skills add openclaw/openclaw --skill model-usage -a gemini-cli2Platform CLI
gemini skills install https://github.com/openclaw/openclaw --path skills/model-usageManually: put the files in place
.devin/skills/model-usage/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add openclaw/openclaw --skill model-usage -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set45
The whole set →Similar
Questions about model-usage
How do I install model-usage in Claude?
Run npx skills add openclaw/openclaw --skill model-usage -a claude-code. The skill lands at ~/.claude/skills/model-usage/SKILL.md.
What does model-usage do?
It summarizes CodexBar's local cost logs by model for Codex or Claude. Current mode covers the latest daily entry, all mode covers every model.
What do I need to run it?
For live reads, codexbar on PATH (macOS and Linux). On other platforms, pass exported JSON with --input — Python is all you need.
Source text
SKILL.md · MIT
---
name: model-usage
description: "Summarize CodexBar local cost logs by model for Codex or Claude, including current or full breakdowns."
metadata:
{
"openclaw":
{
"emoji": "📊",
"os": ["darwin", "linux"],
"requires": { "bins": ["codexbar"] },
"install":
[
{
"id": "brew-cask",
"kind": "brew",
"formula": "steipete/tap/codexbar",
"bins": ["codexbar"],
"label": "Install CodexBar CLI (Homebrew)",
},
],
},
}
---
# 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.
CodexBar ships CLI builds for macOS and Linux. When `codexbar` is on `PATH`, the skill reads local usage directly; the bundled Python summarizer also accepts exported CodexBar JSON through `--input` 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 and Linux: use the bundled Homebrew formula installer above for live local usage reads. Linux users can also use CodexBar's [AUR package](https://aur.archlinux.org/packages/codexbar-cli) or [official release tarballs](https://github.com/steipete/CodexBar/releases).
- Other platforms: use `--input` with exported CodexBar JSON.
- 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.
© openclaw · MIT · openclaw/openclaw