Token Counter for Openclaw

A dedicated monitoring tool to track and analyze token consumption across all Openclaw Skills sessions and sub-agents.

mkhaytman87
v1.0.0
Feb 13, 2026
2
1.9k
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install token-counter

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install token-counter using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Token Counter?

The Token Counter provides developers with a robust way to audit and optimize their AI spending. By analyzing local session transcripts and metadata, this skill delivers a comprehensive breakdown of token usage attributed to specific models, tools, and clients. It is an essential addition to any suite of Openclaw Skills for those needing detailed evidence for cost optimization and resource management.

This utility parses .jsonl files and cron definitions to ensure that no token remains unaccounted for, whether it was spent in a main session or an automated background task. It helps transform raw logs into actionable intelligence by identifying where resources are being directed.

Token Counter Use Cases

  • Monitoring daily or weekly token expenditures to stay within budget.
  • Identifying high-cost tools or models within a specific workflow.
  • Conducting deep-dive audits into specific agent sessions to investigate unexpected usage spikes.
  • Generating structured JSON reports for integration with third-party data visualization tools.
  • Tracking the ROI of different Openclaw Skills by category and client attribution.

How Token Counter Works

  1. The script initializes by locating the Openclaw data directory and session indices.
  2. It scans session transcripts in .jsonl format to find assistant usage fields and token counts.
  3. It uses heuristic logic to attribute assistant-message tokens across specific tool calls within that message.
  4. Rules-based classification maps usage to specific clients (like personal or bonsai) and categories based on path and email markers.
  5. The tool aggregates these findings into a formatted terminal report or a persistent JSON snapshot for long-term tracking.

Token Counter Setup

To begin tracking your usage, run the basic report command from your terminal to see activity from the last 7 days:

$OPENCLAW_SKILLS_DIR/token-counter/scripts/token-counter --period 7d

To save a daily snapshot of your data to your workspace for historical analysis, use the save flag:

$OPENCLAW_SKILLS_DIR/token-counter/scripts/token-counter --period 1d --save

Validation of the installation can be performed using the skill-creator validation script located in your skills directory.

Token Counter Data Schema & Taxonomy

The Token Counter organizes data by scanning the following file structures to build its reports:

Component Location Description
Session Metadata $OPENCLAW_DATA_DIR/agents/main/sessions/sessions.json Contains primary session definitions and metadata mapping.
Usage Logs $OPENCLAW_DATA_DIR/agents/main/sessions/*.jsonl Primary source of token usage and tool call records.
Cron Definitions $OPENCLAW_DATA_DIR/cron/jobs.json Used to attribute tokens to scheduled automated tasks.
JSON Snapshots $OPENCLAW_WORKSPACE/token-usage/daily/ Destination for persisted daily usage records for trend analysis.

Token Counter Advanced Features

  • Multidimensional breakdowns allowing users to filter by tools, category, or client simultaneously.
  • Heuristic token splitting for messages containing multiple tool calls to ensure fair attribution.
  • Automated export to JSON for building custom analytics pipelines and dashboards.
  • Seamless integration with cron job definitions for background usage tracking and auditing.
  • Flexible period selection for historical performance analysis across custom timeframes.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*