Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.
Coding
token-stats-skill
Try itRecord and analyze token usage across eight local agents
What it does
Use for daily collection and for historical analysis. The CLI reads local agent logs and databases and stores normalized daily reports.
The skill document
token-stats-skill
Use token-stats usage for daily collection and token-stats report range for historical analysis. The CLI reads local agent logs and databases and stores normalized daily reports.
Public distribution: baijian/token-stats.
The release baseline verified on 2026-09-07 is v0.0.1. Check latest release when installing or updating. This repository distributes binaries and documentation, not CLI source code. The skill directory and invocation name are token-stats-skill.
Principles
- Keep all collection local. Do not upload session logs or token reports unless the user explicitly asks.
- Prefer
token-statsfromPATH. If missing, install the matching release archive after checksum verification; see the reference for platform selection. The public repository's automatic source archives do not contain the CLI implementation. v0.0.1 has no self-update command. - Prefer JSON output for collection and analysis: pass
--output json. - Pass
--agent allfor machine-level accounting. Single-agent selectors arecodex,claude,openclaw,hermes,opencode, anddeepseek;usageitself defaults tocodex. - Today's
usagereport refreshes automatically unless--refresh=falseis explicit. Historicalusageand everyreport rangequery read stored records unless--refreshis supplied. Refresh missing days or a requested rebuild; cachedallrecords do not automatically gain newly supported agents. - Treat
~/.local/data/cycling-health-cli/token-usage//.jsonas the durable daily record store unless the user sets--data-dir. - Use CLI report fields directly. Do not re-parse raw logs unless debugging the collector. Trae, Doubao, Doubao Work, and WorkBuddy are not supported in v0.0.1;
allmeans all supported collectors, not every application on the machine. - Preserve warnings, skipped-line counts, missing-agent notes, and storage paths in user-facing summaries.
Read references/token-recording.md for installation, scheduling, source paths, JSON fields, and attribution limits.
Workflow
-
Confirm the CLI:
- Run
token-stats version --output json. - If unavailable, use the public release binaries; do not fabricate token totals.
- Run
-
Refresh or read the target day:
- Today or explicit refresh:
token-stats usage --agent all --day YYYY-MM-DD --refresh --output json - Stored historical day:
token-stats usage --agent all --day YYYY-MM-DD --output json - Stored inclusive date range:
token-stats report range --agent all --from YYYY-MM-DD --to YYYY-MM-DD --output json - Add
--refreshto a range query to rescan and persist every day in that range. Without dates, the range is the latest seven days, including today.
- Today or explicit refresh:
-
Set up periodic recording when requested:
- Use
scripts/install-launchd-token-recorder.shon macOS. Installing the CLI alone does not create a scheduler. - Use
scripts/record-token-usage.shas the scheduler command on other systems. - Keep the schedule modest, such as every 30-60 minutes, because each run refreshes the current daily report from local logs.
- Use
-
Analyze history:
- Prefer
report rangefor multi-day totals; use a daily report for session-level investigation. - Use
total.totalTokensdirectly, withinputTokens,cachedInputTokens,cacheWriteTokens,outputTokens, andreasoningOutputTokensas reported breakdowns. Do not add overlapping cache/reasoning fields to the total again. - Use
byAgent,byModel,byDay, andbyRateLimitwhere available. Range reports containdayssummaries; only daily reports containsessions. - Report date range, agent filter, data directory, missing days, and warnings.
- Prefer
Common Tasks
Snapshot Now
Run the bundled wrapper when this skill folder is available:
AI_TOKEN_AGENT=all ./scripts/record-token-usage.sh
Or call the CLI directly:
token-stats usage --agent all --day "$(date +%F)" --refresh --output json
The CLI writes or overwrites the durable daily record. The wrapper can also keep per-run snapshots when AI_TOKEN_RUN_DIR is set.
Install A macOS Recorder
Use the bundled installer from the skill directory:
./scripts/install-launchd-token-recorder.sh --interval 1800 --agent all --bin "$HOME/.local/bin/token-stats"
This creates a user LaunchAgent that periodically runs record-token-usage.sh, refreshes today's token-stats daily record, and writes operational logs under ~/Library/Logs/ai-token-ayalysis.
Query Stored History
For one day:
token-stats usage --agent all --day 2026-07-10 --output json
For a stored date range:
token-stats report range --agent all --from 2026-09-01 --to 2026-09-06 --output json
A missing daily record makes the range query fail with refresh guidance; it is not zero usage. Add --refresh for a first collection or rebuild, including backfilling newly supported agents. Do not sum the all namespace together with individual-agent namespaces, or add repeated per-run snapshots together.
Resources
scripts/record-token-usage.sh: scheduler-safe wrapper aroundtoken-stats usage.scripts/install-launchd-token-recorder.sh: macOS LaunchAgent installer for periodic local recording.references/token-recording.md: detailed CLI flags, storage layout, scheduling guidance, and analysis notes.
Related skills
Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.
Save, search, and manage personal notes and knowledge bases in Get笔记 on explicit request.
Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.
Read and write Excel workbooks, worksheets, ranges, tables, and charts in OneDrive through Microsoft Graph with managed OAuth.
Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.
More from baijian
Browse all skillsSync health and analyze supported cycling data sources
Warm reflection and safe, practical emotional support