agent-usage

agent-usage is a skill for Claude Code, Codex from fmind/dot. It costs 50 tokens per session (1,126 once invoked), scanned A, original, MIT.

A tool for reading and analysing recorded language-model token use across several AI coding-agent systems. It reports usage details such as input, output, cached, total tokens, and cost.

In plain words
What is it for?
Use it to inspect usage statistics, group consumption by model or agent system, and audit token costs.
Why use it?
It helps explain where agent usage and spending come from when comparing sessions, models, or coding environments.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/fmind/dot/agent-usage
Any agent
npx skills add fmind/dot --skill agent-usage
Clone the repo
git clone --depth 1 https://github.com/fmind/dot

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for agent-usage

README.md
[![agentmods](https://agentmods.dev/badge/skills/fmind/dot/agent-usage.svg)](https://agentmods.dev/skills/fmind/dot/agent-usage)
Your own site
<a href="https://agentmods.dev/skills/fmind/dot/agent-usage"><img src="https://agentmods.dev/badge/skills/fmind/dot/agent-usage.svg" alt="Measured on agentmods" height="20"></a>
Per session 50 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,126 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00050 $0.01126
Opus 5 $0.00025 $0.00563
Sonnet 5 $0.00010 $0.00225
Haiku 4.5 $0.00005 $0.00113

Measured yesterday against content hash 0962c1eead69, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

agent-usage scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/agent-usage/SKILL.md · 91 lines

How it starts

The opening of the file, as written. The whole thing — 91 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent Usage

Token usage for all AI harnesses (agy, claude, codex, copilot, grok, opencode) is recorded to ~/.agents/usages/<harness>/<session_id>.json on session completion and turn boundaries.

Directory Layout & Schema

Every session record is stored atomically with permissions 0o600:

~/.agents/usages/
├── agy/
│   └── <session_id>.json
├── claude/
│   └── <session_id>.json
├── codex/
│   └── <session_id>.json
├── copilot/
│   └── <session_id>.json
├── grok/
│   └── <session_id>.json
└── opencode/
    └── <session_id>.json

Each record contains:

{
  "timestamp": "2026-09-03T18:00:00Z",
  "harness": "claude",
  "agent": "claude",
  "session_id": "abc-123",
  "model": "claude-opus-5",
  "input_tokens": 12500,
  "output_tokens": 3400,
  "cached_tokens": 82000,
  "cache_write_tokens": 1200,
  "reasoning_tokens": 0,
  "total_tokens": 99100,
  "cost_usd": 0.1425,
  "turn_count": 8,
  "cwd": "~/project"
}

Commands

dot agent usage stats                                              # summary table of token usage per harness
dot agent usage stats --by-model                                   # break down token usage by harness and model
dot agent usage stats --harness claude                             # filter stats to a specific harness
dot agent usage stats --since 24h --json                           # emit json array for scripting
dot agent usage list -n 20                                         # list recent session records
dot agent usage show claude <session_id>                           # inspect a specific session record
dot agent usage sync                                               # scan raw stores and backfill missing records
duckdb -c "SELECT harness, count(*), sum(total_tokens) FROM read_json_auto('~/.agents/usages/*/*.json', union_by_name=true) GROUP BY harness" # ad-hoc SQL

Workflow

  1. Check aggregate usage: run dot agent usage stats to inspect overall token consumption and costs across harnesses.
  2. Break down by model: run dot agent usage stats --by-model when comparing prompt efficiency or model tiers.
  3. Filter by time window: pass --since 24h or --since 7d to isolate a recent sprint or experiment.
  4. Deep dive with DuckDB: query ~/.agents/usages/*/*.json directly with read_json_auto in duckdb for custom aggregations, percentiles, or CSV exports.
  5. Synchronize historical sessions: run dot agent usage sync after adding an integration to extract metrics from historical transcripts.

Read the full file on GitHub · 91 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 91 lines · 50 tokens per session scan A 0962c1eead69

Subscribe to this mod's changes

agent-usage is a skill published in the GitHub repository fmind/dot (4 stars, last pushed today), licensed MIT. It adds 50 tokens to every session and 1,126 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-04.