agent-usage-tracker

Track AI agent token usage, model costs, and budget thresholds with a TypeScript and SQLite workflow. Use when the user wants to instrument agent runs, calculate token spend, enforce per-session or time-window budgets, or analyze usage by model, session, or time range.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "agent-usage-tracker" with this command: npx skills add imgolye/agent-usage-tracker

Agent Usage Tracker

Use this skill when you need local token accounting for AI agents.

What it provides

  • Real-time token usage persistence in SQLite
  • Cost calculation based on per-model pricing
  • Budget thresholds with persisted warning and blocking states
  • Usage statistics grouped by time window, session, or model

Files to use

  • src/UsageTracker.ts: ingestion, storage, and reporting
  • src/CostCalculator.ts: pricing catalog and cost math
  • src/BudgetManager.ts: budget policy evaluation
  • examples/basic-usage.ts: end-to-end usage example
  • tests/: reference behavior for tracking, budgeting, and aggregation

Recommended workflow

  1. Instantiate UsageTracker with a SQLite path or :memory: for tests.
  2. Register model pricing with CostCalculator.
  3. Record each agent interaction with prompt tokens, completion tokens, session id, and timestamp.
  4. Save reusable budgets with BudgetManager.setBudget, then call evaluateBudget before or after new work to warn or stop when a limit is exceeded.
  5. Use UsageTracker.getUsageSummary or getTimeSeries for reporting.

Integration notes

  • Store token counts at the moment the provider returns usage metadata.
  • Keep model ids normalized. Pricing lookup is exact by model id.
  • Use metadata for provider-specific fields such as request id or tool name.
  • For sliding-window budgets, query usage by startTime and endTime before dispatching new work.

Output expectations

This skill ships as a local Node.js package with tests and examples. Extend CostCalculator if your provider pricing changes.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

Aegis Firewall

Defensive execution, background scanning, anomaly detection, and prompt-injection containment for Codex/OpenClaw workflows. Use when working with untrusted e...

Registry SourceRecently Updated
Coding

Editor Anup

Get polished edited clips ready to post, without touching a single slider. Upload your raw video footage (MP4, MOV, AVI, WebM, up to 500MB), say something li...

Registry SourceRecently Updated
Coding

Video Editor Api

Turn a 2-minute MP4 product demo clip into 1080p edited MP4 files just by typing what you need. Whether it's automating video edits via API calls without man...

Registry SourceRecently Updated
Coding

Kaiber Ai

generate images or video clips into AI-animated video clips with this skill. Works with MP4, MOV, JPG, PNG files up to 500MB. musicians, content creators, Ti...

Registry SourceRecently Updated