Agent Usage Analysis Report: Local Agent Token and Cost Overview

Introduction

Running Agents in Cursor, Claude Code, Codex CLI, or Qwen Work for extended periods often leads to two issues: unclear billing records and the inability to recall exactly what was done or which skills were repeatedly used during that time. Generic weekly or monthly report templates often fail to read local traces and session directories, making reconciliation against billing models impossible.

Below is an introduction to the community Skill “Agent Usage Analysis Report” on SkillHub (Location: @user_c5278a31/agent-analytics-report, Current Version: 1.9.15). It collects usage records from existing local data sources, generates readable reports by day/week/month/year, and supports statistics for Tokens, task types, skill invocations, and automated runs, as well as anomaly alerts based on both cost and Token metrics.

What Is This

One-sentence positioning: A local, offline-first Agent usage and cost report generator.

Published by SkillHub user user_c5278a31, categorized under data-analysis, and sourced from the community. The Skill reads data from local traces, workbuddy.db, usage-log.json, and session directories of various products. By default, it outputs Markdown in the terminal; it can also output HTML (including interactive charts) or JSON. It generates no network requests or uploads data by default; reports are rendered to stdout by default unless you explicitly specify an output path.

Core Features

Token Consumption and Cost

  • Estimates costs based on public billing models and aligns with common backend billing metrics (specifically, the actual bill remains the final authority).
  • Data sources such as Qwen Work, where “the server does not return tokens”: tokens are estimated based on characters, and the amount is presented as tokens_only. These are not usable for reconciliation, as explained in the documentation.
  • The report includes daily trends, cache ratios, and cost monetization. When the cost metric has limited reference value during free or limited-time periods, the report will indicate this and guide you to check the Token metric instead.

Tasks and Skills

  • Summarizes the major task types over a period.
  • Statistics on which Skills are repeatedly invoked.

Automated Execution

  • Counts the number of executions for each task and their success/failure status.
  • Statistics on cost waste in failure scenarios (provided data is available).

Anomaly Detection

  • Dual-metric detection for both cost and Token; high-traffic scenarios during free periods are also included.
  • Explicit warnings are provided for dirty data.

Trigger Methods

When users express phrases similar to “Generate an Agent weekly/monthly/yearly/daily report”, “Help me create a usage report for this week”, or “Count the token consumption for this month,” and the context clearly points to Agent usage / cost / Tokens, the Skill can select the period based on the context without requiring manual parameter entry. If a generic weekly, monthly, or financial report is desired, you should clarify the data source before running the collection.

You can also customize the period via parameters, such as --period, --days, --start, or --end.

Data Sources (--source)

Value Read Location (Documented)
workbuddy (Default) ~/.workbuddy/
claude-code JSONL session logs under ~/.claude/projects/
codex rollout JSONL under ~/.codex/sessions/
qwenwork Qwen Work ~/.qwenworkcn/ (transcripts, invocation logs, agents.db); use this source when running within the Qwen Work environment.
dumate Reads data directory based on WorkBuddy layout, DUMATE_HOME can be used to override; data ownership is unverified, do not use as a basis for usage data of other products.

For more Agent adapters, see docs/ADAPTERS.md within the Skill package.

Output Format

  • Markdown (Default)
  • HTML (Interactive charts, light/dark mode adaptive)
  • JSON

Privacy and Permissions (Key Points)

  1. Default read-only, default offline: Zero network usage, no recursive scanning of the entire ~/.workbuddy directory; the report is not written to a file by default unless you pass --output / -o <path>.
  2. Task Classification LLM (Optional): Session-derived text will only be sent to your specified local or self-hosted LLM endpoint for classification when you explicitly enable --task-classifier llm and confirm it with --task-classifier-llm-ack or an environment variable.
  3. Custom Model Unit Price (Optional): The bounded custom-local:* matching within ~/.workbuddy and asking for unit prices only occur when you explicitly initiate a process like “Add a custom model to the report.” After confirmation, it writes to the local pricing.local.json (it is not included in the release package and will not be overwritten during upgrades).
  4. scripts/task_rules.json is a release asset and will be overwritten during upgrades; please back it up yourself before modifying.

The tag requires_api_key=false indicates that the Skill itself does not enforce an API Key; LLM task classification and similar features are independent opt-in behaviors.

Installation and Activation

The Skill is installed via SkillHub. The coordinates and page are as follows:

  • Coordinate: @user_c5278a31/agent-analytics-report
  • SkillHub Page: https://www.skillhub.cn/skills/user_c5278a31/agent-analytics-report
  • API Endpoint: https://api.skillhub.cn/user_c5278a31/agent-analytics-report

Refer to the instructions on the current SkillHub page for the installation command. Once enabled, simply load the Skill in a client that supports Agent Skills.

Your local machine must have trace or session records for the corresponding product; otherwise, collection will not be possible. For Qwen Work scenarios, please set --source to qwenwork.

Typical Usage

Natural Language Trigger

In an Agent conversation, say:

  • “Generate this week’s Agent weekly report”
  • “Count this month’s token consumption”
  • “Help me create an Agent monthly report”

The context must point to usage or cost to avoid confusion with pure work status reports.

Switching Data Sources

When generating a report from Claude Code logs, set --source to claude-code; when generating a report from the Codex session directory, set it to codex. Refer to SKILL.md and the help documentation within the Skill for field names.

Customizing Time Ranges

When a non-default day/week/month/year range is needed, use --period, --days, or --start / --end to define the interval.

Writing to Local Files

Viewing is limited to the terminal by default; to write to disk, explicitly specify an output path, for example:

-o /path/to/report.md

Refer to the Skill documentation for the specific subcommand format.

Outputting HTML or JSON

Select HTML (with interactive charts) or JSON from the supported output options to facilitate sharing or secondary analysis.

Applicable Scenarios and Notes

Who Is It For

  • Developers who switch between multiple Agent tools and want to view Token and cost uniformly from local logs.
  • People who need to show their team “what the Agent has been doing during this period, and the success/failure and waste of automation.”
  • People who want to discover sudden increases in cost or Token via anomaly alerts rather than digging through bills after the fact.

Limitations and Pitfalls

  • Data all comes from local machine; the report is incomplete if traces aren’t enabled or logs are missing.
  • Cost is estimated based on public unit prices, reconciliation is based on the provider’s bill; pay attention to the Token metric during limited-time periods.
  • dumate is compatible with WorkBuddy layout, but ownership is unverified, so be cautious when citing usage for other products.
  • Backup before modifying task_rules.json to avoid losing custom weights due to upgrade overwriting.

Conclusion

“Agent Usage Analysis Report” aggregates scattered usage traces from various product directories into daily/weekly/monthly/yearly reports. It defaults to offline and read-only operations, making it suitable for scenarios where you can request a weekly or monthly report with a single sentence while clearly seeing an overview of Tokens, Skills, and automated runs. For details and the latest version, refer to SkillHub:

https://www.skillhub.cn/skills/user_c5278a31/agent-analytics-report

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye