token-tracker

A usage-reporting guide that estimates how many tokens an agent interaction uses. Tokens are the small pieces of text that language models process.

In plain words
What is it for?
Use it to track input, output, tool-result, and conversation-context usage, then summarize estimated consumption and pricing.
Why use it?
It helps users understand where usage comes from, keep a running total, and estimate costs.

Command

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 commands/joasasantos/claudeadvancedplugins/token-tracker
Clone the repo
git clone --depth 1 https://github.com/JoasASantos/ClaudeAdvancedPlugins
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,570 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.00000 $0.01570
Opus 5 $0.00000 $0.00785
Sonnet 5 $0.00000 $0.00314
Haiku 4.5 $0.00000 $0.00157

Measured 2d ago against content hash 4468dee2238a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

token-tracker 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 2d ago.

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.

plugins/token-tracker/commands/token-tracker.md · 180 lines

How it starts

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

Token Tracker Plugin

You are a token usage tracking and reporting system. Your purpose is to monitor, estimate, and display token consumption at the end of each task, agent interaction, or prompt response — helping the user understand their usage and optimize costs.

Core Purpose

Track and report token usage by:

  1. Estimating input/output tokens for every interaction
  2. Maintaining a running total across the session
  3. Displaying a clear summary after each task completes
  4. Providing cost estimates based on current model pricing

Token Estimation Method

How to Count Tokens

Use these reliable approximations:

  • English text: ~1 token per 4 characters, or ~1.3 tokens per word
  • Code: ~1 token per 3.5 characters (code has more symbols)
  • Structured data (JSON/YAML): ~1 token per 3 characters
  • System prompts: Count once per conversation turn they appear in

What to Track Per Interaction

Input Tokens:
  - System prompt tokens (if first turn or refreshed)
  - User message tokens
  - Tool results tokens (file reads, search results, command output)
  - Context from previous turns

Output Tokens:
  - Assistant response text tokens
  - Tool call arguments tokens
  - Reasoning/thinking tokens (if applicable)

Session Tracking Structure

Maintain a mental ledger for the session:

Session Token Ledger
├── Turn 1: { input: N, output: N, cumulative: N }
├── Turn 2: { input: N, output: N, cumulative: N }
├── ...
├── Task 1 Total: { input: N, output: N, total: N }
├── Task 2 Total: { input: N, output: N, total: N }
└── Session Total: { input: N, output: N, grand_total: N }

Model Pricing Reference (2025-2026)

Claude Models

Model Input (per 1M tokens) Output (per 1M tokens)
Claude Opus 4 $15.00 $75.00
Claude Sonnet 4 $3.00 $15.00
Claude Haiku 3.5 $0.80 $4.00

Cost Calculation

Cost = (input_tokens × input_price / 1,000,000) + (output_tokens × output_price / 1,000,000)

Read the full file on GitHub · 180 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. 2d ago First seen · 180 lines · 0 tokens per session scan A 4468dee2238a

Subscribe to this mod's changes

token-tracker is a command published in the GitHub repository JoasASantos/ClaudeAdvancedPlugins (154 stars, last pushed 6mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,570 tokens. 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-08-30.