ai-token

ai-token is a command for Claude Code from fatihkan/badi. It costs 0 tokens per session (283 once invoked), scanned A, original, MIT.

A command that measures how much text your coding-agent setup uses, grouped by agents, commands, hooks, skills, references, and project notes.

In plain words
What is it for?
Use it to review token usage in a Badi or Claude Code project, find oversized setup files, and monitor whether the total is growing over time.
Why use it?
Large instruction and reference files can leave less room for the agent to work. The report helps identify the biggest files and suggests ways to reduce unnecessary text.

Command for Claude Code

Part of the badi plugin — 28 commands, 30 agents shipped together

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/fatihkan/badi/ai-token
Clone the repo
git clone --depth 1 https://github.com/fatihkan/badi

Made for: Claude Code.

Or install badi, the plugin that ships this one along with the rest of its 28 commands, 30 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ai-token

README.md
[![agentmods](https://agentmods.dev/badge/commands/fatihkan/badi/ai-token.svg)](https://agentmods.dev/commands/fatihkan/badi/ai-token)
Your own site
<a href="https://agentmods.dev/commands/fatihkan/badi/ai-token"><img src="https://agentmods.dev/badge/commands/fatihkan/badi/ai-token.svg" alt="Measured on agentmods" height="20"></a>
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 283 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.00283
Opus 5 $0.00000 $0.00142
Sonnet 5 $0.00000 $0.00057
Haiku 4.5 $0.00000 $0.00028

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

Security

Grade A, and why

ai-token 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 5d 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.

.claude/commands/ai-token.md · 47 lines

What it actually says

Badi/.claude/ token usage analysis command. Categorized token counts, largest files, optimization suggestions.

Required Tools

  • Bash (badi ai token)

Procedure

Step 1: Run

badi ai token

Step 2: Interpret the Results

Category breakdown:

  • agents — Agent definitions
  • commands — Slash commands
  • hooks — Shell hooks
  • skills — Skill library (usually the largest)
  • references — Project guides
  • memory/workspace — Project notes

Total token thresholds:

  • < 80K — Healthy
  • 80-150K — Needs monitoring
  • > 150K — Optimization mandatory

Step 3: Optimization Suggestions

If the total is high:

  1. Split large SKILL.md files — move into a references/ subdirectory
  2. Remove unused commands — slash commands nobody invokes
  3. Minimize CLAUDE.md — 1.2KB target
  4. Log rotation — automatic cap on .claude/logs/

Step 4: Follow-up

Weekly check:

  • /ai-token every Monday morning
  • Watch the trend (investigate on 10%+ weekly growth)

Example

/ai-token
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. 5d ago First seen · 47 lines · 0 tokens per session scan A 43f6d75a5b8b

Subscribe to this mod's changes

ai-token is a command published in the GitHub repository fatihkan/badi (7 stars, last pushed 18d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 283 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-31.