model-usage

Analyze per-model usage, costs, and token consumption from session JSON files.

30|5|Updated Jul 25, 2025
One-click install
npx skills add https://github.com/phuetz/code-buddy --skill model-usage-phuetz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: model-usage
Source: https://github.com/phuetz/code-buddy/tree/main/.codebuddy/skills/bundled/model-usage
Command: npx skills add https://github.com/phuetz/code-buddy --skill model-usage-phuetz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Track model usage, costs, and token consumption across sessions to reveal spending patterns and support cost-aware model selection.

Core Features & Use Cases

  • Per-model usage and cost breakdowns for budgeting and financial planning.
  • Token accounting and efficiency analysis to identify cost-saving opportunities.
  • Use Case: Compare models across a week of sessions to identify the most cost-effective option for a given task.

Quick Start

Example command: for f in .codebuddy/sessions/*.json; do echo -e "$f\t$(jq -r '.model // "unknown"' "$f")\t$(jq -r '.usage.totalCost // 0' "$f")\t$(jq -r '.usage.totalTokens // 0' "$f")"; done | sort

Frequently Asked Questions about model-usage

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

FAQPage Schema
How do I track AI model usage and costs across sessions?

To track AI model usage and costs, this Skill parses structured session JSON files to compute aggregates for total tokens and total cost. This process reveals spending patterns across different sessions to support cost-aware model selection and budgeting.

What is the best way to compare token consumption between different AI models?

The best way to compare token consumption is by analyzing per-model usage breakdowns extracted from session logs. Comparing these aggregates across multiple sessions identifies the most cost-effective model for specific AI tasks.

What format do session logs need to be in for token accounting and cost analysis?

Session logs must be structured JSON files containing specific fields: model, usage.totalCost, and usage.totalTokens. The analysis tool requires these exact fields to compute per-model usage aggregates and execute accurate token accounting.

Can I use this approach to identify cost-saving opportunities for my AI tasks?

Yes, you can identify cost-saving opportunities by performing token accounting and efficiency analysis on your session JSON files. This reveals per-model usage breakdowns, highlighting which models consume unnecessary tokens or exceed budget limits.

Does this method work without a structured database for tracking AI sessions?

Yes, this method works without a database by directly parsing flat structured session JSON files. It uses command-line text processing to extract usage.totalCost and usage.totalTokens fields to compute the necessary cost and token aggregates.